• 쿠버네티스 기초학습[클러스터 생성, 앱 배포]

    2021. 4. 6. 18:57

    by. 위지원

     

     

    Minikube를 사용해서 클러스터 생성하기

    목표 쿠버네티스 클러스터가 무엇인지 배운다. Minikube가 무엇인지 배운다. 온라인 터미널을 사용해서 쿠버네티스 클러스터를 시작한다. 쿠버네티스 클러스터 쿠버네티스는 컴퓨터들을 연결하

    kubernetes.io

    쿠버네티스 클러스터는 두 가지 형태의 자원으로 구성된다.

    • 컨트롤 플레인은 클러스터를 조율한다.
    • 노드는 애플리케이션을 구동하는 작업자(worker)이다.
    $ minikube start
    $ kubectl cluster-info
    Kubernetes master is running at https://127.0.0.1:64919
    KubeDNS is running at https://127.0.0.1:64919/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
    To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
    $ kubectl get nodes
    NAME STATUS ROLES AGE VERSION
    minikube Ready control-plane,master 28m v1.20.2

     

    디플로이먼트? .. 이걸 오 ㅐ또하는..? 그래도 다른게 있어서 그런거라 생각하고 따라가보겠다. 

    - 애플리케이션의 인스턴스를 어떻게 생성하고 업데이트하는 역할

    - 머신의 장애나 정비에 대응할 수 있는 자동 복구(self-healing) 메커니즘을 제공한다.

     

    terminal1

    아래 명령어를 이용해 디플로이먼트를 생성해준다.

    $ kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1
    deployment.apps/kubernetes-bootcamp created
    $ kubectl get deployments
    NAME READY UP-TO-DATE AVAILABLE AGE
    kubernetes-bootcamp 0/1 1 0 14s

    아래의 작업들은 지난번에 알아본것과 동일하게.. 외부접속을 허용케 하는 작업이다.

    " By default they are visible from other pods and services within the same kubernetes cluster, but not outside that network. "

    아래 명령어를 이용해 프록시를 run해준다.

    $ echo -e "\n\n\n\e[92mStarting Proxy. After starting it will not output a response.
    Please click the first Terminal Tab\n";
    kubectl proxy
    Starting Proxy. After starting it will not output a response. Please click the first
    Terminal Tab
    Starting to serve on 127.0.0.1:8001
    curl http://localhost:8001/version
    " We now have a connection between our host (the online terminal) and the Kubernetes cluster. "

     

    terminal2

    지난번과 과정이 조금 다르긴하다. 

    # we can query the version directly through the API using the curl command:
    curl http://localhost:8001/version <<- 이게 쿼리날리는거다
    {
    "major": "1",
    "minor": "20",
    "gitVersion": "v1.20.2",
    "gitCommit": "faecb196815e248d3ecfb03c680a4507229c2a56",
    "gitTreeState": "clean",
    "buildDate": "2021-01-13T13:20:00Z",
    "goVersion": "go1.15.5",
    "compiler": "gc",
    "platform": "linux/amd64"
    }%

    아래의 명령어를 이용해 .. pod_name 환경변수에 설정을 해줄 수 있다..

    export POD_NAME=$(kubectl get pods -o go-template --template
    '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}')
    echo Name of the Pod: $POD_NAME
    Name of the Pod: kubernetes-bootcamp-57978f5f5d-lql7c

    위에 뜬 주소로 가면 이와같이 확인이 가능하다.

    profile
    위지원

    데이터 엔지니어로 근무 중에 있으며 데이터와 관련된 일을 모두 좋아합니다!. 특히 ETL 부분에 관심이 가장 크며 데이터를 빛이나게 가공하는 일을 좋아한답니다 ✨