Kubernetes : Minikube : Deploy Pods2019/08/26 |
[1] | Create or Delete Pods. |
# run 2 [test-nginx] pods 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 # show environment variable for [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 # shell access to [test-nginx] pod root@dlp:~# kubectl exec -it test-nginx-76b4548894-gbtdd bash
hostname test-nginx-76b4548894-gbtdd
root@test-nginx-76b4548894-gbtdd:/#
exit
# show logs of [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" "-" # scale out pods 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 # set service 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> # delete service root@dlp:~# kubectl delete services test-nginx service "test-nginx" deleted # delete pods root@dlp:~# kubectl delete deployment test-nginx deployment.extensions "test-nginx" deleted |
Sponsored Link |