kubernetes controller manager error if use kubeadm init with --cloud-provider=aws flag

7/5/2018

k8s controller manager cannot start (solved by changing AWS EC2 tag)

I have similar issue as this post: kube-controller-manager don't start when using “cloud-provider=aws” with kubeadm, but that does not provide any solution to solve the issue. Below is the log stats from kubernetes controller manager.

I0705 17:59:05.941049       1 controllermanager.go:116] Version: v1.10.3
W0705 17:59:05.941983       1 authentication.go:55] Authentication is disabled
I0705 17:59:05.942004       1 insecure_serving.go:44] Serving insecurely on 127.0.0.1:10252
I0705 17:59:05.942450       1 leaderelection.go:175] attempting to acquire leader lease  kube-system/kube-controller-manager...
I0705 17:59:22.823671       1 leaderelection.go:184] successfully acquired lease kube-system/kube-controller-manager
I0705 17:59:22.823945       1 event.go:218] Event(v1.ObjectReference{Kind:"Endpoints", Namespace:"kube-system", Name:"kube-controller-manager", UID:"ec7f1208-807c-11e8-bc66-0e594759e784", APIVersion:"v1", ResourceVersion:"289", FieldPath:""}): type: 'Normal' reason: 'LeaderElection' k8s_1bbcc7bc-807d-11e8-859d-0e594759e784 became leader
I0705 17:59:22.849017       1 aws.go:1026] Building AWS cloudprovider
I0705 17:59:22.849064       1 aws.go:988] Zone not specified in configuration file; querying AWS metadata service
F0705 17:59:22.851606       1 controllermanager.go:159] error building controller context: cloud provider could not be initialized: could not init cloud provider "aws": error finding instance i-07df027cffda674bc: "error listing AWS instances: \"NoCredentialProviders: no valid providers in chain. Deprecated.\\n\\tFor verbose messaging see aws.Config.CredentialsChainVerboseErrors\""

The /etc/kubernetes/aws.conf file.

apiVersion: kubeadm.k8s.io/v1alpha1
kind: MasterConfiguration
cloudProvider: aws
kubernetesVersion: 1.10.3

The /etc/kubernetes/cloud-config.conf file.

[Global]
KubernetesClusterTag=k8s
KubernetesClusterID=k8s

Solution

Change EC2 instance tag, KEY=KubernetesCluster, VALUE=k8s(in my case).

-- Jiashen Cao
amazon-web-services
kubernetes

1 Answer

7/6/2018

kube-dns is always pending because of weave net crash

Fix cgroups setting.

  • Add Environment="KUBELET_CGROUP_ARGS=--cgroup-driver=cgroupfs" to /etc/systemd/system/kubelet.service.d/10-kubeadm.conf.
  • Restart kubelet service.

    sudo systemctl deamon-reload
    sudo systemctl restart kubelet

Install weave net and launch before creating kubernetes cluster.

-- Jiashen Cao
Source: StackOverflow