From 82c7dad6c8ac5d573eb396a379cd212ff781fa0f Mon Sep 17 00:00:00 2001 From: Daniel Hougaard Date: Thu, 1 May 2025 06:45:40 +0400 Subject: [PATCH] feat(helm): infisical helm --- .github/workflows/release_docker_gateway.yaml | 44 +++++++++++++ .github/workflows/release_helm_gateway.yaml | 27 ++++++++ Dockerfile.gateway | 24 +++++++ helm-charts/infisical-gateway/.helmignore | 23 +++++++ helm-charts/infisical-gateway/CHANGELOG.md | 3 + helm-charts/infisical-gateway/Chart.yaml | 24 +++++++ .../infisical-gateway/templates/_helpers.tpl | 62 ++++++++++++++++++ .../templates/deployment.yaml | 64 +++++++++++++++++++ .../infisical-gateway/templates/service.yaml | 15 +++++ .../templates/serviceaccount.yaml | 13 ++++ helm-charts/infisical-gateway/values.yaml | 41 ++++++++++++ helm-charts/upload-gateway-cloudsmith.sh | 8 +++ 12 files changed, 348 insertions(+) create mode 100644 .github/workflows/release_docker_gateway.yaml create mode 100644 .github/workflows/release_helm_gateway.yaml create mode 100644 Dockerfile.gateway create mode 100644 helm-charts/infisical-gateway/.helmignore create mode 100644 helm-charts/infisical-gateway/CHANGELOG.md create mode 100644 helm-charts/infisical-gateway/Chart.yaml create mode 100644 helm-charts/infisical-gateway/templates/_helpers.tpl create mode 100644 helm-charts/infisical-gateway/templates/deployment.yaml create mode 100644 helm-charts/infisical-gateway/templates/service.yaml create mode 100644 helm-charts/infisical-gateway/templates/serviceaccount.yaml create mode 100644 helm-charts/infisical-gateway/values.yaml create mode 100755 helm-charts/upload-gateway-cloudsmith.sh diff --git a/.github/workflows/release_docker_gateway.yaml b/.github/workflows/release_docker_gateway.yaml new file mode 100644 index 0000000000..666b2c46c8 --- /dev/null +++ b/.github/workflows/release_docker_gateway.yaml @@ -0,0 +1,44 @@ +name: Release Gateway Docker Image +on: + push: + tags: + - "infisical-gateway/v*.*.*" + +permissions: + contents: write + pull-requests: write + +jobs: + release-image: + name: Release Gateway Docker Image + runs-on: ubuntu-latest + steps: + - name: Extract version from tag + id: extract_version + run: echo "::set-output name=version::${GITHUB_REF_NAME#infisical-gateway/}" + + - name: Checkout code + uses: actions/checkout@v2 + + - name: 🔧 Set up QEMU + uses: docker/setup-qemu-action@v1 + + - name: 🔧 Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: 🐋 Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + context: . + push: true + platforms: linux/amd64,linux/arm64 + tags: | + infisical/gateway:latest + infisical/gateway:${{ steps.extract_version.outputs.version }} diff --git a/.github/workflows/release_helm_gateway.yaml b/.github/workflows/release_helm_gateway.yaml new file mode 100644 index 0000000000..466849a2d5 --- /dev/null +++ b/.github/workflows/release_helm_gateway.yaml @@ -0,0 +1,27 @@ +name: Release Gateway Helm Chart +on: + workflow_dispatch: + +jobs: + release-helm: + name: Release Helm Chart + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Helm + uses: azure/setup-helm@v3 + with: + version: v3.10.0 + + - name: Install python + uses: actions/setup-python@v4 + + - name: Install Cloudsmith CLI + run: pip install --upgrade cloudsmith-cli + + - name: Build and push helm package to CloudSmith + run: cd helm-charts && sh upload-gateway-cloudsmith.sh + env: + CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} diff --git a/Dockerfile.gateway b/Dockerfile.gateway new file mode 100644 index 0000000000..dd4b3f0fea --- /dev/null +++ b/Dockerfile.gateway @@ -0,0 +1,24 @@ +# Build stage +FROM golang:1.23.0-alpine AS builder + +WORKDIR /app + +COPY ./cli . + +RUN go build -o infisical-cli . + +FROM alpine:latest + +ENV TOKEN="" +ENV INFISICAL_API_URL="https://app.infisical.com" + + + +WORKDIR /app + +COPY --from=builder /app/infisical-cli . + +# Make the binary executable +RUN chmod +x /app/infisical-cli + +CMD ["sh", "-c", "if [ -z \"${TOKEN}\" ]; then echo 'ERROR: TOKEN environment variable must be set'; exit 1; fi && ./infisical-cli gateway --token ${TOKEN} --domain ${INFISICAL_API_URL}"] \ No newline at end of file diff --git a/helm-charts/infisical-gateway/.helmignore b/helm-charts/infisical-gateway/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/helm-charts/infisical-gateway/.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/helm-charts/infisical-gateway/CHANGELOG.md b/helm-charts/infisical-gateway/CHANGELOG.md new file mode 100644 index 0000000000..8324230821 --- /dev/null +++ b/helm-charts/infisical-gateway/CHANGELOG.md @@ -0,0 +1,3 @@ +## 0.0.1 (May 1, 2025) + +* Initial helm release \ No newline at end of file diff --git a/helm-charts/infisical-gateway/Chart.yaml b/helm-charts/infisical-gateway/Chart.yaml new file mode 100644 index 0000000000..382acd3e18 --- /dev/null +++ b/helm-charts/infisical-gateway/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: infisical-gateway +description: A Helm chart to deploy Infisical Gateway + +# 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.0.1 + +# 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.0.1" diff --git a/helm-charts/infisical-gateway/templates/_helpers.tpl b/helm-charts/infisical-gateway/templates/_helpers.tpl new file mode 100644 index 0000000000..b983e79df5 --- /dev/null +++ b/helm-charts/infisical-gateway/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "infisical-gateway.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 "infisical-gateway.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 "infisical-gateway.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "infisical-gateway.labels" -}} +helm.sh/chart: {{ include "infisical-gateway.chart" . }} +{{ include "infisical-gateway.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "infisical-gateway.selectorLabels" -}} +app.kubernetes.io/name: {{ include "infisical-gateway.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "infisical-gateway.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "infisical-gateway.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm-charts/infisical-gateway/templates/deployment.yaml b/helm-charts/infisical-gateway/templates/deployment.yaml new file mode 100644 index 0000000000..99b107ef5b --- /dev/null +++ b/helm-charts/infisical-gateway/templates/deployment.yaml @@ -0,0 +1,64 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "infisical-gateway.fullname" . }} + labels: + {{- include "infisical-gateway.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "infisical-gateway.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "infisical-gateway.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "infisical-gateway.serviceAccountName" . }} + {{- with .Values.podSecurityContext }} + securityContext: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + {{- with .Values.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + {{- range $key, $value := .Values.env }} + - name: {{ $key }} + value: {{ $value | quote }} + {{- end }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + {{- with .Values.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- 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/helm-charts/infisical-gateway/templates/service.yaml b/helm-charts/infisical-gateway/templates/service.yaml new file mode 100644 index 0000000000..c1457f80e4 --- /dev/null +++ b/helm-charts/infisical-gateway/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "infisical-gateway.fullname" . }} + labels: + {{- include "infisical-gateway.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "infisical-gateway.selectorLabels" . | nindent 4 }} diff --git a/helm-charts/infisical-gateway/templates/serviceaccount.yaml b/helm-charts/infisical-gateway/templates/serviceaccount.yaml new file mode 100644 index 0000000000..c0040963f9 --- /dev/null +++ b/helm-charts/infisical-gateway/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "infisical-gateway.serviceAccountName" . }} + labels: + {{- include "infisical-gateway.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/helm-charts/infisical-gateway/values.yaml b/helm-charts/infisical-gateway/values.yaml new file mode 100644 index 0000000000..e2bb8e9adf --- /dev/null +++ b/helm-charts/infisical-gateway/values.yaml @@ -0,0 +1,41 @@ +image: + repository: infisical/infisical-gateway + pullPolicy: IfNotPresent + tag: "latest" + +# Environment variables for the gateway +env: + TOKEN: "" + INFISICAL_API_URL: "https://app.infisical.com/api" + +resources: + limits: + cpu: 100m + memory: 128Mi + requests: + cpu: 100m + memory: 128Mi + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + create: true + automount: true + annotations: {} + name: "" + +podAnnotations: {} +podLabels: {} +podSecurityContext: {} +securityContext: {} +affinity: {} +tolerations: {} +nodeSelector: {} +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false diff --git a/helm-charts/upload-gateway-cloudsmith.sh b/helm-charts/upload-gateway-cloudsmith.sh new file mode 100755 index 0000000000..0d6fd11c4b --- /dev/null +++ b/helm-charts/upload-gateway-cloudsmith.sh @@ -0,0 +1,8 @@ +cd infisical-gateway +helm dependency update +helm package . +for i in *.tgz; do + [ -f "$i" ] || break + cloudsmith push helm --republish infisical/helm-charts "$i" +done +cd .. \ No newline at end of file