Files
cozystack/packages/apps/http-cache/templates/nginx/deployment.yaml
Andrei Kvapil f642698921 Preapare release v0.0.1
Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
2024-02-08 12:04:32 +01:00

141 lines
3.9 KiB
YAML

---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: {{ $.Release.Name }}-nginx-cache
labels:
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
spec:
maxUnavailable: 1
selector:
matchLabels:
app: {{ $.Release.Name }}-nginx-cache
{{- range $i := until 3 }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ $.Release.Name }}-nginx-cache-{{ $i }}
labels:
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
spec:
selector:
matchLabels:
app: {{ $.Release.Name }}-nginx-cache
instance: "{{ $i }}"
template:
metadata:
labels:
app: {{ $.Release.Name }}-nginx-cache
instance: "{{ $i }}"
annotations:
checksum/config: {{ include (print $.Template.BasePath "/nginx/configmap.yaml") $ | sha256sum }}
spec:
imagePullSecrets:
- name: {{ $.Release.Name }}-regsecret
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- {{ $.Release.Name }}-nginx-cache
- key: instance
operator: NotIn
values:
- "{{ $i }}"
topologyKey: kubernetes.io/hostname
shareProcessNamespace: true
containers:
- name: nginx
image: "{{ $.Files.Get "images/nginx-cache.tag" | trim }}@{{ index ($.Files.Get "images/nginx-cache.json" | fromJson) "containerimage.digest" }}"
readinessProbe:
httpGet:
path: /healthz
port: metrics
initialDelaySeconds: 5
periodSeconds: 5
livenessProbe:
httpGet:
path: /healthz
port: metrics
failureThreshold: 1
periodSeconds: 10
ports:
- containerPort: 80
name: http
- containerPort: 8087
name: cache
- containerPort: 10253
name: metrics
volumeMounts:
- mountPath: /etc/nginx/nginx.conf
name: config
subPath: nginx.conf
- mountPath: /data
name: data
- mountPath: /run
name: run
- name: reloader
image: "{{ $.Files.Get "images/nginx-cache.tag" | trim }}@{{ index ($.Files.Get "images/nginx-cache.json" | fromJson) "containerimage.digest" }}"
command: ["/usr/bin/nginx-reloader.sh"]
#command: ["sleep", "infinity"]
volumeMounts:
- mountPath: /etc/nginx/nginx.conf
name: config
subPath: nginx.conf
- mountPath: /data
name: data
- mountPath: /run
name: run
volumes:
- name: config
configMap:
name: {{ $.Release.Name }}-nginx-cache
- name: data
persistentVolumeClaim:
claimName: {{ $.Release.Name }}-nginx-cache-{{ $i }}
- name: run
emptyDir: {}
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ $.Release.Name }}-nginx-cache-{{ $i }}
labels:
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: "{{ $.Values.size }}"
---
apiVersion: v1
kind: Service
metadata:
name: {{ $.Release.Name }}-nginx-cache-{{ $i }}
labels:
app: {{ $.Release.Name }}-nginx-cache
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
spec:
type: ClusterIP
selector:
app: {{ $.Release.Name }}-nginx-cache
instance: "{{ $i }}"
ports:
- name: http
protocol: TCP
port: 80
targetPort: http
- name: metrics
protocol: TCP
port: 10253
targetPort: metrics
{{- end }}