Skip to content

Commit

Permalink
Merge pull request #80 from camptocamp/GEO-6100-add-range-on-services
Browse files Browse the repository at this point in the history
GEO-6100: add logic for range over services
  • Loading branch information
danduk82 authored Dec 23, 2022
2 parents 16db19f + 1a2ade4 commit d508caa
Show file tree
Hide file tree
Showing 9 changed files with 409 additions and 285 deletions.
2 changes: 1 addition & 1 deletion Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ version: 0.1.0
dependencies:
- name: common
repository: https://camptocamp.github.io/helm-common
version: 0.3.0
version: 0.4.0
45 changes: 27 additions & 18 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
{{- $root := . -}}
{{- $values := .Values -}}

{{- range $serviceName, $serviceDefinition := $values.services }}
{{- if eq $serviceDefinition.enabled true }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "common.fullname" ( dict "root" . "service" .Values ) }}
{{- include "common.metadata" ( dict "root" . "service" .Values ) | nindent 2 }}
name: {{ include "common.fullname" ( dict "root" $root "service" $serviceDefinition "serviceName" $serviceName ) }}
{{- include "common.metadata" ( dict "root" $root "service" $serviceDefinition "serviceName" $serviceName ) | nindent 2 }}
spec:
replicas: {{ .Values.replicaCount }}
revisionHistoryLimit: {{ .Values.global.revisionHistoryLimit | default 3 }}
replicas: {{ $serviceDefinition.replicaCount | default 1 }}
revisionHistoryLimit: {{ $values.global.revisionHistoryLimit | default 3 }}
strategy:
type: RollingUpdate
selector:
matchLabels: {{- include "common.selectorLabels" ( dict "root" . "service" .Values ) | nindent 6 }}
matchLabels: {{- include "common.selectorLabels" ( dict "root" $root "service" $serviceDefinition "serviceName" $serviceName ) | nindent 6 }}
template:
metadata: {{- include "common.podMetadata" ( dict "root" . "service" .Values ) | nindent 6 }}
metadata: {{- include "common.podMetadata" ( dict "root" $root "service" $serviceDefinition "serviceName" $serviceName ) | nindent 6 }}
spec:
{{- include "common.podConfig" ( dict "root" . "service" .Values ) | nindent 6 }}
{{- if .Values.initContainers }}
{{- include "common.podConfig" ( dict "root" $root "service" $serviceDefinition "serviceName" $serviceName ) | nindent 6 }}
{{- if and (hasKey $serviceDefinition "initContainers") ($serviceDefinition.initContainers) }}
initContainers:
{{- range $name, $config := .Values.initContainers }}
{{- range $name, $config := $serviceDefinition.initContainers }}
- name: {{ $name }}
{{- include "common.containerConfig" ( dict "root" $ "container" $config ) | nindent 10 }}
{{- with $config.command }}
Expand All @@ -26,12 +32,13 @@ spec:
args: {{ $config.args | toYaml | nindent 12 }}
{{- end }}
{{- with $config.volumeMounts }}
volumeMounts: {{ $config.volumeMounts | toYaml | nindent 12 }}
{{- end }}
volumeMounts:
{{- include "common.dictToList" ( dict "keyName" "mountPath" "contents" . ) | nindent 12 -}}
{{- end -}}
{{- end }}
{{- end }}
containers:
{{- range $name, $config := .Values.containers }}
{{- range $name, $config := $serviceDefinition.containers }}
- name: {{ $name }}
{{- include "common.containerConfig" ( dict "root" $ "container" $config ) | nindent 10 }}
{{- with $config.command }}
Expand All @@ -44,12 +51,12 @@ spec:
{{- end }}
{{- with $config.volumeMounts }}
volumeMounts:
{{- . | toYaml | nindent 12 }}
{{- end }}
{{- include "common.dictToList" ( dict "keyName" "mountPath" "contents" . ) | nindent 12 -}}
{{- end -}}
{{- with $config.ports }}
ports:
{{- $config.ports | toYaml | nindent 12 }}
{{- end }}
{{- include "common.dictToList" ( dict "contents" . ) | nindent 12 -}}
{{- end -}}
{{- with $config.livenessProbe }}
livenessProbe:
{{- toYaml . | nindent 12 }}
Expand All @@ -63,7 +70,9 @@ spec:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- end }}
{{- with .Values.volumes }}
{{- with $serviceDefinition.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- include "common.dictToList" ( dict "contents" . ) | nindent 8 -}}
{{- end }}
{{- end }}
{{- end }}
53 changes: 0 additions & 53 deletions templates/ingress.yaml

This file was deleted.

13 changes: 10 additions & 3 deletions templates/pdb.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
{{- $root := . -}}
{{- $values := .Values -}}
{{- range $serviceName, $serviceDefinition := $values.services }}
{{- if eq $serviceDefinition.enabled true }}
---
{{- if semverCompare ">=1.21.0" ( trimPrefix "v" $.Capabilities.KubeVersion.Version ) }}
apiVersion: policy/v1
{{- else -}}
apiVersion: policy/v1beta1
{{- end }}
kind: PodDisruptionBudget
metadata:
name: {{ include "common.fullname" ( dict "root" . "service" .Values ) }}
labels: {{- include "common.selectorLabels" ( dict "root" . "service" .Values ) | nindent 4 }}
name: {{ include "common.fullname" ( dict "root" $root "service" $serviceDefinition "serviceName" $serviceName ) }}
labels: {{- include "common.selectorLabels" ( dict "root" $root "service" $serviceDefinition "serviceName" $serviceName ) | nindent 4 }}
spec:
maxUnavailable: 1
selector:
matchLabels: {{- include "common.selectorLabels" ( dict "root" . "service" .Values ) | nindent 6 }}
matchLabels: {{- include "common.selectorLabels" ( dict "root" $root "service" $serviceDefinition "serviceName" $serviceName ) | nindent 6 }}
{{- end }}
{{- end }}
18 changes: 13 additions & 5 deletions templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
{{- $root := . -}}
{{- $values := .Values -}}

{{- range $serviceName, $serviceDefinition := $values.services }}
{{- if eq $serviceDefinition.enabled true }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "common.fullname" ( dict "root" . "service" .Values ) }}
labels: {{ include "common.labels" ( dict "root" . "service" .Values ) | nindent 4 }}
name: {{ include "common.fullname" ( dict "root" $root "service" $serviceDefinition "serviceName" $serviceName ) }}
labels: {{ include "common.labels" ( dict "root" $root "service" $serviceDefinition "serviceName" $serviceName ) | nindent 4 }}
prometheus: "true"
spec:
type: {{ .Values.service.type }}
{{- with .Values.service.ports }}
type: {{ $serviceDefinition.service.type }}
{{- with $serviceDefinition.service.ports }}
ports:
{{- . | toYaml | nindent 4 }}
{{- end }}
selector: {{- include "common.selectorLabels" ( dict "root" . "service" .Values ) | nindent 4 }}
selector: {{- include "common.selectorLabels" ( dict "root" $root "service" $serviceDefinition "serviceName" $serviceName ) | nindent 4 }}
{{- end }}
{{- end }}
Loading

0 comments on commit d508caa

Please sign in to comment.