(21) Kubernetes Practical Introduction - Deployment

1. Concept

In kubernetes, pod is the smallest control unit, but kubernetes rarely directly controls pod, which is usually done through the Pod controller. The Pod controller is used for pod management to ensure that the pod resource meets the expected state. When the pod resource fails, it will try to restart or rebuild the pod. There are many types of Pod controllers in kubernetes, and this chapter only introduces one: Deployment.

Two, operation

  1. Command operation
#命令格式: kuberctl run deployment名称 [参数]
#--image 指定pod镜像
#--port 指定端口
#--namespace 指定ns
#--replicas pod格式,默认1个
kubectl run nginx --image=nginx:1.17.1 --port=80 --replicas=3 -n dev
#同时查看pod和ns
kubectl get deployment,pods -v dev
#查看deployment详情
kubectl describe deployment nginx -v dev
#删除,删除后deployment下的pod也被删除
kubectl delete deploy nginx -n dev
  1. Configuration operation
    Create the deploy-nginx.yaml file:
apiVersion: apps/v1
kind: Deployment
metadata:
	name: nginx
	namespace: dev
spec:
	replicas: 3
	selector:
		matchLabels:
			run: nginx
	template:
		metadata:
			labels:
				run: nginx
		spec:
			containers:
				- image: nginx:1.17.1
				  name: nginx
				  ports:
				  	- containerPort: 80
				  	  portocol: TCP
#创建deployment
kubectl create -f deploy-nginx.yaml
#删除
kubectl delete -f deploy-nginx.yaml

》》》Bloggers update their learning experience for a long time, recommend likes and follow! ! !
》》》If there is something wrong, please leave a message in the comment area, thank you! ! !

Guess you like

Origin blog.csdn.net/qq_41622739/article/details/114185185