Original article, welcome to reprint. Reprint please specify: reprint from IT people story, thank you! K8s Important Deployment (64)
Pod, ReplicationController, ReplicaSet. This time focus on Deoloyments. Source: github.com/limingios/d…
The official introduction
Kubernetes. IO/docs/concep… Deployment provides declarative updates for Pod and Replica Set. All you need to do is describe what your desired target state is in the Deployment and the Deployment Controller will help you change the actual status of the Pod and ReplicaSet to your target state. You can define a new Deployment to create ReplicaSet or delete the existing Deployment and create a new one to replace it. Note: you should not manage the Replica sets created by Deployment manually, otherwise you usurp the responsibility of Deployment Controller! All use cases that are covered in the Deployment object are listed below. If you don’t have all the use cases covered, please mention the issue directly in Kubernetes’ codebase.
Delpyment demo
- Start the minikube
minikube start
Copy the code
deployment_nginx.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.12.2
ports:
- containerPort: 80
Copy the code
- Create a deployment
kubectl create -f deployment_nginx.yml
kubectl get deployment
kubectl get rs
kubectl get pods
Copy the code
- Deployment information
You can see the details under deloire, nginx is 1.12.2
kubectl get deployment -o wide
Copy the code
- Deployment of the upgrade
For current nginx1.12 upgrade to 1.13 commands, the old ones are automatically removed, and all of them are under the new ones.
kubectl setImage deployment nginx- Deployment nginx=nginx:1.13 kubectl get deployment kubectl get -o wide kubectl get podsCopy the code
- Deployment View the historical version
kubectl rollout history deployment nginx-deployment
Copy the code
- Deployment rolls back to the previous version
This is now nginx 1.12.2
kubectl rollout undo deployment nginx-deployment
Copy the code
- Deployment port exposed
This is essentially exposing the port to the minikube.
kubectl get node
kubectl get node -o wide
kubectl expose deployment nginx-deployment --type=NodePort
# check port 30960 exposed on node
kubectl get svc
Enter minikube and check the IP address 192.168.99.100
minikube ssh
Copy the code
PS: No matter how the service is exposed, what is the service and what is the exposed NodePort? We will talk about it in detail next time.