1
0
Fork 0

experiment with pod affinity

This commit is contained in:
Massaki Archambault 2021-12-26 19:11:38 -05:00
parent 9b7da0a01d
commit e888430474
6 changed files with 68 additions and 11 deletions

View File

@ -5,3 +5,11 @@ bases:
resources:
- nextcloud-deployment.yaml
- nextcloud-ingress.yaml
commonLabels:
app.kubernetes.io/name: nextcloud
# TODO
# patchesStrategicmerge:
# - patches/postgres-podaffinity-patch.yaml
# - patches/redis-podaffinity-patch.yaml

View File

@ -4,6 +4,7 @@ metadata:
name: nextcloud
labels:
app.kubernetes.io/name: nextcloud
app.kubernetes.io/component: server
spec:
replicas: 1
strategy:
@ -11,22 +12,32 @@ spec:
selector:
matchLabels:
app.kubernetes.io/name: nextcloud
app.kubernetes.io/component: server
template:
metadata:
labels:
app.kubernetes.io/name: nextcloud
app.kubernetes.io/component: server
spec:
affinity:
nodeAffinity:
# prefer to not be on a server node (resource contention)
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: kubernetes.io/hostname
operator: NotIn
values:
- k3s-s0
- key: node-role.kubernetes.io/master
operator: DoesNotExist
# podAffinity:
# preferredDuringSchedulingIgnoredDuringExecution:
# - weight: 2
# podAffinityTerm:
# labelSelector:
# matchExpressions:
# - key: app.kubernetes.io/name
# operator: In
# values:
# - nextcloud
# topologyKey: kubernetes.io/hostname
containers:
- name: nextcloud
image: nextcloud

View File

@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: postgres
spec:
template:
spec:
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- nextcloud
topologyKey: kubernetes.io/hostname

View File

@ -0,0 +1,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis
spec:
template:
spec:
affinity:
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app.kubernetes.io/name
operator: In
values:
- nextcloud
topologyKey: kubernetes.io/hostname

View File

@ -3,17 +3,17 @@ kind: StatefulSet
metadata:
name: postgres
labels:
app.kubernetes.io/name: postgres
app.kubernetes.io/component: postgres
spec:
serviceName: postgres
selector:
matchLabels:
app.kubernetes.io/name: postgres
app.kubernetes.io/component: postgres
replicas: 1
template:
metadata:
labels:
app.kubernetes.io/name: postgres
app.kubernetes.io/component: postgres
spec:
containers:
- name: postgres

View File

@ -3,16 +3,16 @@ kind: Deployment
metadata:
name: redis
labels:
app.kubernetes.io/name: redis
app.kubernetes.io/component: redis
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: redis
app.kubernetes.io/component: redis
template:
metadata:
labels:
app.kubernetes.io/name: redis
app.kubernetes.io/component: redis
spec:
containers:
- name: redis