跟随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
答案 0 :(得分:0)
您以某种方式从使用cluster-admin kubeconfig(具有超级用户访问权限)切换到使用主节点kubeconfig(仅可以访问kubelet /节点应该能够执行的操作)
答案 1 :(得分:0)
一旦群集尚未完全正常运行,将其拆下并从头开始重新创建将更容易:
$> 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
(以防万一您没有任何工作节点。)
#> kubectl taint nodes --all node-role.kubernetes.io/master-
#> kubectl get nodes
#> kubectl get pods --all-namespaces
答案 2 :(得分:-1)
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
代替
cp -i /etc/kubernetes/kubelet.conf ~/.kube/config