Skip to content

Commit

Permalink
Mimoto Chart: Added config server as dependency
Browse files Browse the repository at this point in the history
Signed-off-by: Lalith Kota <[email protected]>
  • Loading branch information
lalithkota committed Sep 19, 2024
1 parent 2225939 commit f7c8ed2
Show file tree
Hide file tree
Showing 9 changed files with 332 additions and 81 deletions.
32 changes: 16 additions & 16 deletions charts/mimoto/questions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,39 @@ questions:
type: string
label: Keycloak Base URL

- variable: springConfig.profile
- variable: global.esignetHostname
type: string
label: Spring Config Profile
label: Esignet Hostname

- variable: springConfig.names
type: string
label: Spring Config Names

- variable: springConfig.gitRepo.enabled
description: Enables download of configs from Git repo.
- variable: springCloudConfig.enabled
description: Enables Spring Cloud Config.
type: boolean
label: Spring Config Git Enabled
label: Spring Cloud Config Enabled
show_subquestions_if: true
subquestions:
- variable: springConfig.gitRepo.repoUrl
- variable: springCloudConfig.profile
type: string
label: Spring Cloud Config Profile

- variable: springCloudConfig.gitRepo.url
description: |-
Repo Url for remote Git repo containing configs.
This url should include username password if required.
type: string
label: Spring Config Git Repo Url
label: Spring Cloud Config Git Repo Url

- variable: springConfig.gitRepo.branch
- variable: springCloudConfig.gitRepo.branch
description: Branch of remote Git repo containing configs.
type: string
label: Spring Config Git Repo Branch
label: Spring Cloud Config Git Repo Branch

- variable: springConfig.rawConfig
- variable: rawSpringConfig
description: |-
If git-based config is disabled, the complete application.properties can be
If Sspring Cloud Config is disabled, the complete application.properties can be
directly supplied here.
type: yamlfile
label: Spring Config application properties.
show_if: "springConfig.gitRepo.enabled=false"
show_if: "springCloudConfig.enabled=false"

- variable: oidcClientKeySecretName
description: Name of the secret that contains the p12 file holding OIDC Client Keys
Expand Down
37 changes: 20 additions & 17 deletions charts/mimoto/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@ Return the proper image name (for the init container volume-permissions image)
{{- include "common.images.image" ( dict "imageRoot" .Values.volumePermissions.image "global" .Values.global ) -}}
{{- end -}}

{{/*
Return the config server image name
*/}}
{{- define "mimoto.config-server.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.springCloudConfig.image "global" .Values.global) }}
{{- end -}}

{{/*
Return the proper Docker Image Registry Secret Names
*/}}
{{- define "mimoto.imagePullSecrets" -}}
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.volumePermissions.image) "global" .Values.global) -}}
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.springCloudConfig.image .Values.volumePermissions.image) "global" .Values.global) -}}
{{- end -}}

{{/*
Expand All @@ -30,21 +37,6 @@ Create the name of the service account to use
{{- end -}}
{{- end -}}

{{/*
Compile all warnings into a single message.
*/}}
{{- define "mimoto.validateValues" -}}
{{- $messages := list -}}
{{- $messages := append $messages (include "mimoto.validateValues.foo" .) -}}
{{- $messages := append $messages (include "mimoto.validateValues.bar" .) -}}
{{- $messages := without $messages "" -}}
{{- $message := join "\n" $messages -}}

{{- if $message -}}
{{- printf "\nVALUES VALIDATION:\n%s" $message -}}
{{- end -}}
{{- end -}}

{{/*
Return podAnnotations
*/}}
Expand Down Expand Up @@ -75,7 +67,18 @@ Render Env values section
{{- end -}}

{{- define "mimoto.envVars" -}}
{{- $envVars := merge (deepCopy .Values.envVars) (deepCopy .Values.envVarsFrom) (.Values.springConfig.gitRepo.enabled | ternary (deepCopy .Values.springConfig.gitRepo.envVars) dict) -}}
{{- $envVars := merge (.Values.springCloudConfig.enabled | ternary (deepCopy .Values.springCloudConfigEnvVars) dict) (deepCopy .Values.coreEnvVars) (deepCopy .Values.coreEnvVarsFrom) (.Values.springCloudConfig.enabled | ternary dict (merge (deepCopy .Values.envVars) (deepCopy .Values.envVarsFrom))) -}}
{{- include "mimoto.baseEnvVars" (dict "envVars" $envVars "context" $) }}
{{- end -}}

{{- define "mimoto.config-server.envVars" -}}
{{- $overridesEnvVars := dict -}}
{{- if .Values.springCloudConfig.enabled -}}
{{- range $k, $v := (merge (deepCopy .Values.envVars) (deepCopy .Values.envVarsFrom)) -}}
{{- $_ := set $overridesEnvVars (printf "spring_cloud_config_server_overrides_%s" $k) $v -}}
{{- end -}}
{{- end -}}
{{- $envVars := merge $overridesEnvVars (deepCopy .Values.springCloudConfig.envVars) (deepCopy .Values.springCloudConfig.envVarsFrom) -}}
{{- include "mimoto.baseEnvVars" (dict "envVars" $envVars "context" $) }}
{{- end -}}

