k8s基础命令
【代码】k8s基础命令。
·
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
更多推荐
已为社区贡献1条内容
所有评论(0)