gpt4 book ai didi

kubernetes - kubectl apply yield forbidden,检索当前配置时出错

转载 作者:行者123 更新时间:2023-12-03 22:53:21 26 4
gpt4 key购买 nike

已关注 steps to create single master cluster ,我能够成功地初始化主,但是当申请时我得到了 禁止 错误,有人遇到过吗?谢谢!

我做了以下

1. disable selinux in /etc/selinux/config, and reboot
2. comment out KUBELET_NETWORK_ARGS in
/etc/systemd/system/kubelet.service.d/10-kubeadm.conf
3. export no_proxy=$no_proxy,<master-ip>
4. export KUBECONFIG=/etc/kubernetes/kubelet.conf in .bash_profile

初始化成功后,尝试申请时
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml

我收到以下错误消息
Error from server (Forbidden): error when retrieving current configuration of:
&{0xc42048ab40 0xc421a83730
flannel https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml 0xc42109cc20 false}
from server for: "https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml":
clusterroles.rbac.authorization.k8s.io "flannel" is forbidden:
User "system:node:<master-server-name>"
cannot get clusterroles.rbac.authorization.k8s.io at the cluster scope

最佳答案

一旦您的集群尚未完全正常运行,将其拆除并从头开始重新创建会更容易:

拆掉一切:

$> sudo su
#> kubeadm reset
#> rm -rf $HOME/.kube /etc/kubernetes

准备您的主机(以防万一您还没有这样做):
#> swapoff -a
## Don't forget to comment swap partition line in /etc/fstab

## I assume that you have these packages already installed: docker, kubeadm, kubectl

## tune sysctl to pass bridged IPv4 traffic to iptables’ chains.
## This is a requirement for some CNI plugins to work, for more information please see
## https://kubernetes.io/docs/concepts/cluster-administration/network-plugins/#network-plugin-requirements

#> cat <<EOF >>/etc/ufw/sysctl.conf
net/bridge/bridge-nf-call-ip6tables = 1
net/bridge/bridge-nf-call-iptables = 1
net/bridge/bridge-nf-call-arptables = 1
EOF
#> sudo sysctl --system

初始化集群:
## Do not try to set less than /16 subnet for `--pod-network-cidr`

#> kubeadm init --pod-network-cidr=10.244.0.0/16

## Prepare the kubectl config

#> mkdir -p $HOME/.kube
#> cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
#> chown $(id -u):$(id -g) $HOME/.kube/config

安装法兰绒
#> kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/v0.10.0/Documentation/kube-flannel.yml

允许在主节点上调度 pod。

(以防万一您没有任何工作节点。)
#> kubectl taint nodes --all node-role.kubernetes.io/master-

此时,您应该已经拥有现成的 Kubernetes 集群:
#> kubectl get nodes
#> kubectl get pods --all-namespaces

关于kubernetes - kubectl apply yield forbidden,检索当前配置时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50959228/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com