refactor: standardize namespace and PVC names in Helm templates

This commit is contained in:
Elmar Kresse
2024-11-22 03:53:42 +01:00
parent 74dcdd16d4
commit a96bcea806
7 changed files with 51 additions and 302 deletions

View File

@@ -1,33 +0,0 @@
{{ if .Values.pv.enabled }}
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ .Values.pv.koha.name }}
spec:
capacity:
storage: 10Gi
volumeMode: Filesystem
accessModes:
- ReadWriteMany
persistentVolumeReclaimPolicy: Recycle
nfs:
path: {{ .Values.pv.koha.path }}
server: {{ .Values.pv.koha.server }}
{{ if not .Values.db.external }}
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: {{ .Values.pv.mysql.name }}
spec:
capacity:
storage: 10Gi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Recycle
nfs:
path: {{ .Values.pv.mysql.path }}
server: {{ .Values.pv.mysql.server }}
{{ end }}
{{ end }}

View File

@@ -2,11 +2,11 @@ apiVersion: v1
kind: ConfigMap kind: ConfigMap
metadata: metadata:
name: koha-map name: koha-map
namespace: koha-{{ .Values.instance }} namespace: koha
labels: labels:
app: koha app: koha
data: data:
KOHA_INSTANCE: {{ required "You must provide an instance name, either using --set instance=myinstance or in a custom values.yaml" .Values.instance | quote }} KOHA_INSTANCE: {{ .Values.instance | quote }}
KOHA_DOMAIN: {{ .Values.global.domain | quote }} KOHA_DOMAIN: {{ .Values.global.domain | quote }}
KOHA_INTRANET_PORT: {{ .Values.staff.port | quote }} KOHA_INTRANET_PORT: {{ .Values.staff.port | quote }}
{{ with .Values.staff.prefix }} {{ with .Values.staff.prefix }}

View File

