From db8861c5cb1044816f05c41e4a793efcb801dff9 Mon Sep 17 00:00:00 2001 From: ph1ll Date: Thu, 15 Feb 2024 20:28:16 +0000 Subject: [PATCH] Add netbird chart --- .editorconfig | 9 ++ .github/ct.yaml | 5 - .github/helm-docs.sh | 17 --- .github/kubeval.sh | 48 ------- .github/workflows/lint-and-test-charts.yaml | 106 ---------------- .github/workflows/lint-test.yaml | 45 +++++++ .github/workflows/release-charts.yaml | 45 ------- .github/workflows/release.yaml | 28 +++++ charts/netbird/.helmignore | 23 ++++ charts/netbird/Chart.yaml | 35 ++++++ charts/netbird/charts/coturn/.helmignore | 23 ++++ charts/netbird/charts/coturn/Chart.yaml | 27 ++++ .../charts/coturn/templates/_helpers.tpl | 62 +++++++++ .../charts/coturn/templates/deployment.yaml | 99 +++++++++++++++ .../netbird/charts/coturn/templates/hpa.yaml | 32 +++++ .../charts/coturn/templates/service.yaml | 15 +++ .../coturn/templates/serviceaccount.yaml | 13 ++ charts/netbird/charts/coturn/values.yaml | 88 +++++++++++++ charts/netbird/charts/dashboard/.helmignore | 23 ++++ charts/netbird/charts/dashboard/Chart.yaml | 27 ++++ .../charts/dashboard/templates/NOTES.txt | 22 ++++ .../charts/dashboard/templates/_helpers.tpl | 62 +++++++++ .../dashboard/templates/deployment.yaml | 106 ++++++++++++++++ .../charts/dashboard/templates/hpa.yaml | 32 +++++ .../charts/dashboard/templates/ingress.yaml | 54 ++++++++ .../charts/dashboard/templates/service.yaml | 15 +++ .../dashboard/templates/serviceaccount.yaml | 13 ++ .../templates/tests/test-connection.yaml | 15 +++ charts/netbird/charts/dashboard/values.yaml | 100 +++++++++++++++ charts/netbird/charts/management/.helmignore | 23 ++++ charts/netbird/charts/management/Chart.yaml | 27 ++++ .../charts/management/templates/NOTES.txt | 22 ++++ .../charts/management/templates/_helpers.tpl | 62 +++++++++ .../management/templates/deployment.yaml | 91 ++++++++++++++ .../charts/management/templates/hpa.yaml | 32 +++++ .../management/templates/ingress-grpc.yaml | 54 ++++++++ .../management/templates/ingress-http.yaml | 54 ++++++++ .../charts/management/templates/pvc.yaml | 14 +++ .../charts/management/templates/service.yaml | 15 +++ .../management/templates/serviceaccount.yaml | 13 ++ charts/netbird/charts/management/values.yaml | 119 ++++++++++++++++++ charts/netbird/charts/signal/.helmignore | 23 ++++ charts/netbird/charts/signal/Chart.yaml | 27 ++++ .../netbird/charts/signal/templates/NOTES.txt | 22 ++++ .../charts/signal/templates/_helpers.tpl | 62 +++++++++ .../charts/signal/templates/deployment.yaml | 77 ++++++++++++ .../netbird/charts/signal/templates/hpa.yaml | 32 +++++ .../charts/signal/templates/ingress.yaml | 54 ++++++++ .../charts/signal/templates/service.yaml | 15 +++ .../signal/templates/serviceaccount.yaml | 13 ++ .../templates/tests/test-connection.yaml | 72 +++++++++++ charts/netbird/charts/signal/values.yaml | 101 +++++++++++++++ charts/netbird/templates/.gitkeep | 0 charts/netbird/values.yaml | 53 ++++++++ ct.yaml | 4 + 55 files changed, 2049 insertions(+), 221 deletions(-) create mode 100644 .editorconfig delete mode 100644 .github/ct.yaml delete mode 100755 .github/helm-docs.sh delete mode 100755 .github/kubeval.sh delete mode 100644 .github/workflows/lint-and-test-charts.yaml create mode 100644 .github/workflows/lint-test.yaml delete mode 100644 .github/workflows/release-charts.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 charts/netbird/.helmignore create mode 100644 charts/netbird/Chart.yaml create mode 100644 charts/netbird/charts/coturn/.helmignore create mode 100644 charts/netbird/charts/coturn/Chart.yaml create mode 100644 charts/netbird/charts/coturn/templates/_helpers.tpl create mode 100644 charts/netbird/charts/coturn/templates/deployment.yaml create mode 100644 charts/netbird/charts/coturn/templates/hpa.yaml create mode 100644 charts/netbird/charts/coturn/templates/service.yaml create mode 100644 charts/netbird/charts/coturn/templates/serviceaccount.yaml create mode 100644 charts/netbird/charts/coturn/values.yaml create mode 100644 charts/netbird/charts/dashboard/.helmignore create mode 100644 charts/netbird/charts/dashboard/Chart.yaml create mode 100644 charts/netbird/charts/dashboard/templates/NOTES.txt create mode 100644 charts/netbird/charts/dashboard/templates/_helpers.tpl create mode 100644 charts/netbird/charts/dashboard/templates/deployment.yaml create mode 100644 charts/netbird/charts/dashboard/templates/hpa.yaml create mode 100644 charts/netbird/charts/dashboard/templates/ingress.yaml create mode 100644 charts/netbird/charts/dashboard/templates/service.yaml create mode 100644 charts/netbird/charts/dashboard/templates/serviceaccount.yaml create mode 100644 charts/netbird/charts/dashboard/templates/tests/test-connection.yaml create mode 100644 charts/netbird/charts/dashboard/values.yaml create mode 100644 charts/netbird/charts/management/.helmignore create mode 100644 charts/netbird/charts/management/Chart.yaml create mode 100644 charts/netbird/charts/management/templates/NOTES.txt create mode 100644 charts/netbird/charts/management/templates/_helpers.tpl create mode 100644 charts/netbird/charts/management/templates/deployment.yaml create mode 100644 charts/netbird/charts/management/templates/hpa.yaml create mode 100644 charts/netbird/charts/management/templates/ingress-grpc.yaml create mode 100644 charts/netbird/charts/management/templates/ingress-http.yaml create mode 100644 charts/netbird/charts/management/templates/pvc.yaml create mode 100644 charts/netbird/charts/management/templates/service.yaml create mode 100644 charts/netbird/charts/management/templates/serviceaccount.yaml create mode 100644 charts/netbird/charts/management/values.yaml create mode 100644 charts/netbird/charts/signal/.helmignore create mode 100644 charts/netbird/charts/signal/Chart.yaml create mode 100644 charts/netbird/charts/signal/templates/NOTES.txt create mode 100644 charts/netbird/charts/signal/templates/_helpers.tpl create mode 100644 charts/netbird/charts/signal/templates/deployment.yaml create mode 100644 charts/netbird/charts/signal/templates/hpa.yaml create mode 100644 charts/netbird/charts/signal/templates/ingress.yaml create mode 100644 charts/netbird/charts/signal/templates/service.yaml create mode 100644 charts/netbird/charts/signal/templates/serviceaccount.yaml create mode 100644 charts/netbird/charts/signal/templates/tests/test-connection.yaml create mode 100644 charts/netbird/charts/signal/values.yaml create mode 100644 charts/netbird/templates/.gitkeep create mode 100644 charts/netbird/values.yaml create mode 100644 ct.yaml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..0385e34 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true diff --git a/.github/ct.yaml b/.github/ct.yaml deleted file mode 100644 index 1cdfee0..0000000 --- a/.github/ct.yaml +++ /dev/null @@ -1,5 +0,0 @@ -helm-extra-args: --timeout 600s -check-version-increment: false -debug: true -chart-repos: bitnami=https://charts.bitnami.com/bitnami -target-branch: main \ No newline at end of file diff --git a/.github/helm-docs.sh b/.github/helm-docs.sh deleted file mode 100755 index 8667e74..0000000 --- a/.github/helm-docs.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash - -mkdir ./.bin -export PATH="./.bin:$PATH" - -set -euxo pipefail - -# renovate: datasource=github-releases depName=helm-docs packageName=norwoodj/helm-docs -HELM_DOCS_VERSION=1.11.0 - -# install helm-docs -curl --silent --show-error --fail --location --output /tmp/helm-docs.tar.gz https://github.com/norwoodj/helm-docs/releases/download/v"${HELM_DOCS_VERSION}"/helm-docs_"${HELM_DOCS_VERSION}"_Linux_x86_64.tar.gz -tar -C .bin/ -xf /tmp/helm-docs.tar.gz helm-docs - -# validate docs -helm-docs -git diff --exit-code \ No newline at end of file diff --git a/.github/kubeval.sh b/.github/kubeval.sh deleted file mode 100755 index 3808aa1..0000000 --- a/.github/kubeval.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -mkdir ./.bin -export PATH="./.bin:$PATH" - -set -euxo pipefail - -# renovate: datasource=github-releases depName=kubeval packageName=instrumenta/kubeval -KUBEVAL_VERSION=v0.16.1 - -# renovate: datasource=github-releases depName=semver2 packageName=Ariel-Rodriguez/sh-semversion-2 -SEMVER_VERSION=1.0.3 - -CHART_DIRS="$(git diff --find-renames --name-only "$(git rev-parse --abbrev-ref HEAD)" remotes/origin/main -- charts | cut -d '/' -f 2 | uniq)" -SCHEMA_LOCATION="https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/" - -# install kubeval -curl --silent --show-error --fail --location --output /tmp/kubeval.tar.gz https://github.com/instrumenta/kubeval/releases/download/"${KUBEVAL_VERSION}"/kubeval-linux-amd64.tar.gz -tar -C .bin/ -xf /tmp/kubeval.tar.gz kubeval - -# install semver compare -curl -sSfLo .bin/semver2 https://raw.githubusercontent.com/Ariel-Rodriguez/sh-semversion-2/${SEMVER_VERSION}/semver2.sh -chmod +x .bin/semver2 - -# add helm repos -helm repo add bitnami https://charts.bitnami.com/bitnami - -# Compute required kubernetes api versions -apis=() - -if [[ "$(semver2 "${KUBERNETES_VERSION#v}" 1.21.0)" -ge 0 ]]; then - apis=("${apis[@]}" --api-versions batch/v1/CronJob) -else - apis=("${apis[@]}" --api-versions batch/v1beta1/CronJob) -fi - -# validate charts -for CHART_DIR in ${CHART_DIRS}; do - (cd "charts/${CHART_DIR}"; helm dependency build) - helm template \ - "${apis[@]}" \ - --values charts/"${CHART_DIR}"/ci/ci-values.yaml \ - charts/"${CHART_DIR}" | kubeval \ - --strict \ - --ignore-missing-schemas \ - --kubernetes-version "${KUBERNETES_VERSION#v}" \ - --schema-location "${SCHEMA_LOCATION}" -done \ No newline at end of file diff --git a/.github/workflows/lint-and-test-charts.yaml b/.github/workflows/lint-and-test-charts.yaml deleted file mode 100644 index cdec64c..0000000 --- a/.github/workflows/lint-and-test-charts.yaml +++ /dev/null @@ -1,106 +0,0 @@ -name: lint-and-test-charts - -on: - push: - branches: - - main - pull_request: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.number || github.ref }} - cancel-in-progress: true - -jobs: - lint-chart: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 - with: - fetch-depth: 0 - - - name: Install Helm - uses: azure/setup-helm@b5b231a831f96336bbfeccc1329990f0005c5bb1 # tag=v3.3 - with: - version: v3.9.4 # renovate: datasource=github-releases depName=helm packageName=helm/helm - - - uses: actions/setup-python@b55428b1882923874294fa556849718a1d7f2ca5 # tag=v4.2.0 - with: - python-version: 3.7 - - - name: Install chart-testing - uses: helm/chart-testing-action@09ed88797198755e5031f25be13da255e7e33aad # tag=v2.3.0 - with: - version: v3.7.0 # renovate: datasource=github-releases depName=chart-testing packageName=helm/chart-testing - - - name: Run lint - run: ct lint --config .github/ct.yaml - - lint-docs: - runs-on: ubuntu-latest - needs: lint-chart - steps: - - name: Checkout - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 - - name: Run helm-docs - run: .github/helm-docs.sh - - kubeval-chart: - runs-on: ubuntu-latest - needs: - - lint-chart - - lint-docs - strategy: - matrix: - k8s: - # from https://github.com/yannh/kubernetes-json-schema - - v1.22.13 - - v1.23.10 - - v1.24.4 - - v1.25.0 - steps: - - name: Checkout - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 - with: - fetch-depth: 0 - - - name: Run kubeval - env: - KUBERNETES_VERSION: ${{ matrix.k8s }} - run: .github/kubeval.sh - - install-chart: - name: install-chart - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || github.repository_owner != github.event.pull_request.head.repo.owner.login || !startsWith(github.event.pull_request.head.ref, 'renovate/') }} - needs: - - lint-chart - - lint-docs - - kubeval-chart - strategy: - matrix: - k8s: - # from https://hub.docker.com/r/kindest/node/tags - - v1.22.13 # renovate: kindest - - v1.23.10 # renovate: kindest - - v1.24.4 # renovate: kindest - - v1.25.0 # renovate: kindest - steps: - - name: Checkout - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 - with: - fetch-depth: 0 - - - name: Create kind ${{ matrix.k8s }} cluster - uses: helm/kind-action@d08cf6ff1575077dee99962540d77ce91c62387d # tag=v1.3.0 - with: - node_image: kindest/node:${{ matrix.k8s }} - version: v0.15.0 # renovate: datasource=github-releases depName=kind packageName=kubernetes-sigs/kind - - - name: Install chart-testing - uses: helm/chart-testing-action@09ed88797198755e5031f25be13da255e7e33aad # tag=v2.3.0 - with: - version: v3.7.0 # renovate: datasource=github-releases depName=chart-testing packageName=helm/chart-testing - - - name: Run chart install - run: ct install --config .github/ct.yaml \ No newline at end of file diff --git a/.github/workflows/lint-test.yaml b/.github/workflows/lint-test.yaml new file mode 100644 index 0000000..8ebd293 --- /dev/null +++ b/.github/workflows/lint-test.yaml @@ -0,0 +1,45 @@ +name: Lint and Test Charts + +on: pull_request + +jobs: + lint-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Helm + uses: azure/setup-helm@v4.0.0 + with: + version: v3.12.1 + + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + check-latest: true + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2 + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }}) + if [[ -n "$changed" ]]; then + echo "changed=true" >> "$GITHUB_OUTPUT" + fi + + - name: Run chart-testing (lint) + if: steps.list-changed.outputs.changed == 'true' + run: ct lint --target-branch ${{ github.event.repository.default_branch }} + + - name: Create kind cluster + if: steps.list-changed.outputs.changed == 'true' + uses: helm/kind-action@v1 + + - name: Run chart-testing (install) + if: steps.list-changed.outputs.changed == 'true' + run: ct install --target-branch ${{ github.event.repository.default_branch }} diff --git a/.github/workflows/release-charts.yaml b/.github/workflows/release-charts.yaml deleted file mode 100644 index 7b7bddd..0000000 --- a/.github/workflows/release-charts.yaml +++ /dev/null @@ -1,45 +0,0 @@ -name: Release Charts - -on: - push: - branches: - - main - paths: - - 'charts/**' - workflow_dispatch: - -jobs: - release: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3.0.2 - with: - fetch-depth: 0 - - - name: Configure Git - run: | - git config user.name "$GITHUB_ACTOR" - git config user.email "$GITHUB_ACTOR@users.noreply.github.com" - - - name: Install Helm - uses: azure/setup-helm@b5b231a831f96336bbfeccc1329990f0005c5bb1 # tag=v3.3 - with: - version: v3.9.4 # renovate: datasource=github-releases depName=helm packageName=helm/helm - - - name: Add external Helm repos - run: helm repo add bitnami https://charts.bitnami.com/bitnami - - - name: Build chart dependencies - run: | - for dir in charts/*/ - do - (cd ${dir}; helm dependency build) - done - - - name: Run chart-releaser - uses: helm/chart-releaser-action@a3454e46a6f5ac4811069a381e646961dda2e1bf # tag=v1.4.0 - with: - version: v1.4.0 # renovate: datasource=github-releases depName=chart-releaser packageName=helm/chart-releaser - env: - CR_TOKEN: '${{ secrets.GITHUB_TOKEN }}' \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..5144ce8 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,28 @@ +name: Release Charts + +on: + push: + branches: + - main + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Install Helm + uses: azure/setup-helm@v4.0.0 + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/charts/netbird/.helmignore b/charts/netbird/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/netbird/.helmignore @@ -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/ diff --git a/charts/netbird/Chart.yaml b/charts/netbird/Chart.yaml new file mode 100644 index 0000000..41d5039 --- /dev/null +++ b/charts/netbird/Chart.yaml @@ -0,0 +1,35 @@ +apiVersion: v2 +name: netbird +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +dependencies: + - name: dashboard + condition: dashboard.enabled + version: 0.1.0 + - name: management + condition: management.enabled + version: 0.1.0 + - name: signal + condition: signal.enabled + version: 0.1.0 + - name: coturn + condition: coturn.enabled + version: 0.1.0 + +maintainers: + - name: ph1ll diff --git a/charts/netbird/charts/coturn/.helmignore b/charts/netbird/charts/coturn/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/netbird/charts/coturn/.helmignore @@ -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/ diff --git a/charts/netbird/charts/coturn/Chart.yaml b/charts/netbird/charts/coturn/Chart.yaml new file mode 100644 index 0000000..2488805 --- /dev/null +++ b/charts/netbird/charts/coturn/Chart.yaml @@ -0,0 +1,27 @@ +apiVersion: v2 +name: coturn +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "4.6.2-alpine" + +maintainers: + - name: ph1ll diff --git a/charts/netbird/charts/coturn/templates/_helpers.tpl b/charts/netbird/charts/coturn/templates/_helpers.tpl new file mode 100644 index 0000000..2e83cfa --- /dev/null +++ b/charts/netbird/charts/coturn/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "coturn.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 "coturn.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 "coturn.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "coturn.labels" -}} +helm.sh/chart: {{ include "coturn.chart" . }} +{{ include "coturn.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "coturn.selectorLabels" -}} +app.kubernetes.io/name: {{ include "coturn.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "coturn.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "coturn.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/netbird/charts/coturn/templates/deployment.yaml b/charts/netbird/charts/coturn/templates/deployment.yaml new file mode 100644 index 0000000..7380cbe --- /dev/null +++ b/charts/netbird/charts/coturn/templates/deployment.yaml @@ -0,0 +1,99 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "coturn.fullname" . }} + labels: + {{- include "coturn.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "coturn.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "coturn.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "coturn.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + {{- if and .Values.password .Values.password.value }} + {{- if not .Values.password.existingSecret }} + - name: COTURN_PASSWORD + value: "{{ .Values.password.value }}" + {{- end }} + {{- end }} + {{- if and .Values.password .Values.password.existingSecret }} + - name: COTURN_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.password.existingSecret }} + value: COTURN_PASSWORD + {{- end }} + ports: + - name: stun-turn-tcp + containerPort: {{ .Values.service.port }} + protocol: TCP + - name: stun-turn-udp + containerPort: {{ .Values.service.port }} + protocol: UDP + args: + - --listening-port={{ .Values.service.port }} + - --external-ip={{ .Values.externalIpAddress }} + - --min-port={{ .Values.minPort | default 49152 }} + - --max-port={{ .Values.maxPort | default 65535 }} + - --fingerprint + - --lt-cred-mech + - --user=self:$$COTURN_PASSWORD + - --realm=wiretrustee.com + - --no-software-attribute + - --log-file=stdout + - --no-cli + livenessProbe: + tcpSocket: + port: {{ .Values.service.port }} + readinessProbe: + tcpSocket: + port: {{ .Values.service.port }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- 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 }} diff --git a/charts/netbird/charts/coturn/templates/hpa.yaml b/charts/netbird/charts/coturn/templates/hpa.yaml new file mode 100644 index 0000000..7a342b0 --- /dev/null +++ b/charts/netbird/charts/coturn/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "coturn.fullname" . }} + labels: + {{- include "coturn.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "coturn.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 }} diff --git a/charts/netbird/charts/coturn/templates/service.yaml b/charts/netbird/charts/coturn/templates/service.yaml new file mode 100644 index 0000000..31b65ec --- /dev/null +++ b/charts/netbird/charts/coturn/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "coturn.fullname" . }} + labels: + {{- include "coturn.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "coturn.selectorLabels" . | nindent 4 }} diff --git a/charts/netbird/charts/coturn/templates/serviceaccount.yaml b/charts/netbird/charts/coturn/templates/serviceaccount.yaml new file mode 100644 index 0000000..031b052 --- /dev/null +++ b/charts/netbird/charts/coturn/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "coturn.serviceAccountName" . }} + labels: + {{- include "coturn.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/charts/netbird/charts/coturn/values.yaml b/charts/netbird/charts/coturn/values.yaml new file mode 100644 index 0000000..12f594f --- /dev/null +++ b/charts/netbird/charts/coturn/values.yaml @@ -0,0 +1,88 @@ +# Default values for coturn. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: coturn/coturn + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Automatically mount a ServiceAccount's API credentials? + automount: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} +podLabels: {} + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + +securityContext: + allowPrivilegeEscalation: false + capabilities: + add: + - NET_BIND_SERVICE + drop: + - ALL + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 10000 + runAsGroup: 10000 + +service: + type: ClusterIP + port: 3478 + +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:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/netbird/charts/dashboard/.helmignore b/charts/netbird/charts/dashboard/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/netbird/charts/dashboard/.helmignore @@ -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/ diff --git a/charts/netbird/charts/dashboard/Chart.yaml b/charts/netbird/charts/dashboard/Chart.yaml new file mode 100644 index 0000000..78acd27 --- /dev/null +++ b/charts/netbird/charts/dashboard/Chart.yaml @@ -0,0 +1,27 @@ +apiVersion: v2 +name: dashboard +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "v2.0.3" + +maintainers: + - name: ph1ll diff --git a/charts/netbird/charts/dashboard/templates/NOTES.txt b/charts/netbird/charts/dashboard/templates/NOTES.txt new file mode 100644 index 0000000..9b9d4e3 --- /dev/null +++ b/charts/netbird/charts/dashboard/templates/NOTES.txt @@ -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 "dashboard.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 "dashboard.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "dashboard.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 "dashboard.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 }} diff --git a/charts/netbird/charts/dashboard/templates/_helpers.tpl b/charts/netbird/charts/dashboard/templates/_helpers.tpl new file mode 100644 index 0000000..cc7fdc3 --- /dev/null +++ b/charts/netbird/charts/dashboard/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "dashboard.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 "dashboard.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 "dashboard.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "dashboard.labels" -}} +helm.sh/chart: {{ include "dashboard.chart" . }} +{{ include "dashboard.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "dashboard.selectorLabels" -}} +app.kubernetes.io/name: {{ include "dashboard.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "dashboard.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "dashboard.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/netbird/charts/dashboard/templates/deployment.yaml b/charts/netbird/charts/dashboard/templates/deployment.yaml new file mode 100644 index 0000000..d45d7b9 --- /dev/null +++ b/charts/netbird/charts/dashboard/templates/deployment.yaml @@ -0,0 +1,106 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "dashboard.fullname" . }} + labels: + {{- include "dashboard.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "dashboard.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "dashboard.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "dashboard.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: NETBIRD_MGMT_API_ENDPOINT + value: "https://{{ .Values.global.netbird.domain }}" + - name: NETBIRD_MGMT_GRPC_API_ENDPOINT + value: "https://{{ .Values.global.netbird.domain }}" + - name: AUTH_AUDIENCE + value: "{{ .Values.auth.audience }}" + - name: AUTH_CLIENT_ID + value: "{{ .Values.auth.clientId }}" + {{- if and .Values.auth.clientSecret .Values.auth.clientSecret.value }} + {{- if not .Values.auth.clientSecret.existingSecret }} + - name: AUTH_CLIENT_SECRET + value: "{{ .Values.auth.clientSecret.value }}" + {{- end }} + {{- end }} + {{- if and .Values.auth.clientSecret .Values.auth.clientSecret.existingSecret }} + - name: AUTH_CLIENT_SECRET + valueFrom: + secretKeyRef: + name: {{ .Values.auth.clientSecret.existingSecret }} + value: NETBIRD_AUTH_CLIENT_SECRET + {{- end }} + - name: AUTH_AUTHORITY + value: "{{ .Values.auth.authority }}" + - name: USE_AUTH0 + value: "{{ .Values.useAuth0 | default "false" }}" + - name: AUTH_SUPPORTED_SCOPES + value: "{{ .Values.auth.supportedScopes }}" + - name: AUTH_REDIRECT_URI + value: "{{ .Values.auth.redirectUri }}" + - name: AUTH_SILENT_REDIRECT_URI + value: "{{ .Values.auth.silentRedirectUri }}" + - name: NETBIRD_TOKEN_SOURCE + value: "{{ .Values.tokenSource }}" + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- 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 }} diff --git a/charts/netbird/charts/dashboard/templates/hpa.yaml b/charts/netbird/charts/dashboard/templates/hpa.yaml new file mode 100644 index 0000000..c5f6544 --- /dev/null +++ b/charts/netbird/charts/dashboard/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "dashboard.fullname" . }} + labels: + {{- include "dashboard.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "dashboard.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 }} diff --git a/charts/netbird/charts/dashboard/templates/ingress.yaml b/charts/netbird/charts/dashboard/templates/ingress.yaml new file mode 100644 index 0000000..28138da --- /dev/null +++ b/charts/netbird/charts/dashboard/templates/ingress.yaml @@ -0,0 +1,54 @@ +{{- if .Values.global.ingress.enabled -}} +{{- $fullName := include "dashboard.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- $domainName := .Values.global.netbird.domain | required ".Values.global.netbird.domain is required." -}} +{{- if and .Values.global.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.global.ingress.annotations.http "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.global.ingress.annotations.http "kubernetes.io/ingress.class" .Values.global.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "dashboard.labels" . | nindent 4 }} + {{- with .Values.global.ingress.annotations.http }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.global.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.global.ingress.className }} + {{- end }} + {{- if .Values.global.ingress.tls.enabled }} + tls: + - hosts: + - "{{ $domainName }}" + secretName: {{ $domainName }}-tls + {{- end }} + rules: + - host: {{ $domainName }} + http: + paths: + - path: / + {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} + pathType: Prefix + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} +{{- end }} diff --git a/charts/netbird/charts/dashboard/templates/service.yaml b/charts/netbird/charts/dashboard/templates/service.yaml new file mode 100644 index 0000000..155124b --- /dev/null +++ b/charts/netbird/charts/dashboard/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "dashboard.fullname" . }} + labels: + {{- include "dashboard.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "dashboard.selectorLabels" . | nindent 4 }} diff --git a/charts/netbird/charts/dashboard/templates/serviceaccount.yaml b/charts/netbird/charts/dashboard/templates/serviceaccount.yaml new file mode 100644 index 0000000..41f2265 --- /dev/null +++ b/charts/netbird/charts/dashboard/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "dashboard.serviceAccountName" . }} + labels: + {{- include "dashboard.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/charts/netbird/charts/dashboard/templates/tests/test-connection.yaml b/charts/netbird/charts/dashboard/templates/tests/test-connection.yaml new file mode 100644 index 0000000..90a22ee --- /dev/null +++ b/charts/netbird/charts/dashboard/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "dashboard.fullname" . }}-test-connection" + labels: + {{- include "dashboard.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "dashboard.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/netbird/charts/dashboard/values.yaml b/charts/netbird/charts/dashboard/values.yaml new file mode 100644 index 0000000..7d39d58 --- /dev/null +++ b/charts/netbird/charts/dashboard/values.yaml @@ -0,0 +1,100 @@ +# Default values for dashboard. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +global: + +replicaCount: 1 + +image: + repository: netbirdio/dashboard + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Automatically mount a ServiceAccount's API credentials? + automount: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +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:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/netbird/charts/management/.helmignore b/charts/netbird/charts/management/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/netbird/charts/management/.helmignore @@ -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/ diff --git a/charts/netbird/charts/management/Chart.yaml b/charts/netbird/charts/management/Chart.yaml new file mode 100644 index 0000000..30119b9 --- /dev/null +++ b/charts/netbird/charts/management/Chart.yaml @@ -0,0 +1,27 @@ +apiVersion: v2 +name: management +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "0.25.9" + +maintainers: + - name: ph1ll diff --git a/charts/netbird/charts/management/templates/NOTES.txt b/charts/netbird/charts/management/templates/NOTES.txt new file mode 100644 index 0000000..c57a367 --- /dev/null +++ b/charts/netbird/charts/management/templates/NOTES.txt @@ -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 "management.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 "management.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "management.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 "management.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 }} diff --git a/charts/netbird/charts/management/templates/_helpers.tpl b/charts/netbird/charts/management/templates/_helpers.tpl new file mode 100644 index 0000000..6641e86 --- /dev/null +++ b/charts/netbird/charts/management/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "management.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 "management.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 "management.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "management.labels" -}} +helm.sh/chart: {{ include "management.chart" . }} +{{ include "management.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "management.selectorLabels" -}} +app.kubernetes.io/name: {{ include "management.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "management.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "management.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/netbird/charts/management/templates/deployment.yaml b/charts/netbird/charts/management/templates/deployment.yaml new file mode 100644 index 0000000..21305e1 --- /dev/null +++ b/charts/netbird/charts/management/templates/deployment.yaml @@ -0,0 +1,91 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "management.fullname" . }} + labels: + {{- include "management.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "management.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "management.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "management.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - --log-file + - console + - --log-level + - {{ .Values.logLevel | default "info" }} + - --port + - {{ quote .Values.service.port }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + tcpSocket: + port: {{ .Values.service.port }} + readinessProbe: + tcpSocket: + port: {{ .Values.service.port }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + {{- if and .Values.configuration .Values.configuration.existingSecret }} + - mountPath: /etc/netbird + name: config + readOnly: true + {{- end }} + - mountPath: /var/lib/netbird + name: data + volumes: + {{- if and .Values.configuration .Values.configuration.existingSecret }} + - name: config + secret: + secretName: {{ .Values.configuration.existingSecret }} + {{- end }} + - name: data + {{- if .Values.persistence.enabled }} + persistentVolumeClaim: + claimName: {{ include "management.fullname" . }}-data + {{- else }} + emptyDir: + medium: Memory + {{- 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 }} diff --git a/charts/netbird/charts/management/templates/hpa.yaml b/charts/netbird/charts/management/templates/hpa.yaml new file mode 100644 index 0000000..9783458 --- /dev/null +++ b/charts/netbird/charts/management/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "management.fullname" . }} + labels: + {{- include "management.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "management.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 }} diff --git a/charts/netbird/charts/management/templates/ingress-grpc.yaml b/charts/netbird/charts/management/templates/ingress-grpc.yaml new file mode 100644 index 0000000..12cd6ea --- /dev/null +++ b/charts/netbird/charts/management/templates/ingress-grpc.yaml @@ -0,0 +1,54 @@ +{{- if .Values.global.ingress.enabled -}} +{{- $fullName := include "management.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- $domainName := .Values.global.netbird.domain | required ".Values.global.netbird.domain is required." -}} +{{- if and .Values.global.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.global.ingress.annotations.grpc "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.global.ingress.annotations.grpc "kubernetes.io/ingress.class" .Values.global.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }}-grpc + labels: + {{- include "management.labels" . | nindent 4 }} + {{- with .Values.global.ingress.annotations.grpc }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.global.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.global.ingress.className }} + {{- end }} + {{- if .Values.global.ingress.tls.enabled }} + tls: + - hosts: + - "{{ $domainName }}" + secretName: {{ $domainName }}-tls + {{- end }} + rules: + - host: {{ $domainName }} + http: + paths: + - path: /management.ManagementService/ + {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} + pathType: Prefix + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} +{{- end }} diff --git a/charts/netbird/charts/management/templates/ingress-http.yaml b/charts/netbird/charts/management/templates/ingress-http.yaml new file mode 100644 index 0000000..2bcec90 --- /dev/null +++ b/charts/netbird/charts/management/templates/ingress-http.yaml @@ -0,0 +1,54 @@ +{{- if .Values.global.ingress.enabled -}} +{{- $fullName := include "management.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- $domainName := .Values.global.netbird.domain | required ".Values.global.netbird.domain is required." -}} +{{- if and .Values.global.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.global.ingress.annotations.http "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.global.ingress.annotations.htpp "kubernetes.io/ingress.class" .Values.global.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }}-http + labels: + {{- include "management.labels" . | nindent 4 }} + {{- with .Values.global.ingress.annotations.http }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.global.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.global.ingress.className }} + {{- end }} + {{- if .Values.global.ingress.tls.enabled }} + tls: + - hosts: + - "{{ $domainName }}" + secretName: {{ $domainName }}-tls + {{- end }} + rules: + - host: {{ $domainName }} + http: + paths: + - path: /api/ + {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} + pathType: Prefix + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} +{{- end }} diff --git a/charts/netbird/charts/management/templates/pvc.yaml b/charts/netbird/charts/management/templates/pvc.yaml new file mode 100644 index 0000000..f77620f --- /dev/null +++ b/charts/netbird/charts/management/templates/pvc.yaml @@ -0,0 +1,14 @@ +{{- if .Values.persistence.enabled -}} +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: {{ include "management.fullname" . }}-data + labels: + {{- include "management.labels" . | nindent 4 }} +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: "{{ .Values.persistence.size }}" +{{- end -}} diff --git a/charts/netbird/charts/management/templates/service.yaml b/charts/netbird/charts/management/templates/service.yaml new file mode 100644 index 0000000..b079201 --- /dev/null +++ b/charts/netbird/charts/management/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "management.fullname" . }} + labels: + {{- include "management.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "management.selectorLabels" . | nindent 4 }} diff --git a/charts/netbird/charts/management/templates/serviceaccount.yaml b/charts/netbird/charts/management/templates/serviceaccount.yaml new file mode 100644 index 0000000..c21f635 --- /dev/null +++ b/charts/netbird/charts/management/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "management.serviceAccountName" . }} + labels: + {{- include "management.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/charts/netbird/charts/management/values.yaml b/charts/netbird/charts/management/values.yaml new file mode 100644 index 0000000..f396aa9 --- /dev/null +++ b/charts/netbird/charts/management/values.yaml @@ -0,0 +1,119 @@ +# Default values for management. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +global: + +replicaCount: 1 + +image: + repository: netbirdio/management + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Automatically mount a ServiceAccount's API credentials? + automount: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} +podLabels: {} + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + +securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 10000 + runAsGroup: 10000 + +service: + type: ClusterIP + port: 8080 + +ingress: + http: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + grpc: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +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:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/netbird/charts/signal/.helmignore b/charts/netbird/charts/signal/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/netbird/charts/signal/.helmignore @@ -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/ diff --git a/charts/netbird/charts/signal/Chart.yaml b/charts/netbird/charts/signal/Chart.yaml new file mode 100644 index 0000000..f87592b --- /dev/null +++ b/charts/netbird/charts/signal/Chart.yaml @@ -0,0 +1,27 @@ +apiVersion: v2 +name: signal +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "0.25.9" + +maintainers: + - name: ph1ll diff --git a/charts/netbird/charts/signal/templates/NOTES.txt b/charts/netbird/charts/signal/templates/NOTES.txt new file mode 100644 index 0000000..4e5af05 --- /dev/null +++ b/charts/netbird/charts/signal/templates/NOTES.txt @@ -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 "signal.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 "signal.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "signal.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 "signal.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 }} diff --git a/charts/netbird/charts/signal/templates/_helpers.tpl b/charts/netbird/charts/signal/templates/_helpers.tpl new file mode 100644 index 0000000..abd52db --- /dev/null +++ b/charts/netbird/charts/signal/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "signal.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 "signal.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 "signal.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "signal.labels" -}} +helm.sh/chart: {{ include "signal.chart" . }} +{{ include "signal.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "signal.selectorLabels" -}} +app.kubernetes.io/name: {{ include "signal.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "signal.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "signal.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/netbird/charts/signal/templates/deployment.yaml b/charts/netbird/charts/signal/templates/deployment.yaml new file mode 100644 index 0000000..136356f --- /dev/null +++ b/charts/netbird/charts/signal/templates/deployment.yaml @@ -0,0 +1,77 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "signal.fullname" . }} + labels: + {{- include "signal.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "signal.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "signal.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "signal.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - --log-file + - console + - --log-level + - {{ .Values.logLevel | default "info" }} + - --port + - {{ quote .Values.service.port }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + tcpSocket: + port: {{ .Values.service.port }} + readinessProbe: + tcpSocket: + port: {{ .Values.service.port }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- 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 }} diff --git a/charts/netbird/charts/signal/templates/hpa.yaml b/charts/netbird/charts/signal/templates/hpa.yaml new file mode 100644 index 0000000..d15e245 --- /dev/null +++ b/charts/netbird/charts/signal/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "signal.fullname" . }} + labels: + {{- include "signal.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "signal.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 }} diff --git a/charts/netbird/charts/signal/templates/ingress.yaml b/charts/netbird/charts/signal/templates/ingress.yaml new file mode 100644 index 0000000..024fef8 --- /dev/null +++ b/charts/netbird/charts/signal/templates/ingress.yaml @@ -0,0 +1,54 @@ +{{- if .Values.global.ingress.enabled -}} +{{- $fullName := include "signal.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- $domainName := .Values.global.netbird.domain | required ".Values.global.netbird.domain is required." -}} +{{- if and .Values.global.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.global.ingress.annotations.grpc "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.global.ingress.annotations.grpc "kubernetes.io/ingress.class" .Values.global.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "signal.labels" . | nindent 4 }} + {{- with .Values.global.ingress.annotations.grpc }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.global.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.global.ingress.className }} + {{- end }} + {{- if .Values.global.ingress.tls.enabled }} + tls: + - hosts: + - "{{ $domainName }}" + secretName: {{ $domainName }}-tls + {{- end }} + rules: + - host: {{ $domainName }} + http: + paths: + - path: /signalexchange.SignalExchange/ + {{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }} + pathType: Prefix + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} +{{- end }} diff --git a/charts/netbird/charts/signal/templates/service.yaml b/charts/netbird/charts/signal/templates/service.yaml new file mode 100644 index 0000000..b90c688 --- /dev/null +++ b/charts/netbird/charts/signal/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "signal.fullname" . }} + labels: + {{- include "signal.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: {{ .Values.service.port }} + protocol: TCP + name: http + selector: + {{- include "signal.selectorLabels" . | nindent 4 }} diff --git a/charts/netbird/charts/signal/templates/serviceaccount.yaml b/charts/netbird/charts/signal/templates/serviceaccount.yaml new file mode 100644 index 0000000..cd33060 --- /dev/null +++ b/charts/netbird/charts/signal/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "signal.serviceAccountName" . }} + labels: + {{- include "signal.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/charts/netbird/charts/signal/templates/tests/test-connection.yaml b/charts/netbird/charts/signal/templates/tests/test-connection.yaml new file mode 100644 index 0000000..33fc2a8 --- /dev/null +++ b/charts/netbird/charts/signal/templates/tests/test-connection.yaml @@ -0,0 +1,72 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "signal.fullname" . }}-test-connection" + labels: + {{- include "signal.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: golang + image: golang + command: + - /bin/sh + args: + - -c + - | + cd /root + go mod init netbird-helm-chart/signal-test + go get github.com/netbirdio/netbird/encryption@v{{ .Chart.AppVersion }} + go get github.com/netbirdio/netbird/signal/client@v{{ .Chart.AppVersion }} + go get github.com/netbirdio/netbird/signal/proto@v{{ .Chart.AppVersion }} + go get github.com/netbirdio/netbird/version@v{{ .Chart.AppVersion }} + cat < main.go + package main + + import ( + "context" + "fmt" + "os" + "golang.zx2c4.com/wireguard/wgctrl/wgtypes" + signal "github.com/netbirdio/netbird/signal/client" + signalProto "github.com/netbirdio/netbird/signal/proto" + ) + + func main() { + key, err := wgtypes.GeneratePrivateKey() + if err != nil { + fmt.Fprintf(os.Stderr, "error: %v\n", err) + os.Exit(1) + } + + ctx := context.Background() + + client, err := signal.NewClient(ctx, "{{ include "signal.fullname" . }}:{{ .Values.service.port }}", key, false) + if err != nil { + fmt.Fprintf(os.Stderr, "error: %v\n", err) + os.Exit(1) + } + + go func() { + err := client.Receive(func(msg *signalProto.Message) error { + return nil + }) + if err != nil { + return + } + }() + + client.WaitStreamConnected() + + if client.IsHealthy() { + fmt.Println("IsHealthy() reported success!") + os.Exit(0) + } else { + fmt.Println("IsHealthy() reported failure!") + os.Exit(1) + } + } + EOF + go run . + restartPolicy: Never diff --git a/charts/netbird/charts/signal/values.yaml b/charts/netbird/charts/signal/values.yaml new file mode 100644 index 0000000..81c4ea7 --- /dev/null +++ b/charts/netbird/charts/signal/values.yaml @@ -0,0 +1,101 @@ +# Default values for signal. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: netbirdio/signal + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Automatically mount a ServiceAccount's API credentials? + automount: false + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +podAnnotations: {} +podLabels: {} + +podSecurityContext: + seccompProfile: + type: RuntimeDefault + +securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 10000 + runAsGroup: 10000 + +service: + type: ClusterIP + port: 8080 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +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:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} diff --git a/charts/netbird/templates/.gitkeep b/charts/netbird/templates/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/charts/netbird/values.yaml b/charts/netbird/values.yaml new file mode 100644 index 0000000..1425c50 --- /dev/null +++ b/charts/netbird/values.yaml @@ -0,0 +1,53 @@ +global: + netbird: + domain: netbird.example.com + ingress: + enabled: false + className: "" + tls: + enabled: false + annotations: + http: {} + # cert-manager.io/cluster-issuer: letsencrypt + grpc: {} + # cert-manager.io/cluster-issuer: letsencrypt + # nginx.ingress.kubernetes.io/backend-protocol: GRPC + # nginx.ingress.kubernetes.io/configuration-snippet: | + # grpc_ssl_verify off; + # grpc_socket_keepalive on; + # grpc_read_timeout 1d; + # grpc_send_timeout 1d; + +dashboard: + enabled: false + auth: + audience: "" + clientId: "" + clientSecret: + value: "" + existingSecret: "" + authority: "" + supportedScopes: "" + redirectUri: "" + silentRedirectUri: "" + useAuth0: false + tokenSource: "" + +management: + enabled: false + configuration: + existingSecret: "" + persistence: + enabled: false + +signal: + enabled: false + +coturn: + enabled: false + password: + value: "" + existingSecret: "" + externalIpAddress: 203.0.113.1 + minPort: 49152 + maxPort: 65535 diff --git a/ct.yaml b/ct.yaml new file mode 100644 index 0000000..c8681f7 --- /dev/null +++ b/ct.yaml @@ -0,0 +1,4 @@ +# See https://github.com/helm/chart-testing#configuration +remote: origin +chart-dirs: + - charts