Just I am starting to learn Kubernetes. I\'ve installed CentOS 7.5 with SELinux disabled kubectl, kubeadm and kubelet by Kubernetes YUM repository.
However, when I w
You are hitting the following issue in kubernetes
https://github.com/kubernetes/kubeadm/issues/1092
The workaround is to provide --node-name=<hostname>
. Just go through the above ticket for more info. Hope this helps
EDIT: I have the same issue in kubeadm-1.10.0 After removing --hostname-override from /etc/systemd/system/kubelet.service.d/10-kubeadm.conf file, atleast able to initialize cluster. Didn't give provide --node-name in my cluster
I would recommend to bootstrap Kubernetes cluster as guided in the official documentation. I've proceeded with some steps to build cluster on the same CentOS version CentOS Linux release 7.5.1804 (Core)
and will share them with you, hope it can be helpful to you to get rid of the issue during installation.
First wipe your current cluster installation:
# kubeadm reset -f && rm -rf /etc/kubernetes/
Add Kubernetes repo for further kubeadm
, kubelet
, kubectl
installation:
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
exclude=kube*
EOF
Check whether SELinux
is in permissive mode:
# getenforce
Permissive
Ensure net.bridge.bridge-nf-call-iptables
is set to 1 in your sysctl:
# cat <<EOF > /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
sysctl --system
Install required Kubernetes components and start services:
# yum update && yum upgrade && yum install -y docker kubelet kubeadm kubectl --disableexcludes=kubernetes
# systemctl start docker kubelet && systemctl enable docker kubelet
Deploy the cluster via kubeadm
:
kubeadm init --pod-network-cidr=10.244.0.0/16
I prefer to install Flannel
as the main CNI
in my cluster, although there are some prerequisites for proper Pod network installation, I've passed --pod-network-cidr=10.244.0.0/16
flag to kubeadm init
command.
Create Kubernetes Home directory for your user and store config
file:
$ mkdir -p $HOME/.kube
$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
$ sudo chown $(id -u):$(id -g) $HOME/.kube/config
Install Pod network, in my case it was Flannel
:
$ kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/bc79dd1505b0c8681ece4de4c0d86c5cd2643275/Documentation/kube-flannel.yml
Finally check Kubernetes core Pods status:
$ kubectl get pods --all-namespaces
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-576cbf47c7-4x7zq 1/1 Running 0 36m
kube-system coredns-576cbf47c7-666jm 1/1 Running 0 36m
kube-system etcd-centos-7-5 1/1 Running 0 35m
kube-system kube-apiserver-centos-7-5 1/1 Running 0 35m
kube-system kube-controller-manager-centos-7-5 1/1 Running 0 35m
kube-system kube-flannel-ds-amd64-2bmw9 1/1 Running 0 33m
kube-system kube-proxy-pcgw8 1/1 Running 0 36m
kube-system kube-scheduler-centos-7-5 1/1 Running 0 35m
In case you still have any doubts, just write down a comment below this answer.