我尝试使用dashboard安装Kubernetes,但遇到以下问题:
test@ubuntukubernetes1:~$ kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-flannel kube-flannel-ds-ksc9n 0/1 CrashLoopBackOff 14 (2m15s ago) 49m
kube-system coredns-6d4b75cb6d-27m6b 0/1 ContainerCreating 0 4h
kube-system coredns-6d4b75cb6d-vrgtk 0/1 ContainerCreating 0 4h
kube-system etcd-ubuntukubernetes1 1/1 Running 1 (106m ago) 4h
kube-system kube-apiserver-ubuntukubernetes1 1/1 Running 1 (106m ago) 4h
kube-system kube-controller-manager-ubuntukubernetes1 1/1 Running 1 (106m ago) 4h
kube-system kube-proxy-6v8w6 1/1 Running 1 (106m ago) 4h
kube-system kube-scheduler-ubuntukubernetes1 1/1 Running 1 (106m ago) 4h
kubernetes-dashboard dashboard-metrics-scraper-7bfdf779ff-dfn4q 0/1 Pending 0 48m
kubernetes-dashboard dashboard-metrics-scraper-8c47d4b5d-9kh7h 0/1 Pending 0 73m
kubernetes-dashboard kubernetes-dashboard-5676d8b865-q459s 0/1 Pending 0 73m
kubernetes-dashboard kubernetes-dashboard-6cdd697d84-kqnxl 0/1 Pending 0 48m
test@ubuntukubernetes1:~$
日志文件:
test@ubuntukubernetes1:~$ kubectl logs --namespace kube-flannel kube-flannel-ds-ksc9n
Defaulted container "kube-flannel" out of: kube-flannel, install-cni-plugin (init), install-cni (init)
I0808 23:40:17.324664 1 main.go:207] CLI flags config: {etcdEndpoints:http://127.0.0.1:4001,http://127.0.0.1:2379 etcdPrefix:/coreos.com/network etcdKeyfile: etcdCertfile: etcdCAFile: etcdUsername: etcdPassword: version:false kubeSubnetMgr:true kubeApiUrl: kubeAnnotationPrefix:flannel.alpha.coreos.com kubeConfigFile: iface:[] ifaceRegex:[] ipMasq:true ifaceCanReach: subnetFile:/run/flannel/subnet.env publicIP: publicIPv6: subnetLeaseRenewMargin:60 healthzIP:0.0.0.0 healthzPort:0 iptablesResyncSeconds:5 iptablesForwardRules:true netConfPath:/etc/kube-flannel/net-conf.json setNodeNetworkUnavailable:true}
W0808 23:40:17.324753 1 client_config.go:614] Neither --kubeconfig nor --master was specified. Using the inClusterConfig. This might not work.
E0808 23:40:17.547453 1 main.go:224] Failed to create SubnetManager: error retrieving pod spec for 'kube-flannel/kube-flannel-ds-ksc9n': pods "kube-flannel-ds-ksc9n" is forbidden: User "system:serviceaccount:kube-flannel:flannel" cannot get resource "pods" in API group "" in the namespace "kube-flannel"
test@ubuntukubernetes1:~$
你知道如何解决这个问题吗?我尝试了以下安装:
Swapoff -a
Remove following line from /etc/fstab
/swap.img none swap sw 0 0
sudo apt update
sudo apt install docker.io
sudo systemctl start docker
sudo systemctl enable docker
sudo apt install apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add
echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" >> ~/kubernetes.list
sudo mv ~/kubernetes.list /etc/apt/sources.list.d
sudo apt update
sudo apt install kubeadm kubelet kubectl kubernetes-cni
sudo kubeadm init --pod-network-cidr=192.168.0.0/16
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.5.0/aio/deploy/recommended.yaml
kubectl proxy --address 192.168.1.133 --accept-hosts '.*'
你能给点建议吗?
3条答案
按热度按时间vjrehmav1#
我今天在一次新的部署中遇到了同样的情况。结果发现,kube-flannel-rbac.yml文件的名称空间错误。它现在是'kube-flannel',而不是'kube-system',所以我修改了它并重新应用。
我还在kube-flannel.yml中的每个“name”条目下添加了一个“namespace”条目,roleRef标题下除外。(当我在那里添加它时,它抛出了一个错误)在应用新的yml之后,所有的pod都显示为‘Running‘。
vngu2lb82#
问题似乎出在
kube-flannel-rbac.yaml
上它需要
kube-system
中的服务帐户所以删掉这个
因为
kube-flannel.yml
已经在正确的命名空间中创建了这个。https://github.com/flannel-io/flannel/blob/master/Documentation/kube-flannel.yml#L43
mkh04yzy3#
我尝试部署一个3节点集群,其中包含1个主节点和2个工作节点。我采用了类似的方法,如上所述。然后尝试部署Nginx,但失败了。当我检查我的pod时,master上的flannel正在运行,但在worker节点上却失败了。
我删除了法兰绒,从头开始。首先,我只使用了kube-flannel-rbac.yaml,因为有一些提到kube-flannel-rbac.yaml会导致问题。
ubuntu@master:~$ kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml namespace/kube-flannel createdclusterrole.rbac.authorization.k8s.io/flannelclusterrolebinding.rbac.authorization.k8s.io/flannelcreated serviceaccount/flannel created configmap/kube-flannel-cfg created daemonset.apps/kube-flannel-ds created
ubuntu@master:~$ kubectl describe ClusterRoleBinding flannel Name:Labels:注解:角色:种类:ClusterRole名称:法兰绒主题:种类名称命名空间
ServiceAccount flennel kube-flennel
然后我可以创建nginx图像。但是,我随后删除了图像并应用了第二个yaml。这更改了名称空间
ubuntu@master:~$ kubectl describe ClusterRoleBinding flannel Name:Labels:注解:角色:种类:ClusterRole名称:法兰绒主题:种类名称命名空间
ServiceAccount法兰绒kube-system
Nginx再次成功。
此配置的用途是什么?是否需要它,因为部署映像时使用和不使用它?
https://raw.githubusercontent.com/coreos/flannel/master/Documentation/k8s-manifests/kube-flannel-rbac.yml