본문 바로가기

클라우드/쿠버네티스(Kubernetes)

쿠버네티스 Kubernetes 설치 / Cluster(클러스터) 생성

Control-plane 설정

https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/

 

Creating a cluster with kubeadm

Using kubeadm, you can create a minimum viable Kubernetes cluster that conforms to best practices. In fact, you can use kubeadm to set up a cluster that will pass the Kubernetes Conformance tests. kubeadm also supports other cluster lifecycle functions, su

kubernetes.io

 

 

https://www.projectcalico.org/

 

Home - Project Calico

1 What is Calico? Project Calico is an open-source networking and security solution for Kubernetes. Calico supports multiple data planes, so you can choose the technologies that best suit your … Home Read More »

www.projectcalico.org


k-node 설정

 

더보기

# control-plane 설정
vagrant@k-control:~$ sudo kubeadm init --control-plane-endpoint 192.168.200.50 
--pod-network-cidr 192.168.0.0/16 --apiserver-advertise-address 192.168.200.50

vagrant@k-control:~$ mkdir -p $HOME/.kube
vagrant@k-control:~$ sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
vagrant@k-control:~$ 
vagrant@k-control:~$ sudo chown $(id -u):$(id -g) $HOME/.kube/config

 
# pod에 네트워크 add-on 설치
# 컨테이너 네트워크 인터페이스
# calico 쿠버네티스에 네트워크를 제공하는 프로젝트
vagrant@k-control:~$ kubectl apply -f https://docs.projectcalico.org/manifests/calico.yaml 

# 상태 확인
vagrant@k-control:~$ kubectl get nodes
NAME        STATUS   ROLES                  AGE   VERSION
k-control   Ready    control-plane,master   5m    v1.21.2 # kudeadm 버전에 따라 쿠버네티스의 버전이 정해진다




# 각 node에 명령어 설정
# node를 클러스터에 추가
vagrant@k-node1:~$ sudo kubeadm join 192.168.200.50:6443 --token mvm7ak.inu6m4417mngvw2r 
--discovery-token-ca-cert-hash sha256:d850e598710034c80b0348e5ed7bae4ea27258531cbc7c7d97b8ce42fc04c75e 

# 확인
vagrant@k-node1:~$ sudo docker ps
CONTAINER ID   IMAGE                    COMMAND                  CREATED         STATUS         PORTS     NAMES
d4d19a810af8   k8s.gcr.io/kube-proxy    "/usr/local/bin/kube…"   3 minutes ago   Up 3 minutes             k8s_kube-proxy_kube-proxy-78fsf_kube-system_344599ef-decb-414b-a553-c652770c5144_0
e75926d1c099   k8s.gcr.io/pause:3.4.1   "/pause"                 4 minutes ago   Up 4 minutes             k8s_POD_kube-proxy-78fsf_kube-system_344599ef-decb-414b-a553-c652770c5144_0
012995d4a45c   k8s.gcr.io/pause:3.4.1   "/pause"                 4 minutes ago   Up 4 minutes             k8s_POD_calico-node-mrstf_kube-system_9b913233-60df-45b4-b703-565b1fa3b773_0


# k-control 확인 
vagrant@k-control:~$ kubectl get nodes
NAME        STATUS     ROLES                  AGE   VERSION
k-control   Ready      control-plane,master   31m   v1.21.2
k-node1     NotReady   <none>                 14m   v1.21.2
k-node2     NotReady   <none>                 14m   v1.21.2
k-node3     NotReady   <none>                 4s    v1.21.2


# NotReady 상태일때 방법
# NotReady 상태인곳에 명령어 입력 
sudo docker login
docker pull calico/node:v3.19.1
docker pull calico/pod2daemon-flexvol:v3.19.1
docker pull calico/cni:v3.19.1
docker pull calico/kube-controllers:v3.19.1


확인

더보기

# 노드 상태 
vagrant@k-control:~$ kubectl get nodes
NAME        STATUS   ROLES    AGE   VERSION
k-control   Ready    master   16h   v1.18.19
k-node1     Ready    <none>   16h   v1.18.19
k-node2     Ready    <none>   16h   v1.18.19
k-node3     Ready    <none>   16h   v1.18.19

# 컨테이너 상태 
vagrant@k-control:~$ kubectl get pods -A
NAMESPACE     NAME                                       READY   STATUS    RESTARTS   AGE
kube-system   calico-kube-controllers-5978c5f6b5-zhhhd   1/1     Running   2          16h
kube-system   calico-node-282ch                          1/1     Running   1          16h
kube-system   calico-node-7hk5h                          1/1     Running   2          16h
kube-system   calico-node-lmmcz                          1/1     Running   2          16h
kube-system   calico-node-ztzqn                          1/1     Running   2          16h
kube-system   coredns-66bff467f8-g9vjm                   1/1     Running   2          16h
kube-system   coredns-66bff467f8-w6dq4                   1/1     Running   2          16h
kube-system   etcd-k-control                             1/1     Running   2          16h
kube-system   kube-apiserver-k-control                   1/1     Running   2          16h
kube-system   kube-controller-manager-k-control          1/1     Running   2          16h
kube-system   kube-proxy-6mtjm                           1/1     Running   1          16h
kube-system   kube-proxy-6zvhz                           1/1     Running   1          16h
kube-system   kube-proxy-vw25w                           1/1     Running   1          16h
kube-system   kube-proxy-zv9g9                           1/1     Running   2          16h
kube-system   kube-scheduler-k-control                   1/1     Running   2          16h