From 164570616bd6b1e9ff2909067d33073da2117688 Mon Sep 17 00:00:00 2001 From: Noemi <45180344+unflxw@users.noreply.github.com> Date: Tue, 29 Jul 2025 13:46:01 +0200 Subject: [PATCH 1/2] Update version in Helm values Update the default version of the image that is to be deployed by the Helm chart. --- .changesets/fix-helm-chart-version.md | 6 ++++++ charts/appsignal-kubernetes/values.yaml | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 .changesets/fix-helm-chart-version.md diff --git a/.changesets/fix-helm-chart-version.md b/.changesets/fix-helm-chart-version.md new file mode 100644 index 0000000..f56d1ad --- /dev/null +++ b/.changesets/fix-helm-chart-version.md @@ -0,0 +1,6 @@ +--- +bump: patch +type: fix +--- + +Fix Helm chart version. Ensure the default value for the AppSignal for Kubernetes version to install for a given Helm chart release matches the AppSignal for Kubernetes version being released. diff --git a/charts/appsignal-kubernetes/values.yaml b/charts/appsignal-kubernetes/values.yaml index 9ffa136..5dcf537 100644 --- a/charts/appsignal-kubernetes/values.yaml +++ b/charts/appsignal-kubernetes/values.yaml @@ -7,8 +7,6 @@ replicaCount: 1 image: repository: appsignal/appsignal-kubernetes pullPolicy: IfNotPresent - # Overrides the image tag whose default is the chart appVersion. - tag: "1.1.2" serviceAccount: From 8bac8b6d8e6c4e0aa95e0df58f7733c53192465b Mon Sep 17 00:00:00 2001 From: Noemi <45180344+unflxw@users.noreply.github.com> Date: Tue, 29 Jul 2025 15:30:12 +0200 Subject: [PATCH 2/2] Add basic CI checks for Helm chart Stop breaking the Helm chart all the time by verifying that it passes the Helm linter, that templates can be built for it with and without `--set kubectl=true`, and that changes to it have been committed. --- .github/workflows/ci.yaml | 7 +++ Rakefile | 49 ++++++++++++------- .../templates/deployment.yaml | 6 +-- script/write_version | 2 +- 4 files changed, 41 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e00fbd9..1e4e6cf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -30,6 +30,13 @@ jobs: - run: cargo clippy --verbose --tests --all-targets --all-features -- -D warnings - run: cargo fmt --check --verbose - run: cargo test --verbose + - name: "Install Helm" + uses: azure/setup-helm@v4 + with: + version: 'v3.14.0' + - run: rake helm:lint + - run: rake helm:test + - run: rake helm:deployment:check build_release: name: "Build every target" diff --git a/Rakefile b/Rakefile index bcaaf87..eda5b5a 100644 --- a/Rakefile +++ b/Rakefile @@ -133,29 +133,40 @@ task :protocol do `protoc -I ../appsignal-protocol --rust_out=protocol ../appsignal-protocol/kubernetes.proto` end -desc "Generate deployment.yaml from Helm chart" -task :generate_deployment do - require 'tempfile' - - # Create a temporary values file with only the overrides needed for standalone deployment - values_override = <<~VALUES - kubectl: true - image: - tag: "#{current_version}" - VALUES - - # Write temporary override values file - Tempfile.create(['values-override', '.yaml']) do |override_file| - override_file.write(values_override) - override_file.flush - - # Generate deployment.yaml using helm template with existing values.yaml plus overrides - output = `helm template appsignal-kubernetes charts/appsignal-kubernetes --values charts/appsignal-kubernetes/values.yaml --values #{override_file.path} --namespace appsignal` - + +namespace :helm do + desc "Generate deployment.yaml for kubectl from Helm chart" + task :deployment do + command = "helm template appsignal-kubernetes charts/appsignal-kubernetes" \ + " --set kubectl=true" \ + " --namespace appsignal" + output = Command.run(command, :output => false) # Write the output to deployment.yaml File.write('deployment.yaml', output) puts "Generated deployment.yaml from Helm chart" end + + desc "Lint the Helm chart" + task :lint do + Command.run("helm lint charts/appsignal-kubernetes --debug") + end + + desc "Check that the Helm chart can be used to build templates" + task :test do + output = Command.run("helm template appsignal-kubernetes charts/appsignal-kubernetes", :output => false) + raise "Regular output should not include namespace" if output.include?("kind: Namespace") + output = Command.run("helm template appsignal-kubernetes charts/appsignal-kubernetes --set kubectl=true", :output => false) + raise "Kubectl output should include namespace" unless output.include?("kind: Namespace") + end + + namespace :deployment do + desc "Check that the `deployment.yaml` file has been generated" + task :check do + Command.run("rake helm:deployment") + raise "deployment.yaml file does not exist" unless File.exist?("deployment.yaml") + Command.run("git diff --exit-code deployment.yaml") + end + end end def current_version diff --git a/charts/appsignal-kubernetes/templates/deployment.yaml b/charts/appsignal-kubernetes/templates/deployment.yaml index fcb373b..0016872 100644 --- a/charts/appsignal-kubernetes/templates/deployment.yaml +++ b/charts/appsignal-kubernetes/templates/deployment.yaml @@ -34,9 +34,9 @@ Create chart name and version as used by the chart label. Common labels */}} {{- define "appsignal-kubernetes.labels" -}} -{{- if not .Values.kubectl }} +{{- if not .Values.kubectl -}} helm.sh/chart: {{ include "appsignal-kubernetes.chart" . }} -{{- end }} +{{ end }} {{- include "appsignal-kubernetes.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} @@ -105,7 +105,7 @@ spec: resources: {{- toYaml .Values.resources | nindent 12 }} --- -{{- if .Values.serviceAccount.create -}} +{{ if .Values.serviceAccount.create -}} apiVersion: v1 kind: ServiceAccount metadata: diff --git a/script/write_version b/script/write_version index 03363c3..6f55ad0 100755 --- a/script/write_version +++ b/script/write_version @@ -13,4 +13,4 @@ File.write( File.write( "charts/appsignal-kubernetes/Chart.yaml", File.read("charts/appsignal-kubernetes/Chart.yaml").sub(/^appVersion: .*$/, %(appVersion: "#{VERSION}"))) -system("rake generate_deployment") +system("rake helm:deployment")