쿠버네티스 – Kubernetes 마스터 노드 설치

kubernetes 마스터 노드 설치

EKS, GKE, AKS 등 각 public cloud 업체에서 지원해 주는 controle plane를 사용하지 않고 VM 환경에서 마스터 노드를 구축을 하려한다.

OS 환경 : ubuntu 16.04

1. ubuntu update 및 docker 설치

$ sudo -i 
$ apt-get update; apt-get upgrade -y 
$ apt-get install docker.io

docker을 설치를 하고 네트워크 인터페이스를 확인하면 broadcast, multicast 를 지원하는 docker0 인 인터페이스가 설치가 된다.( ip address 설명)

$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host 
valid_lft forever preferred_lft forever

2: ens4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1460 qdisc mq state UP group default qlen 1000
link/ether 42:01:0a:80:00:08 brd ff:ff:ff:ff:ff:ff
inet 10.128.0.8/32 brd 10.128.0.8 scope global ens4
valid_lft forever preferred_lft forever
inet6 fe80::4001:aff:fe80:8/64 scope link
valid_lft forever preferred_lft forever

3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:54:08:24:aa brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever

2. apt repository kubernetes 추가 및 GPG key 추가

$ sudo apt-get update && sudo apt-get install -y apt-transport-https curl 
$ curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - 
$ cat <

3. kubernetes 설치 및 설정

kubernetes 설치

$ sudo apt-get update 
$ sudo apt-get install -y kubelet kubeadm kubectl 
$ sudo apt-mark hold kubelet kubeadm kubectl

dns alias

$ vi /etc/hosts 10.128.0.38 k8smaster

swaf off

$ swapoff -a

cluster 초기화

$ vi kubeadm-config.yaml
apiVersion: kubeadm.k8s.io/vibeta2
kind: ClusterConfiguration
kubernetesVersion: 1.15.1
controlPlaneEndpoint: "k8smaster:6443"
networking:
  podSubnet: 192.168.0.0/16

$ kubeadm init --config=kubeadm-config.yaml --upload-certs | tee kubeadm-init.out
kubeadm-init.out 파일 내용을 보면 join 할 수 있는 key 나 명령어 내용이 저장되어 있다.

4. kubectl 을 사용

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

5. network plugin 적용 및 rbac 적용

$ wge https://tinyurl.com/yb4xturm -O rbac-kdd.yaml 
$ wge https://tinyurl.com/y8lvqc9g -O calico.yaml 
$ kubectl apply -f rbac-kdd.yaml clusterrole.rbac.authorization.k8s.io/calico-node created 
$ kubectl apply -f calico.yaml 
configmap/calico-config created 
service/calico-typha created 
deployment.apps/calico-typha created 
poddisruptionbudget.policy/calico-typha created 
daemonset.extensions/calico-node created 
serviceaccount/calico-node created 
customresourcedefinition.apiextensions.k8s.io/felixconfigurations.crd.projectcalico.org created 
customresourcedefinition.apiextensions.k8s.io/bgppeers.crd.projectcalico.org created 
customresourcedefinition.apiextensions.k8s.io/bgpconfigurations.crd.projectcalico.org created 
customresourcedefinition.apiextensions.k8s.io/ippools.crd.projectcalico.org created 
customresourcedefinition.apiextensions.k8s.io/hostendpoints.crd.projectcalico.org created 
customresourcedefinition.apiextensions.k8s.io/clusterinformations.crd.projectcalico.org created 
customresourcedefinition.apiextensions.k8s.io/globalnetworkpolicies.crd.projectcalico.org created 
customresourcedefinition.apiextensions.k8s.io/globalnetworksets.crd.projectcalico.org created 
customresourcedefinition.apiextensions.k8s.io/networkpolicies.crd.projectcalico.org created

6. bash auto-completion

$ source <(kubectl completion bash) 
$ echo "source <(kubectl completion bash)" >> ~/.bashrc

답글 남기기