[WIFI-4909] Add: helm chart

This commit is contained in:
Dmitry Dunaev
2021-10-13 10:11:21 +03:00
parent fa3df2ae0a
commit 1d77d410e7
10 changed files with 419 additions and 0 deletions

1
helm/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.swp

22
helm/.helmignore Normal file
View File

@@ -0,0 +1,22 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

5
helm/Chart.yaml Normal file
View File

@@ -0,0 +1,5 @@
apiVersion: v1
appVersion: "1.0"
description: A Helm chart for Kubernetes
name: owprovui
version: 0.1.0

82
helm/README.md Normal file
View File

@@ -0,0 +1,82 @@
# owprovui
This Helm chart helps to deploy OpenWIFI Provisining Web UI (further on refered as __Provisioning UI__) to the Kubernetes clusters. It is mainly used in [assembly chart](https://github.com/Telecominfraproject/wlan-cloud-ucentral-deploy/tree/main/chart) as Web UI requires other services as dependencies that are considered in that Helm chart. This chart is purposed to define deployment logic close to the application code itself and define default values that could be overriden during deployment.
## TL;DR;
```bash
$ helm install .
```
## Introduction
This chart bootstraps the Provisioning UI on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.
## Installing the Chart
Currently this chart is not assembled in charts archives, so [helm-git](https://github.com/aslafy-z/helm-git) is required for remote the installation
To install the chart with the release name `my-release`:
```bash
$ helm install --name my-release git+https://github.com/Telecominfraproject/wlan-cloud-owprov-ui@helm?ref=main
```
The command deploys the Provisioning UI on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.
> **Tip**: List all releases using `helm list`
## Uninstalling the Chart
To uninstall/delete the `my-release` deployment:
```bash
$ helm delete my-release
```
The command removes all the Kubernetes components associated with the chart and deletes the release.
## Configuration
The following table lists the configurable parameters of the chart and their default values. If Default value is not listed in the table, please refer to the [Values](values.yaml) files for details.
| Parameter | Type | Description | Default |
|-----------|------|-------------|---------|
| replicaCount | number | Amount of replicas to be deployed | `1` |
| nameOverride | string | Override to be used for application deployment | |
| fullnameOverride | string | Override to be used for application deployment (has priority over nameOverride) | |
| images.owprovui.repository | string | Docker image repository | |
| images.owprovui.tag | string | Docker image tag | `'master'` |
| images.owprovui.pullPolicy | string | Docker image pull policy | `'Always'` |
| services.owprovui.type | string | OpenWIFI Provisioning UI service type | `'ClusterIP'` |
| services.owprovui.ports.http.servicePort | number | Websocket endpoint port to be exposed on service | `80` |
| services.owprovui.ports.http.targetPort | number | Websocket endpoint port to be targeted by service | `80` |
| services.owprovui.ports.http.protocol | string | Websocket endpoint protocol | `'TCP'` |
| checks.owprovui.liveness.httpGet.path | string | Liveness check path to be used | `'/'` |
| checks.owprovui.liveness.httpGet.port | number | Liveness check port to be used (should be pointint to ALB endpoint) | `http` |
| checks.owprovui.readiness.httpGet.path | string | Readiness check path to be used | `'/'` |
| checks.owprovui.readiness.httpGet.port | number | Readiness check port to be used | `http` |
| ingresses.default.enabled | boolean | Defines if the Provisioning UI should be exposed via Ingress controller | `False` |
| ingresses.default.hosts | array | List of hosts for the exposed Provisioning UI | |
| ingresses.default.paths | array | List of paths to be exposed for the Provisioning UI | |
| public_env_variables | hash | Defines list of environment variables to be passed to the Provisioning UI (required for application configuration) | |
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
```bash
$ helm install --name my-release \
--set replicaCount=1 \
.
```
The above command sets that only 1 instance of your app should be running
Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,
```bash
$ helm install --name my-release -f values.yaml .
```
> **Tip**: You can use the default [values.yaml](values.yaml) as a base for customization.

View File

@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "owprovui.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 "owprovui.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 "owprovui.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

View File

@@ -0,0 +1,86 @@
{{- $root := . -}}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "owprovui.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "owprovui.name" . }}
helm.sh/chart: {{ include "owprovui.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "owprovui.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- with .Values.services.owprovui.labels }}
{{- toYaml . | nindent 6 }}
{{- end }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "owprovui.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- with .Values.services.owprovui.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
containers:
- name: owprovui
image: "{{ .Values.images.owprovui.repository }}:{{ .Values.images.owprovui.tag }}"
imagePullPolicy: {{ .Values.images.owprovui.pullPolicy }}
env:
- name: KUBERNETES_DEPLOYED
value: "{{ now }}"
{{- range $key, $value := .Values.public_env_variables }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
ports:
{{- range $key, $value := .Values.services.owprovui.ports }}
- name: {{ $key }}
containerPort: {{ $value.targetPort }}
protocol: {{ $value.protocol }}
{{- end }}
{{- if .Values.checks.owprovui.liveness }}
livenessProbe:
{{- toYaml .Values.checks.owprovui.liveness | nindent 12 }}
{{- end }}
{{- if .Values.checks.owprovui.readiness }}
readinessProbe:
{{- toYaml .Values.checks.owprovui.readiness | nindent 12 }}
{{- end }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
imagePullSecrets:
{{- range $image, $imageValue := .Values.images }}
{{- if $imageValue.regcred }}
- name: {{ include "owprovui.fullname" $root }}-{{ $image }}-regcred
{{- end }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@@ -0,0 +1,47 @@
{{- $root := . -}}
{{- range $ingress, $ingressValue := .Values.ingresses }}
{{- if $ingressValue.enabled }}
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ include "owprovui.fullname" $root }}-{{ $ingress }}
labels:
app.kubernetes.io/name: {{ include "owprovui.name" $root }}
helm.sh/chart: {{ include "owprovui.chart" $root }}
app.kubernetes.io/instance: {{ $root.Release.Name }}
app.kubernetes.io/managed-by: {{ $root.Release.Service }}
{{- with $ingressValue.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if $ingressValue.tls }}
tls:
{{- range $ingressValue.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ tpl .secretName $root }}
{{- end }}
{{- end }}
rules:
{{- range $ingressValue.hosts }}
- host: {{ . | quote }}
http:
paths:
{{- range $ingressValue.paths }}
- path: {{ .path }}
backend:
serviceName: {{ include "owprovui.fullname" $root }}-{{ .serviceName }}
servicePort: {{ .servicePort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,21 @@
{{- define "imagePullSecret" }}
{{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .registry (printf "%s:%s" .username .password | b64enc) | b64enc }}
{{- end }}
{{- $root := . -}}
{{- range $image, $imageValue := .Values.images }}
{{- if $imageValue.regcred }}
---
apiVersion: v1
kind: Secret
type: kubernetes.io/dockerconfigjson
metadata:
labels:
app.kuberentes.io/name: {{ include "owprovui.name" $root }}
helm.sh/chart: {{ include "owprovui.chart" $root }}
app.kubernetes.io/instance: {{ $root.Release.Name }}
app.kubernetes.io/managed-by: {{ $root.Release.Service }}
name: {{ include "owprovui.fullname" $root }}-{{ $image }}-regcred
data:
.dockerconfigjson: {{ template "imagePullSecret" $imageValue.regcred }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,48 @@
{{- $root := . -}}
{{- range $service, $serviceValue := .Values.services }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ include "owprovui.fullname" $root }}-{{ $service }}
{{- with $serviceValue.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "owprovui.name" $root }}
helm.sh/chart: {{ include "owprovui.chart" $root }}
app.kubernetes.io/instance: {{ $root.Release.Name }}
app.kubernetes.io/managed-by: {{ $root.Release.Service }}
{{- with $serviceValue.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if $serviceValue.serviceMonitor }}
{{- range $selector, $selectorValue := $serviceValue.serviceMonitor.serviceSelector }}
{{ $selector }}: {{ tpl $selectorValue $root }}
{{- end }}
{{- end }}
spec:
type: {{ $serviceValue.type }}
ports:
{{- range $service_service, $service_value := $serviceValue.ports }}
- name: {{ $service_service }}
targetPort: {{ $service_value.targetPort }}
protocol: {{ $service_value.protocol }}
port: {{ $service_value.servicePort }}
{{- if and (eq "NodePort" $serviceValue.type) $service_value.nodePort }}
nodePort: {{ $service_value.nodePort }}
{{- end }}
{{- end }}
selector:
app.kubernetes.io/name: {{ include "owprovui.name" $root }}
app.kubernetes.io/instance: {{ $root.Release.Name }}
{{- with $serviceValue.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}

75
helm/values.yaml Normal file
View File

@@ -0,0 +1,75 @@
# System
replicaCount: 1
nameOverride: ""
fullnameOverride: ""
images:
owprovui:
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owprov-ui
tag: main
pullPolicy: Always
services:
owprovui:
type: ClusterIP
ports:
http:
servicePort: 80
targetPort: 80
protocol: TCP
checks:
owprovui:
liveness:
httpGet:
path: /
port: http
readiness:
httpGet:
path: /
port: http
ingresses:
default:
enabled: false
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
# tls:
# - secretName: '{{ include "owprovui.fullname" . }}-default-tls' # template may be used
# cert: |
# CERT_HERE_IN_PEM
# key: |
# KEY_HERE_IN_PEM
# hosts:
# - chart-example.local
hosts:
- chart-example.local
paths:
- path: /
serviceName: owprovui
servicePort: http
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# requests:
# cpu: 100m
# memory: 128Mi
# limits:
# cpu: 100m
# memory: 128Mi
nodeSelector: {}
tolerations: []
affinity: {}
# Application
public_env_variables:
DEFAULT_UCENTRALSEC_URL: https://ucentral.dpaas.arilia.com:16001
ALLOW_UCENTRALSEC_CHANGE: false