Skip to content

Commit

Permalink
Merge pull request #6 from NorskHelsenett/feature/chart
Browse files Browse the repository at this point in the history
Adding helm chart
  • Loading branch information
rogerwesterbo authored Jan 10, 2025
2 parents 4d406d6 + 72754d9 commit 8a83cc2
Show file tree
Hide file tree
Showing 13 changed files with 417 additions and 0 deletions.
23 changes: 23 additions & 0 deletions charts/ror-webapp/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
8 changes: 8 additions & 0 deletions charts/ror-webapp/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v2
name: web
description: ROR web

type: application
version: 0.1.0
appVersion: "1.16.0"
icon: https://raw.githubusercontent.com/NorskHelsenett/ror/main/media/ror.svg
22 changes: 22 additions & 0 deletions charts/ror-webapp/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "ror-admin.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "ror-admin.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "ror-admin.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "ror-admin.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
62 changes: 62 additions & 0 deletions charts/ror-webapp/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "ror-admin.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "ror-admin.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "ror-admin.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "ror-admin.labels" -}}
helm.sh/chart: {{ include "ror-admin.chart" . }}
{{ include "ror-admin.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "ror-admin.selectorLabels" -}}
app.kubernetes.io/name: {{ include "ror-admin.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "ror-admin.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "ror-admin.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/ror-webapp/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: ror-web-cm-config
data:
config.json: |
{
"auth": {
"issuer": "{{ .Values.web.authUrl }}",
"clientId": "ror.sky.test.nhn.no",
"redirectUri": "/auth/callback",
"scope": "profile email groups",
"response_type": "id_token token",
"requireHttps": true,
"strictDiscoveryDocumentValidation": true
},
"regex": {
"forms": "^[@()\\/:?\\r\\n.,a-zA-Z æøåÆØÅ0-9_-]+$"
},
"rowsPerPage": [10, 25, 50, 75, 100],
"rows": 25,
"rorApi": "{{ .Values.web.apiUrl }}",
"sse": {
"postfixUrl": "/v1/events/listen",
"method": "GET",
"timeout": 30000
}
}
74 changes: 74 additions & 0 deletions charts/ror-webapp/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "ror-admin.fullname" . }}
labels:
{{- include "ror-admin.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
revisionHistoryLimit: 2
selector:
matchLabels:
{{- include "ror-admin.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "ror-admin.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "ror-admin.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.securityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
volumeMounts:
- mountPath: /app/assets/config/config.json
name: json-configmap-volume
subPath: config.json
- mountPath: /tmp
name: tmp-volume
ports:
- name: http
containerPort: {{ .Values.pod.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: 8080
readinessProbe:
httpGet:
path: /
port: 8080
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
volumes:
- name: json-configmap-volume
configMap:
name: ror-web-cm-config
- name: tmp-volume
emptyDir: {}
33 changes: 33 additions & 0 deletions charts/ror-webapp/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "ror-admin.fullname" . }}
labels:
{{- include "ror-admin.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "ror-admin.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}

{{- end }}
{{- end }}
50 changes: 50 additions & 0 deletions charts/ror-webapp/templates/ingress-helsenett.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
name: admin-helsenett-ingress
spec:
ingressClassName: avi-ingress-class-helsenett
rules:
- host: {{ .Values.web.host }}
http:
paths:
- backend:
service:
name: {{ include "ror-admin.fullname" . }}
port:
number: {{ .Values.service.port }}
path: {{ .Values.ingress.path }}
pathType: {{ .Values.ingress.pathType }}
tls:
- hosts:
- {{ .Values.web.host }}
secretName: nhn-ror-admin-tls
---
apiVersion: ako.vmware.com/v1alpha1
kind: HostRule
metadata:
name: admin-allow-dcn-paw
namespace: {{ .Release.namespace}}
spec:
virtualhost:
datascripts:
- expose-nhn-office-isp
- expose-nhn-office-client
- expose-nhn-office-devops
- expose-nsg-amk-paws
- expose-nhn-dc-any
- expose-nsg-cloud-paws
- expose-nsg-container-paws
- expose-nsg-soc-paws
- expose-nsg-mon-paws
- expose-nhn-office-devops
- expose-nsg-esm-paws
- bottom-deny-rule
fqdn: ror.sky.test.nhn.no
analyticsProfile: NHN-System-Analytics-Profile
analyticsPolicy:
fullClientLogs:
enabled: false
throttle: DISABLED
11 changes: 11 additions & 0 deletions charts/ror-webapp/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ include "ror-admin.fullname" . }}-rolebindings
roleRef:
kind: ClusterRole
name: psp:vmware-system-restricted #Kan erstattes med: "psp:vmware-system-privileged" for root access
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: {{ include "ror-admin.serviceAccountName" . }}
15 changes: 15 additions & 0 deletions charts/ror-webapp/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "ror-admin.fullname" . }}
labels:
{{- include "ror-admin.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}
protocol: TCP
name: http
selector:
{{- include "ror-admin.selectorLabels" . | nindent 4 }}
12 changes: 12 additions & 0 deletions charts/ror-webapp/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "ror-admin.serviceAccountName" . }}
labels:
{{- include "ror-admin.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions charts/ror-webapp/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "ror-admin.fullname" . }}-test-connection"
labels:
{{- include "ror-admin.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "ror-admin.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
Loading

0 comments on commit 8a83cc2

Please sign in to comment.