- Introduce podAntiAffinity settings to avoid scheduling multiple Pods with the same app: taw label on the same node. - This is a soft requirement, meaning that if there are not enough nodes, Pods may still be scheduled on the same node. This change enhances the deployment strategy by improving availability and fault tolerance of the taw application.
121 lines
3.4 KiB
YAML
121 lines
3.4 KiB
YAML
apiVersion: apps/v1
|
|
kind: Deployment
|
|
#kind: DaemonSet
|
|
metadata:
|
|
name: app
|
|
namespace: taw
|
|
labels:
|
|
app: taw
|
|
spec:
|
|
replicas: 3
|
|
selector:
|
|
matchLabels:
|
|
app: taw
|
|
template:
|
|
metadata:
|
|
annotations: {}
|
|
labels:
|
|
app: taw
|
|
spec:
|
|
#nodeSelector:
|
|
# region: us
|
|
# dc: vkus
|
|
tolerations:
|
|
- key: "scheduling"
|
|
operator: "Equal"
|
|
value: "restricted"
|
|
effect: "NoSchedule"
|
|
affinity:
|
|
nodeAffinity:
|
|
requiredDuringSchedulingIgnoredDuringExecution:
|
|
nodeSelectorTerms:
|
|
- matchExpressions:
|
|
- key: kubernetes.io/hostname
|
|
operator: In
|
|
values:
|
|
- vkvm-us1
|
|
- vkvm-us2
|
|
- zgocloud-us1
|
|
podAntiAffinity:
|
|
# 尽量避免将拥有相同 app: taw 标签的 Pod 调度到同一节点上
|
|
# 这是一个"软性"要求,如果没有足够的节点,多个 Pod 仍可能调度到同一节点
|
|
preferredDuringSchedulingIgnoredDuringExecution:
|
|
- weight: 100
|
|
podAffinityTerm:
|
|
labelSelector:
|
|
matchExpressions:
|
|
- key: app
|
|
operator: In
|
|
values:
|
|
- taw
|
|
topologyKey: kubernetes.io/hostname
|
|
containers:
|
|
- name: app
|
|
image: songtianlun/today_ai_weather:main
|
|
imagePullPolicy: Always
|
|
ports:
|
|
- containerPort: 3000
|
|
name: web
|
|
env:
|
|
- name: DATABASE_URL
|
|
value: "postgresql://postgres:JG5haZAVcqpkYQtW@pg.taw.svc.cluster.local:5432/taw"
|
|
#value: "postgresql://taw:BEhQkRSw3eGPti2c@8.134.120.243:5432/today_ai_weather"
|
|
#value: "postgresql://taw:BEhQkRSw3eGPti2c@172.26.12.25:5432/today_ai_weather"
|
|
- name: REDIS_URL
|
|
value: "redis://redis.taw.svc.cluster.local:6379/0"
|
|
- name: RAILS_ENV
|
|
value: "production"
|
|
- name: RAILS_LOG_LEVEL
|
|
value: "info"
|
|
- name: RAILS_MASTER_KEY
|
|
value: "a1f61bf46afa19f4ca54d99638f6e7ce"
|
|
- name: TZ
|
|
value: "Asia/Shanghai"
|
|
|
|
---
|
|
apiVersion: apps/v1
|
|
kind: Deployment
|
|
metadata:
|
|
name: tasks
|
|
namespace: taw
|
|
labels:
|
|
app: tasks
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels:
|
|
app: tasks
|
|
template:
|
|
metadata:
|
|
annotations: {}
|
|
labels:
|
|
app: tasks
|
|
spec:
|
|
nodeSelector:
|
|
region: us
|
|
containers:
|
|
- name: tasks
|
|
image: songtianlun/today_ai_weather:main
|
|
imagePullPolicy: Always
|
|
command: ["bundle"]
|
|
args: ["exec", "sidekiq"]
|
|
env:
|
|
- name: DATABASE_URL
|
|
value: "postgresql://postgres:JG5haZAVcqpkYQtW@pg.taw.svc.cluster.local:5432/taw"
|
|
#value: "postgresql://taw:BEhQkRSw3eGPti2c@8.134.120.243:5432/today_ai_weather"
|
|
#value: "postgresql://taw:BEhQkRSw3eGPti2c@172.26.12.25:5432/today_ai_weather"
|
|
- name: REDIS_URL
|
|
value: "redis://redis.taw.svc.cluster.local:6379/0"
|
|
- name: RAILS_ENV
|
|
value: "production"
|
|
- name: RAILS_LOG_LEVEL
|
|
value: "info"
|
|
- name: RAILS_MASTER_KEY
|
|
value: "a1f61bf46afa19f4ca54d99638f6e7ce"
|
|
- name: TZ
|
|
value: "Asia/Shanghai"
|
|
|
|
|
|
---
|
|
|