만들기/EagleEye

[EagleEye][환경세팅] 쿠버네티스 설치 1 - 설치

pythaac 2022. 5. 14. 00:00

sudo systemctl enable kubelethttps://computingforgeeks.com/deploy-kubernetes-cluster-on-ubuntu-with-kubeadm/

 

Install Kubernetes Cluster on Ubuntu 20.04 with kubeadm | ComputingForGeeks

Kubernetes is a tool for orchestrating and managing containerized applications at scale on on-premise server or across hybrid cloud environments. Kubeadm is a

computingforgeeks.com

 

쿠버네티스 서버 설치

  • update / upgrade / reboot
    >> sudo apt update
    >> sudo apt full-upgrade -y
    >> sudo reboot
    >> sudo apt autoremove

 

kubelet, kubeadm, kubectl 설치

  • add repository
    >> sudo apt -y install curl apt-transport-https
    >> sudo curl -fsSLo /usr/share/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
  • install packages
    >> sudo apt update
    >> sudo apt -y install vim git curl wget kubelet kubeadm kubectl
    >> sudo apt-mark hold kubelet kubeadm kubectl
  • 설치 확인
    >> kubectl version --client && kubeadm version

 

Swap 끄기

  • swap 끄기
    >> sudo sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
    >> sudo swapoff -a
  • 커널 모듈 enable
    >> sudo modprobe overlay
    >> sudo modprobe br_netfilter
  • sysctl 설정
    >> sudo tee /etc/sysctl.d/kubernetes.conf<<EOF
    net.bridge.bridge-nf-call-ip6tables = 1
    net.bridge.bridge-nf-call-iptables = 1
    net.ipv4.ip_forward = 1
    EOF
  • sysctl reload
    >> sudo sysctl --system

 

Docker 설정

  • Docker 설치했다고 가정 후 설정 내용
  • 디렉토리 생성
    >> sudo mkdir -p /etc/systemd/system/docker.service.d
  • damon json config 파일 생성
    >> sudo tee /etc/docker/daemon.json <<EOF
    {
      "exec-opts": ["native.cgroupdriver=systemd"],
      "log-driver": "json-file",
      "log-opts": {
        "max-size": "100m"
      },
      "storage-driver": "overlay2"
    }
    EOF
  • 서비스 시작/enable
    >> sudo systemctl daemon-reload
    >> sudo systemctl restart docker
    >> sudo systemctl enable docker
  • Docker 대신 containerd 사용하기로 결정
    - 위 내용 진행 후 폴더 삭제함
    >> sudo rm -r /etc/systemd/system/docker.service.d
    - docker service 정지
    >> systemctl stop docker.service
    >> systemctl stop docker.socket

 

Containerd 설치

  • Configure persistent loading of modules
    >> sudo tee /etc/modules-load.d/containerd.conf <<EOF
    overlay
    br_netfilter
    EOF
  • Load at runtime
    >> sudo modprobe overlay
    >> sudo modprobe br_netfilter
  • sysctl 파라미터 설정 확인
    >> sudo tee /etc/sysctl.d/kubernetes.conf<<EOF
    net.bridge.bridge-nf-call-ip6tables = 1
    net.bridge.bridge-nf-call-iptables = 1
    net.ipv4.ip_forward = 1
    EOF

  • Reload
    >> sudo sysctl --system
  • 패키지 설치
    >> sudo apt install -y curl gnupg2 software-properties-common apt-transport-https ca-certificates
  • Docker repo 추가
    >> curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    >> sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
  • containerd 설치
    >> sudo apt update
    >> sudo apt install -y containerd.io
  • containerd 설정
    >> sudo su -
    >> mkdir -p /etc/containerd
    >> containerd config default>/etc/containerd/config.toml
  • restart containerd
    >> sudo systemctl restart containerd
    >> sudo systemctl enable containerd
    >> systemctl status  containerd