标签:yam ons 声明 守护进程 周期性 image date max template
# kubectl explain ReplicaSet
# kubectl explain ReplicaSet.spec
# kubectl explain ReplicaSet.spec.template
# kubectl explain ReplicaSet.spec.template.spec
manifests]# vim rs-demo.yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: myapp
namespace: default
spec:
replicas: 2
selector:
matchLabels:
app: myapp
release: canary
template:
metadata:
name: myapp-pod
labels:
app: myapp
release: canary
environment: qa
spec:
containers:
- name: myapp-container
image: dongfeimg/myapp:v1
ports:
- name: http
containerPort: 80
# kubectl get rs
# kubectl edit rs myapp
spec:
replicas: 5 #可动态修改Pod副本
# kubectl edit rs myapp
spec:
containers:
- image: dongfeimg/myapp:v2
# kubectl get rs -o wide
注意:只有重建的Pod才是新版本的image
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp-deploy
namespace: default
spec:
replicas: 2
selector:
matchLabels:
app: myapp
release: canary
template:
metadata:
labels:
app: myapp
release: canary
spec:
containers:
- name: myapp
image: dongfeimg/myapp:v1
ports:
- name: http
containerPort: 80
# kubectl apply -f Deployment-damo.yaml
# kubectl get deploy
# kubectl get rs
# kubectl get pods
# kubectl describe deploy myapp-deploy
# kubectl rollout history deployment myapp-deploy
# kubectl get pods -l app=myapp -w
# kubectl patch deployment myapp-deploy -p '{"spec":{"relicas":5}}'
# kubectl patch deployment myapp-deploy -p '{"spec":{"strategy":{"rollingUpdate":{"maxSurge":1,"maxUnavailable":0}}}}'
# kubectl set image deployment myapp-deploy myapp=dongfeimg/myapp:v2 && kubectl rollout pause deployment myapp-deploy #丢出一只金丝雀
# kubectl rollout status deployment myapp-deploy
# kubectl get pods -l app=myapp -w
# kubectl rollout resume deployment myapp-deploy #所有的都开始更新
# kubectl rollout history deployment myapp-deploy #查看历史版本
# kubectl rollout undo deployment myapp-deploy --to-revision=1 #回滚到第一版
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: filebeat-ds
namespace: default
spec:
selector:
matchLabels:
app: filebeat
release: stable
template:
metadata:
labels:
app: filebeat
release: stable
spec:
containers:
- name: filebeat
image: dongfeimg/filebeat:5.6.5-alpine
env:
- name: REDIS_HOST
value: redis.default.svc.cluster.local
- name: REDIS_LOG_LEVEL
value: info
filebeat + redis
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: redis
role: logstor
template:
metadata:
labels:
app: redis
role: logstor
spec:
containers:
- name: redis
image: redis:4.0-alpine
ports:
- name: redis
containerPort: 6379
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: filebeat-ds
namespace: default
spec:
selector:
matchLabels:
app: filebeat
release: stable
template:
metadata:
labels:
app: filebeat
release: stable
spec:
containers:
- name: filebeat
image: dongfeimg/filebeat:5.6.5-alpine
env:
- name: REDIS_HOST
value: redis.default.svc.cluster.local
- name: REDIS_LOG_LEVEL
value: info
# kubectl set image daemonsets filebeat-ds filebeat=ikubernetes/filebeat:5.6.6-alpine
标签:yam ons 声明 守护进程 周期性 image date max template
原文地址:https://www.cnblogs.com/L-dongf/p/9918067.html