Skip to content

Commit

Permalink
Merge pull request #52 from Telecominfraproject/WIFI-13835
Browse files Browse the repository at this point in the history
Wifi 13835
  • Loading branch information
carsten989 authored Jun 26, 2024
2 parents ac129c4 + e86f807 commit 89d4b2e
Show file tree
Hide file tree
Showing 30 changed files with 971 additions and 24 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: CI

on:
push:
paths-ignore:
- '**.md'
branches:
- next
- 'release/*'
tags:
- 'v*'
pull_request:
branches:
- next
- 'release/*'

defaults:
run:
shell: bash

jobs:
docker:
runs-on: ubuntu-latest
env:
DOCKER_REGISTRY_URL: tip-tip-wlan-cloud-ucentral.jfrog.io
DOCKER_REGISTRY_USERNAME: ucentral
steps:
- name: Checkout actions repo
uses: actions/checkout@v4
with:
repository: Telecominfraproject/.github
path: github

- name: Build and push Docker image
uses: ./github/composite-actions/docker-image-build
with:
image_name: cgw
registry: tip-tip-wlan-cloud-ucentral.jfrog.io
registry_user: ucentral
registry_password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}

- name: Notify on failure via Slack
if: failure() && github.ref == 'refs/heads/next'
uses: rtCamp/action-slack-notify@v2
env:
SLACK_USERNAME: GitHub Actions failure notifier
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_COLOR: "${{ job.status }}"
SLACK_ICON: https://raw.githubusercontent.com/quintessence/slack-icons/master/images/github-logo-slack-icon.png
SLACK_TITLE: Docker build failed for OWGW service

trigger-deploy-to-dev:
runs-on: ubuntu-latest
#if: github.ref == 'refs/heads/next'
if: github.ref == 'zzzzzzz'
needs:
- docker
steps:
- name: Checkout actions repo
uses: actions/checkout@v4
with:
repository: Telecominfraproject/.github
path: github

- name: Trigger deployment of the latest version to dev instance and wait for result
uses: ./github/composite-actions/trigger-workflow-and-wait
with:
owner: Telecominfraproject
repo: wlan-testing
workflow: cgw-dev-deployment.yaml
token: ${{ secrets.WLAN_TESTING_PAT }}
ref: master
inputs: '{"just_component": "true"}'
1 change: 1 addition & 0 deletions helm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.swp
22 changes: 22 additions & 0 deletions helm/.helmignore
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
appVersion: "1.0.0"
description: A CGW Helm chart for Kubernetes
name: cgw
version: 0.1.0
92 changes: 92 additions & 0 deletions helm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# cgw

