Skip to content

Instantly share code, notes, and snippets.

@dirty49374
Last active October 15, 2018 05:47
Show Gist options
  • Save dirty49374/418275bfe863a81f1fc6f4ca61736bcd to your computer and use it in GitHub Desktop.
Save dirty49374/418275bfe863a81f1fc6f4ca61736bcd to your computer and use it in GitHub Desktop.
ubuntu 18.04에 kubernetes 띄우기

master node

apt 소스 (root유저)

sudo su -

# google k8s 패키지 소스 등록
apt update && apt upgrade -y
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

cat <<EOF > /etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF

apt-get update
apt install linux-image-extra-virtual ca-certificates curl software-properties-common -y

# docker 소스 등록
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
stable"

apt update

install packages (root유저)

sudo su -

apt install docker-ce kubelet kubeadm kubectl kubernetes-cni -y

swap off (root유저)

sudo su -

swapoff -a
vi /etc/fstab ; swap을 #로 커맨트

install master node (root유저)

% sudo su -

% kubeadm init --pod-network-cidr 192.168.0.0/16 --service-cidr 10.96.0.0/12 --service-dns-domain "k8s" --apiserver-advertise-address __IP_ADDR__
...
   kubeadm join 10.0.1.2:6443 --token nnnnnnnnnnn --discovery-token-ca-cert-hash sha256:nnnnnnnnn
...

출력되는 메시지 잘 적어두기

kubernetes config 설정 (normal 유저)

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
export KUBECONFIG=$HOME/.kube/config
export KUBECONFIG=$HOME/.kube/config | tee -a ~/.bashrc

pod network 설정

kubectl apply -f https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml
kubectl apply -f https://docs.projectcalico.org/v3.1/getting-started/kubernetes/installation/hosted/kubernetes-datastore/calico-networking/1.7/calico.yaml

worker node

apt 소스 (root유저, master와 동일)

sudo su -

# google k8s 패키지 소스 등록
apt update && apt upgrade -y
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

cat <<EOF > /etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF

apt-get update
apt install linux-image-extra-virtual ca-certificates curl software-properties-common -y

# docker 소스 등록
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
stable"

apt update

install packages (root유저)

sudo su -

apt install docker-ce kubelet kubeadm kubectl kubernetes-cni -y

swap off (root유저)

sudo su -

swapoff -a
vi /etc/fstab ; swap을 #로 커맨트

join 하기 (root 유저)

sudo su -

# master 설치시에 나온 명령을 그대로 입력
kubeadm join 10.0.1.2:6443 --token nnnnnnnnnnn --discovery-token-ca-cert-hash sha256:nnnnnnnnn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment