From 93c719b4c99fa57ccb0aad0eb56ed3daf2b8dc11 Mon Sep 17 00:00:00 2001 From: feedc0de Date: Sun, 18 Oct 2026 18:57:35 +0200 Subject: [PATCH] Add maintained visual-studio-code Helm chart --- .gitea/workflows/ci.yml | 86 +++++++++++++++++++ README.md | 16 ++++ chart/visual-studio-code/Chart.yaml | 6 ++ .../templates/resources.yaml | 71 +++++++++++++++ chart/visual-studio-code/values.yaml | 13 +++ install.sh | 10 +++ scripts/chart-version.sh | 9 ++ test.sh | 10 +++ 8 files changed, 221 insertions(+) create mode 100644 .gitea/workflows/ci.yml create mode 100644 README.md create mode 100644 chart/visual-studio-code/Chart.yaml create mode 100644 chart/visual-studio-code/templates/resources.yaml create mode 100644 chart/visual-studio-code/values.yaml create mode 100755 install.sh create mode 100755 scripts/chart-version.sh create mode 100755 test.sh diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..41e1fbb --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -0,0 +1,86 @@ +name: Validate, publish and promote visual-studio-code + +on: + push: + branches: [main] + pull_request: + +env: + HELM_VERSION: v4.2.2 + CHART_NAME: visual-studio-code + GITOPS_REPOSITORY: feedc0de/homelab-gitops + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: azure/setup-helm@v4 + with: + version: ${{ env.HELM_VERSION }} + - run: ./test.sh + + publish: + if: gitea.ref == 'refs/heads/main' + needs: validate + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: azure/setup-helm@v4 + with: + version: ${{ env.HELM_VERSION }} + - name: Publish chart + env: + PACKAGE_USERNAME: ${{ secrets.PACKAGE_USERNAME }} + PACKAGE_TOKEN: ${{ secrets.PACKAGE_TOKEN }} + run: | + set -euo pipefail + CHART_VERSION=$(./scripts/chart-version.sh) + install -d dist + helm package "chart/${CHART_NAME}" --destination dist --version "${CHART_VERSION}" + curl --fail-with-body \ + --user "${PACKAGE_USERNAME}:${PACKAGE_TOKEN}" \ + --request POST \ + --upload-file "dist/${CHART_NAME}-${CHART_VERSION}.tgz" \ + https://code.brunner.ninja/api/packages/feedc0de/helm/api/charts + printf 'CHART_VERSION=%s\n' "${CHART_VERSION}" >> "${GITHUB_ENV}" + - name: Check that this is still current main + id: current-main + env: + COMMIT_SHA: ${{ gitea.sha }} + run: | + git fetch --no-tags origin main + if [ "$(git rev-parse FETCH_HEAD)" = "${COMMIT_SHA}" ]; then + echo 'promote=true' >> "${GITEA_OUTPUT}" + else + echo 'promote=false' >> "${GITEA_OUTPUT}" + fi + - name: Check out GitOps + if: steps.current-main.outputs.promote == 'true' + uses: actions/checkout@v4 + with: + repository: ${{ env.GITOPS_REPOSITORY }} + ref: main + token: ${{ secrets.GITOPS_TOKEN }} + path: homelab-gitops + - name: Promote exact chart version + if: steps.current-main.outputs.promote == 'true' + working-directory: homelab-gitops + run: | + set -euo pipefail + ./scripts/update-chart-version.sh "${CHART_NAME}" "${CHART_VERSION}" + git config user.name feedc0de + git config user.email feedc0de@users.noreply.code.brunner.ninja + git add "bootstrap/${CHART_NAME}.yaml" + if git diff --cached --quiet; then exit 0; fi + git commit -m "Deploy ${CHART_NAME} chart ${CHART_VERSION}" + for attempt in 1 2 3; do + if git push origin HEAD:main; then exit 0; fi + test "${attempt}" != 3 + git fetch origin main + git rebase origin/main + done diff --git a/README.md b/README.md new file mode 100644 index 0000000..b3503d4 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# code-server Helm chart + +This repository maintains the public `visual-studio-code` Helm chart. + +```sh +helm repo add brunner.ninja https://brunner.ninja/charts +helm repo update brunner.ninja +helm upgrade --install visual-studio-code brunner.ninja/visual-studio-code +``` + +Git tags version the chart. A `v1.0.0` tag publishes chart `1.0.0`; later +commits publish immutable versions such as `1.0.0-1-gabcdef0` using +`git describe --tags --long`. + +Homelab-specific values live in +[`homelab-gitops/apps/visual-studio-code`](https://code.brunner.ninja/feedc0de/homelab-gitops/src/branch/main/apps/visual-studio-code). diff --git a/chart/visual-studio-code/Chart.yaml b/chart/visual-studio-code/Chart.yaml new file mode 100644 index 0000000..fae6a2b --- /dev/null +++ b/chart/visual-studio-code/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: visual-studio-code +description: Kubernetes deployment for Coder code-server +type: application +version: 0.1.0 +appVersion: 4.141.0 diff --git a/chart/visual-studio-code/templates/resources.yaml b/chart/visual-studio-code/templates/resources.yaml new file mode 100644 index 0000000..04cf24c --- /dev/null +++ b/chart/visual-studio-code/templates/resources.yaml @@ -0,0 +1,71 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: visual-studio-code +spec: + selector: + matchLabels: {app: visual-studio-code} + template: + metadata: + labels: {app: visual-studio-code} + spec: + automountServiceAccountToken: false + containers: + - name: visual-studio-code + image: {{ printf "%s:%s" .Values.image.repository (default .Chart.AppVersion .Values.image.tag) | quote }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: {{- toYaml .Values.args | nindent 8 }} + ports: [{name: http, containerPort: 8080}] + startupProbe: + httpGet: {path: /healthz, port: http} + failureThreshold: 30 + periodSeconds: 2 + readinessProbe: + httpGet: {path: /healthz, port: http} + periodSeconds: 10 + livenessProbe: + httpGet: {path: /healthz, port: http} + periodSeconds: 30 + resources: {{- toYaml .Values.resources | nindent 10 }} + {{- with .Values.persistence.mounts }} + volumeMounts: + {{- range . }} + - name: {{ .name }} + mountPath: {{ .mountPath }} + {{- end }} + {{- end }} + {{- with .Values.persistence.mounts }} + volumes: + {{- range . }} + - name: {{ .name }} + persistentVolumeClaim: {claimName: "{{ .claimName }}"} + {{- end }} + {{- end }} +--- +apiVersion: v1 +kind: Service +metadata: + name: visual-studio-code +spec: + ports: [{name: http, port: 80, protocol: TCP, targetPort: http}] + selector: {app: visual-studio-code} +{{- if .Values.ingress.enabled }} +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: visual-studio-code + {{- with .Values.ingress.annotations }} + annotations: {{- toYaml . | nindent 4 }} + {{- end }} +spec: + ingressClassName: {{ .Values.ingress.className }} + rules: + - host: {{ .Values.ingress.host }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: {name: visual-studio-code, port: {name: http}} +{{- end }} diff --git a/chart/visual-studio-code/values.yaml b/chart/visual-studio-code/values.yaml new file mode 100644 index 0000000..73a77ef --- /dev/null +++ b/chart/visual-studio-code/values.yaml @@ -0,0 +1,13 @@ +image: + repository: ghcr.io/coder/code-server + tag: "" + pullPolicy: IfNotPresent +args: [--auth, none] +persistence: + mounts: [] +ingress: + enabled: false + className: "" + host: code.example.com + annotations: {} +resources: {} diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..6365a40 --- /dev/null +++ b/install.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -eu + +namespace=${NAMESPACE:-default} +release=${RELEASE_NAME:-visual-studio-code} +helm repo add brunner.ninja https://brunner.ninja/charts --force-update +helm repo update brunner.ninja +helm upgrade --install "$release" brunner.ninja/visual-studio-code \ + --namespace "$namespace" --create-namespace \ + --wait --timeout 10m "$@" diff --git a/scripts/chart-version.sh b/scripts/chart-version.sh new file mode 100755 index 0000000..4a7ba2e --- /dev/null +++ b/scripts/chart-version.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -eu + +description=$(git describe --tags --long --match 'v[0-9]*') +version=${description#v} +case "$version" in + *-0-g*) version=${version%%-0-g*} ;; +esac +printf '%s\n' "$version" diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..d6f1fef --- /dev/null +++ b/test.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -eu + +chart="chart/visual-studio-code" +helm lint "$chart" +rendered=$(mktemp) +trap 'rm -f "$rendered"' EXIT +helm template visual-studio-code "$chart" > "$rendered" +grep -q '^kind: Deployment$' "$rendered" +grep -q '^kind: Service$' "$rendered"