From 110b3ff0c90d7daf666ed092b00269c9695565f1 Mon Sep 17 00:00:00 2001 From: "maik.schaefer" <maik.schaefer@open-xchange.com> Date: Tue, 19 Oct 2021 09:11:34 +0000 Subject: [PATCH] Integrate ox common --- .gitlab-ci/values.yaml | 3 + helm/core-manifest-service/Chart.lock | 6 ++ helm/core-manifest-service/Chart.yaml | 6 +- .../templates/_ingress.tpl | 4 ++ .../templates/configMap.yaml | 2 +- .../templates/deployment.yaml | 62 ++++++------------- .../templates/ingress.yaml | 60 +----------------- .../templates/service.yaml | 6 +- helm/core-manifest-service/values.yaml | 24 +++++-- 9 files changed, 61 insertions(+), 112 deletions(-) create mode 100644 helm/core-manifest-service/Chart.lock create mode 100644 helm/core-manifest-service/templates/_ingress.tpl diff --git a/.gitlab-ci/values.yaml b/.gitlab-ci/values.yaml index d598961..1337231 100644 --- a/.gitlab-ci/values.yaml +++ b/.gitlab-ci/values.yaml @@ -8,7 +8,10 @@ manifests: ingress: enabled: false +defaultRegistry: "" + image: + registry: "" repository: ${CI_REGISTRY_IMAGE} pullPolicy: Always tag: ${TAG_NAME} diff --git a/helm/core-manifest-service/Chart.lock b/helm/core-manifest-service/Chart.lock new file mode 100644 index 0000000..a309de3 --- /dev/null +++ b/helm/core-manifest-service/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: ox-common + repository: oci://registry.open-xchange.com//common/charts + version: 1.0.9 +digest: sha256:e204cbfc5c68f4cd492bd4c5eaa87ad685ed1403e921b05c0fb2498b0aa9f299 +generated: "2021-10-13T16:00:59.193216+02:00" diff --git a/helm/core-manifest-service/Chart.yaml b/helm/core-manifest-service/Chart.yaml index ac277f4..3c30b59 100644 --- a/helm/core-manifest-service/Chart.yaml +++ b/helm/core-manifest-service/Chart.yaml @@ -15,10 +15,14 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.1.0 +version: 2.0.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. appVersion: "1.1.0" +dependencies: + - name: ox-common + version: 1.0.9 + repository: "oci://registry.open-xchange.com//common/charts" diff --git a/helm/core-manifest-service/templates/_ingress.tpl b/helm/core-manifest-service/templates/_ingress.tpl new file mode 100644 index 0000000..8df12d9 --- /dev/null +++ b/helm/core-manifest-service/templates/_ingress.tpl @@ -0,0 +1,4 @@ +{{- define "core-manifest-service.ingressPathMappings" -}} +paths: + - path: / +{{- end -}} diff --git a/helm/core-manifest-service/templates/configMap.yaml b/helm/core-manifest-service/templates/configMap.yaml index 1d216fe..9a09801 100644 --- a/helm/core-manifest-service/templates/configMap.yaml +++ b/helm/core-manifest-service/templates/configMap.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "core-manifest-service.fullname" . }} + name: {{ include "ox-common.names.fullname" . }} data: urls.yaml: | manifests: diff --git a/helm/core-manifest-service/templates/deployment.yaml b/helm/core-manifest-service/templates/deployment.yaml index afd1525..5eca31e 100644 --- a/helm/core-manifest-service/templates/deployment.yaml +++ b/helm/core-manifest-service/templates/deployment.yaml @@ -1,41 +1,24 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "core-manifest-service.fullname" . }} + name: {{ include "ox-common.names.fullname" . }} labels: - {{- include "core-manifest-service.labels" . | nindent 4 }} - {{- with .Values.deploymentAnnotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} + {{- include "ox-common.labels.standard" . | nindent 4 }} spec: - {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} - {{- end }} selector: matchLabels: - {{- include "core-manifest-service.selectorLabels" . | nindent 6 }} + {{- include "ox-common.labels.matchLabels" . | nindent 6 }} template: metadata: - {{- with .Values.podAnnotations }} - annotations: - {{- toYaml . | nindent 8 }} - {{- end }} + annotations: {{ toYaml .Values.podAnnotations | nindent 8 }} labels: - {{- include "core-manifest-service.selectorLabels" . | nindent 8 }} - spec: - {{- with .Values.imagePullSecrets }} - imagePullSecrets: - {{- toYaml . | nindent 8 }} - {{- end }} - serviceAccountName: {{ include "core-manifest-service.serviceAccountName" . }} - securityContext: - {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- include "ox-common.labels.matchLabels" . | nindent 8 }} + spec: {{ include "ox-common.pods.podSpec" (dict "podRoot" .Values "global" $ "context" . ) | nindent 6 }} containers: - - name: {{ .Chart.Name }} - securityContext: - {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + - name: main + securityContext: {{ toYaml .Values.securityContext | nindent 12 }} + image: {{ include "ox-common.images.image" (dict "imageRoot" .Values.image "global" $ "context" . ) }} imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: CACHE_TTL @@ -46,14 +29,20 @@ spec: - name: http containerPort: {{ .Values.containerPort | default 8080 }} protocol: TCP + {{- if .Values.probe.liveness.enabled }} livenessProbe: httpGet: - path: /healthy + path: / port: http + {{- omit .Values.probe.liveness "enabled" | toYaml | nindent 12 }} + {{- end }} + {{- if .Values.probe.readiness.enabled }} readinessProbe: httpGet: - path: /ready - port: http + path: / + port: http + {{- omit .Values.probe.readiness "enabled" | toYaml | nindent 12 }} + {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} volumeMounts: @@ -62,16 +51,5 @@ spec: volumes: - name: manifest-config configMap: - name: {{ include "core-manifest-service.fullname" . }} - {{- with .Values.nodeSelector }} - nodeSelector: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.affinity }} - affinity: - {{- toYaml . | nindent 8 }} - {{- end }} - {{- with .Values.tolerations }} - tolerations: - {{- toYaml . | nindent 8 }} - {{- end }} + name: {{ include "ox-common.names.fullname" . }} + diff --git a/helm/core-manifest-service/templates/ingress.yaml b/helm/core-manifest-service/templates/ingress.yaml index c965713..027e9ac 100644 --- a/helm/core-manifest-service/templates/ingress.yaml +++ b/helm/core-manifest-service/templates/ingress.yaml @@ -1,61 +1,3 @@ {{- if .Values.ingress.enabled -}} -{{- $fullName := include "core-manifest-service.fullname" . -}} -{{- $svcPort := .Values.service.port -}} -{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} - {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} - {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} - {{- end }} -{{- end }} -{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1 -{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} -apiVersion: networking.k8s.io/v1beta1 -{{- else -}} -apiVersion: extensions/v1beta1 -{{- end }} -kind: Ingress -metadata: - name: {{ $fullName }} - labels: - {{- include "core-manifest-service.labels" . | nindent 4 }} - {{- with .Values.ingress.annotations }} - annotations: - {{- toYaml . | nindent 4 }} - {{- end }} -spec: - {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} - ingressClassName: {{ .Values.ingress.className }} - {{- end }} - {{- if .Values.ingress.tls }} - tls: - {{- range .Values.ingress.tls }} - - hosts: - {{- range .hosts }} - - {{ . | quote }} - {{- end }} - secretName: {{ .secretName }} - {{- end }} - {{- end }} - rules: - {{- range .Values.ingress.hosts }} - - host: {{ .host | quote }} - http: - paths: - {{- range .paths }} - - path: {{ .path }} - {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} - pathType: {{ .pathType }} - {{- end }} - backend: - {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} - service: - name: {{ $fullName }} - port: - number: {{ $svcPort }} - {{- else }} - serviceName: {{ $fullName }} - servicePort: {{ $svcPort }} - {{- end }} - {{- end }} - {{- end }} +{{ include "ox-common.ingress.defaultIngress" (dict "ingress" .Values.ingress "context" . "global" $) }} {{- end }} diff --git a/helm/core-manifest-service/templates/service.yaml b/helm/core-manifest-service/templates/service.yaml index 551297e..47649d7 100644 --- a/helm/core-manifest-service/templates/service.yaml +++ b/helm/core-manifest-service/templates/service.yaml @@ -1,9 +1,9 @@ apiVersion: v1 kind: Service metadata: - name: {{ include "core-manifest-service.fullname" . }} + name: {{ include "ox-common.names.fullname" . }} labels: - {{- include "core-manifest-service.labels" . | nindent 4 }} + {{- include "ox-common.labels.standard" . | nindent 4 }} spec: type: {{ .Values.service.type }} ports: @@ -12,4 +12,4 @@ spec: protocol: TCP name: http selector: - {{- include "core-manifest-service.selectorLabels" . | nindent 4 }} + {{- include "ox-common.labels.matchLabels" . | nindent 4 }} diff --git a/helm/core-manifest-service/values.yaml b/helm/core-manifest-service/values.yaml index b613183..a2476fb 100644 --- a/helm/core-manifest-service/values.yaml +++ b/helm/core-manifest-service/values.yaml @@ -4,10 +4,12 @@ replicaCount: 1 +defaultRegistry: registry.open-xchange.com + containerPort: 8080 image: - repository: gitlab.open-xchange.com:4567/frontend/infrastructure/manifest-service + repository: "core-manifest-service" pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: "" @@ -44,15 +46,13 @@ service: ingress: enabled: true - className: "" + pathMappings: "core-manifest-service.ingressPathMappings" annotations: {} # kubernetes.io/ingress.class: nginx # kubernetes.io/tls-acme: "true" hosts: - host: chart-example.local - paths: - - path: / - pathType: ImplementationSpecific + tls: [] # - secretName: chart-example-tls # hosts: @@ -83,6 +83,18 @@ tolerations: [] affinity: {} -# service specific configuration +probe: + liveness: + enabled: true + periodSeconds: 10 + failureThreshold: 15 + + readiness: + enabled: true + initialDelaySeconds: 30 + periodSeconds: 5 + failureThreshold: 2 + timeoutSeconds: 5 + cacheTTL: 30000 logLevel: info -- GitLab