Skip to content

Commit

Permalink
feat: add dynamic values for services and add container tty/stdin
Browse files Browse the repository at this point in the history
  • Loading branch information
royki committed Feb 6, 2023
1 parent 29ab4d2 commit 0afaf64
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 23 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Generic helm chart for Energy Web Foundation microservices

| Name | Email | Url |
| ---- | ------ | --- |
| EWF DevOps Team | <devops@energyweb.org> | |
| EWF DevOps Team | devops@energyweb.org | |

## Installing the chart

Expand Down Expand Up @@ -37,7 +37,7 @@ pre-commit install-hooks
| autoscaling.maxReplicas | int | `100` | |
| autoscaling.minReplicas | int | `1` | |
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
| containerPort | int | `80` | |
| container.ports.http | int | `80` | |
| deploymentStrategy | string | `"RollingUpdate"` | |
| env | object | `{}` | |
| extraLabels | object | `{}` | Extra lables to be added to all resources |
Expand All @@ -47,6 +47,7 @@ pre-commit install-hooks
| image.pullPolicy | string | `"IfNotPresent"` | |
| image.repository | string | `"nginx"` | |
| image.tag | string | `""` | |
| image.tty.enabled | bool | `true` | |
| imagePullSecrets | list | `[]` | |
| ingress.annotations | object | `{}` | |
| ingress.className | string | `""` | |
Expand Down Expand Up @@ -87,7 +88,8 @@ pre-commit install-hooks
| sealedSecret.enabled | bool | `false` | |
| sealedSecret.encryptedData | object | `{}` | |
| securityContext | object | `{}` | |
| service.port | int | `80` | |
| service.ports[0].name | string | `"http"` | |
| service.ports[0].port | int | `80` | |
| service.type | string | `"ClusterIP"` | |
| serviceAccount.annotations | object | `{}` | |
| serviceAccount.create | bool | `true` | |
Expand Down
36 changes: 21 additions & 15 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ spec:
strategy:
type: {{ .Values.deploymentStrategy }}
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
Expand Down Expand Up @@ -36,10 +36,16 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- if .Values.image.tty.enabled }}
stdin: true
tty: true
{{- end }}
ports:
- name: http
containerPort: {{ .Values.containerPort }}
{{- range $key, $value := $.Values.container.ports }}
- name: {{ $key }}
containerPort: {{ $value }}
protocol: TCP
{{- end }}
{{- with .Values.image.command }}
command:
{{- toYaml . | nindent 12 }}
Expand All @@ -48,7 +54,7 @@ spec:
args:
{{- toYaml . | nindent 12 }}
{{- end }}
env:
env:
{{- range $key, $val := .Values.env }}
- name: {{ $key }}
value: {{ $val | quote }}
Expand All @@ -63,22 +69,22 @@ spec:
httpGet:
path: {{ .Values.livenessProbe.httpGet.path }}
port: {{ .Values.livenessProbe.httpGet.port }}
scheme: {{ .Values.readinessProbe.httpGet.scheme }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
scheme: {{ .Values.readinessProbe.httpGet.scheme }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
successThreshold: {{ .Values.livenessProbe.successThreshold }}
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
{{- end }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: {{ .Values.readinessProbe.httpGet.path }}
port: {{ .Values.readinessProbe.httpGet.port }}
scheme: {{ .Values.readinessProbe.httpGet.scheme }}
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
port: {{ .Values.readinessProbe.httpGet.port }}
scheme: {{ .Values.readinessProbe.httpGet.scheme }}
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
successThreshold: {{ .Values.readinessProbe.successThreshold }}
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
Expand Down
9 changes: 6 additions & 3 deletions templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{ $servicePorts := .Values.service.ports }}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -7,9 +8,11 @@ metadata:
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
{{- range $key, $value := $servicePorts }}
- port: {{ .port }}
targetPort: {{ .name }}
protocol: TCP
name: http
name: {{ .name }}
{{- end }}
selector:
{{- include "microservice.selectorLabels" . | nindent 4 }}
10 changes: 8 additions & 2 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ pvc:
mountPath: "/tmp"


containerPort: 80
container:
ports:
http: 80

image:
repository: nginx
Expand All @@ -49,6 +51,8 @@ image:
tag: ""
command: []
args: []
tty:
enabled: false

env: {}

Expand Down Expand Up @@ -86,7 +90,9 @@ securityContext: {}

service:
type: ClusterIP
port: 80
ports:
- port: 80
name: http

ingress:
enabled: false
Expand Down

0 comments on commit 0afaf64

Please sign in to comment.