I'm trying to initialize a Kubernetes cluster using Kubeadm.
I basically have 3 questions. 1 big one and 2 "sub questions" if you will
I am having difficulty in assigning a cluster name to the cluster. When I read the kubeadm
docs, it has a flag --config
where you can specify the yml file which will be used to initialize the cluster.
There is an example yml file specified on their page but that file has a lot of configurations that I do not know how to set. So therefore I created a config file as below:
apiVersion: kubeadm.k8s.io/v1beta1
kind: InitConfiguration
advertiseAddress: "10.62.194.4" # is this correct (see below)
bindPort: 6443
---
apiVersion: kubeadm.k8s.io/v1beta1
kind: ClusterConfiguration
networking:
podSubnet: "10.62.194.0/16" # is this correct (see below)
controlPlaneEndpoint: "10.62.194.4:6443" #is this correct (see below)
clusterName: "dev-cluster"
I initialize like this sudo kubeadm init --config=config.yml
However, when I try to initialize the above file, it doesnt work as expected and times out after a while
The error is similar to this: Unfortunately, an error has occurred: timed out waiting for the condition This error is likely caused by: - The kubelet is not running - The kubelet is unhealthy due to a misconfiguration of the node in some way (required cgroups disabled)
When I do a docker ps
I can see kube-system containers all running, with no exited containers. The containers that are running are kube-scheduler kube-controller-manager_kube-controller kube-apiserver etcd-ubuntu kube-controller-manager-ubuntu-xenial
Second question: are cluster names important? I want to set a cluster name because I am planning to set up 3 clusters for 3 different environments, which would mean 3 different contexts. If all 3 have the same default cluster name, will there be an issue?
Also a final third part to this question if the IP of the server ( this is also the master ) I am running the commands is 10.62.194.4
are the fields advertiseAddress
, podSubnet
and controlPlaneEndpoint
correct? I am planning to add one more node to this cluster and the IP of that node is 10.62.194.5 Thanks
I believe, you are planing to setup highly available kubernetes setup. You have to configure/provide the Loadbalancer IP on the controlPlaneEndpoint option.
apiVersion: kubeadm.k8s.io/v1beta1
kind: ClusterConfiguration
networking:
podSubnet: "10.62.194.0/16"
controlPlaneEndpoint: "Loadbalancer IP:6443"
clusterName: "dev-cluster"
You have to add --upload-certs option on the kubeadm initialization command as below.
sudo kubeadm init --config=config.yaml --upload-certs
The output of the above command provides the join command to add another master node on to this HA kubernetes cluster setup.