Skip to content

Commit 5315bbd

Browse files
feat(dso-console): add new strangler service
It is a NGINX-based strangler service that has everything needed to route requests through either `server` (the current backend) to `backend` (the new one)
1 parent f7f27e8 commit 5315bbd

File tree

9 files changed

+454
-6
lines changed

9 files changed

+454
-6
lines changed

charts/dso-console/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,59 @@ A Helm chart to deploy Cloud Pi Native Console
333333
| server.startupProbe.timeoutSeconds | int | `5` | Number of seconds after which the probe times out. |
334334
| server.strategy.type | string | `"RollingUpdate"` | Strategy type used to replace old Pods by new ones, can be "Recreate" or "RollingUpdate". |
335335
| server.tolerations | list | `[]` | Default tolerations for Console CPN backend. |
336+
| strangler.affinity | object | `{}` | Default affinity for Console CPN strangler. |
337+
| strangler.autoscaling.enabled | bool | `false` | Enable Horizontal Pod Autoscaler ([HPA]) for the Console CPN strangler. |
338+
| strangler.autoscaling.maxReplicas | int | `3` | Maximum number of replicas for the Console CPN strangler [HPA]. |
339+
| strangler.autoscaling.minReplicas | int | `1` | Minimum number of replicas for the Console CPN strangler [HPA]. |
340+
| strangler.autoscaling.targetCPUUtilizationPercentage | int | `80` | Average CPU utilization percentage for the Console CPN strangler [HPA]. |
341+
| strangler.autoscaling.targetMemoryUtilizationPercentage | int | `80` | Average memory utilization percentage for the Console CPN strangler [HPA]. |
342+
| strangler.container.args | list | `[]` | Console CPN strangler container command args. |
343+
| strangler.container.command | list | `[]` | Console CPN strangler container command. |
344+
| strangler.container.port | int | `8080` | Console CPN strangler container port. |
345+
| strangler.container.securityContext | object | `{}` | Toggle and define container-level security context. |
346+
| strangler.env | object | `{}` | Console CPN strangler container env variables, it will be injected into a configmap and loaded into the container. |
347+
| strangler.envFrom | list | `[]` | Console CPN strangler container env variables loaded from configmap or secret reference. |
348+
| strangler.extraContainers | list | `[]` | Extra containers to add to the Console CPN strangler pod as sidecars. |
349+
| strangler.extraVolumeMounts | list | `[]` | List of extra mounts to add (normally used with extraVolumes). |
350+
| strangler.extraVolumes | list | `[]` | List of extra volumes to add. |
351+
| strangler.healthcheckPath | string | `"/"` | Console CPN strangler container healthcheck endpoint. |
352+
| strangler.hostAliases | list | `[]` | Host aliases that will be injected at pod-level into /etc/hosts. |
353+
| strangler.image.pullPolicy | string | `"Always"` | Image pull policy for the Console CPN strangler. |
354+
| strangler.image.repository | string | `"ghcr.io/cloud-pi-native/console/strangler"` | Repository to use for the Console CPN strangler. |
355+
| strangler.image.tag | string | `""` | Tag to use for the Console CPN strangler. # Overrides the image tag whose default is the chart appVersion. |
356+
| strangler.initContainers | list | `[]` | Init containers to add to the Console CPN strangler pod. |
357+
| strangler.livenessProbe.enabled | bool | `true` | Whether or not enable the probe. |
358+
| strangler.livenessProbe.failureThreshold | int | `3` | Minimum consecutive failures for the probe to be considered failed after having succeeded. |
359+
| strangler.livenessProbe.initialDelaySeconds | int | `30` | Number of seconds after the container has started before probe is initiated. |
360+
| strangler.livenessProbe.periodSeconds | int | `30` | How often (in seconds) to perform the probe. |
361+
| strangler.livenessProbe.successThreshold | int | `1` | Minimum consecutive successes for the probe to be considered successful after having failed. |
362+
| strangler.livenessProbe.timeoutSeconds | int | `5` | Number of seconds after which the probe times out |
363+
| strangler.nodeSelector | object | `{}` | Default node selector for Console CPN strangler. |
364+
| strangler.podAnnotations | object | `{}` | Annotations for the Console CPN strangler deployed pods. |
365+
| strangler.podLabels | object | `{}` | Labels for the Console CPN strangler deployed pods. |
366+
| strangler.podSecurityContext | object | `{}` | Toggle and define pod-level security context. |
367+
| strangler.readinessProbe.enabled | bool | `true` | Whether or not enable the probe. |
368+
| strangler.readinessProbe.failureThreshold | int | `2` | Minimum consecutive failures for the probe to be considered failed after having succeeded. |
369+
| strangler.readinessProbe.initialDelaySeconds | int | `15` | Number of seconds after the container has started before probe is initiated. |
370+
| strangler.readinessProbe.periodSeconds | int | `10` | How often (in seconds) to perform the probe. |
371+
| strangler.readinessProbe.successThreshold | int | `2` | Minimum consecutive successes for the probe to be considered successful after having failed. |
372+
| strangler.readinessProbe.timeoutSeconds | int | `5` | Number of seconds after which the probe times out. |
373+
| strangler.replicaCount | int | `1` | The number of application controller pods to run. |
374+
| strangler.resources.limits.cpu | string | `"500m"` | CPU limit for the Console CPN strangler. |
375+
| strangler.resources.limits.memory | string | `"512Mi"` | Memory limit for the Console CPN strangler. |
376+
| strangler.resources.requests.cpu | string | `"250m"` | CPU request for the Console CPN strangler. |
377+
| strangler.resources.requests.memory | string | `"128Mi"` | Memory request for the Console CPN strangler. |
378+
| strangler.secrets | object | `{}` | Console CPN strangler container env secrets, it will be injected into a secret and loaded into the container. |
379+
| strangler.service.port | int | `80` | Console CPN strangler service port. |
380+
| strangler.service.type | string | `"ClusterIP"` | Console CPN strangler service type. |
381+
| strangler.startupProbe.enabled | bool | `true` | Whether or not enable the probe. |
382+
| strangler.startupProbe.failureThreshold | int | `10` | Minimum consecutive failures for the probe to be considered failed after having succeeded. |
383+
| strangler.startupProbe.initialDelaySeconds | int | `0` | Number of seconds after the container has started before probe is initiated. |
384+
| strangler.startupProbe.periodSeconds | int | `10` | How often (in seconds) to perform the probe. |
385+
| strangler.startupProbe.successThreshold | int | `1` | Minimum consecutive successes for the probe to be considered successful after having failed. |
386+
| strangler.startupProbe.timeoutSeconds | int | `5` | Number of seconds after which the probe times out. |
387+
| strangler.strategy.type | string | `"RollingUpdate"` | Strategy type used to replace old Pods by new ones, can be "Recreate" or "RollingUpdate". |
388+
| strangler.tolerations | list | `[]` | Default tolerations for Console CPN strangler. |
336389

