From fea0dac33432d4ca6fc770cba11d3a8e4df03783 Mon Sep 17 00:00:00 2001 From: "Barrera, Angel" Date: Fri, 30 Jun 2023 12:56:47 +0200 Subject: [PATCH] Add helm chart --- .github/workflows/branch.yml | 7 + .github/workflows/release.yml | 10 ++ README.md | 68 ++++++++++ .../prometheus-multi-tenant-proxy/.helmignore | 23 ++++ .../prometheus-multi-tenant-proxy/Chart.yaml | 7 + .../prometheus-multi-tenant-proxy/README.md | 57 ++++++++ .../templates/NOTES.txt | 22 ++++ .../templates/_helpers.tpl | 62 +++++++++ .../templates/deployment.yaml | 91 +++++++++++++ .../templates/hpa.yaml | 28 ++++ .../templates/ingress.yaml | 61 +++++++++ .../templates/secret.yaml | 19 +++ .../templates/service.yaml | 15 +++ .../templates/serviceaccount.yaml | 12 ++ .../templates/tests/test-connection.yaml | 15 +++ .../prometheus-multi-tenant-proxy/values.yaml | 123 ++++++++++++++++++ .../manifests.yaml} | 0 17 files changed, 620 insertions(+) create mode 100644 deployments/kubernetes/helm/prometheus-multi-tenant-proxy/.helmignore create mode 100644 deployments/kubernetes/helm/prometheus-multi-tenant-proxy/Chart.yaml create mode 100644 deployments/kubernetes/helm/prometheus-multi-tenant-proxy/README.md create mode 100644 deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/NOTES.txt create mode 100644 deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/_helpers.tpl create mode 100644 deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/deployment.yaml create mode 100644 deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/hpa.yaml create mode 100644 deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/ingress.yaml create mode 100644 deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/secret.yaml create mode 100644 deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/service.yaml create mode 100644 deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/serviceaccount.yaml create mode 100644 deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/tests/test-connection.yaml create mode 100644 deployments/kubernetes/helm/prometheus-multi-tenant-proxy/values.yaml rename deployments/{kubernetes.yaml => kubernetes/manifests.yaml} (100%) diff --git a/.github/workflows/branch.yml b/.github/workflows/branch.yml index 8c90b18..e19849e 100644 --- a/.github/workflows/branch.yml +++ b/.github/workflows/branch.yml @@ -58,3 +58,10 @@ jobs: RELEASE_DATE=${{ env.RELEASE_DATE }} VERSION=${{ env.RELEASE_VERSION }} COMMIT=${{ github.sha }} + - name: Publish Unstable Helm charts + uses: stefanprodan/helm-gh-pages@v1.7.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + charts_dir: deployments/kubernetes/helm + chart_version: 0.0.0-${{ env.RELEASE_VERSION }} + app_version: ${{ env.RELEASE_VERSION }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c6b7be4..aba127c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,6 +22,8 @@ jobs: echo "RELEASE_VERSION=$VERSION" >> $GITHUB_ENV export CURRENT_DATE=$(date --iso-8601=seconds) echo "RELEASE_DATE=$CURRENT_DATE" >> $GITHUB_ENV + export CHART_RELEASE_VERSION=${VERSION:1} + echo "CHART_RELEASE_VERSION=$CHART_RELEASE_VERSION" >> $GITHUB_ENV - name: Building binaries run: | @@ -90,3 +92,11 @@ jobs: asset_path: ./binaries/prometheus-multi-tenant-proxy-darwing-amd64 asset_name: prometheus-multi-tenant-proxy-darwing-amd64 asset_content_type: application/octet-stream + + - name: Publish Helm charts + uses: stefanprodan/helm-gh-pages@v1.7.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + charts_dir: deployments/kubernetes/helm + chart_version: ${{ env.CHART_RELEASE_VERSION }} + app_version: ${{ env.RELEASE_VERSION }} diff --git a/README.md b/README.md index b4927a6..c8b4f0e 100644 --- a/README.md +++ b/README.md @@ -224,6 +224,74 @@ The proxy can be configured to use either namespaces and/or labels to query Prom At least one must be configured, otherwise the proxy will not proxy the query to Prometheus. *(It could lead to a security issue if the proxy is not configured to use namespaces or labels)* +### Deploy on Kubernetes using Helm + +The proxy can be deployed on Kubernetes using Helm. The Helm chart is available at [k8spin/prometheus-multi-tenant-proxy](https://k8spin.github.io/prometheus-multi-tenant-proxy). Find the chart's documentation on its [README.md](deployments/kubernetes/helm/prometheus-multi-tenant-proxy/README.md). + +TL;DR: + +```bash +$ helm repo add k8spin-prometheus-multi-tenant-proxy https://k8spin.github.io/prometheus-multi-tenant-proxy +$ helm repo update +$ helm upgrade --install prometheus-multi-tenant-proxy k8spin-prometheus-multi-tenant-proxy/prometheus-multi-tenant-proxy --set proxy.prometheusEndpoint=http://prometheus.monitoring.svc.cluster.local:9090 +``` + +#### Example using flux + +```yaml +--- +apiVersion: source.toolkit.fluxcd.io/v1beta2 +kind: HelmRepository +metadata: + name: prometheus-multi-tenant-proxy + namespace: flux-system + labels: + phase: seed +spec: + interval: 1m0s + url: https://k8spin.github.io/prometheus-multi-tenant-proxy +--- +apiVersion: helm.toolkit.fluxcd.io/v2beta1 +kind: HelmRelease +metadata: + name: prometheus-multi-tenant-proxy + namespace: flux-system +spec: + timeout: 30m + install: + remediation: + retries: 3 + upgrade: + remediation: + retries: 3 + interval: 1m + chart: + spec: + chart: prometheus-multi-tenant-proxy + version: "1.10.0" + sourceRef: + kind: HelmRepository + name: prometheus-multi-tenant-proxy + namespace: flux-system + interval: 1m + releaseName: prometheus-multi-tenant-proxy + targetNamespace: monitoring + storageNamespace: monitoring + valuesFrom: [] + values: + proxy: + prometheusEndpoint: http://prometheus.monitoring.svc.cluster.local:9090 + auth: + basic: + authn: | + users: + - username: User-a + password: pass-a + namespace: tenant-a + - username: User-b + password: pass-b + namespace: tenant-b +``` ## Build it diff --git a/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/.helmignore b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/.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/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/Chart.yaml b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/Chart.yaml new file mode 100644 index 0000000..a6c6b26 --- /dev/null +++ b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/Chart.yaml @@ -0,0 +1,7 @@ +apiVersion: v2 +name: prometheus-multi-tenant-proxy +description: K8Spin - Prometheus multi-tenant proxy +type: application +# The version is injected by the release workflow +version: 0.0.0 +appVersion: 0.0.0 diff --git a/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/README.md b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/README.md new file mode 100644 index 0000000..1b8dc42 --- /dev/null +++ b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/README.md @@ -0,0 +1,57 @@ + +Prometheus-multi-tenant-proxy +=========== + +K8Spin - Prometheus multi-tenant proxy + + +## Configuration + +The following table lists the configurable parameters of the Prometheus-multi-tenant-proxy chart and their default values. + +| Parameter | Description | Default | +| ------------------------ | ----------------------- | -------------- | +| `replicaCount` | | `1` | +| `image.repository` | | `"ghcr.io/k8spin/prometheus-multi-tenant-proxy"` | +| `image.pullPolicy` | | `"IfNotPresent"` | +| `image.tag` | | `""` | +| `imagePullSecrets` | | `[]` | +| `nameOverride` | | `""` | +| `fullnameOverride` | | `""` | +| `serviceAccount.create` | | `true` | +| `serviceAccount.annotations` | | `{}` | +| `serviceAccount.name` | | `""` | +| `podAnnotations` | | `{}` | +| `podSecurityContext.fsGroup` | | `2000` | +| `securityContext.capabilities.drop` | | `["ALL"]` | +| `securityContext.readOnlyRootFilesystem` | | `true` | +| `securityContext.runAsNonRoot` | | `true` | +| `securityContext.runAsUser` | | `1000` | +| `service.type` | | `"ClusterIP"` | +| `service.port` | | `80` | +| `ingress.enabled` | | `false` | +| `ingress.className` | | `""` | +| `ingress.annotations` | | `{}` | +| `ingress.hosts` | | `[{"host": "chart-example.local", "paths": [{"path": "/", "pathType": "ImplementationSpecific"}]}]` | +| `ingress.tls` | | `[]` | +| `resources` | | `{}` | +| `autoscaling.enabled` | | `false` | +| `autoscaling.minReplicas` | | `1` | +| `autoscaling.maxReplicas` | | `100` | +| `autoscaling.targetCPUUtilizationPercentage` | | `80` | +| `nodeSelector` | | `{}` | +| `tolerations` | | `[]` | +| `affinity` | | `{}` | +| `proxy.port` | | `9092` | +| `proxy.prometheusEndpoint` | | `""` | +| `proxy.extraArgs` | | `[]` | +| `proxy.extraEnv` | | `[]` | +| `proxy.auth.type` | basic or jwt | `"basic"` | +| `proxy.auth.jwt.url` | URL/Path to the JWT configuration | `""` | +| `proxy.auth.basic.createSecret` | | `true` | +| `proxy.auth.basic.secretName` | In use only if createSecret is false | `"prometheus-multi-tenant-proxy"` | + + + + + diff --git a/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/NOTES.txt b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/NOTES.txt new file mode 100644 index 0000000..f34e8e7 --- /dev/null +++ b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/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 "prometheus-multi-tenant-proxy.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 "prometheus-multi-tenant-proxy.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "prometheus-multi-tenant-proxy.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 "prometheus-multi-tenant-proxy.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/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/_helpers.tpl b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/_helpers.tpl new file mode 100644 index 0000000..bacea20 --- /dev/null +++ b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "prometheus-multi-tenant-proxy.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 "prometheus-multi-tenant-proxy.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 "prometheus-multi-tenant-proxy.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "prometheus-multi-tenant-proxy.labels" -}} +helm.sh/chart: {{ include "prometheus-multi-tenant-proxy.chart" . }} +{{ include "prometheus-multi-tenant-proxy.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "prometheus-multi-tenant-proxy.selectorLabels" -}} +app.kubernetes.io/name: {{ include "prometheus-multi-tenant-proxy.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "prometheus-multi-tenant-proxy.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "prometheus-multi-tenant-proxy.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/deployment.yaml b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/deployment.yaml new file mode 100644 index 0000000..7bc78bd --- /dev/null +++ b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/deployment.yaml @@ -0,0 +1,91 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "prometheus-multi-tenant-proxy.fullname" . }} + labels: + {{- include "prometheus-multi-tenant-proxy.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "prometheus-multi-tenant-proxy.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "prometheus-multi-tenant-proxy.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "prometheus-multi-tenant-proxy.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: + - run + {{- if .Values.proxy.extraArgs }} + {{- toYaml .Values.proxy.extraArgs | nindent 12 }} + {{- end }} + env: + - name: PROM_PROXY_PROMETHEUS_ENDPOINT + value: {{ .Values.proxy.prometheusEndpoint | quote }} + - name: PROM_PROXY_PORT + value: {{ .Values.proxy.port | quote }} + - name: PROM_PROXY_AUTH_TYPE + value: {{ .Values.proxy.auth.type | quote }} + - name: PROM_PROXY_AUTH_CONFIG + value: {{ if eq .Values.proxy.auth.type "basic" }}"/etc/prometheus-multi-tenant-proxy/authn.yaml"{{ else }}{{ .Values.proxy.auth.jwt.url | quote }}{{ end }} + {{- if .Values.proxy.extraEnv }} + {{- toYaml .Values.proxy.extraEnv | nindent 12 }} + {{- end }} + ports: + - name: http + containerPort: {{ .Values.proxy.port }} + protocol: TCP + livenessProbe: + httpGet: + path: /-/healthy + port: http + readinessProbe: + httpGet: + path: /-/ready + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} +{{- if eq .Values.proxy.auth.type "basic" }} + volumeMounts: + - name: authn + mountPath: /etc/prometheus-multi-tenant-proxy/authn.yaml + subPath: authn.yaml + volumes: + - name: authn + secret: + secretName: {{ if .Values.proxy.auth.basic.createSecret }}{{ include "prometheus-multi-tenant-proxy.fullname" . }}{{ else }}{{ .Values.proxy.auth.basic.secretName }}{{ end }} + items: + - key: authn.yaml + path: authn.yaml +{{- 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/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/hpa.yaml b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/hpa.yaml new file mode 100644 index 0000000..ddda6ae --- /dev/null +++ b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "prometheus-multi-tenant-proxy.fullname" . }} + labels: + {{- include "prometheus-multi-tenant-proxy.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "prometheus-multi-tenant-proxy.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/ingress.yaml b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/ingress.yaml new file mode 100644 index 0000000..27e069c --- /dev/null +++ b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "prometheus-multi-tenant-proxy.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.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 "prometheus-multi-tenant-proxy.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/secret.yaml b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/secret.yaml new file mode 100644 index 0000000..4a9251d --- /dev/null +++ b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/secret.yaml @@ -0,0 +1,19 @@ +{{- if .Values.proxy.auth.basic.createSecret }} +--- +apiVersion: v1 +kind: Secret +metadata: + labels: + {{- include "prometheus-multi-tenant-proxy.labels" . | nindent 4 }} + name: {{ include "prometheus-multi-tenant-proxy.fullname" . }} +data: + # Values contains a key containing a multiline string, so we need to base64 encode it + # In case the key is not present or empty, we need to provide an empty users list + # to avoid a YAML error + authn.yaml: + {{- if .Values.proxy.auth.basic.authn }} + {{ .Values.proxy.auth.basic.authn | b64enc }} + {{- else }} + {{ print "users: []" | b64enc }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/service.yaml b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/service.yaml new file mode 100644 index 0000000..ac1ef00 --- /dev/null +++ b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "prometheus-multi-tenant-proxy.fullname" . }} + labels: + {{- include "prometheus-multi-tenant-proxy.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "prometheus-multi-tenant-proxy.selectorLabels" . | nindent 4 }} diff --git a/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/serviceaccount.yaml b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/serviceaccount.yaml new file mode 100644 index 0000000..cc81464 --- /dev/null +++ b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "prometheus-multi-tenant-proxy.serviceAccountName" . }} + labels: + {{- include "prometheus-multi-tenant-proxy.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/tests/test-connection.yaml b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/tests/test-connection.yaml new file mode 100644 index 0000000..52c55ca --- /dev/null +++ b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "prometheus-multi-tenant-proxy.fullname" . }}-test-connection" + labels: + {{- include "prometheus-multi-tenant-proxy.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "prometheus-multi-tenant-proxy.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/values.yaml b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/values.yaml new file mode 100644 index 0000000..921d660 --- /dev/null +++ b/deployments/kubernetes/helm/prometheus-multi-tenant-proxy/values.yaml @@ -0,0 +1,123 @@ +# Default values for prometheus-multi-tenant-proxy. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: ghcr.io/k8spin/prometheus-multi-tenant-proxy + 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: true + # 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: {} + +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 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +# Prometheus multi-tenant proxy configuration +proxy: + port: 9092 + # Prometheus endpoint + prometheusEndpoint: "" + # prometheusEndpoint: "http://prometheus-operated.default.svc.cluster.local:9090" + + extraArgs: [] + # extraArgs: + # - --aws + extraEnv: [] + # extraEnv: + # - name: AWS_ACCESS_KEY_ID + # valueFrom: + # secretKeyRef: + # name: aws-credentials + # key: AWS_ACCESS_KEY_ID + + + auth: + type: basic # basic or jwt + # Basic auth configuration + jwt: + url: "" # URL/Path to the JWT configuration + basic: + # Users configuration + createSecret: true + # If createSecret is true, you can specify the users here + # Default values are: users: [] (empty list) + # authn: | + # users: + # - username: Happy + # password: Prometheus + # namespace: default + # - username: Sad + # password: Prometheus + # namespace: kube-system + secretName: prometheus-multi-tenant-proxy # In use only if createSecret is false + # Create a secret with the name above, It must contain a key named authn.yaml with the content of the authn.yaml file + # kubectl create secret generic prometheus-multi-tenant-proxy --from-file=authn.yaml=authn.yaml diff --git a/deployments/kubernetes.yaml b/deployments/kubernetes/manifests.yaml similarity index 100% rename from deployments/kubernetes.yaml rename to deployments/kubernetes/manifests.yaml