Added option to run init as a job instead of initContainers
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
example.yaml
|
example.yaml
|
||||||
example*.yaml
|
example*.yaml
|
||||||
example*.yml
|
example*.yml
|
||||||
|
test-*.yaml
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
variables:
|
variables:
|
||||||
HELM_CHART_VERSION: "1.0.15"
|
HELM_CHART_VERSION: "1.0.16"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- deploy
|
- deploy
|
||||||
|
|||||||
@@ -51,3 +51,22 @@ cloudyne.systems/customer: {{ .Values.customer.legalName | replace " " "-" | rep
|
|||||||
cloudyne.systems/customer-legal-id: '{{ .Values.customer.legalId }}'
|
cloudyne.systems/customer-legal-id: '{{ .Values.customer.legalId }}'
|
||||||
cloudyne.systems/site: {{ .Values.site.domain | quote }}
|
cloudyne.systems/site: {{ .Values.site.domain | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- define "..affinity-labels" -}}
|
||||||
|
podAffinity:
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- labelSelector:
|
||||||
|
matchExpressions:
|
||||||
|
- key: cloudyne.systems/customer
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- {{ .Values.customer.legalName | replace " " "-" | replace "," "" | trunc 63 | trimSuffix "-" | quote }}
|
||||||
|
- key: cloudyne.systems/site
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- cloudyne.systems/site: {{ .Values.site.domain | quote }}
|
||||||
|
- key: cloudyne.systems/component
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
- "site"
|
||||||
|
topologyKey: kubernetes.io/hostname
|
||||||
|
{{- end }}
|
||||||
|
|||||||
@@ -12,12 +12,10 @@ spec:
|
|||||||
replicas: 1
|
replicas: 1
|
||||||
{{- end }}
|
{{- end }}
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels: {{- include "..selector-labels" . | nindent 6 }}
|
||||||
{{- include "..selector-labels" . | nindent 6 }}
|
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels: {{- include "..selector-labels" . | nindent 8 }}
|
||||||
{{- include "..selector-labels" . | nindent 8 }}
|
|
||||||
spec:
|
spec:
|
||||||
securityContext:
|
securityContext:
|
||||||
fsGroup: 101
|
fsGroup: 101
|
||||||
@@ -73,6 +71,7 @@ spec:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if not .Values.init.asJob }}
|
||||||
initContainers:
|
initContainers:
|
||||||
{{- if and .Values.storage.cloud.active .Values.storage.local.active .Values.storage.local.cloneCloud }}
|
{{- if and .Values.storage.cloud.active .Values.storage.local.active .Values.storage.local.cloneCloud }}
|
||||||
- name: init-local-storage
|
- name: init-local-storage
|
||||||
@@ -82,7 +81,7 @@ spec:
|
|||||||
image: cloudyne/ubuntu-ci:latest
|
image: cloudyne/ubuntu-ci:latest
|
||||||
command: ["python3"]
|
command: ["python3"]
|
||||||
args: ["/usr/local/bin/storage-clone", "/mnt/cloud", "/mnt/local"]
|
args: ["/usr/local/bin/storage-clone", "/mnt/cloud", "/mnt/local"]
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: Always
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: cloud
|
- name: cloud
|
||||||
mountPath: /mnt/cloud
|
mountPath: /mnt/cloud
|
||||||
@@ -118,6 +117,7 @@ spec:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
envFrom:
|
envFrom:
|
||||||
- configMapRef:
|
- configMapRef:
|
||||||
name: {{ include "..fullname" . }}-env
|
name: {{ include "..fullname" . }}-env
|
||||||
@@ -133,6 +133,7 @@ spec:
|
|||||||
name: {{ include "..fullname" . }}-db-auth
|
name: {{ include "..fullname" . }}-db-auth
|
||||||
command: ["sh"]
|
command: ["sh"]
|
||||||
args: ["-c", "/init-go/init-go"]
|
args: ["-c", "/init-go/init-go"]
|
||||||
|
{{- end }}
|
||||||
containers:
|
containers:
|
||||||
- name: wordpress
|
- name: wordpress
|
||||||
securityContext:
|
securityContext:
|
||||||
|
|||||||
129
Chart/templates/job.yaml
Normal file
129
Chart/templates/job.yaml
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
{{- if .Values.init.asJob }}
|
||||||
|
apiVersion: batch/v1
|
||||||
|
kind: Job
|
||||||
|
metadata:
|
||||||
|
name: {{ include "..fullname" . }}-wpc-reg
|
||||||
|
labels:
|
||||||
|
{{- include "..labels" . | nindent 4 }}
|
||||||
|
cloudyne.systems/component: site-init
|
||||||
|
spec:
|
||||||
|
template:
|
||||||
|
spec:
|
||||||
|
affinity: {{ include "..affinity-labels" . | nindent 8 }}
|
||||||
|
securityContext:
|
||||||
|
fsGroup: 101
|
||||||
|
volumes:
|
||||||
|
- name: serverconfig
|
||||||
|
configMap:
|
||||||
|
name: {{ include "..fullname" . }}-cfg
|
||||||
|
{{- if and .Values.secrets .Values.secrets.external }}
|
||||||
|
{{- range .Values.secrets.external }}
|
||||||
|
{{- if eq .type "file" }}
|
||||||
|
- name: {{ .name }}
|
||||||
|
secret:
|
||||||
|
secretName: {{- include "..fullname" $ }}-exts-{{ .name }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.storage.kubernetes }}
|
||||||
|
{{- range .Values.storage.kubernetes }}
|
||||||
|
- name: {{ .name }}
|
||||||
|
{{- if eq .type "secret" }}
|
||||||
|
secret:
|
||||||
|
secretName: "{{- include "..fullname" $ }}-sec-{{ .name }}"
|
||||||
|
{{- end }}
|
||||||
|
{{- if eq .type "configmap" }}
|
||||||
|
configMap:
|
||||||
|
name: "{{- include "..fullname" $ }}-sec-{{ .name }}"
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.storage.cloud.active }}
|
||||||
|
- name: cloud
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: pvc-{{- include "..name" . }}-cloud
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.storage.local.active }}
|
||||||
|
- name: local
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: pvc-{{- include "..name" . }}-local
|
||||||
|
{{- end }}
|
||||||
|
{{- if and .Values.secrets .Values.secrets.external }}
|
||||||
|
{{- range .Values.secrets.external }}
|
||||||
|
{{- if eq .type "docker" }}
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: "{{- include "..fullname" $ }}-exts-{{ .name }}"
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.storage.kubernetes }}
|
||||||
|
{{- range .Values.storage.kubernetes }}
|
||||||
|
{{- if eq .type "docker" }}
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: "{{- include "..fullname" $ }}-sec-{{ .name }}"
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and .Values.storage.cloud.active .Values.storage.local.active .Values.storage.local.cloneCloud }}
|
||||||
|
initContainers:
|
||||||
|
- name: init-local-storage
|
||||||
|
securityContext:
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
runAsUser: 0
|
||||||
|
image: cloudyne/ubuntu-ci:latest
|
||||||
|
command: ["python3"]
|
||||||
|
args: ["/usr/local/bin/storage-clone", "/mnt/cloud", "/mnt/local"]
|
||||||
|
imagePullPolicy: IfNotPresent
|
||||||
|
volumeMounts:
|
||||||
|
- name: cloud
|
||||||
|
mountPath: /mnt/cloud
|
||||||
|
- name: local
|
||||||
|
mountPath: /mnt/local
|
||||||
|
{{- end }}
|
||||||
|
containers:
|
||||||
|
- name: init-site
|
||||||
|
securityContext:
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
runAsUser: 0
|
||||||
|
image: "{{ .Values.site.image }}"
|
||||||
|
imagePullPolicy: Always
|
||||||
|
volumeMounts:
|
||||||
|
- name: serverconfig
|
||||||
|
mountPath: /init-go/config.json
|
||||||
|
subPath: init.json
|
||||||
|
{{- if .Values.storage.local.active }}
|
||||||
|
{{- range .Values.storage.folders }}
|
||||||
|
- name: local
|
||||||
|
mountPath: "/app/web/app/{{ . }}"
|
||||||
|
subPath: "{{ . }}"
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.storage.cloud.active }}
|
||||||
|
- name: cloud
|
||||||
|
mountPath: "/mnt/cloud"
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
{{- if .Values.storage.cloud.active }}
|
||||||
|
{{- range .Values.storage.folders }}
|
||||||
|
- name: cloud
|
||||||
|
mountPath: "/app/web/app/{{ . }}"
|
||||||
|
subPath: "{{ . }}"
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
envFrom:
|
||||||
|
- configMapRef:
|
||||||
|
name: {{ include "..fullname" . }}-env
|
||||||
|
{{- if and .Values.secrets .Values.secrets.external }}
|
||||||
|
{{- range .Values.secrets.external }}
|
||||||
|
{{- if eq .type "env" }}
|
||||||
|
- secretRef:
|
||||||
|
name: "{{- include "..fullname" $ }}-exts-{{ .name }}"
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
- secretRef:
|
||||||
|
name: {{ include "..fullname" . }}-db-auth
|
||||||
|
command: ["sh"]
|
||||||
|
args: ["-c", "/init-go/init-go"]
|
||||||
|
{{- end }}
|
||||||
@@ -123,6 +123,7 @@ storage:
|
|||||||
- languages
|
- languages
|
||||||
|
|
||||||
init:
|
init:
|
||||||
|
asJob: false
|
||||||
wp:
|
wp:
|
||||||
theme: "abctheme"
|
theme: "abctheme"
|
||||||
updatePermissions: true
|
updatePermissions: true
|
||||||
|
|||||||
Reference in New Issue
Block a user