diff --git a/.github/workflows/build-chart.yml b/.github/workflows/build-chart.yml index cbd5850..e41e818 100644 --- a/.github/workflows/build-chart.yml +++ b/.github/workflows/build-chart.yml @@ -33,6 +33,9 @@ jobs: - name: Install Helm S3 Plugin run: helm plugin install https://github.com/hypnoglow/helm-s3.git + - name: Create output directory for spacelift-promex Chart + run: mkdir -p build/chart/spacelift-promex + - name: Create output directory for Spacelift Worker Pool Chart run: mkdir -p build/chart/worker-pool @@ -55,6 +58,9 @@ jobs: timestamp=$(date +'%s') echo "CHART_VERSION=${CHART_VERSION_PREFIX}.${timestamp}" >> $GITHUB_ENV + - name: Lint spacelift-promex chart + run: helm lint --strict spacelift-promex/ + - name: Lint Spacelift Worker Pool chart run: helm lint spacelift-worker-pool/ @@ -67,6 +73,10 @@ jobs: - name: Lint spacelift-operator chart run: helm lint --strict spacelift-operator/ + - name: Package Spacelift PromEx chart + run: | + helm package --version "$CHART_VERSION" --destination build/chart/spacelift-promex spacelift-promex/ + - name: Package Spacelift Worker Pool chart run: | helm package --version "$CHART_VERSION" --destination build/chart/worker-pool spacelift-worker-pool/ diff --git a/.github/workflows/chart-publish-preprod.yml b/.github/workflows/chart-publish-preprod.yml index 995b187..5eee266 100644 --- a/.github/workflows/chart-publish-preprod.yml +++ b/.github/workflows/chart-publish-preprod.yml @@ -34,6 +34,9 @@ jobs: - name: Install Helm S3 Plugin run: helm plugin install https://github.com/hypnoglow/helm-s3.git + - name: Create output directory for Spacelift PromEx Chart + run: mkdir -p build/chart/spacelift-promex + - name: Create output directory for Spacelift Worker Pool Chart run: mkdir -p build/chart/worker-pool @@ -63,6 +66,9 @@ jobs: timestamp=$(date +'%s') echo "CHART_VERSION=${CHART_VERSION_PREFIX}.${timestamp}" >> $GITHUB_ENV + - name: Lint spacelift-promex chart + run: helm lint spacelift-promex/ + - name: Lint Spacelift Worker Pool chart run: helm lint spacelift-worker-pool/ @@ -75,6 +81,11 @@ jobs: - name: Lint spacelift-operator chart run: helm lint spacelift-operator/ + - name: Package spacelift-promex chart + run: | + helm package --version "$CHART_VERSION" --destination build/chart/spacelift-promex spacelift-promex/ + helm s3 push --relative build/chart/spacelift-promex/spacelift-promex-${CHART_VERSION}.tgz spacelift + - name: Package Spacelift Worker Pool chart run: | helm package --version "$CHART_VERSION" --destination build/chart/worker-pool spacelift-worker-pool/ @@ -121,6 +132,7 @@ jobs: run: | helm repo add spacelift https://downloads.spacelift.dev/helm helm repo update + helm pull --devel spacelift/spacelift-promex helm pull --devel spacelift/spacelift-worker helm pull --devel spacelift/vcs-agent helm pull --devel spacelift/spacelift-workerpool-controller diff --git a/.github/workflows/chart-publish-prod.yml b/.github/workflows/chart-publish-prod.yml index 68034af..6de8f39 100644 --- a/.github/workflows/chart-publish-prod.yml +++ b/.github/workflows/chart-publish-prod.yml @@ -33,6 +33,9 @@ jobs: - name: Install Helm S3 Plugin run: helm plugin install https://github.com/hypnoglow/helm-s3.git + - name: Create output directory for Spacelift PromEx Chart + run: mkdir -p build/chart/spacelift-promex + - name: Create output directory for Spacelift Worker Pool Chart run: mkdir -p build/chart/worker-pool @@ -66,6 +69,9 @@ jobs: echo "CHART_VERSION=${GITHUB_REF_NAME:1}" >> $GITHUB_ENV + - name: Lint Spacelift PromEx chart + run: helm lint spacelift-promex/ + - name: Lint Spacelift Worker Pool chart run: helm lint spacelift-worker-pool/ @@ -78,6 +84,11 @@ jobs: - name: Lint spacelift-operator chart run: helm lint spacelift-operator/ + - name: Package Spacelift PromEx chart + run: | + helm package --version "$CHART_VERSION" --destination build/chart/spacelift-promex spacelift-promex/ + helm s3 push --force --relative build/chart/spacelift-promex/spacelift-promex-${CHART_VERSION}.tgz spacelift + - name: Package Spacelift Worker Pool chart run: | helm package --version "$CHART_VERSION" --destination build/chart/worker-pool spacelift-worker-pool/ @@ -123,6 +134,7 @@ jobs: run: | helm repo add spacelift https://downloads.spacelift.io/helm helm repo update + helm pull spacelift/spacelift-promex helm pull spacelift/spacelift-worker helm pull spacelift/vcs-agent helm pull spacelift/spacelift-workerpool-controller diff --git a/spacelift-promex/.helmignore b/spacelift-promex/.helmignore new file mode 100644 index 0000000..7009af4 --- /dev/null +++ b/spacelift-promex/.helmignore @@ -0,0 +1,3 @@ +.gitignore +.git +.github \ No newline at end of file diff --git a/spacelift-promex/Chart.yaml b/spacelift-promex/Chart.yaml new file mode 100644 index 0000000..8c6acd8 --- /dev/null +++ b/spacelift-promex/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: spacelift-promex +description: A Helm chart for deploying the Spacelift Prometheus exporter. +type: application +version: 0.0.1 +appVersion: "v0.3.1" diff --git a/spacelift-promex/README.md b/spacelift-promex/README.md new file mode 100644 index 0000000..35372d5 --- /dev/null +++ b/spacelift-promex/README.md @@ -0,0 +1,27 @@ +# Helm chart spacelift-prometheus-exporter + +This chart allows to deploy the Spacelift prometheus exporter. + +## Quick Start + +Add our Helm chart repo and update your local chart cache: + +```shell +helm repo add spacelift https://downloads.spacelift.io/helm +helm repo update +``` + +Create a secret with your spacelift api key secret +```shell +kubectl create secret generic spacelift-api-key --from-literal=SPACELIFT_PROMEX_API_KEY_SECRET="{yourApiKeySecret}" +``` + +You can then install the controller using this chart +```shell +helm upgrade spacelift-prometheus-exporter spacelift/spacelift-promex --install \ + --set spacelift.apiEndpoint="https://{yourAccount}.app.spacelift.io" \ + --set spacelift.apiKeyId="{yourApiToken}" \ + --set spacelift.apiKeySecretName="spacelift-api-key" +``` + +Follow the instructions on the [user-documentation](https://github.com/spacelift-io/prometheus-exporter) for more detailed instructions. diff --git a/spacelift-promex/templates/_helpers.tpl b/spacelift-promex/templates/_helpers.tpl new file mode 100644 index 0000000..054c36d --- /dev/null +++ b/spacelift-promex/templates/_helpers.tpl @@ -0,0 +1,51 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "spacelift-promex.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 "spacelift-promex.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 "spacelift-promex.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "spacelift-promex.labels" -}} +helm.sh/chart: {{ include "spacelift-promex.chart" . }} +{{ include "spacelift-promex.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "spacelift-promex.selectorLabels" -}} +app.kubernetes.io/name: {{ include "spacelift-promex.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/spacelift-promex/templates/deployment.yaml b/spacelift-promex/templates/deployment.yaml new file mode 100644 index 0000000..b99b94a --- /dev/null +++ b/spacelift-promex/templates/deployment.yaml @@ -0,0 +1,55 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "spacelift-promex.fullname" . }} + labels: + {{- include "spacelift-promex.labels" . | nindent 4 }} + {{- with .Values.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "spacelift-promex.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "spacelift-promex.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: spacelift-promex + {{- if .Values.image.digest }} + image: "{{ .Values.image.repository }}@{{ .Values.image.digest }}" + {{- else }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + {{- end }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: metrics + containerPort: 9953 + readinessProbe: + httpGet: + path: /health + port: metrics + periodSeconds: 5 + env: + - name: "SPACELIFT_PROMEX_API_ENDPOINT" + value: "{{ .Values.apiEndpoint | required "must include apiEndpoint in values" }}" + - name: "SPACELIFT_PROMEX_API_KEY_ID" + value: "{{ .Values.apiKeyId | required "must include apiKeyId in values" }}" + - name: "SPACELIFT_PROMEX_API_KEY_SECRET" + valueFrom: + secretKeyRef: + name: {{ .Values.apiKeySecretName | required "must include apiKeySecretName in values" }} + key: "SPACELIFT_PROMEX_API_KEY_SECRET" + - name: "SPACELIFT_PROMEX_LISTEN_ADDRESS" + value: "{{ .Values.listenAddress}}" \ No newline at end of file diff --git a/spacelift-promex/values.yaml b/spacelift-promex/values.yaml new file mode 100644 index 0000000..10f29e7 --- /dev/null +++ b/spacelift-promex/values.yaml @@ -0,0 +1,27 @@ +replicaCount: 1 + +image: + repository: public.ecr.aws/spacelift/promex + tag: v0.3.1 + pullPolicy: IfNotPresent + + +# The address to listen on for HTTP requests +listenAddress: ":9953" + +# Labels to add to the deployment +labels: + app.spacelift.io/example: spacelift-promx + +# Annotations to add to the deployment +annotations: + app.spacelift.io/example: spacelift-promx + +## Your api endpoint, must be provided +#apiEndpoint: https://{myaccount}.app.spacelift.io +# +## Your api key id, must be provided +#apiKeyId: "" +# +## your api key secret, the secret should contain the key "SPACELIFT_PROMEX_API_KEY_SECRET" +#apiKeySecretName: "" \ No newline at end of file diff --git a/spacelift-workerpool-controller/Chart.yaml b/spacelift-workerpool-controller/Chart.yaml index 95b5930..12f16a7 100644 --- a/spacelift-workerpool-controller/Chart.yaml +++ b/spacelift-workerpool-controller/Chart.yaml @@ -4,3 +4,13 @@ description: A Helm chart for deploying spacelift workerpool controller type: application version: 0.1.0 appVersion: "v0.0.12" + +# TODO:// Make spacelift-promex a dependency of this chart +# This should be done after spacelift-promex is published to the Helm repository +#dependencies: +# - name: spacelift-promex +# version: 0.0.1 +# repository: "https://downloads.spacelift.io/helm" +# # For local testing +# #repository: "file://../spacelift-promex" +# condition: spacelift-promex.enabled \ No newline at end of file diff --git a/spacelift-workerpool-controller/values.yaml b/spacelift-workerpool-controller/values.yaml index 14e5125..9dea5bf 100644 --- a/spacelift-workerpool-controller/values.yaml +++ b/spacelift-workerpool-controller/values.yaml @@ -67,3 +67,6 @@ metricsService: protocol: TCP targetPort: https type: ClusterIP + +spacelift-promex: + enabled: false \ No newline at end of file