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: #亲和性设置
podAffinity: #设置pod亲和性
requiredDuringSchedulingIgnoredDuringExecution: #硬限制
- labelSelector:
matchExpressions: # 匹配env的值在["xxx","yyy"]中的标签
- key: podenv
operator: In
values: ["xxx","yyy"]
topologyKey: kubernetes.io/hostname
标签:name,亲和性,environment,nginx,Affinity,pod
From: https://www.cnblogs.com/bangbangzoutianya/p/16851840.html