Kubernetes 설치 / kubeadm, IPv6 DualStack 이용 / Ubuntu 18.04 환경

Kubernetes 설치 / kubeadm, IPv6 DualStack 이용 / Ubuntu 18.04 환경

1. 설치 환경

[Figure 1] Kubernetes 설치를 위한 Node 구성도

[Figure 1] Kubernetes 설치를 위한 Node 구성도

[Figure 1]은 Kubernetes 설치를 위한 Node의 구성도를 나타내고 있다. 설치 환경은 다음과 같다.

  • VM : 4 vCPU, 4GB Memory
    • Master Node * 1
    • Worker Node * 2
  • Network
    • Node Network : 192.168.0.0/24, fdaa::/64
    • Pod Network : 192.167.0.0/16, fdbb::/64
    • Service Network : 10.96.0.0/12, fdcc::/112
  • Kubernetes : 1.18.3
    • CNI : Calico 3.14 Plugin

2. Ubuntu Package 설치

2.1. All Node

모든 Node에서 Kubernetes를 위한 Package를 설치한다.

(All)$ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
(All)$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
(All)$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb-release -cs) stable"
(All)$ apt-get update
(All)$ apt-get install docker-ce docker-ce-cli containerd.io

Docker를 설치한다.

(All)$ apt-get update && apt-get install -y apt-transport-https curl
(All)$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
(All)$ echo deb http://apt.kubernetes.io/ kubernetes-xenial main > /etc/apt/sources.list.d/kubernetes.list
(All)$ apt-get update
(All)$ apt-get install -y kubeadm=1.18.3-00 kubelet=1.18.3-00

kubelet, kubeadm를 설치한다.

(ALL)$ sysctl -w net.ipv6.conf.all.forwarding=1
(ALL)$ echo net.ipv6.conf.all.forwarding=1 >> /etc/sysctl.conf

IPv6 Forwarding을 설정한다.

3. Kubernetes Cluster 구축

3.1. Master Node

(Master)$ kubeadm init --apiserver-advertise-address=192.168.0.61 --kubernetes-version=v1.18.3 --feature-gates=IPv6DualStack=true --pod-network-cidr=192.167.0.0/16,fdbb::0/64 --service-cidr=10.96.0.0/12,fdcc::0/112
...
kubeadm join 192.168.0.61:6443 --token 6gu1o3.dwhguhu651x137eq --discovery-token-ca-cert-hash sha256:2ab0fa9f6f8c3c49c263bc0a0edc19ddf973bf7fdf5e464c807df45e8bf49ab8

kubeadm를 초기화 한다. –pod-network-cidr, –service-cidr 각각 IPv6 CIDR도 설정한다.

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

kubernetes config 파일을 설정한다.

3.2. Worker Node

(Worker)$ kubeadm join 192.168.0.61:6443 --token 6gu1o3.dwhguhu651x137eq --discovery-token-ca-cert-hash sha256:2ab0fa9f6f8c3c49c263bc0a0edc19ddf973bf7fdf5e464c807df45e8bf49ab8

kubeadm init 결과로 나온 kubeadm join ~~ 명령어를 모든 Worker Node에서 수행한다.

4. Calico 설치

(Master)$ wget https://docs.projectcalico.org/v3.14/manifests/calico.yaml

Calico Manifest 파일을 Download한다.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
...
          "mtu": --CNI-MTU--,
          "ipam": {
              "type": "calico-ipam",
              "assign-ipv4": "true",
              "assign-ipv6": "true"
          },
...
            # The default IPv4 pool to create on startup if none exists. Pod IPs will be
            # chosen from this range. Changing this value after installation will have
            # no effect. This should fall within `--cluster-cidr`.
            - name: CALICO-IPV4POOL-CIDR
              value: "192.167.0.0/16"
            - name: IP6
              value: "autodetect"
            - name: CALICO-IPV6POOL-CIDR
              value: "fdbb::0/64"
...
            - name: FELIX-DEFAULTENDPOINTTOHOSTACTION
              value: "ACCEPT"
            - name: FELIX-IPV6SUPPORT
              value: true
[File 1] calico.yaml

Calico Manifest 파일을 [File 1]의 내용으로 수정한다.

(Master)$ kubectl apply -f calico.yaml

Calico를 설치한다.

5. 참조