Skip to content

Commit

Permalink
Add Helm chart for deployment
Browse files Browse the repository at this point in the history
This change adds the necessary Helm configuration to deploy the
application within an appropriate Kubernetes cluster.
  • Loading branch information
LiamMacP committed Oct 18, 2023
1 parent d5aef09 commit 07a6755
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 0 deletions.
5 changes: 5 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: engineering-guidance-and-standards
description: A Helm chart for Engineering Guidance and Standards
type: application
version: 1.0.0
6 changes: 6 additions & 0 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{{/*
Name of the chart.
*/}}
{{- define "app.name" -}}
{{- .Chart.Name | trunc 63 | trimSuffix "-" }}
{{- end }}
28 changes: 28 additions & 0 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "app.name" . }}
spec:
selector:
matchLabels:
app: {{ include "app.name" . }}
replicas: 1
template:
metadata:
labels:
app: {{ include "app.name" . }}
spec:
containers:
- name: {{ .Chart.Name }}
image: {{ .Values.app.image.repository }}:{{ .Values.app.image.version }}
imagePullPolicy: Always
resources:
requests:
memory: "20Mi"
cpu: "100m"
limits:
memory: "400Mi"
cpu: "500m"
ports:
- containerPort: {{ .Values.app.port }}
29 changes: 29 additions & 0 deletions helm/templates/ingress-external.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- if .Values.ingress.external.enabled }}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "app.name" . }}-external
labels:
cert-manager.io/solver: route53
annotations:
cert-manager.io/enabled: "true"
ingress.kubernetes.io/force-ssl-redirect: "true"
spec:
ingressClassName: "nginx-external"
tls:
- hosts:
- {{ .Values.ingress.external.host }}
secretName: {{ include "app.name" . }}-external
rules:
- host: {{ .Values.ingress.external.host }}
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: {{ include "app.name" . }}
port:
number: {{ .Values.service.port }}
{{- end }}
29 changes: 29 additions & 0 deletions helm/templates/ingress-internal.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- if .Values.ingress.internal.enabled }}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "app.name" . }}-internal
labels:
cert-manager.io/solver: route53
annotations:
cert-manager.io/enabled: "true"
ingress.kubernetes.io/force-ssl-redirect: "true"
spec:
ingressClassName: "nginx-internal"
tls:
- hosts:
- {{ .Values.ingress.internal.host }}
secretName: {{ include "app.name" . }}-internal
rules:
- host: {{ .Values.ingress.internal.host }}
http:
paths:
- path: /
pathType: ImplementationSpecific
backend:
service:
name: {{ include "app.name" . }}
port:
number: {{ .Values.service.port }}
{{- end}}
19 changes: 19 additions & 0 deletions helm/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "app.name" . }}-service-policy
spec:
podSelector:
matchLabels:
app: {{ include "app.name" . }}
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
name: ingress-internal
- namespaceSelector:
matchLabels:
name: ingress-external
13 changes: 13 additions & 0 deletions helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "app.name" . }}
spec:
selector:
app: {{ include "app.name" . }}
type: ClusterIP
ports:
- name: https
port: 443
targetPort: {{ .Values.app.port }}
16 changes: 16 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
app:
image:
repository: quay.io/ukhomeofficedigital/engineering-guidance-and-standards
version:
port: 80

service:
port: 443

ingress:
internal:
enabled: true
host: engineering.internal.sas.homeoffice.gov.uk
external:
enabled: false
host: engineering.homeoffice.gov.uk

0 comments on commit 07a6755

Please sign in to comment.