성공적인 운영의 예시 포켓몬Go
~$ minikube version
~$ minikube start --wait=false
* minikube v1.25.2 on Ubuntu 18.04
* Kubernetes 1.23.3 is now available. If you would like to upgrade, specify: --kubernetes-version=v1.23.3
* Using the virtualbox driver based on existing profile
* Starting control plane node minikube in cluster minikube
* minikube 1.26.0 is available! Download it: https://github.com/kubernetes/minikube/releases/tag/v1.26.0
* To disable this notice, run: 'minikube config set WantUpdateNotification false'
* Restarting existing virtualbox VM for "minikube" ...
* Preparing Kubernetes v1.23.1 on Docker 20.10.12 ...
- kubelet.housekeeping-interval=5m
- Using image gcr.io/k8s-minikube/storage-provisioner:v5
* Verifying Kubernetes components...
* Enabled addons: storage-provisioner, default-storageclass
* Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
~$ kubectl create deployment first-deployment --image=katacoda/docker-http-server
deployment.apps/first-deployment created
~$ kubectl get pods
NAME READY STATUS RESTARTS AGE
first-deployment-54c6c6b5bc-vrqhk 1/1 Running 0 72s
~$ kubectl expose deployment first-deployment --port=80 --type=NodePort
service/first-deployment exposed
// 이 컨테이너들이 port80을 통해서 외부와 통신을 위해 NodePort라는 서비스를 사용한다.
//port를 열어주는 export 작업
~$ export PORT=$(kubectl get svc first-deployment -o go-template='{{range.spec.ports}}{{if.nodePort}}{{.nodePort}}{{"\n"}}{{end}}{{end}}')
~$ echo "Accessing host01:$PORT"
Accessing host01:32694
//접속
~$ curl host01:$PORT
<h1>This request was processed by host : first-deployment-54c6c6b5bc-vrqhk</h1>
예제를 실행함으로써 도커와 쿠버네티스의 차이를 알아보았다.
도커의 경우, 손으로 입력해보고 무얼해야하는지 CLI를 확인했었다.
쿠버네티스는 복잡한 일을 많이 제공해준다. 대시보드라는 기능을 제공한다.
~$ minikube addons enable dashboard
- Using image kubernetesui/dashboard:v2.3.1
- Using image kubernetesui/metrics-scraper:v1.0.7
* Some dashboard features require the metrics-server addon. To enable all features please run:
minikube addons enable metrics-server
* The 'dashboard' addon is enabled
//대시보드라는 서비스를 deploy한다.
//dockre-compose를 실행한것과 비슷하다.
~$ kubectl apply -f /opt/kubernetes-dashboard.yaml
// 정상적으로 작동하는지 확인
~$ kubectl get pods -n kubernetes-dashboard -w
NAME READY STATUS RESTARTS AGE
dashboard-metrics-scraper-58549894f-gd957 1/1 Running 0 4m12s
kubernetes-dashboard-ccd587f44-bsnnl 1/1 Running 0 4m12s