@@ -2,7 +2,7 @@ apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: koha name: koha
namespace: koha-{{ .Values.instance }} namespace: koha
labels: labels:
app: koha app: koha
component: plack component: plack
@@ -24,6 +24,8 @@ spec:
env: env:
- name: USE_PLACK - name: USE_PLACK
value: "1" value: "1"
- name: USE_BACKEND
value: "1"
envFrom: envFrom:
- configMapRef: - configMapRef:
name: koha-map name: koha-map
@@ -41,13 +43,13 @@ spec:
volumes: volumes:
- name: koha-pv - name: koha-pv
persistentVolumeClaim: persistentVolumeClaim:
claimName: koha-{{ .Values.instance }}-pvc claimName: koha-pvc
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: koha-apache name: koha-apache
namespace: koha-{{ .Values.instance }} namespace: koha
labels: labels:
app: koha app: koha
component: apache component: apache
@@ -67,16 +69,27 @@ spec:
- name: init-wait - name: init-wait
image: alpine image: alpine
command: ["sh", "-c", "for i in $(seq 1 300); do nc -zvw1 {{ .Values.instance }}-plack 5000 && exit 0 || sleep 3; done; exit 1"] command: ["sh", "-c", "for i in $(seq 1 300); do nc -zvw1 {{ .Values.instance }}-plack 5000 && exit 0 || sleep 3; done; exit 1"]
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
runAsNonRoot: true
runAsUser: 1000 # Set a non-root user
seccompProfile:
type: RuntimeDefault
containers: containers:
- name: apache - name: apache
image: {{ .Values.docker.registry }}:{{ .Values.docker.tag }} image: {{ .Values.docker.registry }}:{{ .Values.docker.tag }}
securityContext: securityContext:
capabilities: capabilities:
add: add:
- ALL - NET_BIND_SERVICE
env: env:
- name: USE_APACHE2 - name: USE_APACHE2
value: "1" value: "1"
- name: USE_BACKEND
value: "0"
envFrom: envFrom:
- configMapRef: - configMapRef:
name: koha-map name: koha-map
@@ -93,14 +106,14 @@ spec:
volumes: volumes:
- name: koha-pv - name: koha-pv
persistentVolumeClaim: persistentVolumeClaim:
claimName: koha-{{ .Values.instance }}-pvc claimName: koha-pvc
{{ if not .Values.db.external }} {{ if not .Values.db.external }}
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: koha-mysql name: koha-mysql
namespace: koha-{{ .Values.instance }} namespace: koha
labels: labels:
app: koha app: koha
component: db component: db
@@ -133,7 +146,7 @@ spec:
volumes: volumes:
- name: koha-mysql-pv - name: koha-mysql-pv
persistentVolumeClaim: persistentVolumeClaim:
claimName: koha-{{ .Values.instance }}-mysql-pvc claimName: koha-mysql-pvc
{{ end }} {{ end }}
{{ if and .Values.elasticsearch.enabled (not .Values.elasticsearch.external) }} {{ if and .Values.elasticsearch.enabled (not .Values.elasticsearch.external) }}
--- ---
@@ -141,7 +154,7 @@ apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: koha-es name: koha-es
namespace: koha-{{ .Values.instance }} namespace: koha
labels: labels:
app: koha app: koha
component: es component: es
@@ -161,10 +174,13 @@ spec:
- name: es - name: es
image: koha/elasticsearch-icu image: koha/elasticsearch-icu
securityContext: securityContext:
allowPrivilegeEscalation: false
runAsNonRoot: true
capabilities: capabilities:
add: drop:
- IPC_LOCK - ALL
- SYS_RESOURCE seccompProfile:
type: RuntimeDefault
env: env:
- name: cluster.name - name: cluster.name
value: "docker-cluster" value: "docker-cluster"
@@ -180,159 +196,23 @@ spec:
- name: set-max-map-count - name: set-max-map-count
image: alpine image: alpine
securityContext: securityContext:
privileged: true allowPrivilegeEscalation: false
runAsNonRoot: true
runAsUser: 1000
capabilities:
drop:
- ALL
seccompProfile:
type: RuntimeDefault
command: ["sh", "-c", "sysctl -w vm.max_map_count=262144 && sysctl -w fs.file-max=65536"] command: ["sh", "-c", "sysctl -w vm.max_map_count=262144 && sysctl -w fs.file-max=65536"]
{{ end }} {{ end }}
{{ if .Values.sip.enabled }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: koha-sip
namespace: koha-{{ .Values.instance }}
labels:
app: koha
component: sip
spec:
replicas: 1
selector:
matchLabels:
app: koha
component: sip
template:
metadata:
labels:
app: koha
component: sip
spec:
initContainers:
- name: init-wait
image: alpine
command: ["sh", "-c", "for i in $(seq 1 300); do nc -zvw1 {{ .Values.instance }}-plack 5000 && exit 0 || sleep 3; done; exit 1"]
containers:
- name: sip
image: {{ .Values.docker.registry }}:{{ .Values.docker.tag }}
env:
- name: USE_SIP
value: "1"
envFrom:
- configMapRef:
name: koha-map
volumeMounts:
- name: koha-pv
mountPath: /etc/koha/sites
subPath: sites
- name: koha-pv
mountPath: /tmp/libshare
subPath: lib
ports:
- containerPort: 6001
volumes:
- name: koha-pv
persistentVolumeClaim:
claimName: koha-{{ .Values.instance }}-pvc
{{ end }}
{{ if .Values.z3950.enabled }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: koha-z3950
namespace: koha-{{ .Values.instance }}
labels:
app: koha
component: z3950
spec:
replicas: 1
selector:
matchLabels:
app: koha
component: z3950
template:
metadata:
labels:
app: koha
component: z3950
spec:
initContainers:
- name: init-wait
image: alpine
command: ["sh", "-c", "for i in $(seq 1 300); do nc -zvw1 {{ .Values.instance }}-plack 5000 && exit 0 || sleep 3; done; exit 1"]
containers:
- name: z3950
image: {{ .Values.docker.registry }}:{{ .Values.docker.tag }}
env:
- name: USE_Z3950
value: "1"
envFrom:
- configMapRef:
name: koha-map
volumeMounts:
- name: koha-pv
mountPath: /etc/koha/sites
subPath: sites
- name: koha-pv
mountPath: /tmp/libshare
subPath: lib
ports:
- containerPort: 2100
volumes:
- name: koha-pv
persistentVolumeClaim:
claimName: koha-{{ .Values.instance }}-pvc
{{ end }}
{{ if .Values.ncip.enabled }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: koha-ncip
namespace: koha-{{ .Values.instance }}
labels:
app: koha
component: ncip
spec:
replicas: 1
selector:
matchLabels:
app: koha
component: ncip
template:
metadata:
labels:
app: koha
component: ncip
spec:
initContainers:
- name: init-wait
image: alpine
command: ["sh", "-c", "for i in $(seq 1 300); do nc -zvw1 {{ .Values.instance }}-plack 5000 && exit 0 || sleep 3; done; exit 1"]
containers:
- name: ncip
image: bywater/koha-ncip-server:v19.05-latest
env:
- name: KOHA_CONF
value: "/conf/{{ .Values.instance }}/koha-conf.xml"
volumeMounts:
- name: koha-pv
mountPath: /conf
subPath: sites
- name: koha-pv
mountPath: /usr/share/koha/lib
subPath: lib
volumes:
- name: koha-pv
persistentVolumeClaim:
claimName: koha-{{ .Values.instance }}-pvc
{{ end }}
{{ if and .Values.memcached.enabled (not .Values.memcached.external) }} {{ if and .Values.memcached.enabled (not .Values.memcached.external) }}
--- ---
apiVersion: apps/v1 apiVersion: apps/v1
kind: Deployment kind: Deployment
metadata: metadata:
name: koha-memcached name: koha-memcached
namespace: koha-{{ .Values.instance }} namespace: koha
labels: labels:
app: koha app: koha
component: memcached component: memcached

View File

@@ -2,7 +2,7 @@ apiVersion: networking.k8s.io/v1
kind: Ingress kind: Ingress
metadata: metadata:
name: koha-ingress name: koha-ingress
namespace: koha-{{ .Values.instance }} namespace: koha
{{ if and .Values.tls.enabled .Values.tls.cert_manager.enabled }} {{ if and .Values.tls.enabled .Values.tls.cert_manager.enabled }}
annotations: annotations:
{{ if eq .Values.tls.cert_manager.kind "cluster-issuer" }} {{ if eq .Values.tls.cert_manager.kind "cluster-issuer" }}
@@ -40,35 +40,3 @@ spec:
port: port:
number: {{ .Values.opac.port }} number: {{ .Values.opac.port }}
pathType: ImplementationSpecific pathType: ImplementationSpecific
{{ if .Values.sip.enabled }}
- host: {{ .Values.instance }}{{ .Values.sip.suffix }}{{ .Values.global.domain }}
http:
paths:
- backend:
service:
name: {{ .Values.instance }}-sip
port:
number: 6001
{{ end }}
{{ if .Values.ncip.enabled }}
- host: {{ .Values.instance }}{{ .Values.ncip.suffix }}{{ .Values.global.domain }}
http:
paths:
- backend:
service:
name: {{ .Values.instance }}-ncip
port:
number: 3000
pathType: ImplementationSpecific
{{ end }}
{{ if .Values.z3950.enabled }}
- host: {{ .Values.instance }}{{ .Values.z3950.suffix }}{{ .Values.global.domain }}
http:
paths:
- backend:
service:
name: {{ .Values.instance }}-z3950
port:
number: 2100
pathType: ImplementationSpecific
{{ end }}

View File

@@ -2,7 +2,7 @@ apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: {{ .Values.instance }}-koha name: {{ .Values.instance }}-koha
namespace: koha-{{ .Values.instance }} namespace: koha
labels: labels:
run: {{ .Values.instance }}-koha run: {{ .Values.instance }}-koha
spec: spec:
@@ -22,7 +22,7 @@ apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: {{ .Values.instance }}-plack name: {{ .Values.instance }}-plack
namespace: koha-{{ .Values.instance }} namespace: koha
labels: labels:
run: {{ .Values.instance }}-plack run: {{ .Values.instance }}-plack
spec: spec:
@@ -33,67 +33,13 @@ spec:
selector: selector:
app: koha app: koha
component: plack component: plack
{{ if .Values.sip.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.instance }}-sip
namespace: koha-{{ .Values.instance }}
labels:
run: {{ .Values.instance }}-sip
spec:
type: ClusterIP
ports:
- port: 6001
protocol: TCP
selector:
app: koha
component: sip
{{ end }}
{{ if .Values.ncip.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.instance }}-ncip
namespace: koha-{{ .Values.instance }}
labels:
run: {{ .Values.instance }}-ncip
spec:
type: ClusterIP
ports:
- port: 3000
protocol: TCP
selector:
app: koha
component: ncip
{{ end }}
{{ if .Values.z3950.enabled }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.instance }}-z3950
namespace: koha-{{ .Values.instance }}
labels:
run: {{ .Values.instance }}-z3950
spec:
type: ClusterIP
ports:
- port: 2100
protocol: TCP
selector:
app: koha
component: z3950
{{ end }}
{{ if and .Values.elasticsearch.enabled (not .Values.elasticsearch.external) }} {{ if and .Values.elasticsearch.enabled (not .Values.elasticsearch.external) }}
--- ---
apiVersion: v1 apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: {{ .Values.instance }}-es name: {{ .Values.instance }}-es
namespace: koha-{{ .Values.instance }} namespace: koha
labels: labels:
run: {{ .Values.instance }}-es run: {{ .Values.instance }}-es
spec: spec:
@@ -111,7 +57,7 @@ apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: {{ .Values.instance }}-db name: {{ .Values.instance }}-db
namespace: koha-{{ .Values.instance }} namespace: koha
labels: labels:
run: {{ .Values.instance }}-db run: {{ .Values.instance }}-db
spec: spec:
@@ -129,7 +75,7 @@ apiVersion: v1
kind: Service kind: Service
metadata: metadata:
name: {{ .Values.instance }}-memcached name: {{ .Values.instance }}-memcached
namespace: koha-{{ .Values.instance }} namespace: koha
labels: labels:
run: {{ .Values.instance }}-memcached run: {{ .Values.instance }}-memcached
spec: spec:

View File

@@ -1,8 +1,8 @@
apiVersion: v1 apiVersion: v1
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
metadata: metadata:
name: koha-{{ .Values.instance }}-pvc name: koha-pvc
namespace: koha-{{ .Values.instance }} namespace: koha
labels: labels:
app: koha app: koha
spec: spec:
@@ -17,8 +17,8 @@ spec:
apiVersion: v1 apiVersion: v1
kind: PersistentVolumeClaim kind: PersistentVolumeClaim
metadata: metadata:
name: koha-{{ .Values.instance }}-mysql-pvc name: koha-mysql-pvc
namespace: koha-{{ .Values.instance }} namespace: koha
labels: labels:
app: koha app: koha
spec: spec:

View File

@@ -1,9 +1,8 @@
# On purpose we don't include a instance default value. It must be provided on install. # On purpose we don't include a instance default value. It must be provided on install.
instance: htwk-fsrim instance: fsrim
global: global:
domain: .koha.fsr.imn.htwk-leipzig.de domain: .koha.fsr.imn.htwk-leipzig.de
marc_flavour: "marc21" marc_flavour: "marc21"
# Set alternate languages to install as an array # Set alternate languages to install as an array
@@ -86,18 +85,7 @@ memcached:
zebra: zebra:
marc_format: marc21 marc_format: marc21
sip: # pv stands for Persistent Volume. It is a storage solution that allows you to store data on a disk that is separate from the main server disk
enabled: false
suffix: -sip
z3950:
enabled: false
suffix: -z3950
ncip:
enabled: false
suffix: -ncip
pv: pv:
enabled: false enabled: false