This Helm chart helps to deploy OpenLAN CGW (further on refered as __Gateway__) to the Kubernetes clusters. It is mainly used in [assembly chart](https://github.com/Telecominfraproject/wlan-cloud-ucentral-deploy/tree/main/cgwchart) as Gateway 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 Gateway 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/openlan-cgw@helm/cgw-0.1.0.tgz?ref=master
```

The command deploys the Gateway 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` |
| strategyType | string | Application deployment strategy | `'Recreate'` |
| nameOverride | string | Override to be used for application deployment | |
| fullnameOverride | string | Override to be used for application deployment (has priority over nameOverride) | |
| images.cgw.repository | string | Docker image repository | |
| images.cgw.tag | string | Docker image tag | `'master'` |
| images.cgw.pullPolicy | string | Docker image pull policy | `'Always'` |
| services.cgw.type | string | Gateway service type | `'ClusterIP'` |
| services.cgw.ports.websocket.servicePort | number | Websocket endpoint port to be exposed on service | `15002` |
| services.cgw.ports.websocket.targetPort | number | Websocket endpoint port to be targeted by service | `15002` |
| services.cgw.ports.websocket.protocol | string | Websocket endpoint protocol | `'TCP'` |
| services.cgw.ports.metrics.servicePort | number | Metrics API endpoint port to be exposed on service | `15003` |
| services.cgw.ports.metrics.targetPort | number | Metrics API endpoint port to be targeted by service | `8080` |
| services.cgw.ports.metrics.protocol | string | Metrics API endpoint protocol | `'TCP'` |
| services.cgw.ports.grpc.servicePort | string | Internal REST API endpoint port to be exposed on service | `15051` |
| services.cgw.ports.grpc.targetPort | number | Internal REST API endpoint port to be targeted by service | `50051` |
| services.cgw.ports.grpc.protocol | string | Internal REST API endpoint protocol | `'TCP'` |
| checks.cgw.liveness.httpGet.path | string | Liveness check path to be used | `'/health'` |
| checks.cgw.liveness.httpGet.port | number | Liveness check port to be used (should be pointint to ALB endpoint) | `15003` |
| checks.cgw.readiness.httpGet.path | string | Readiness check path to be used | `'/health'` |
| checks.cgw.readiness.httpGet.port | number | Readiness check port to be used (should be pointint to ALB endpoint) | `15003` |
| volumes.cgw | array | Defines list of volumes to be attached to the Gateway | |
| persistence.enabled | boolean | Defines if the Gateway requires Persistent Volume (required for permanent files storage and SQLite DB if enabled) | `True` |
| persistence.accessModes | array | Defines PV access modes | |
| persistence.size | string | Defines PV size | `'10Gi'` |
| public\_env\_variables | hash | Defines list of environment variables to be passed to the Gateway via ConfigMaps | |
| secret\_env\_variables | hash | Defines list of secret environment variables to be passed to the Gateway via secrets | |
| existingCertsSecret | string | Existing Kubernetes secret containing all required certificates and private keys for microservice operation. If set, certificates from `certs` key are ignored | `""` |
| certs | hash | Defines files (keys and certificates) that should be passed to the Gateway (PEM format is adviced to be used) (see `volumes.cgw` on where it is mounted). If `existingCertsSecret` is set, certificates passed this way will not be used. | |
| certsCAs | hash | Defines files with CAs that should be passed to the Gateway (see `volumes.cgw` on where it is mounted) | |


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.
42 changes: 42 additions & 0 deletions helm/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "cgw.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 "cgw.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 "cgw.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{- define "cgw.ingress.apiVersion" -}}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" -}}
{{- print "networking.k8s.io/v1" -}}
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "extensions/v1beta1" -}}
{{- end -}}
{{- end -}}
125 changes: 125 additions & 0 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{{- $root := . -}}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "cgw.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "cgw.name" . }}
helm.sh/chart: {{ include "cgw.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
spec:
replicas: {{ .Values.replicaCount }}
strategy:
type: {{ .Values.strategyType }}
revisionHistoryLimit: {{ .Values.revisionHistoryLimit }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "cgw.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- with .Values.services.cgw.labels }}
{{- toYaml . | nindent 6 }}
{{- end }}
template:
metadata:
annotations:
{{- if .Values.podSecurityPolicy.enabled }}
kubernetes.io/psp: {{ include "cgw.fullname" . }}-{{ .Release.Namespace }}-cgw-unsafe-sysctl
{{- end }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "cgw.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- with .Values.services.cgw.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:

containers:

- name: cgw
image: "{{ .Values.images.cgw.repository }}:{{ .Values.images.cgw.tag }}"
imagePullPolicy: {{ .Values.images.cgw.pullPolicy }}

env:
- name: KUBERNETES_DEPLOYED
value: "{{ now }}"
{{- range $key, $value := .Values.public_env_variables }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- range $key, $value := .Values.secret_env_variables }}
- name: {{ $key }}
valueFrom:
secretKeyRef:
name: {{ include "cgw.fullname" $root }}-env
key: {{ $key }}
{{- end }}

ports:
{{- range $port, $portValue := .Values.services.cgw.ports }}
- name: {{ $port }}
containerPort: {{ $portValue.targetPort }}
protocol: {{ $portValue.protocol }}
{{- end }}

volumeMounts:
{{- range .Values.volumes.cgw }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
{{- if .subPath }}
subPath: {{ .subPath }}
{{- end }}
{{- end }}

{{- if .Values.checks.cgw.liveness }}
livenessProbe:
{{- toYaml .Values.checks.cgw.liveness | nindent 12 }}
{{- end }}
{{- if .Values.checks.cgw.readiness }}
readinessProbe:
{{- toYaml .Values.checks.cgw.readiness | nindent 12 }}
{{- end }}

{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}

{{- with .Values.securityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}

imagePullSecrets:
{{- range $image, $imageValue := .Values.images }}
{{- if $imageValue.regcred }}
- name: {{ include "cgw.fullname" $root }}-{{ $image }}-regcred
{{- end }}
{{- end }}

volumes:
{{- range $container, $containerVolumes := .Values.volumes }}
{{- range $containerVolumes }}
- name: {{ .name }}
{{- tpl .volumeDefinition $root | nindent 8 }}
{{- 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 }}
Loading

0 comments on commit 89d4b2e

Please sign in to comment.