Commit 52240d4c authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

modified deployment

parent ab8296c8
Pipeline #5583 passed with stages
in 1 minute and 56 seconds
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 24 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trimSuffix "-app" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- define "appname" -}}
{{- $releaseName := default .Release.Name .Values.releaseOverride -}}
{{- printf "%s" $releaseName | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- define "imagename" -}}
{{- if eq .Values.image.tag "" -}}
{{- .Values.image.repository -}}
{{- else -}}
{{- printf "%s:%s" .Values.image.repository .Values.image.tag -}}
{{- end -}}
{{- end -}}
{{- define "trackableappname" -}}
{{- $trackableName := printf "%s-%s" (include "appname" .) .Values.application.track -}}
{{- $trackableName | trimSuffix "-stable" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Get a hostname from URL
*/}}
{{- define "hostname" -}}
{{- . | trimPrefix "http://" | trimPrefix "https://" | trimSuffix "/" | trim | quote -}}
{{- end -}}
{{/*
Get SecRule's arguments with unescaped single&double quotes
*/}}
{{- define "secrule" -}}
{{- $operator := .operator | quote | replace "\"" "\\\"" | replace "'" "\\'" -}}
{{- $action := .action | quote | replace "\"" "\\\"" | replace "'" "\\'" -}}
{{- printf "SecRule %s %s %s" .variable $operator $action -}}
{{- end -}}
{{- define "sharedlabels" -}}
app: {{ template "appname" . }}
appname: yacy
chart: "{{ .Chart.Name }}-{{ .Chart.Version| replace "+" "_" }}"
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
app.kubernetes.io/name: {{ template "appname" . }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version| replace "+" "_" }}"
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.extraLabels }}
{{ toYaml $.Values.extraLabels }}
{{- end }}
{{- end -}}
\ No newline at end of file
{{- if .Values.service.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ template "fullname" . }}
annotations:
{{- if .Values.service.annotations }}
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
{{- if .Values.prometheus.metrics }}
prometheus.io/scrape: "true"
prometheus.io/port: "{{ .Values.service.internalPort }}"
{{- end }}
labels:
track: "{{ .Values.application.track }}"
{{ include "sharedlabels" . | indent 4 }}
spec:
type: {{ .Values.service.type }}
externalTrafficPolicy: {{ .Values.service.trafficpolicy }}
ports:
- port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
protocol: TCP
name: {{ .Values.service.name }}
selector:
app: {{ template "appname" . }}
tier: "{{ .Values.application.tier }}"
track: "{{ .Values.application.track }}"
{{- end -}}
{{- if not .Values.application.initializeCommand -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ template "trackableappname" . }}
annotations:
{{ if .Values.gitlab.app }}app.gitlab.com/app: {{ .Values.gitlab.app | quote }}{{ end }}
{{ if .Values.gitlab.env }}app.gitlab.com/env: {{ .Values.gitlab.env | quote }}{{ end }}
labels:
track: "{{ .Values.application.track }}"
tier: "{{ .Values.application.tier }}"
{{ include "sharedlabels" . | indent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
serviceName: {{ template "fullname" . }}
selector:
matchLabels:
app: {{ template "appname" . }}
track: "{{ .Values.application.track }}"
tier: "{{ .Values.application.tier }}"
release: {{ .Release.Name }}
{{- if .Values.strategyType }}
strategy:
type: {{ .Values.strategyType | quote }}
{{- end }}
template:
metadata:
annotations:
checksum/application-secrets: "{{ .Values.application.secretChecksum }}"
{{ if .Values.gitlab.app }}app.gitlab.com/app: {{ .Values.gitlab.app | quote }}{{ end }}
{{ if .Values.gitlab.env }}app.gitlab.com/env: {{ .Values.gitlab.env | quote }}{{ end }}
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
labels:
track: "{{ .Values.application.track }}"
tier: "{{ .Values.application.tier }}"
{{ include "sharedlabels" . | indent 8 }}
spec:
{{- if or (.Values.serviceAccount.name) (.Values.serviceAccountName) }}
serviceAccountName: {{ .Values.serviceAccount.name | default .Values.serviceAccountName | quote }}
{{- end }}
imagePullSecrets:
{{ toYaml .Values.image.secrets | indent 10 }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
volumes:
- name: yacy-data
persistentVolumeClaim:
claimName: yacy-data
- name: yacy-config
configMap:
name: {{ template "trackableappname" . }}-config
items:
- key: "yacy.init"
path: "yacy.init"
initContainers:
- name: clear-config
image: busybox:1.28
command: ['sh', '-c', "rm -f /data/yacy_search_server/DATA/SETTINGS/yacy.conf"]
volumeMounts:
- name: yacy-data
mountPath: /data
containers:
- name: {{ .Chart.Name }}
image: "yacy/yacy_search_server:latest"
imagePullPolicy: "IfNotPresent"
command: ['bash']
args:
- -c
- >-
cat /config/yacy.init >> /opt/yacy_search_server/defaults/yacy.init &&
[[ `hostname` =~ -([0-9]+)$ ]] || exit 1 &&
ordinal=${BASH_REMATCH[1]} &&
if [ ! -z $NETWORK_UNIT_AGENT ]; then echo "network.unit.agent = $NETWORK_UNIT_AGENT-$ordinal" >> /opt/yacy_search_server/defaults/yacy.init; fi &&
export ADMIN_PASSWORD=$(echo -n "${ADMIN_USER}:${ADMIN_REALM}:${ADMIN_PASSWORD}" | md5sum | awk '{print $1}') &&
echo "adminAccountUserName = ${ADMIN_USER}" >> /opt/yacy_search_server/defaults/yacy.init &&
echo "adminRealm = ${ADMIN_REALM}" >> /opt/yacy_search_server/defaults/yacy.init &&
echo "adminAccountBase64MD5 = MD5:${ADMIN_PASSWORD}" >> /opt/yacy_search_server/defaults/yacy.init &&
/opt/yacy_search_server/startYACY.sh -f
envFrom:
- secretRef:
name: {{ template "fullname" . }}-admin-credentials
{{- if .Values.application.secretName }}
- secretRef:
name: {{ .Values.application.secretName }}
{{- end }}
env:
- name: NETWORK_UNIT_AGENT
value: {{ .Values.yacy.namePrefix }}
- name: GITLAB_ENVIRONMENT_NAME
value: {{ .Values.gitlab.envName | quote }}
- name: GITLAB_ENVIRONMENT_URL
value: {{ .Values.gitlab.envURL | quote }}
{{- if .Values.lifecycle }}
lifecycle:
{{ toYaml .Values.lifecycle | indent 10 }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.yacy.port }}
hostPort: {{ .Values.yacy.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
volumeMounts:
- name: yacy-data
mountPath: /opt/yacy_search_server/DATA
- name: yacy-config
mountPath: "/config"
readOnly: false
resources:
{{ toYaml .Values.resources | indent 12 }}
volumeClaimTemplates:
- metadata:
name: yacy-data
labels:
{{ include "sharedlabels" . | indent 8 }}
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: {{ .Values.yacy.volume.class }}
resources:
requests:
storage: {{ .Values.yacy.volume.size }}
{{- end -}}
# Default values for chart.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
strategyType:
# `serviceAccountName` is deprecated in favor of `serviceAccount.name`
serviceAccountName:
image:
repository: gitlab.example.com/group/project
tag: stable
pullPolicy: IfNotPresent
secrets:
- name: gitlab-registry
extraLabels: {}
lifecycle: {}
# preStop:
# exec:
# command: ["/bin/sh", "-c", "sleep 10"]
yacy:
# A name Prefix for your yacy instances (corresponds to yacy option network.unit.agent)
# A ordinal number corresponding to the replica will get added to it.
namePrefix:
port: 31234
admin:
username:
realm: Yacy Admin UI
password:
volume:
class:
size:
# Here you can define additional config parameters for your yacy deployment.
# You can set any valid yacy config
# i.e.
# - name: network.unit.domain.nocheck
# value: true
# The following configs are already set by above values and shouldn't be set again:
# - port
# - network.unit.agent
# - adminRealm, adminAccountUserName, adminAccountBase64MD5
additionalConfig:
- name: autocrawl
value: false
- name: crawlResponse
value: false
podAnnotations: {}
nodeSelector: {}
affinity: {}
tolerations: []
application:
track: stable
tier: web
migrateCommand:
initializeCommand:
secretName:
secretChecksum:
gitlab:
app:
env:
envName:
envURL:
projectID:
service:
enabled: true
annotations: {}
name: web
type: NodePort
trafficpolicy: Local
url: http://my.host.com/
additionalHosts:
commonName:
externalPort: 31234
internalPort: 31234
prometheus:
metrics: false
livenessProbe:
path: "/"
initialDelaySeconds: 15
timeoutSeconds: 15
scheme: "HTTP"
probeType: "httpGet"
readinessProbe:
path: "/"
initialDelaySeconds: 5
timeoutSeconds: 3
scheme: "HTTP"
probeType: "httpGet"
resources:
# limits:
# cpu: 100m
# memory: 128Mi
requests: {}
# cpu: 100m
# memory: 128Mi
serviceAccount:
name:
annotations: {}
createNew: false
\ No newline at end of file
......@@ -51,6 +51,7 @@ Get SecRule's arguments with unescaped single&double quotes
{{- define "sharedlabels" -}}
app: {{ template "appname" . }}
appname: yacy
chart: "{{ .Chart.Name }}-{{ .Chart.Version| replace "+" "_" }}"
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
......@@ -61,4 +62,4 @@ app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.extraLabels }}
{{ toYaml $.Values.extraLabels }}
{{- end }}
{{- end -}}
{{- end -}}
\ No newline at end of file
{{- if .Values.service.enabled -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "Yacy.name" . }}
name: {{ template "fullname" . }}
annotations:
{{- if .Values.service.annotations }}
{{ toYaml .Values.service.annotations | indent 4 }}
{{- end }}
{{- if .Values.prometheus.metrics }}
prometheus.io/scrape: "true"
prometheus.io/port: "{{ .Values.service.internalPort }}"
{{- end }}
labels:
{{ include "sharedlabels" . | indent 4 }}
track: "{{ .Values.application.track }}"
{{ include "sharedlabels" . | indent 4 }}
spec:
type: NodePort
externalTrafficPolicy: Local
type: {{ .Values.service.type }}
externalTrafficPolicy: {{ .Values.service.trafficpolicy }}
ports:
- port: {{ .Values.yacy.port }}
nodePort: {{ .Values.yacy.port }}
targetPort: {{ .Values.yacy.port }}
protocol: TCP
name: http
- port: {{ .Values.service.externalPort }}
targetPort: {{ .Values.service.internalPort }}
protocol: TCP
name: {{ .Values.service.name }}
selector:
app: {{ template "appname" . }}
tier: "{{ .Values.application.tier }}"
track: "{{ .Values.application.track }}"
{{- end -}}
{{- with .Values.serviceAccount -}}
{{- if .createNew }}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .name | quote }}
{{- if .annotations }}
annotations:
{{ toYaml .annotations | indent 4 }}
{{- end }}
{{- end }}
{{- end -}}
{{- if not .Values.application.initializeCommand -}}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ template "trackableappname" . }}
annotations:
{{ if .Values.gitlab.app }}app.gitlab.com/app: {{ .Values.gitlab.app | quote }}{{ end }}
{{ if .Values.gitlab.env }}app.gitlab.com/env: {{ .Values.gitlab.env | quote }}{{ end }}
labels:
appname: yacy
track: "{{ .Values.application.track }}"
tier: "{{ .Values.application.tier }}"
{{ include "sharedlabels" . | indent 4 }}
{{ include "sharedlabels" . | indent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
serviceName: {{ template "fullname" . }}
selector:
matchLabels:
matchLabels:
app: {{ template "appname" . }}
track: "{{ .Values.application.track }}"
tier: "{{ .Values.application.tier }}"
release: {{ .Release.Name }}
app: {{ template "appname" . }}
track: "{{ .Values.application.track }}"
tier: "{{ .Values.application.tier }}"
release: {{ .Release.Name }}
{{- if .Values.strategyType }}
strategy:
type: {{ .Values.strategyType | quote }}
{{- end }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
checksum/application-secrets: "{{ .Values.application.secretChecksum }}"
{{ if .Values.gitlab.app }}app.gitlab.com/app: {{ .Values.gitlab.app | quote }}{{ end }}
{{ if .Values.gitlab.env }}app.gitlab.com/env: {{ .Values.gitlab.env | quote }}{{ end }}
{{- if .Values.podAnnotations }}
{{ toYaml .Values.podAnnotations | indent 8 }}
{{- end }}
labels:
appname: yacy
track: "{{ .Values.application.track }}"
tier: "{{ .Values.application.tier }}"
{{ include "sharedlabels" . | indent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if or (.Values.serviceAccount.name) (.Values.serviceAccountName) }}
{{- if or (.Values.serviceAccount.name) (.Values.serviceAccountName) }}
serviceAccountName: {{ .Values.serviceAccount.name | default .Values.serviceAccountName | quote }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- end }}
imagePullSecrets:
{{ toYaml .Values.image.secrets | indent 10 }}
{{- if .Values.nodeSelector }}
nodeSelector:
{{ toYaml .Values.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.tolerations }}
tolerations:
{{ toYaml .Values.tolerations | indent 8 }}
{{- end }}
{{- if .Values.affinity }}
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
volumes:
- name: yacy-data
persistentVolumeClaim:
claimName: yacy-data
- name: yacy-config
configMap:
name: {{ template "fullname" . }}-config
name: {{ template "trackableappname" . }}-config
items:
- key: "yacy.init"
path: "yacy.init"
......@@ -56,71 +72,70 @@ spec:
- name: yacy-data
mountPath: /data
containers:
- name: {{ .Chart.Name }}-search-server
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "yacy/yacy_search_server:latest"
imagePullPolicy: "IfNotPresent"
command: ['bash']
args:
- -c
- >-
cat /config/yacy.init >> /opt/yacy_search_server/defaults/yacy.init &&
[[ `hostname` =~ -([0-9]+)$ ]] || exit 1 &&
ordinal=${BASH_REMATCH[1]} &&
if [ ! -z $NETWORK_UNIT_AGENT ]; then echo "network.unit.agent = $NETWORK_UNIT_AGENT-$ordinal" >> /opt/yacy_search_server/defaults/yacy.init; fi &&
export ADMIN_PASSWORD=$(echo -n "${ADMIN_USER}:${ADMIN_REALM}:${ADMIN_PASSWORD}" | md5sum | awk '{print $1}') &&
echo "adminAccountUserName = ${ADMIN_USER}" >> /opt/yacy_search_server/defaults/yacy.init &&
echo "adminRealm = ${ADMIN_REALM}" >> /opt/yacy_search_server/defaults/yacy.init &&
echo "adminAccountBase64MD5 = MD5:${ADMIN_PASSWORD}" >> /opt/yacy_search_server/defaults/yacy.init &&
/opt/yacy_search_server/startYACY.sh -f
env:
- name: NETWORK_UNIT_AGENT
value: {{ .Values.yacy.namePrefix }}
envFrom:
- secretRef:
name: {{ template "fullname" . }}-admin-credentials
ports:
- name: http
containerPort: {{ .Values.yacy.port }}
hostPort: {{ .Values.yacy.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
volumeMounts:
# - name: yacy-data
# mountPath: /opt/yacy_search_server/DATA
- name: yacy-config
mountPath: "/config"
readOnly: false
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumeClaimTemplates:
- metadata:
name: yacy-data
labels:
{{ include "sharedlabels" . | indent 10 }}
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: {{ .Values.yacy.volume.class }}
- name: {{ .Chart.Name }}
image: "yacy/yacy_search_server:latest"
imagePullPolicy: "IfNotPresent"
command: ['bash']
args:
- -c
- >-
cat /config/yacy.init >> /opt/yacy_search_server/defaults/yacy.init &&
[[ `hostname` =~ -([0-9]+)$ ]] || exit 1 &&
ordinal=${BASH_REMATCH[1]} &&
if [ ! -z $NETWORK_UNIT_AGENT ]; then echo "network.unit.agent = $NETWORK_UNIT_AGENT-$ordinal" >> /opt/yacy_search_server/defaults/yacy.init; fi &&
export ADMIN_PASSWORD=$(echo -n "${ADMIN_USER}:${ADMIN_REALM}:${ADMIN_PASSWORD}" | md5sum | awk '{print $1}') &&
echo "adminAccountUserName = ${ADMIN_USER}" >> /opt/yacy_search_server/defaults/yacy.init &&
echo "adminRealm = ${ADMIN_REALM}" >> /opt/yacy_search_server/defaults/yacy.init &&
echo "adminAccountBase64MD5 = MD5:${ADMIN_PASSWORD}" >> /opt/yacy_search_server/defaults/yacy.init &&
/opt/yacy_search_server/startYACY.sh -f
envFrom:
- secretRef:
name: {{ template "fullname" . }}-admin-credentials
{{- if .Values.application.secretName }}
- secretRef:
name: {{ .Values.application.secretName }}
{{- end }}
env:
- name: NETWORK_UNIT_AGENT
value: {{ .Values.yacy.namePrefix }}
- name: GITLAB_ENVIRONMENT_NAME
value: {{ .Values.gitlab.envName | quote }}
- name: GITLAB_ENVIRONMENT_URL
value: {{ .Values.gitlab.envURL | quote }}
{{- if .Values.lifecycle }}
lifecycle:
{{ toYaml .Values.lifecycle | indent 10 }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.yacy.port }}
hostPort: {{ .Values.yacy.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet: