9.5 Deployment

Time:2021-10-3

Deployment

Create a new pod_ 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

Then execute the following command to complete the creation

kubectl create -f pod_nginx.yml

see

kubectl get deployment -o wide
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
nginx-deployment 3 3 3 0 3m nginx nginx:1.12.2 app=nginx

kubectl get rs
NAME DESIRED CURRENT READY AGE
nginx-deployment-7498dc98f8 3 3 0 2m

kubectl get pods
NAME READY STATUS RESTARTS AGE
nginx-deployment-7498dc98f8-5687w 0/1 ContainerCreating 0 2m
nginx-deployment-7498dc98f8-f2lbx 0/1 ContainerCreating 0 2m
nginx-deployment-7498dc98f8-f8zwj 0/1 ContainerCreating 0 2m

Upgrade image

kubectl set image deployment nginx-deployment nginx=nginx:1.13
deployment.apps "nginx-deployment" image updated

NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
nginx-deployment 3 4 1 0 5m nginx nginx:1.13 app=nginx

Rollback image

kubectl rollout undo deployment nginx-deployment
deployment.apps "nginx-deployment"

kubectl get deployment -o wide
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE CONTAINERS IMAGES SELECTOR
nginx-deployment 3 4 3 0 7m nginx nginx:1.12.2 app=nginx

Node

see

kubectl get node -o wide
NAME STATUS ROLES AGE VERSION EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
minikube Ready <none> 2d v1.10.0 <none> Buildroot 2018.05 4.16.14 docker://17.12.1-ce

Port exposure

#Check
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2d

#Port exposure
kubectl expose deployment nginx-deployment --type=NodePort
Error from server (AlreadyExists): services "nginx-deployment" already exists

#Delete old
kubectl delete services nginx-deployment
service "nginx-deployment" deleted

#Re exposure
kubectl expose deployment nginx-deployment --type=NodePort
service "nginx-deployment" exposed

#Again, you can access the web page on the host using curl 192.168.99.100:30437
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2d
nginx-deployment NodePort 10.99.122.148 <none> 80:30437/TCP 15s

Recommended Today

Pull project branch process

reference resources:https://blog.csdn.net/qq_3972… —————-Corresponding code—————[email protected] MINGW64 ~/Desktop/userManag$ git initInitialized empty Git repository in C:/Users/qzxl/Desktop/userManag/.git/ [email protected] MINGW64 ~/Desktop/userManag (master)$ git remote add origin [email protected]:campus/frontend.git [email protected] MINGW64 ~/Desktop/userManag (master)$ git branch [email protected] MINGW64 ~/Desktop/userManag (master)$ git fetch origin devfatal: couldn’t find remote ref devfatal: the remote end hung up unexpectedly [email protected] MINGW64 ~/Desktop/userManag (master)$ ^C [email protected] MINGW64 ~/Desktop/userManag […]