当前位置:网站首页>Deployment of kubernetes' controller

Deployment of kubernetes' controller

2022-06-26 15:01:00 Hua Weiyun

kubernetes Of Controller And deployment

Controller yes kubernetes Objects that manage and run containers in a cluster ,pod adopt Controller Perform application operations ,Controller And pod adopt label Label to correspond ,Controller Load can be carried out

deployment yes pod A kind of controller , Deploy stateless applications , It's used to manage pod and replicaSet, It supports rolling upgrade and other functions

Use yaml To create an application

First we use the command to create a yaml file

kubectl create deployment web --image=nginx --dry-run -o yaml > nginx.yaml

among web Indicates the name of the application

So we can generate a Nginx Of yaml file , Then you can make changes based on this file , To use this file, use the command

kubectl apply -f nginx.yaml

And then expose the ports :

kubectl expose deployment web --port=80 --type=NodePort --target-port=80 --name=web1 -o yaml > web1.yaml

among port It's the internal port ,target-port It's an open port

After that, you can use the following command to view the status of the service

kubectl get pods,svc

We just said that it supports application upgrade 、 Rollback and elastic scaling

upgrade

Use command

kubectl set image deployment web nginx=nginx:1.16

Upgrade the app by setting its version number

The upgrade process will not be suspended until the application container is created

Check the upgrade status

kubectl rollout status deployment webname

Rollback the previous version command :

kubectl rollout undo deployment web

You can also rollback to the specified version , Add parameters - -to revision=3

View historical version

kubectl rollout history deployment web

summary

deployment It can guarantee the support services pod Number , Dynamic scaling , Elastic expansion and contraction , But it does not solve the problem of how to access the service , When a new node with a new ip When it starts , Not sure about its ip And port , Therefore, service discovery and load balancing cannot be carried out , This requires service Object .service It's like a registry , adopt service Get the provided ip and port,service Load balancing can also be done ,pod and service Is associated through label and selector Associated .Service Three common types are ClusterIp,NodePort and LoadBalancer, The default is ClusterIp,LoadBalancer It can be used during external visits . You can add yaml In file type The property value of the field changes service type .

️ Thank you for your

If you think this is helpful for you :

  1. Welcome to follow me ️, give the thumbs-up , Comment on , forward
  2. Focus on Panpan small class , Push good articles for you regularly , There are also group chat and irregular lottery activities , You can say what you want , Communicate with the great gods , Learning together .
  3. If there is anything inappropriate, you are welcome to criticize and correct .
原网站

版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261438086337.html

随机推荐