summaryrefslogtreecommitdiffstats
path: root/helm/policy-models-simulator/templates
diff options
context:
space:
mode:
authorputhuparambil.aditya <aditya.puthuparambil@bell.ca>2020-10-01 12:06:33 +0100
committerputhuparambil.aditya <aditya.puthuparambil@bell.ca>2020-10-05 10:19:13 +0100
commit7edc7955d012fea43290b21bfd72d77d70ea4ec3 (patch)
tree0d4ab44ecad0ef051fb03cb04521aab35d4a2c3a /helm/policy-models-simulator/templates
parentbf47a0752450eaacc55176b4eec104693c94defc (diff)
Helm chart for policy-models-simulator
Issue-ID: POLICY-2828 Signed-off-by: puthuparambil.aditya <aditya.puthuparambil@bell.ca> Change-Id: Ic5e94edb2bc76067d5cde03dae2670dc6cf99a0e
Diffstat (limited to 'helm/policy-models-simulator/templates')
-rw-r--r--helm/policy-models-simulator/templates/NOTES.txt21
-rw-r--r--helm/policy-models-simulator/templates/_helpers.tpl56
-rw-r--r--helm/policy-models-simulator/templates/configmap.yaml12
-rw-r--r--helm/policy-models-simulator/templates/deployment.yaml80
-rw-r--r--helm/policy-models-simulator/templates/service.yaml30
-rw-r--r--helm/policy-models-simulator/templates/serviceaccount.yaml8
-rw-r--r--helm/policy-models-simulator/templates/tests/test-connection.yaml15
7 files changed, 222 insertions, 0 deletions
diff --git a/helm/policy-models-simulator/templates/NOTES.txt b/helm/policy-models-simulator/templates/NOTES.txt
new file mode 100644
index 00000000..f6e027f2
--- /dev/null
+++ b/helm/policy-models-simulator/templates/NOTES.txt
@@ -0,0 +1,21 @@
+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 }}{{ . }}
+ {{- 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 "policy-models-simulator.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 "policy-models-simulator.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "policy-models-simulator.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 "policy-models-simulator.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl port-forward $POD_NAME 8080:80
+{{- end }}
diff --git a/helm/policy-models-simulator/templates/_helpers.tpl b/helm/policy-models-simulator/templates/_helpers.tpl
new file mode 100644
index 00000000..a741f0de
--- /dev/null
+++ b/helm/policy-models-simulator/templates/_helpers.tpl
@@ -0,0 +1,56 @@
+{{/* vim: set filetype=mustache: */}}
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "policy-models-simulator.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 "policy-models-simulator.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 "policy-models-simulator.chart" -}}
+{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Common labels
+*/}}
+{{- define "policy-models-simulator.labels" -}}
+app.kubernetes.io/name: {{ include "policy-models-simulator.name" . }}
+helm.sh/chart: {{ include "policy-models-simulator.chart" . }}
+app.kubernetes.io/instance: {{ .Release.Name }}
+{{- if .Chart.AppVersion }}
+app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
+{{- end }}
+app.kubernetes.io/managed-by: {{ .Release.Service }}
+{{- end -}}
+
+{{/*
+Create the name of the service account to use
+*/}}
+{{- define "policy-models-simulator.serviceAccountName" -}}
+{{- if .Values.serviceAccount.create -}}
+ {{ default (include "policy-models-simulator.fullname" .) .Values.serviceAccount.name }}
+{{- else -}}
+ {{ default "default" .Values.serviceAccount.name }}
+{{- end -}}
+{{- end -}}
diff --git a/helm/policy-models-simulator/templates/configmap.yaml b/helm/policy-models-simulator/templates/configmap.yaml
new file mode 100644
index 00000000..c0f75199
--- /dev/null
+++ b/helm/policy-models-simulator/templates/configmap.yaml
@@ -0,0 +1,12 @@
+
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: {{ include "policy-models-simulator.fullname" . }}-configmap
+ labels:
+ app: {{ include "policy-models-simulator.name" . }}
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ heritage: {{ .Release.Service }}
+data:
+{{ tpl (.Files.Glob "resources/config/*.{json,xml}").AsConfig . | indent 2 }}
+{{ tpl (.Files.Glob "resources/cds/*.{json,xml}").AsConfig . | indent 2 }}
diff --git a/helm/policy-models-simulator/templates/deployment.yaml b/helm/policy-models-simulator/templates/deployment.yaml
new file mode 100644
index 00000000..02c49df7
--- /dev/null
+++ b/helm/policy-models-simulator/templates/deployment.yaml
@@ -0,0 +1,80 @@
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "policy-models-simulator.fullname" . }}
+ labels:
+{{ include "policy-models-simulator.labels" . | indent 4 }}
+spec:
+ replicas: {{ .Values.replicaCount }}
+ selector:
+ matchLabels:
+ app.kubernetes.io/name: {{ include "policy-models-simulator.name" . }}
+ app.kubernetes.io/instance: {{ .Release.Name }}
+ template:
+ metadata:
+ labels:
+ app.kubernetes.io/name: {{ include "policy-models-simulator.name" . }}
+ app.kubernetes.io/instance: {{ .Release.Name }}
+ spec:
+ {{- with .Values.imagePullSecrets }}
+ imagePullSecrets:
+ {{- toYaml . | nindent 8 }}
+ {{- end }}
+ serviceAccountName: {{ template "policy-models-simulator.serviceAccountName" . }}
+ securityContext:
+ {{- toYaml .Values.podSecurityContext | nindent 8 }}
+ containers:
+ - name: {{ .Chart.Name }}
+ securityContext:
+ {{- toYaml .Values.securityContext | nindent 12 }}
+ image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
+ imagePullPolicy: {{ .Values.image.pullPolicy }}
+ command: ["/opt/app/policy/simulators/bin/simulators.sh"]
+ args: ["/opt/app/policy/simulators/etc/mounted/simParameters.json"]
+ ports:
+ - containerPort: {{ .Values.service.internalPort }}
+ - containerPort: {{ .Values.service.internalPort2 }}
+ - containerPort: {{ .Values.service.internalPort3 }}
+ - containerPort: {{ .Values.service.internalPort4 }}
+ - containerPort: {{ .Values.service.internalPort5 }}
+ - containerPort: {{ .Values.service.internalPort6 }}
+ livenessProbe:
+ exec:
+ command:
+ - /bin/bash
+ - -c
+ - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
+ initialDelaySeconds: 120
+ periodSeconds: 20
+ readinessProbe:
+ exec:
+ command:
+ - /bin/bash
+ - -c
+ - nodetool status | grep $POD_IP | awk '$1!="UN" { exit 1; }'
+ initialDelaySeconds: 120
+ periodSeconds: 20
+ volumeMounts:
+ - mountPath: /opt/app/policy/simulators/etc/mounted/
+ name: simconfig
+ readOnly: true
+ 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: simconfig
+ configMap:
+ name: {{ include "policy-models-simulator.fullname" . }}-configmap
+ defaultMode: 0755
+
diff --git a/helm/policy-models-simulator/templates/service.yaml b/helm/policy-models-simulator/templates/service.yaml
new file mode 100644
index 00000000..362ac93a
--- /dev/null
+++ b/helm/policy-models-simulator/templates/service.yaml
@@ -0,0 +1,30 @@
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ include "policy-models-simulator.fullname" . }}
+ labels:
+{{ include "policy-models-simulator.labels" . | indent 4 }}
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ - port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ name: {{ .Values.service.portName }}
+ - port: {{ .Values.service.externalPort2 }}
+ targetPort: {{ .Values.service.internalPort2 }}
+ name: {{ .Values.service.portName }}2
+ - port: {{ .Values.service.externalPort3 }}
+ targetPort: {{ .Values.service.internalPort3 }}
+ name: {{ .Values.service.portName }}3
+ - port: {{ .Values.service.externalPort4 }}
+ targetPort: {{ .Values.service.internalPort4 }}
+ name: {{ .Values.service.portName }}4
+ - port: {{ .Values.service.externalPort5 }}
+ targetPort: {{ .Values.service.internalPort5 }}
+ name: {{ .Values.service.portName }}5
+ - port: {{ .Values.service.externalPort6 }}
+ targetPort: {{ .Values.service.internalPort6 }}
+ name: {{ .Values.service.portName }}6
+ selector:
+ app.kubernetes.io/name: {{ include "policy-models-simulator.name" . }}
+ app.kubernetes.io/instance: {{ .Release.Name }}
diff --git a/helm/policy-models-simulator/templates/serviceaccount.yaml b/helm/policy-models-simulator/templates/serviceaccount.yaml
new file mode 100644
index 00000000..27ee5daa
--- /dev/null
+++ b/helm/policy-models-simulator/templates/serviceaccount.yaml
@@ -0,0 +1,8 @@
+{{- if .Values.serviceAccount.create -}}
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+ name: {{ template "policy-models-simulator.serviceAccountName" . }}
+ labels:
+{{ include "policy-models-simulator.labels" . | indent 4 }}
+{{- end -}}
diff --git a/helm/policy-models-simulator/templates/tests/test-connection.yaml b/helm/policy-models-simulator/templates/tests/test-connection.yaml
new file mode 100644
index 00000000..e90661bc
--- /dev/null
+++ b/helm/policy-models-simulator/templates/tests/test-connection.yaml
@@ -0,0 +1,15 @@
+apiVersion: v1
+kind: Pod
+metadata:
+ name: "{{ include "policy-models-simulator.fullname" . }}-test-connection"
+ labels:
+{{ include "policy-models-simulator.labels" . | indent 4 }}
+ annotations:
+ "helm.sh/hook": test-success
+spec:
+ containers:
+ - name: wget
+ image: busybox
+ command: ['wget']
+ args: ['{{ include "policy-models-simulator.fullname" . }}:{{ .Values.service.port }}']
+ restartPolicy: Never