Kubernetes : Minikube : Pod デプロイ2019/08/26 |
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-76b4548894-gbtdd 1/1 Running 0 23s # [test-nginx] pod の環境変数を表示する root@dlp:~# kubectl exec test-nginx-76b4548894-gbtdd env PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOSTNAME=test-nginx-76b4548894-gbtdd KUBERNETES_SERVICE_PORT=443 KUBERNETES_SERVICE_PORT_HTTPS=443 KUBERNETES_PORT=tcp://10.96.0.1:443 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 NGINX_VERSION=1.17.3 NJS_VERSION=0.3.5 PKG_RELEASE=1~buster HOME=/root # [test-nginx] pod にシェルアクセス root@dlp:~# kubectl exec -it test-nginx-76b4548894-gbtdd bash
hostname test-nginx-76b4548894-gbtdd
root@test-nginx-76b4548894-gbtdd:/#
exit
# [test-nginx] pod のログを表示する root@dlp:~# kubectl logs test-nginx-76b4548894-gbtdd 127.0.0.1 - - [23/Aug/2019: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-76b4548894-dkp74 1/1 Running 0 16s test-nginx-76b4548894-gbtdd 1/1 Running 0 2m22s test-nginx-76b4548894-sz5gc 1/1 Running 0 16s # サービスを設定する 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.97.196.173 <none> 80:31941/TCP 7sroot@dlp:~# minikube service test-nginx --url * http://192.168.39.235:31941 root@dlp:~# curl http://192.168.39.235:31941 <!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 |
|