반응형

docker 설치

  • kubernetes는 docker 기반이므로 사전에 설치되어있어야함
  • 참고
    • https://sg-choi.tistory.com/235

Kubernetes 설치

sudo apt update \
&& sudo apt install -y apt-transport-https \
&& sudo curl -fsSLo /etc/apt/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list \
&& sudo apt update \
&& sudo apt install -y kubelet kubeadm kubectl

disable swap

sudo swapoff -a

Kubernetes 초기화

  • 아래는 master node의 ip가 192.168.0.11
  • Network 설정시 kube-flannel 사용할 경우 pod-network-cidr은 10.244.0.0/16로 지정
sudo kubeadm init --pod-network-cidr=10.244.0.0/16
# 추후에 다시 초기화가 필요할 경우 아래 명령어 수행
sudo kubeadm reset; \
rm -rf $HOME/.kube; \
sudo kubeadm init --pod-network-cidr=10.244.0.0/16

config 설정

mkdir -p $HOME/.kube; \
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config; \
sudo chown $(id -u):$(id -g) $HOME/.kube/config

Network 설정

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

Pod 상태 확인

STATUS가 모두 Running으로 잘 바뀌는지 확인

$ kubectl get pod --all-namespaces
NAMESPACE     NAME                                       READY   STATUS    RESTARTS       AGE
kube-system   calico-kube-controllers-7ddc4f45bc-7vrv2   1/1     Running   0              17s
kube-system   calico-node-6h644                          1/1     Running   0              17s
kube-system   etcd-ubuntu-server                         1/1     Running   27 (80s ago)   81s
kube-system   kube-apiserver-ubuntu-server               1/1     Running   27 (49s ago)   47s
kube-system   kube-controller-manager-ubuntu-server      1/1     Running   26 (79s ago)   47s
kube-system   kube-scheduler-ubuntu-server               1/1     Running   35 (80s ago)   47s

master node 라벨 확인

$ kubectl get node
NAME            STATUS   ROLES           AGE     VERSION
ubuntu-server   Ready    control-plane   5m40s   v1.28.2
$ kubectl describe node ubuntu-server | grep Taints
Taints:             node-role.kubernetes.io/control-plane:NoSchedule

master 노드에서도 pod 생성 가능하도록 설정

kubectl taint nodes --all node-role.kubernetes.io/control-plane-

확인

kubectl run -it test-pod --image=busybox --rm --restart=Never --command -- ls -al

참고

  • https://www.devdiaries.net/blog/Single-Node-Kubernetes-Cluster-Part-2/
반응형

'Development > Kubernetes' 카테고리의 다른 글

[Kubernetes] Service  (0) 2020.12.29
[Kubernetes] 예제  (0) 2020.12.29
[Kubernetes] 명령어  (0) 2020.12.29
[Kubernetes] Minikube 설치  (0) 2020.12.29
[Kubernetes] 클러스터 설정하기  (0) 2019.12.03

+ Recent posts