Skip to content

Add annotations to service #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 5 additions & 0 deletions .changeset/smart-cougars-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@openproject/helm-charts": minor
---

Allow annotations on service
4 changes: 4 additions & 0 deletions charts/openproject/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ metadata:
name: {{ include "common.names.fullname" . }}
labels:
{{- include "common.labels.standard" . | nindent 4 }}
{{- with .Values.service.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if eq .Values.service.type "LoadBalancer" }}
Expand Down
4 changes: 4 additions & 0 deletions charts/openproject/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,10 @@ service:
#
type: "ClusterIP"

## Define custom service annotations
#
annotations: {}

## Specify the external IP address for the LoadBalancer service. If your cloud provider supports
## specifying a static IP for the load balancer, you can set it here.
## Example:
Expand Down
36 changes: 36 additions & 0 deletions spec/charts/openproject/service_annotations_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true
require 'spec_helper'

describe 'service annotations' do
let(:template) { HelmTemplate.new(default_values) }

context 'when setting annotations' do
let(:default_values) do
HelmTemplate.with_defaults(<<~YAML
service:
annotations:
prometheus.io/host: 'foobar.example'
prometheus.io/port: '8080'
YAML
)
end

it 'adds the annotations', :aggregate_failures do
annotations = template.dig("Service/optest-openproject", "metadata", "annotations")

expect(annotations["prometheus.io/host"]).to eq 'foobar.example'
expect(annotations["prometheus.io/port"]).to eq '8080'
end
end

context 'when setting no tolerations' do
let(:default_values) do
{}
end

it 'adds the default secrets', :aggregate_failures do
annotations = template.dig("Service/optest-openproject", "metadata", "annotations")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliverguenther what's the expected behaviour here? should it merged any existing annotation with the user-provided ones? (I would assume yes). Should we add a test about it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can only test the input from the values in the specs, it doesn't use any real nodes or helm deployments. But I would assume that kubernetes merges those?

expect(annotations).to be_nil
end
end
end
Loading