标签:fail png 场景 rtp 运维 http busybox 扩容 rev
kubernetes控制器kubectl explain deployment.spec
$ vim deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deploy
namespace: prod
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.18-alpine
ports:
- containerPort: 80
$ kubectl apply -f deployment.yml
$ kubectl get deploy -n prod -o wide
被控制对象是放在template下的containers
$ kubectl create deployment web --image=nginx:1.14
$ kubectl get deploy,pods
$ kubectl expose deployment web --port=80 --type=NodePort --target-port=80 --name=web
$ kubectl get svc,deploy,pod
$ kubectl set image deploy/web nginx=nginx:1.15
$ kubectl rollout status deploy/web #查看升级状态
$ kubectl rollout history deploy/web #查看版本
$ kubectl rollout undo deploy/web #回滚到上一个版本
$ kubectl rollout undo deploy/web --to-revision=1 #回到指定版本
$ kubectl scale deployment web --replicas=10 #扩容
$ kubectl scale deployment web --replicas=1 #缩容
$ cat job.yml
apiVersion: batch/v1
kind: Job
metadata:
name: pi
namespace: prod
spec:
template:
spec:
containers:
- name: pi
image: perl
command: ["perl","-Mbignum=bpi","-wle","print bpi(20000)"]
restartPolicy: Never
backoffLimit: 4
$ kubectl get pod -n prod
$ kubectl get job -n prod
$ kubectl logs -f pi-rjdhm -n prod
$ vim cronjob.yml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: cron
namespace: prod
spec:
schedule: "*/1 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: hello
image: busybox
args:
- /bin/sh
- -c
- date;echo hello from the kubernetes cluster
restartPolicy: OnFailure
$ kubectl get cronjob -n prod
$ kubectl logs -f cron-1595347620-nptsf -n prod
标签:fail png 场景 rtp 运维 http busybox 扩容 rev
原文地址:https://blog.51cto.com/13812615/2513029