337390
----------------------------------------------
338391
Autogenerated from chart metadata using [helm-docs v1.14.2](https://github.com/norwoodj/helm-docs/releases/v1.14.2)

charts/dso-console/templates/_helpers.tpl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,10 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
127127
{{ include "cpnConsole.server.selectorLabels" . }}
128128
{{- end }}
129129

130+
{{- define "cpnConsole.strangler.labels" -}}
131+
{{ include "cpnConsole.common.labels" . }}
132+
{{ include "cpnConsole.strangler.selectorLabels" . }}
133+
{{- end }}
130134

131135
{{- define "cpnConsole.backend.labels" -}}
132136
{{ include "cpnConsole.common.labels" . }}
@@ -141,6 +145,11 @@ app.kubernetes.io/name: {{ include "cpnConsole.name" . }}-client
141145
app.kubernetes.io/instance: {{ .Release.Name }}
142146
{{- end }}
143147

148+
{{- define "cpnConsole.strangler.selectorLabels" -}}
149+
app.kubernetes.io/name: {{ include "cpnConsole.name" . }}-strangler
150+
app.kubernetes.io/instance: {{ .Release.Name }}
151+
{{- end }}
152+
144153
{{- define "cpnConsole.server.selectorLabels" -}}
145154
app.kubernetes.io/name: {{ include "cpnConsole.name" . }}-server
146155
app.kubernetes.io/instance: {{ .Release.Name }}

charts/dso-console/templates/ingress.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{{- if .Values.ingress.enabled -}}
22
{{- $fullName := include "cpnConsole.fullname" . -}}
33
{{- $svcPortClient := .Values.client.service.port -}}
4+
{{- $svcPortStrangler := .Values.strangler.service.port -}}
45
{{- $svcPortServer := .Values.server.service.port -}}
56
apiVersion: networking.k8s.io/v1
67
kind: Ingress
@@ -42,9 +43,9 @@ spec:
4243
pathType: Prefix
4344
backend:
4445
service:
45-
name: {{ $fullName }}-server
46+
name: {{ $fullName }}-strangler
4647
port:
47-
number: {{ $svcPortServer }}
48+
number: {{ $svcPortStrangler }}
4849
- path: /swagger-ui
4950
pathType: Prefix
5051
backend:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
kind: ConfigMap
2+
apiVersion: v1
3+
metadata:
4+
name: {{ include "cpnConsole.fullname" . }}-strangler
5+
labels: {{- include "cpnConsole.strangler.labels" . | nindent 4 }}
6+
data:
7+
LEGACY_UPSTREAM: {{ include "cpnConsole.fullname" . }}-server:{{ .Values.server.service.port }}
8+
NESTJS_UPSTREAM: {{ include "cpnConsole.fullname" . }}-backend:{{ .Values.backend.service.port }}
9+
{{- if .Values.global.env -}}
10+
{{- include "cpnConsole.env" .Values.global | indent 2 }}
11+
{{- end -}}
12+
{{- if .Values.strangler.env -}}
13+
{{- include "cpnConsole.env" .Values.strangler | indent 2 }}
14+
{{- end -}}
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "cpnConsole.fullname" . }}-strangler
5+
labels:
6+
{{- include "cpnConsole.strangler.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.strangler.autoscaling.enabled }}
9+
replicas: {{ .Values.strangler.replicaCount }}
10+
{{- end }}
11+
selector:
12+
matchLabels:
13+
{{- include "cpnConsole.strangler.selectorLabels" . | nindent 6 }}
14+
strategy:
15+
type: {{ .Values.strangler.strategy.type }}
16+
template:
17+
metadata:
18+
annotations:
19+
{{- include "checksum" (list $ "/strangler/configmap.yaml") | nindent 8 }}
20+
{{- include "checksum" (list $ "/strangler/secret.yaml") | nindent 8 }}
21+
{{- with .Values.strangler.podAnnotations }}
22+
{{- toYaml . | nindent 8 }}
23+
{{- end }}
24+
labels:
25+
{{- include "cpnConsole.strangler.selectorLabels" . | nindent 8 }}
26+
{{- with .Values.strangler.podLabels }}
27+
{{- toYaml . | nindent 8 }}
28+
{{- end }}
29+
spec:
30+
{{- if and .Values.imageCredentials.username .Values.imageCredentials.password }}
31+
imagePullSecrets:
32+
- name: {{ include "cpnConsole.name" . }}-pullsecret
33+
{{- end }}
34+
securityContext:
35+
{{- toYaml .Values.strangler.podSecurityContext | nindent 8 }}
36+
{{- if .Values.strangler.initContainers }}
37+
initContainers:
38+
{{- tpl (toYaml .Values.strangler.initContainers) . | nindent 8 }}
39+
{{- end }}
40+
containers:
41+
- name: strangler
42+
securityContext:
43+
{{- toYaml .Values.strangler.container.securityContext | nindent 12 }}
44+
image: "{{ .Values.strangler.image.repository }}:{{ .Values.strangler.image.tag | default .Chart.AppVersion }}"
45+
imagePullPolicy: {{ .Values.strangler.image.pullPolicy }}
46+
{{- if .Values.strangler.container.command }}
47+
command:
48+
{{- range .Values.strangler.container.command }}
49+
- {{ . | quote }}
50+
{{- end }}
51+
{{- end }}
52+
{{- if .Values.strangler.container.args }}
53+
args:
54+
{{- range .Values.strangler.container.args }}
55+
- {{ . | quote }}
56+
{{- end }}
57+
{{- end }}
58+
ports:
59+
- containerPort: {{ .Values.strangler.container.port }}
60+
protocol: TCP
61+
envFrom:
62+
- configMapRef:
63+
name: {{ include "cpnConsole.fullname" . }}-strangler
64+
{{- if or .Values.global.secrets .Values.strangler.secrets }}
65+
- secretRef:
66+
name: {{ include "cpnConsole.fullname" . }}-strangler
67+
{{- end }}
68+
{{- if .Values.strangler.envFrom }}
69+
{{- toYaml .Values.strangler.envFrom | nindent 8 }}
70+
{{- end }}
71+
{{- if .Values.strangler.startupProbe.enabled }}
72+
startupProbe:
73+
httpGet:
74+
path: {{ .Values.strangler.healthcheckPath }}
75+
port: {{ .Values.strangler.container.port }}
76+
initialDelaySeconds: {{ .Values.strangler.startupProbe.initialDelaySeconds }}
77+
successThreshold: {{ .Values.strangler.startupProbe.successThreshold }}
78+
failureThreshold: {{ .Values.strangler.startupProbe.failureThreshold }}
79+
periodSeconds: {{ .Values.strangler.startupProbe.periodSeconds }}
80+
timeoutSeconds: {{ .Values.strangler.startupProbe.timeoutSeconds }}
81+
{{- end }}
82+
{{- if .Values.strangler.readinessProbe.enabled }}
83+
readinessProbe:
84+
httpGet:
85+
path: {{ .Values.strangler.healthcheckPath }}
86+
port: {{ .Values.strangler.container.port }}
87+
initialDelaySeconds: {{ .Values.strangler.readinessProbe.initialDelaySeconds }}
88+
successThreshold: {{ .Values.strangler.readinessProbe.successThreshold }}
89+
failureThreshold: {{ .Values.strangler.readinessProbe.failureThreshold }}
90+
periodSeconds: {{ .Values.strangler.readinessProbe.periodSeconds }}
91+
timeoutSeconds: {{ .Values.strangler.readinessProbe.timeoutSeconds }}
92+
{{- end }}
93+
{{- if .Values.strangler.livenessProbe.enabled }}
94+
livenessProbe:
95+
httpGet:
96+
path: {{ .Values.strangler.healthcheckPath }}
97+
port: {{ .Values.strangler.container.port }}
98+
initialDelaySeconds: {{ .Values.strangler.livenessProbe.initialDelaySeconds }}
99+
successThreshold: {{ .Values.strangler.livenessProbe.successThreshold }}
100+
failureThreshold: {{ .Values.strangler.livenessProbe.failureThreshold }}
101+
periodSeconds: {{ .Values.strangler.livenessProbe.periodSeconds }}
102+
timeoutSeconds: {{ .Values.strangler.livenessProbe.timeoutSeconds }}
103+
{{- end }}
104+
{{- if .Values.strangler.hostAliases }}
105+
hostAliases:
106+
{{- toYaml .Values.strangler.hostAliases | nindent 8 }}
107+
{{- end }}
108+
resources:
109+
{{- toYaml .Values.strangler.resources | nindent 10 }}
110+
volumeMounts:
111+
{{- range $volumeMount := .Values.strangler.extraVolumeMounts }}
112+
- name: {{ $volumeMount.name }}
113+
mountPath: {{ $volumeMount.mountPath }}
114+
{{- end }}
115+
{{- if .Values.strangler.extraContainers }}
116+
{{- tpl (toYaml .Values.strangler.extraContainers) . | nindent 8 }}
117+
{{- end }}
118+
{{- with .Values.strangler.nodeSelector }}
119+
nodeSelector:
120+
{{- toYaml . | nindent 8 }}
121+
{{- end }}
122+
{{- with .Values.strangler.affinity }}
123+
affinity:
124+
{{- toYaml . | nindent 8 }}
125+
{{- end }}
126+
{{- with .Values.strangler.tolerations }}
127+
tolerations:
128+
{{- toYaml . | nindent 8 }}
129+
{{- end }}
130+
volumes:
131+
{{- range $volume := .Values.strangler.extraVolumes }}
132+
- name: {{ $volume.name }}
133+
{{- if eq $volume.type "hostPath" }}
134+
hostPath:
135+
path: {{ $volume.path }}
136+
{{- end }}
137+
{{- if eq $volume.type "configMap" }}
138+
configMap:
139+
name: {{ $volume.name }}
140+
{{- end }}
141+
{{- end }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{- if .Values.strangler.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "cpnConsole.fullname" . }}-strangler
6+
labels:
7+
{{- include "cpnConsole.strangler.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "cpnConsole.fullname" . }}-strangler
13+
minReplicas: {{ .Values.strangler.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.strangler.autoscaling.maxReplicas }}
15+
metrics:
16+
{{- if .Values.strangler.autoscaling.targetCPUUtilizationPercentage }}
17+
- type: Resource
18+
resource:
19+
name: cpu
20+
target:
21+
type: Utilization
22+
averageUtilization: {{ .Values.strangler.autoscaling.targetCPUUtilizationPercentage }}
23+
{{- end }}
24+
{{- if .Values.strangler.autoscaling.targetMemoryUtilizationPercentage }}
25+
- type: Resource
26+
resource:
27+
name: memory
28+
target:
29+
type: Utilization
30+
averageUtilization: {{ .Values.strangler.autoscaling.targetMemoryUtilizationPercentage }}
31+
{{- end }}
32+
{{- end }}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{{- if or .Values.global.secrets .Values.strangler.secrets }}
2+
kind: Secret
3+
apiVersion: v1
4+
metadata:
5+
name: {{ include "cpnConsole.fullname" . }}-strangler
6+
labels: {{- include "cpnConsole.strangler.labels" . | nindent 4 }}
7+
data:
8+
{{- if .Values.global.secrets -}}
9+
{{- include "cpnConsole.secret" .Values.global | indent 2 }}
10+
{{- end -}}
11+
{{- if .Values.strangler.secrets -}}
12+
{{- include "cpnConsole.secret" .Values.strangler | indent 2 }}
13+
{{- end -}}
14+
{{- end -}}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "cpnConsole.fullname" . }}-strangler
5+
labels:
6+
{{- include "cpnConsole.strangler.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.strangler.service.type }}
9+
ports:
10+
- port: {{ .Values.strangler.service.port }}
11+
targetPort: {{ .Values.strangler.container.port }}
12+
protocol: TCP
13+
selector:
14+
{{- include "cpnConsole.strangler.selectorLabels" . | nindent 4 }}

0 commit comments

Comments
 (0)