two step to create a single master cluster
- create vm
- kubeadm init
os | kubernetes | CPU | MEM |
---|---|---|---|
centos7.4 | 1.11.2 | 2C | 4G |
- Install brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
- Install vagrant and virtualbox
brew cask install vagrant
brew cask install virtualbox
- Run this cmd in directory with Vagrantfile
vagrant up
- Init kubernetes master
kubeadm init --config=kubeadm.config
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
- Remove master taint
kubectl taint nodes --all node-role.kubernetes.io/master-
- Install flannel
kubectl create -f flannel.yaml
- Check cluster
kubectl cluster-info
kubectl get cs
kubectl get nodes
- Join node
Option 1
# join node
kubeadm join --token <token> <master-ip>:<master-port> --discovery-token-ca-cert-hash sha256:<hash>
# list token
kubeadm token list
# discovery-token-ca-cert-hash
root@ubuntu:/home/cong# openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
Option 2
kubeadm token create --print-join-command
- delete node
kubectl drain <node name> --delete-local-data --force --ignore-daemonsets
kubectl delete node <node name>