Kubernetes : Minikube : Pod デプロイ2018/10/22 |
Minikube で構成した シングルノード Kubernetes クラスターでの Pod 作成等の基本操作です。
|
[1] | Pod の作成/削除等の操作です。 |
# [test-nginx] pod を起動する root@dlp:~# kubectl create deployment test-nginx --image=nginx deployment.apps/test-nginx created kubectl get pods NAME READY STATUS RESTARTS AGE test-nginx-6dbb5ccbb6-ghxhm 1/1 Running 0 10s # [test-nginx] pod の環境変数を表示する root@dlp:~# kubectl exec test-nginx-6dbb5ccbb6-ghxhm env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOSTNAME=test-nginx-6dbb5ccbb6-ghxhm KUBERNETES_PORT_443_TCP=tcp://10.96.0.1:443 KUBERNETES_PORT_443_TCP_PROTO=tcp KUBERNETES_PORT_443_TCP_PORT=443 KUBERNETES_PORT_443_TCP_ADDR=10.96.0.1 KUBERNETES_SERVICE_HOST=10.96.0.1 KUBERNETES_SERVICE_PORT=443 KUBERNETES_SERVICE_PORT_HTTPS=443 KUBERNETES_PORT=tcp://10.96.0.1:443 NGINX_VERSION=1.15.5-1~stretch NJS_VERSION=1.15.5.0.2.4-1~stretch HOME=/root # [test-nginx] pod にシェルアクセス root@dlp:~# kubectl exec -it test-nginx-6dbb5ccbb6-ghxhm bash
hostname test-nginx-6dbb5ccbb6-ghxhm
root@test-nginx-6dbb5ccbb6-ghxhm:/#
exit
# [test-nginx] pod のログを表示する root@dlp:~# kubectl logs test-nginx-6dbb5ccbb6-ghxhm 127.0.0.1 - - [22/Oct/2018:04:53:47 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.52.1" "-" # pod をスケールアウトする root@dlp:~# kubectl scale deployment test-nginx --replicas=3 deployment.extensions/test-nginx scaled root@dlp:~# kubectl get pods NAME READY STATUS RESTARTS AGE test-nginx-6dbb5ccbb6-ghxhm 1/1 Running 0 4m test-nginx-6dbb5ccbb6-j4z2p 1/1 Running 0 11s test-nginx-6dbb5ccbb6-n54g4 1/1 Running 0 11s # サービスを設定する root@dlp:~# kubectl expose deployment test-nginx --type="NodePort" --port 80 service "test-nginx" exposed root@dlp:~# kubectl get services test-nginx NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE test-nginx NodePort 10.96.215.196 <none> 80:31051/TCP 10sroot@dlp:~# minikube service test-nginx --url http://192.168.39.30:31051 root@dlp:~# curl http://192.168.39.30:31051 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title> ..... ..... <p><em>Thank you for using nginx.</em></p> </body> </html> # サービスを削除する root@dlp:~# kubectl delete services test-nginx service "test-nginx" deleted # Pod を削除する root@dlp:~# kubectl delete deployment test-nginx deployment.extensions "test-nginx" deleted |
Sponsored Link |