Expand Down
97 changes: 97 additions & 0 deletions charts/mimoto/templates/config-server/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{{- if .Values.springCloudConfig.enabled }}
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
kind: Deployment
metadata:
name: {{ template "common.names.fullname" . }}-config-server
labels: {{- include "common.labels.standard" (dict "customLabels" .Values.commonLabels "context" $) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.springCloudConfig.replicaCount }}
{{- if .Values.springCloudConfig.updateStrategy }}
strategy: {{- toYaml .Values.springCloudConfig.updateStrategy | nindent 4 }}
{{- end }}
selector:
matchLabels: {{- include "common.labels.matchLabels" (dict "customLabels" .Values.springCloudConfig.podLabels "context" $) | nindent 6 }}
template:
metadata:
{{- if .Values.springCloudConfig.podAnnotations }}
annotations: {{- include "common.tplvalues.render" (dict "value" .Values.springCloudConfig.podAnnotations "context" $) | nindent 8 }}
{{- end }}
labels: {{- include "common.labels.standard" (dict "customLabels" .Values.springCloudConfig.podLabels "context" $) | nindent 8 }}
spec:
serviceAccountName: {{ template "mimoto.serviceAccountName" . }}
{{- include "mimoto.imagePullSecrets" . | nindent 6 }}
{{- if .Values.springCloudConfig.hostAliases }}
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.springCloudConfig.hostAliases "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.springCloudConfig.affinity }}
affinity: {{- include "common.tplvalues.render" ( dict "value" .Values.springCloudConfig.affinity "context" $) | nindent 8 }}
{{- else }}
affinity:
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.springCloudConfig.podAffinityPreset "context" $) | nindent 10 }}
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.springCloudConfig.podAntiAffinityPreset "context" $) | nindent 10 }}
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.springCloudConfig.nodeAffinityPreset.type "key" .Values.springCloudConfig.nodeAffinityPreset.key "values" .Values.springCloudConfig.nodeAffinityPreset.values) | nindent 10 }}
{{- end }}
{{- if .Values.springCloudConfig.nodeSelector }}
nodeSelector: {{- include "common.tplvalues.render" ( dict "value" .Values.springCloudConfig.nodeSelector "context" $) | nindent 8 }}
{{- end }}
{{- if .Values.springCloudConfig.tolerations }}
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.springCloudConfig.tolerations "context" .) | nindent 8 }}
{{- end }}
{{- if .Values.springCloudConfig.priorityClassName }}
priorityClassName: {{ .Values.springCloudConfig.priorityClassName | quote }}
{{- end }}
{{- if .Values.springCloudConfig.podSecurityContext.enabled }}
securityContext: {{- omit .Values.springCloudConfig.podSecurityContext "enabled" | toYaml | nindent 8 }}
{{- end }}
{{- if .Values.springCloudConfig.initContainers }}
initContainers:
{{- include "common.tplvalues.render" (dict "value" .Values.springCloudConfig.initContainers "context" $) | nindent 8 }}
{{- end }}
containers:
- name: config-server
image: {{ template "mimoto.config-server.image" . }}
imagePullPolicy: {{ .Values.springCloudConfig.image.pullPolicy }}
{{- if .Values.springCloudConfig.lifecycleHooks }}
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.springCloudConfig.lifecycleHooks "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.springCloudConfig.containerSecurityContext.enabled }}
securityContext: {{- omit .Values.springCloudConfig.containerSecurityContext "enabled" | toYaml | nindent 12 }}
{{- end }}
{{- if .Values.springCloudConfig.command }}
command: {{- include "common.tplvalues.render" (dict "value" .Values.springCloudConfig.command "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.springCloudConfig.args }}
args: {{- include "common.tplvalues.render" (dict "value" .Values.springCloudConfig.args "context" $) | nindent 12 }}
{{- end }}
env:
{{- include "mimoto.config-server.envVars" . | nindent 12 }}
ports:
- name: http
containerPort: {{ .Values.springCloudConfig.containerPort }}
{{- if .Values.springCloudConfig.resources }}
resources: {{- toYaml .Values.springCloudConfig.resources | nindent 12 }}
{{- end }}
{{- if .Values.springCloudConfig.startupProbe.enabled }}
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.springCloudConfig.startupProbe "enabled") "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.springCloudConfig.livenessProbe.enabled }}
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.springCloudConfig.livenessProbe "enabled") "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.springCloudConfig.readinessProbe.enabled }}
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.springCloudConfig.readinessProbe "enabled") "context" $) | nindent 12 }}
{{- end }}
volumeMounts:
{{- if .Values.springCloudConfig.extraVolumeMounts }}
{{- include "common.tplvalues.render" (dict "value" .Values.springCloudConfig.extraVolumeMounts "context" $) | nindent 12 }}
{{- end }}
{{- if .Values.springCloudConfig.sidecars }}
{{- include "common.tplvalues.render" ( dict "value" .Values.springCloudConfig.sidecars "context" $) | nindent 8 }}
{{- end }}
volumes:
{{- if .Values.springCloudConfig.extraVolumes }}
{{- include "common.tplvalues.render" (dict "value" .Values.springCloudConfig.extraVolumes "context" $) | nindent 8 }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{{- if .Values.springConfig.gitRepo.enabled }}
{{- if .Values.springCloudConfig.enabled }}
apiVersion: v1
kind: Secret
metadata:
name: {{ template "common.names.fullname" . }}-git-config-secret
name: {{ template "common.names.fullname" . }}-config-server-git-secret
labels: {{- include "common.labels.standard" (dict "customLabels" .Values.commonLabels "context" $) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
type: Opaque
data:
{{- range $k, $v := (omit .Values.springConfig.gitRepo "enabled" "envVars") }}
{{- range $k, $v := .Values.springCloudConfig.gitRepo }}
{{ $k }}: {{ include "common.tplvalues.render" (dict "value" $v "context" $) | b64enc | quote }}
{{- end }}
{{- end }}
26 changes: 26 additions & 0 deletions charts/mimoto/templates/config-server/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{- if .Values.springCloudConfig.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "common.names.fullname" . }}-config-server
labels: {{- include "common.labels.standard" (dict "customLabels" .Values.commonLabels "context" $) | nindent 4 }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.springCloudConfig.service.type }}
{{- if (or (eq .Values.springCloudConfig.service.type "LoadBalancer") (eq .Values.springCloudConfig.service.type "NodePort")) }}
externalTrafficPolicy: {{ .Values.springCloudConfig.service.externalTrafficPolicy | quote }}
{{- end }}
{{ if eq .Values.springCloudConfig.service.type "LoadBalancer" }}
loadBalancerSourceRanges: {{ .Values.springCloudConfig.service.loadBalancerSourceRanges }}
{{ end }}
{{- if (and (eq .Values.springCloudConfig.service.type "LoadBalancer") (not (empty .Values.springCloudConfig.service.loadBalancerIP))) }}
loadBalancerIP: {{ .Values.springCloudConfig.service.loadBalancerIP }}
{{- end }}
ports:
- name: http
port: {{ .Values.springCloudConfig.service.port }}
targetPort: {{ .Values.springCloudConfig.containerPort }}
selector: {{- include "common.labels.matchLabels" (dict "customLabels" .Values.springCloudConfig.podLabels "context" $) | nindent 4 }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/mimoto/templates/configmap-spring-config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.springConfig.rawConfig }}
{{- if .Values.rawSpringConfig }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand All @@ -9,5 +9,5 @@ metadata:
{{- end }}
data:
application.properties: |-
{{- include "common.tplvalues.render" (dict "value" .Values.springConfig.rawConfig "context" $) | nindent 4 }}
{{- include "common.tplvalues.render" (dict "value" .Values.rawSpringConfig "context" $) | nindent 4 }}
{{- end }}
6 changes: 3 additions & 3 deletions charts/mimoto/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ spec:
mountPath: /startup.sh
subPath: startup.sh
{{- end }}
{{- if and .Values.springConfig.rawConfig (not .Values.springConfig.gitRepo.enabled) }}
{{- if and .Values.rawSpringConfig (not .Values.springCloudConfig.enabled) }}
- name: spring-config
mountPath: {{ include "common.tplvalues.render" (dict "value" .Values.springConfig.rawConfigMountPath "context" $) }}
mountPath: {{ include "common.tplvalues.render" (dict "value" .Values.rawSpringConfigMountPath "context" $) }}
subPath: application.properties
{{- end }}
- name: oidc-client-keys
Expand All @@ -110,7 +110,7 @@ spec:
name: {{ template "common.names.fullname" . }}-startup
defaultMode: 0755
{{- end }}
{{- if and .Values.springConfig.rawConfig (not .Values.springConfig.gitRepo.enabled) }}
{{- if and .Values.rawSpringConfig (not .Values.springCloudConfig.enabled) }}
- name: spring-config
configMap:
name: {{ template "common.names.fullname" . }}-spring-config
Expand Down
15 changes: 15 additions & 0 deletions charts/mimoto/templates/virtualservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,20 @@ spec:
host: {{ include "common.tplvalues.render" (dict "value" .Values.istio.virtualservice.destination "context" $) }}
port:
number: {{ include "common.tplvalues.render" (dict "value" .Values.istio.virtualservice.destinationPort "context" $) }}
{{- if .Values.istio.virtualservice.rewriteUri }}
- headers:
request:
set:
x-forwarded-host: {{ default .Values.hostname .Values.istio.virtualservice.host | quote }}
x-forwarded-proto: https
match:
- uri:
prefix: {{ include "common.tplvalues.render" (dict "value" .Values.istio.virtualservice.rewriteUri "context" $) }}
route:
- destination:
host: {{ include "common.tplvalues.render" (dict "value" .Values.istio.virtualservice.destination "context" $) }}
port:
number: {{ include "common.tplvalues.render" (dict "value" .Values.istio.virtualservice.destinationPort "context" $) }}
{{- end }}
{{- end }}
{{- end }}
Loading

0 comments on commit f7c8ed2

Please sign in to comment.