Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Commit

Permalink
Add custom annotation for service
Browse files Browse the repository at this point in the history
  • Loading branch information
jb-abbadie committed Mar 9, 2020
1 parent a70e71e commit 8d2dac5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions templates/server-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
annotations:
{{- if .Values.server.service.annotations }}
{{ tpl .Values.server.service.annotations . | nindent 4 | trim }}
{{- end }}
# This must be set in addition to publishNotReadyAddresses due
# to an open issue where it may not work:
# https://github.com/kubernetes/kubernetes/issues/58662
Expand Down
22 changes: 22 additions & 0 deletions test/unit/server-service.bats
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,25 @@ load _helpers
yq -r '.spec.ports[] | select(.name == "http") | .port' | tee /dev/stderr)
[ "${actual}" == "" ]
}

#--------------------------------------------------------------------
# annotations

@test "server/Service: one annotation by default" {
cd `chart_dir`
local actual=$(helm template \
-x templates/server-service.yaml \
. | tee /dev/stderr |
yq -r '.metadata.annotations | length' | tee /dev/stderr)
[ "${actual}" = "1" ]
}

@test "server/Service: can set annotations" {
cd `chart_dir`
local actual=$(helm template \
-x templates/server-service.yaml \
--set 'server.service.annotations=key: value' \
. | tee /dev/stderr |
yq -r '.metadata.annotations.key' | tee /dev/stderr)
[ "${actual}" = "value" ]
}
5 changes: 5 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,11 @@ server:
# the annotations to apply to the server pods
annotations: null

service:
# This should be a multi-line string mapping directly to the a map of
# the annotations to apply to the server service
annotations: null

# extraEnvVars is a list of extra environment variables to set with the stateful set. These could be
# used to include proxy settings required for cloud auto-join feature,
# in case kubernetes cluster is behind egress http proxies. Additionally, it could be used to configure
Expand Down

0 comments on commit 8d2dac5

Please sign in to comment.