<aside> <img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/4fdb62ea-b6a0-4289-b552-6fe2feed518a/logo.png" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/4fdb62ea-b6a0-4289-b552-6fe2feed518a/logo.png" width="40px" /> Kubernetes

<aside> 🐳 Docker의 container 강점

<aside> 🐳 Docker의 container 약점

→ container의 약점을 보완한 K8S - Container Orchestration

<aside> 📌 K8S (container orchestration)

Untitled

<aside> 💡 서비스 관리를 개별적 → 집단적

</aside>

</aside>

<aside> 🚧 Kubernetes 설치

master | node1 | node2 | node3 작업

  1. SWAP 기능 끄기

    swapoff -a
    vi /etc/fstab
    reboot
    

    Untitled

    modprobe br_netfilter
    echo '1' > /proc/sys/net/bridge/bridge-nf-call-iptables
    
    vi /etc/sysctl.conf
    
    # 내용추가
    

    net.bridge.bridge-nf-call-iptables = 1 net.bridge.bridge-nf-call-ip6tables = 1

    reboot
    

    Untitled

    # kubernetes repository 다운
    cd /etc/yum.repos.d
    wget <http://down.cloudshell.kr/k8s/kubernetes.repo>
    
    vi /usr/lib/systemd/system/docker.service
    ExecStart=/usr/bin/dockerd 바로 뒤에 
    

    --exec-opt native.cgroupdriver=systemd

    를 삽입한다
    

    Untitled

    systemctl daemon-reload
    systemctl restart docker
    
    # 확인
    docker info | grep -i cgroup
    

    Untitled

    #kubernetes 설치
    yum install -y kubelet-1.21.1-0 kubeadm-1.21.1-0 kubectl-1.21.1-0
    systemctl daemon-reload
    systemctl enable kubelet --now
    

    Master에서 작업 (Clustering 구축)

    #Clustering 구성하기 
    kubeadm init --kubernetes-version=v1.21.1
    
    # Master API로 commands를 config 
    mkdir -p $HOME/.kube
    cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
    chown $(id -u):$(id -g) $HOME/.kube/config
    
    # 꼭 복사
    ⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
    kubeadm join 10.0.2.12:6443 --token il46it.62rwg4lqjokztqbk \\
            --discovery-token-ca-cert-hash sha256:92001b9269af854651db34a3e1f7e4fd19c06803c53717b7dbc3df4323d09f77
    ⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐⭐
    

    Untitled

    # version 확인 (kubectl: 제어, kubeamd: 관리자, kubelet: )
    kubectl version --short
    kubeadm version -o yaml
    kubelet --version
    
    #weave-net 설치
    export kubever=$(kubectl version | base64 | tr -d '\\n')
    kubectl apply -f "<https://cloud.weave.works/k8s/net?k8s-version=$kubever>"
    

    Untitled

    kubectl get pods -A
    kubectl get pod -n kube-system
    

    Untitled

    kubectl get nodes
    

    Untitled

    node1 | node2 | node3 에서만 작업

    # node1, node2, node3 실행
    kubeadm join 10.0.2.12:6443 --token il46it.62rwg4lqjokztqbk \\
            --discovery-token-ca-cert-hash sha256:92001b9269af854651db34a3e1f7e4fd19c06803c53717b7dbc3df4323d09f77
    
    # master에서 확인
    kubectl get nodes
    

    Untitled

</aside>