Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changesets/fix-helm-chart-version.md
Original file line number Diff line number Diff line change
@@ -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.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
49 changes: 30 additions & 19 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions charts/appsignal-kubernetes/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -105,7 +105,7 @@ spec:
resources:
{{- toYaml .Values.resources | nindent 12 }}
---
{{- if .Values.serviceAccount.create -}}
{{ if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down
2 changes: 0 additions & 2 deletions charts/appsignal-kubernetes/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion script/write_version
Original file line number Diff line number Diff line change
Expand Up @@ -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")