Deploy a k8s cluster

8/28/2018

I have deployed a k8s cluster using "kubeadm init" successfully before. I re-install the k8s when meet a problem. Now I re-deploy the k8s cluster failed!

linux os

uname -a
Linux kube-master 4.15.0-33-generic #36-Ubuntu SMP Wed Aug 15 16:00:05 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

k8s env

kubectl version
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:17:28Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
The connection to the server localhost:8080 was refused - did you specify the right host or port?

kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:14:39Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}

My deploy command:

sudo kubeadm -v 10 init --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.0.100 --kubernetes-version v1.11.2

[init] this might take a minute or longer if the control plane images have to be pulled
I0828 17:12:47.780302   28675 round_trippers.go:386] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubeadm/v1.11.2 (linux/amd64) kubernetes/bb9ffb1" 'https://192.168.0.100:6443/healthz?timeout=32s'
I0828 17:12:47.780492   28675 round_trippers.go:405] GET https://192.168.0.100:6443/healthz?timeout=32s  in 0 milliseconds
I0828 17:12:47.780500   28675 round_trippers.go:411] Response Headers:
I0828 17:12:48.280824   28675 round_trippers.go:386] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubeadm/v1.11.2 (linux/amd64) kubernetes/bb9ffb1" 'https://192.168.0.100:6443/healthz?timeout=32s'
I0828 17:12:48.281238   28675 round_trippers.go:405] GET https://192.168.0.100:6443/healthz?timeout=32s  in 0 milliseconds
I0828 17:12:48.281283   28675 round_trippers.go:411] Response Headers:
I0828 17:12:48.780836   28675 round_trippers.go:386] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubeadm/v1.11.2 (linux/amd64) kubernetes/bb9ffb1" 'https://192.168.0.100:6443/healthz?timeout=32s'
I0828 17:12:48.781171   28675 round_trippers.go:405] GET https://192.168.0.100:6443/healthz?timeout=32s  in 0 milliseconds
I0828 17:12:48.781199   28675 round_trippers.go:411] Response Headers:
I0828 17:12:49.281440   28675 round_trippers.go:386] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubeadm/v1.11.2 (linux/amd64) kubernetes/bb9ffb1" 'https://192.168.0.100:6443/healthz?timeout=32s'

Who can help me?

-- peikaiqiang
kubernetes

1 Answer

8/28/2018

After kubeadm init you should copy admin.conf file into the home directory of the user who will use the kubectl command and set the config path into the KUBECONFIG system variable:

sudo cp /etc/kubernetes/admin.conf $HOME/
sudo chown $(id -u):$(id -g) $HOME/admin.conf
export KUBECONFIG=$HOME/admin.conf

It is a configuration file from where the kubectl reads details required to make a connection into your K8s cluster.

-- cgrim
Source: StackOverflow