Skip to content

Commit

Permalink
ci: add pod affinity + remove kustomize prefix (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
NGPixel committed Aug 26, 2024
1 parent 36bafea commit 7b61a07
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 34 deletions.
4 changes: 2 additions & 2 deletions k8s/iabweb/cron.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: cron-weekly
name: iabwww-cron-weekly
spec:
schedule: "30 0 * * 0" # "At 00:30 on Sunday."
timeZone: "Etc/UTC"
Expand All @@ -13,7 +13,7 @@ spec:
spec:
restartPolicy: Never
containers:
- name: cron-weekly
- name: iabwww-cron-weekly
image: "ghcr.io/ietf-tools/www:$APP_IMAGE_TAG"
imagePullPolicy: Always
volumeMounts:
Expand Down
3 changes: 1 addition & 2 deletions k8s/iabweb/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace: iabwww
namePrefix: iabwww-
configMapGenerator:
- name: files-cfgmap
- name: iabwww-files-cfgmap
files:
- local.py
- supervisord.conf
Expand Down
24 changes: 17 additions & 7 deletions k8s/iabweb/memcached.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: memcached
name: iabwww-memcached
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
matchLabels:
app: memcached
app: iabwww-memcached
template:
metadata:
labels:
app: memcached
app: iabwww-memcached
spec:
securityContext:
runAsNonRoot: true
containers:
- image: "quay.io/prometheus/memcached-exporter:v0.14.3"
imagePullPolicy: IfNotPresent
name: memcached-exporter
name: iabwww-memcached-exporter
ports:
- name: metrics
containerPort: 9150
Expand All @@ -34,7 +34,7 @@ spec:
- image: "memcached:1.6-alpine"
imagePullPolicy: IfNotPresent
args: ["-m", "256"]
name: memcached
name: iabwww-memcached
ports:
- name: memcached
containerPort: 11211
Expand All @@ -51,11 +51,21 @@ spec:
dnsPolicy: ClusterFirst
restartPolicy: Always
terminationGracePeriodSeconds: 30
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- iabwww-wagtail
topologyKey: "kubernetes.io/hostname"
---
apiVersion: v1
kind: Service
metadata:
name: memcached
name: iabwww-memcached
annotations:
k8s.grafana.com/scrape: "true" # this is not a bool
k8s.grafana.com/metrics.portName: "metrics"
Expand All @@ -71,4 +81,4 @@ spec:
protocol: TCP
name: metrics
selector:
app: memcached
app: iabwww-memcached
2 changes: 1 addition & 1 deletion k8s/iabweb/secrets.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: secrets-env
name: iabwww-secrets-env
type: Opaque
stringData:
IABWWW_ADMINS: null
Expand Down
22 changes: 16 additions & 6 deletions k8s/iabweb/wagtail.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: wagtail
name: iabwww-wagtail
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
matchLabels:
app: wagtail
app: iabwww-wagtail
template:
metadata:
labels:
app: wagtail
app: iabwww-wagtail
spec:
securityContext:
fsGroup: 1000
Expand All @@ -20,7 +20,7 @@ spec:
# -----------------------------------------------------
# wagtail Container
# -----------------------------------------------------
- name: wagtail
- name: iabwww-wagtail
image: "ghcr.io/ietf-tools/www:$APP_IMAGE_TAG"
imagePullPolicy: Always
ports:
Expand Down Expand Up @@ -78,6 +78,16 @@ spec:
dnsPolicy: ClusterFirst
restartPolicy: Always
terminationGracePeriodSeconds: 30
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- ietfwww-wagtail

This comment was marked as resolved.

Copy link
@kesara

kesara Aug 26, 2024

Member

@NGPixel: This should be iabwww-wagtail.

This comment was marked as resolved.

Copy link
@NGPixel

NGPixel Aug 26, 2024

Author Member

No, it's an anti-affinity constraint.

topologyKey: "kubernetes.io/hostname"
volumeClaimTemplates:
- metadata:
name: iabwww-media
Expand All @@ -92,7 +102,7 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: wagtail
name: iabwww-wagtail
spec:
type: ClusterIP
ports:
Expand All @@ -101,4 +111,4 @@ spec:
protocol: TCP
name: http
selector:
app: wagtail
app: iabwww-wagtail
3 changes: 1 addition & 2 deletions k8s/ietfweb/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace: ietfwww
namePrefix: ietfwww-
configMapGenerator:
- name: files-cfgmap
- name: ietfwww-files-cfgmap
files:
- local.py
- supervisord.conf
Expand Down
24 changes: 17 additions & 7 deletions k8s/ietfweb/memcached.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: memcached
name: ietfwww-memcached
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
matchLabels:
app: memcached
app: ietfwww-memcached
template:
metadata:
labels:
app: memcached
app: ietfwww-memcached
spec:
securityContext:
runAsNonRoot: true
containers:
- image: "quay.io/prometheus/memcached-exporter:v0.14.3"
imagePullPolicy: IfNotPresent
name: memcached-exporter
name: ietfwww-memcached-exporter
ports:
- name: metrics
containerPort: 9150
Expand All @@ -34,7 +34,7 @@ spec:
- image: "memcached:1.6-alpine"
imagePullPolicy: IfNotPresent
args: ["-m", "1024"]
name: memcached
name: ietfwww-memcached
ports:
- name: memcached
containerPort: 11211
Expand All @@ -51,11 +51,21 @@ spec:
dnsPolicy: ClusterFirst
restartPolicy: Always
terminationGracePeriodSeconds: 30
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- ietfwww-wagtail
topologyKey: "kubernetes.io/hostname"
---
apiVersion: v1
kind: Service
metadata:
name: memcached
name: ietfwww-memcached
annotations:
k8s.grafana.com/scrape: "true" # this is not a bool
k8s.grafana.com/metrics.portName: "metrics"
Expand All @@ -71,4 +81,4 @@ spec:
protocol: TCP
name: metrics
selector:
app: memcached
app: ietfwww-memcached
2 changes: 1 addition & 1 deletion k8s/ietfweb/secrets.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: secrets-env
name: ietfwww-secrets-env
type: Opaque
stringData:
IETFWWW_ADMINS: null
Expand Down
22 changes: 16 additions & 6 deletions k8s/ietfweb/wagtail.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: wagtail
name: ietfwww-wagtail
spec:
replicas: 1
revisionHistoryLimit: 2
selector:
matchLabels:
app: wagtail
app: ietfwww-wagtail
template:
metadata:
labels:
app: wagtail
app: ietfwww-wagtail
spec:
securityContext:
fsGroup: 1000
Expand All @@ -20,7 +20,7 @@ spec:
# -----------------------------------------------------
# wagtail Container
# -----------------------------------------------------
- name: wagtail
- name: ietfwww-wagtail
image: "ghcr.io/ietf-tools/www:$APP_IMAGE_TAG"
imagePullPolicy: Always
ports:
Expand Down Expand Up @@ -83,6 +83,16 @@ spec:
dnsPolicy: ClusterFirst
restartPolicy: Always
terminationGracePeriodSeconds: 30
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- iabwww-wagtail

This comment was marked as resolved.

Copy link
@kesara

kesara Aug 26, 2024

Member

And this should be ietfwww-wagtail

This comment was marked as resolved.

Copy link
@kesara

kesara Aug 26, 2024

Member

Actually, it's correct see 7b61a07#r145854531

topologyKey: "kubernetes.io/hostname"
volumeClaimTemplates:
- metadata:
name: www-media
Expand All @@ -97,7 +107,7 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: wagtail
name: ietfwww-wagtail
spec:
type: ClusterIP
ports:
Expand All @@ -106,4 +116,4 @@ spec:
protocol: TCP
name: http
selector:
app: wagtail
app: ietfwww-wagtail

0 comments on commit 7b61a07

Please sign in to comment.