控制器Deployment资源清单
官网
https://kubernetes.io/zh-cn/docs/concepts/workloads/controllers/deployment/
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment
namespace: test
spec:
replicas: 1
selector:
matchLabels:
environment: stg
template:
metadata:
labels:
environment: stg
spec:
containers:
- name: nginx-container
image: nginx:latest
imagePullPolicy: IfNotPresent
ports:
- name: nginx-port
containerPort: 80
protocol: TCP
lifecycle:
postStart:
exec:
command: ["/bin/sh","-c","echo jiayouba!!!!!>/usr/share/nginx/html/index.html"]
affinity: #亲和性设置
nodeAffinity: #设置node亲和性
requiredDuringSchedulingIgnoredDuringExecution: # 硬限制
nodeSelectorTerms:
- matchExpressions: # 匹配env的值在["xxx","yyy"]中的标签
- key: env
operator: In
values: ["test1","stg"]
亲和性
node亲和性,软限制:优先选择满足条件的Node进行调度,如果没有,也可以调度到不满足条件的节点上
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-deployment
namespace: test
spec:
replicas: 1
selector:
matchLabels:
environment: stg
template:
metadata:
labels:
environment: stg
spec:
containers:
- name: nginx-container
image: nginx:latest
imagePullPolicy: IfNotPresent
ports:
- name: nginx-port
containerPort: 80
protocol: TCP
lifecycle:
postStart:
exec:
command: ["/bin/sh","-c","echo jiayouba!!!!!>/usr/share/nginx/html/index.html"]
affinity: #亲和性设置
nodeAffinity: #设置node亲和性
preferredDuringSchedulingIgnoredDuringExecution: #软限制
- weight: 1
preference:
matchExpressions:
- key: env
operator: In
values: ["aaaa","bbbb"]
本文来自博客园,作者:弩哥++,转载请注明原文链接:https://www.cnblogs.com/bangbangzoutianya/p/16850393.html