diff --git a/charts/portal/Chart.yaml b/charts/portal/Chart.yaml new file mode 100644 index 0000000..f9445d1 --- /dev/null +++ b/charts/portal/Chart.yaml @@ -0,0 +1,9 @@ +apiVersion: v2 +name: portal +appVersion: 0.0.7 +description: A generated Helm Chart for Soniclabs T&M Portal +version: 0.0.1 +type: application +maintainers: + - name: cdecatapult + url: cdecatapult.github.io/soniclabs-helmcharts diff --git a/charts/portal/README.md b/charts/portal/README.md new file mode 100644 index 0000000..a6f1326 --- /dev/null +++ b/charts/portal/README.md @@ -0,0 +1,52 @@ +# SonicLabs Portal + +## Parameters + +### Portal Parameters + +| Name | Description | Value | +| -------------------------- | ----------------------------------------------------------------------- | ---------------- | +| `config.replicaCount` | The amount of containers to run | `1` | +| `config.type` | The type of service to create | `LoadBalancer` | +| `config.appPort` | The port to expose the service and application on | `80` | +| `config.nodePort` | The nodePort to use if the the service type is LoadBalancer or NodePort | `30342` | +| `config.commonAnnotations` | The annotations to set on the Portal application | `{}` | +| `config.cma.host` | The hostname of the Config Manager service | `configmanager` | +| `config.cma.port` | The port of the Config Manager service | `8000` | +| `config.sma.host` | The hostname of the Suite Manager service | `suitemanager` | +| `config.sma.port` | The port of the Suite Manager service | `8000` | +| `config.tma.host` | The hostname of the Test Manager service | `testmanager` | +| `config.tma.port` | The port of the Test Manager service | `8000` | +| `config.rma.host` | The hostname of the Results Manager service | `resultsmanager` | +| `config.rma.port` | The port of the Results Manager service | `8000` | +| `config.dma.host` | The hostname of the Deploy Manager service | `deploymanager` | +| `config.dma.port` | The port of the Deploy Manager service | `8000` | + +### ConfigManager Image Parameters + +| Name | Description | Value | +| ------------------- | -------------------------------------------- | -------------------------------------- | +| `image.repository` | The repository to use for the Portal image | `ghcr.io/cdecatapult/soniclabs-portal` | +| `image.pullPolicy` | The pull policy to use for the Portal image | `Always` | +| `image.tag` | The tag to use for the Portal image | `v0.0.7` | +| `image.pullSecrets` | The pull secrets to use for the Portal image | `["soniclabs"]` | + +### Portal Ingress parameters + +| Name | Description | Value | +| --------------------------- | ---------------------------------------------------------------- | -------------- | +| `ingress.enabled` | Whether or not to enable the ingress for the Portal application | `true` | +| `ingress.annotations` | The annotations to set on the ingress for the Portal application | `{}` | +| `ingress.ingressClassName` | The ingress class to use for the Portal application | `""` | +| `ingress.hostname` | The hostname to use for the Portal application | `portal.local` | +| `ingress.paths` | The paths to use for the Portal application | | +| `ingress.paths[0].path` | The path to use for the Portal application | `/` | +| `ingress.paths[0].pathType` | The path type to use for the Portal application | `Prefix` | + +### Portal ServiceAccount parameters + +| Name | Description | Value | +| ---------------------------- | ----------------------------------------------------------------- | ------- | +| `serviceAccount.create` | Whether or not to create a service account for the Portal service | `false` | +| `serviceAccount.annotations` | The annotations to use for the Portal service account | `{}` | +| `serviceAccount.name` | The name of the service account to use for the Portal service | `""` | diff --git a/charts/portal/ci/ct-values.yaml b/charts/portal/ci/ct-values.yaml new file mode 100644 index 0000000..11c41be --- /dev/null +++ b/charts/portal/ci/ct-values.yaml @@ -0,0 +1,2 @@ +config: + type: ClusterIP diff --git a/charts/portal/templates/_helpers.tpl b/charts/portal/templates/_helpers.tpl new file mode 100644 index 0000000..b763ca6 --- /dev/null +++ b/charts/portal/templates/_helpers.tpl @@ -0,0 +1,102 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "portal.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 "portal.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 "portal.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "portal.labels" -}} +helm.sh/chart: {{ include "portal.chart" . }} +{{ include "portal.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "portal.selectorLabels" -}} +app.kubernetes.io/name: {{ include "portal.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "portal.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "portal.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Create a default fully qualified postgresql name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "portal.postgresql.fullname" -}} +{{- if .Values.config.externalPostgresql -}} +{{ .Values.config.externalPostgresql | trunc 63 | trimSuffix "-" -}} +{{- else if not ( .Values.postgresql.enabled ) -}} +{{ fail "Postgresql must either be enabled or passed via config.externalPostgresql" }} +{{- else if .Values.postgresql.fullnameOverride -}} +{{- .Values.postgresql.fullnameOverride | trunc 63 | trimSuffix "-" -}} +{{- else -}} +{{- $name := default "postgresql" .Values.postgresql.nameOverride -}} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} +{{- end -}} + +{{/* +Conditionally populate imagePullSecrets if present in the context +*/}} +{{- define "portal.imagePullSecrets" -}} + {{- if (not (empty .Values.image.pullSecrets)) }} +imagePullSecrets: + {{- range .Values.image.pullSecrets }} + - name: {{ . }} + {{- end }} + {{- end }} +{{- end -}} + +{{/* +Create the image path for the passed in image field +*/}} +{{- define "portal.image" -}} +{{- if eq (substr 0 7 .tag) "sha256:" -}} +{{- printf "%s@%s" .repository .tag -}} +{{- else -}} +{{- printf "%s:%s" .repository .tag -}} +{{- end -}} +{{- end -}} diff --git a/charts/portal/templates/configmap.yaml b/charts/portal/templates/configmap.yaml new file mode 100644 index 0000000..4c23a33 --- /dev/null +++ b/charts/portal/templates/configmap.yaml @@ -0,0 +1,29 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "portal.fullname" . }}-configmap + labels: + {{- include "portal.labels" . | nindent 4 }} +data: + config.js: | + const config = { + TEST_MANAGER_HOST: '{{ .Values.config.tma.host }}', + TEST_MANAGER_PORT: '{{ .Values.config.tma.port }}', + DEPLOY_MANAGER_HOST: '{{ .Values.config.dma.host }}', + DEPLOY_MANAGER_PORT: '{{ .Values.config.dma.port }}', + CONFIG_MANAGER_HOST: '{{ .Values.config.cma.host }}', + CONFIG_MANAGER_PORT: '{{ .Values.config.cma.port }}', + RESULTS_MANAGER_HOST: '{{ .Values.config.rma.host }}', + RESULTS_MANAGER_PORT: '{{ .Values.config.rma.port }}', + SUITE_MANAGER_HOST: '{{ .Values.config.sma.host }}', + SUITE_MANAGER_PORT: '{{ .Values.config.sma.port }}' + } + + if (!Window.config) { + Window.config = {} + } + + Window.config = Object.keys(config).reduce((out, next) => { + if (!out.hasOwnProperty(next)) out[next] = config[next] + return out + }, {}) diff --git a/charts/portal/templates/deployment.yaml b/charts/portal/templates/deployment.yaml new file mode 100644 index 0000000..5156597 --- /dev/null +++ b/charts/portal/templates/deployment.yaml @@ -0,0 +1,54 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "portal.fullname" . }}-app + labels: + {{- include "portal.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.config.replicaCount }} + selector: + matchLabels: + {{- include "portal.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + {{- if .Values.config.commonAnnotations }} + {{- toYaml .Values.config.commonAnnotations | nindent 6 }} + {{- end }} + labels: + {{- include "portal.labels" . | nindent 8 }} + spec: + {{- include "portal.imagePullSecrets" . | indent 6 }} + containers: + - name: {{ include "portal.fullname" . }}-app + image: {{ template "portal.image" .Values.image }} + imagePullPolicy: {{ .Values.image.pullPolicy | quote }} + ports: + - containerPort: {{ .Values.config.appPort }} + livenessProbe: + httpGet: + path: / + port: {{ .Values.config.appPort }} + timeoutSeconds: 3 + periodSeconds: 10 + failureThreshold: 3 + readinessProbe: + httpGet: + path: / + port: {{ .Values.config.appPort }} + timeoutSeconds: 3 + periodSeconds: 10 + failureThreshold: 3 + volumeMounts: + - name: configmap + mountPath: /soniclabs-portal/config.js + subPath: config.js + readOnly: true + volumes: + - name: configmap + configMap: + name: {{ include "portal.fullname" . }}-configmap + items: + - key: config.js + path: config.js diff --git a/charts/portal/templates/ingress.yaml b/charts/portal/templates/ingress.yaml new file mode 100644 index 0000000..e7a468b --- /dev/null +++ b/charts/portal/templates/ingress.yaml @@ -0,0 +1,35 @@ +{{- if .Values.ingress.enabled }} +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "portal.fullname" . }}-app + labels: + {{- include "portal.labels" . | nindent 4 }} + {{- if or .Values.ingress.annotations .Values.config.commonAnnotations }} + annotations: + {{- if .Values.ingress.annotations }} + {{- toYaml .Values.ingress.annotations | nindent 4 }} + {{- end }} + {{- if .Values.config.commonAnnotations }} + {{- toYaml .Values.config.commonAnnotations | nindent 4 }} + {{- end }} + {{- end }} +spec: + {{ if .Values.ingress.ingressClassName }} + ingressClassName: {{ .Values.ingress.ingressClassName | quote }} + {{ end }} + rules: + - host: {{ .Values.ingress.hostname }} + http: + paths: + {{- range .Values.ingress.paths }} + - path: {{ .path }} + pathType: {{ .pathType }} + {{- end }} + backend: + service: + name: {{ include "portal.fullname" . }} + port: + number: {{ $.Values.config.appPort }} +{{- end }} diff --git a/charts/portal/templates/svc.yaml b/charts/portal/templates/svc.yaml new file mode 100644 index 0000000..e3f75bf --- /dev/null +++ b/charts/portal/templates/svc.yaml @@ -0,0 +1,19 @@ +{{- $fullName := include "portal.fullname" . -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ $fullName }} + labels: + {{- include "portal.labels" . | nindent 4 }} +spec: + type: {{ .Values.config.type }} + ports: + - port: {{ .Values.config.appPort }} + targetPort: {{ .Values.config.appPort }} + {{- if or (eq .Values.config.type "NodePort") (eq .Values.config.type "LoadBalancer") }} + nodePort: {{ .Values.config.nodePort }} + {{- end }} + protocol: TCP + name: http + selector: + {{- include "portal.selectorLabels" . | nindent 4 }} diff --git a/charts/portal/templates/svcaccount.yaml b/charts/portal/templates/svcaccount.yaml new file mode 100644 index 0000000..13e9173 --- /dev/null +++ b/charts/portal/templates/svcaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "portal.serviceAccountName" . }} + labels: + {{- include "portal.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/portal/values.yaml b/charts/portal/values.yaml new file mode 100644 index 0000000..1d29caa --- /dev/null +++ b/charts/portal/values.yaml @@ -0,0 +1,76 @@ +## @section Portal Parameters +## +config: +## @param config.replicaCount The amount of containers to run + replicaCount: 1 +## @param config.type The type of service to create + type: LoadBalancer + ## @param config.appPort The port to expose the service and application on + appPort: 80 + ## @param config.nodePort The nodePort to use if the the service type is LoadBalancer or NodePort + nodePort: 30342 + ## @param config.commonAnnotations The annotations to set on the Portal application + commonAnnotations: {} + cma: + ## @param config.cma.host The hostname of the Config Manager service + host: configmanager + ## @param config.cma.port The port of the Config Manager service + port: 8000 + sma: + ## @param config.sma.host The hostname of the Suite Manager service + host: suitemanager + ## @param config.sma.port The port of the Suite Manager service + port: 8000 + tma: + ## @param config.tma.host The hostname of the Test Manager service + host: testmanager + ## @param config.tma.port The port of the Test Manager service + port: 8000 + rma: + ## @param config.rma.host The hostname of the Results Manager service + host: resultsmanager + ## @param config.rma.port The port of the Results Manager service + port: 8000 + dma: + ## @param config.dma.host The hostname of the Deploy Manager service + host: deploymanager + ## @param config.dma.port The port of the Deploy Manager service + port: 8000 + +## @section ConfigManager Image Parameters +image: + ## @param image.repository The repository to use for the Portal image + repository: ghcr.io/cdecatapult/soniclabs-portal + ## @param image.pullPolicy The pull policy to use for the Portal image + pullPolicy: Always + ## @param image.tag The tag to use for the Portal image + tag: v0.0.7 + ## @param image.pullSecrets The pull secrets to use for the Portal image + pullSecrets: ['soniclabs'] + +## @section Portal Ingress parameters +## +ingress: + ## @param ingress.enabled Whether or not to enable the ingress for the Portal application + enabled: true + ## @param ingress.annotations The annotations to set on the ingress for the Portal application + annotations: {} + ## @param ingress.ingressClassName The ingress class to use for the Portal application + ingressClassName: "" + ## @param ingress.hostname The hostname to use for the Portal application + hostname: portal.local + ## @extra ingress.paths The paths to use for the Portal application + paths: + ## @param ingress.paths[0].path The path to use for the Portal application + ## @param ingress.paths[0].pathType The path type to use for the Portal application + - path: / + pathType: Prefix + +## @section Portal ServiceAccount parameters +serviceAccount: + ## @param serviceAccount.create Whether or not to create a service account for the Portal service + create: false + ## @param serviceAccount.annotations The annotations to use for the Portal service account + annotations: {} + ## @param serviceAccount.name The name of the service account to use for the Portal service + name: ""