0. list all deployments & pods:

kubectl get deployments
kubectl get pods

1. view current app version:

kubectl describe pods

2. update your app

kubectl set image deployments/deploymentName deploymentName=jocatalin/deploymentName:newVersion

kubectl set image deployments/kubernetes-bootcamp kubernetes-bootcamp=jocatalin/kubernetes-bootcamp:v2

check that app is running, view the exposed ip & port

kubectl describe services/deploymentName

kubectl describe services/kubernetes-bootcamp

confirm update status:

kubectl rollout status deployments/kubernetes-bootcamp

roll back to previous version:

kubectl rollout undo deployments/kubernetes-bootcamp

3. expand the deployments

view the replicates that deployment created.

kubectl get rs

scale the deployment:

kubectl scale deployments/kubernetes-bootcamp --replicas=4

view the number of pods

kubectl get pods -o wide

Create an environment variable called NODE_PORT that has a value as the Node port:

export NODE_PORT=$(kubectl get services/kubernetes-bootcamp -o go-template='{{(index .spec.ports 0).nodePort}}')
echo NODE_PORT=$NODE_PORT

Next, we’ll do a curl to the exposed IP and port. Execute the command multiple times:

curl $(minikube ip):$NODE_PORT

We hit a different Pod with every request. This demonstrates that the load-balancing is working.

4. exposed your app

list the services of our cluster:

kubectl get services
kubectl expose deployment/kubernetes-bootcamp --type="NodePort" --port 8080
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