초기화

기존 kubeadm init 명령어를 통해 클러스터를 구축했다면 다음과 같이 쿠버네티스 클러스터를 초기화 할 수 있다. root 계정 혹은 sudo 권한으로 실행한다.

$ sudo kubeadm reset

>>> 
[reset] Reading configuration from the cluster...
[reset] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
[reset] WARNING: Changes made to this host by 'kubeadm init' or 'kubeadm join' will be reverted.
[reset] Are you sure you want to proceed? [y/N]: y
# y 입력

[preflight] Running pre-flight checks
The 'update-cluster-status' phase is deprecated and will be removed in a future release. Currently it performs no operation
[reset] Stopping the kubelet service
[reset] Unmounting mounted directories in "/var/lib/kubelet"
[reset] Deleting contents of config directories: [/etc/kubernetes/manifests /etc/kubernetes/pki]
[reset] Deleting files: [/etc/kubernetes/admin.conf /etc/kubernetes/kubelet.conf /etc/kubernetes/bootstrap-kubelet.conf /etc/kubernetes/controller-manager.conf /etc/kubernetes/scheduler.conf]
[reset] Deleting contents of stateful directories: [/var/lib/etcd /var/lib/kubelet /var/lib/dockershim /var/run/kubernetes /var/lib/cni]

The reset process does not clean CNI configuration. To do so, you must remove /etc/cni/net.d

The reset process does not reset or clean up iptables rules or IPVS tables.
If you wish to reset iptables, you must do so manually by using the "iptables" command.

If your cluster was setup to utilize IPVS, run ipvsadm --clear (or similar)
to reset your system's IPVS tables.

The reset process does not clean your kubeconfig files and you must remove them manually.
Please, check the contents of the $HOME/.kube/config file.

출력 응답에 나온 내용을 참조하여 CNI 설정 및 쿠버네티스 관련 설정을 삭제한다.

$ sudo rm -r /etc/cni/net.d/*
$ sudo rm -r ~/.kube/config

kubelet 서비스 재시작

$ sudo systemctl restart kubelet

Worker Node

  • 워커노드에서도 일부 마스터노드에서 해준 작업을 수행해줘야한다. 추가로 추후 다른 CNI를 이용하여 클러스터 구축을 하는 것을 대비해 CNI 설정파일도 삭제한다.
$ sudo kubeadm reset

>>> 
[reset] WARNING: Changes made to this host by 'kubeadm init' or 'kubeadm join' will be reverted.
[reset] Are you sure you want to proceed? [y/N]:

# y 입력하여 진행

# cni, 클러스터관련 설정파일 삭제 
$ sudo rm -r /etc/cni/net.d/*
$ sudo rm -r /etc/kubernetes/*

해당 작업을 하지 않고 마스터노드만 리셋 후 다시 클러스터를 구축하려고 한다면 다음과 같은 오류를 볼 수 있으니 참고하자.

error execution phase preflight: [preflight] Some fatal errors occurred:
	[ERROR FileAvailable--etc-kubernetes-kubelet.conf]: /etc/kubernetes/kubelet.conf already exists
	[ERROR Port-10250]: Port 10250 is in use
	[ERROR FileAvailable--etc-kubernetes-pki-ca.crt]: /etc/kubernetes/pki/ca.crt already exists

댓글남기기