Skip to content

Commit

Permalink
Add namespace to injector-leader-elector role, rolebinding and secret (
Browse files Browse the repository at this point in the history
  • Loading branch information
thechristschn committed Mar 16, 2022
1 parent a81a992 commit f59f3d4
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ CHANGES:

Improvements:
* CSI: Set `extraLabels` for daemonset, pods, and service account [GH-690](https://github.com/hashicorp/vault-helm/pull/690)
* Add namespace to injector-leader-elector role, rolebinding and secret [GH-683](https://github.com/hashicorp/vault-helm/pull/683)

## 0.19.0 (January 20th, 2022)

Expand Down
1 change: 1 addition & 0 deletions templates/injector-certs-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Secret
metadata:
name: vault-injector-certs
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "vault.name" . }}-agent-injector
app.kubernetes.io/instance: {{ .Release.Name }}
Expand Down
1 change: 1 addition & 0 deletions templates/injector-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ template "vault.fullname" . }}-agent-injector-leader-elector-role
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "vault.name" . }}-agent-injector
app.kubernetes.io/instance: {{ .Release.Name }}
Expand Down
1 change: 1 addition & 0 deletions templates/injector-rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ template "vault.fullname" . }}-agent-injector-leader-elector-binding
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ include "vault.name" . }}-agent-injector
app.kubernetes.io/instance: {{ .Release.Name }}
Expand Down
33 changes: 33 additions & 0 deletions test/unit/injector-leader-elector.bats
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ load _helpers
[ "${actual}" = "true" ]
}

@test "injector/certs-secret: namespace is set" {
cd `chart_dir`
local actual=$( (helm template \
--show-only templates/injector-certs-secret.yaml \
--set "injector.replicas=2" \
--namespace foo \
. || echo "---") | tee /dev/stderr |
yq '.metadata.namespace' | tee /dev/stderr)
[ "${actual}" = "\"foo\"" ]
}

@test "injector/role: created/skipped as appropriate" {
cd `chart_dir`
local actual=$( (helm template \
Expand Down Expand Up @@ -127,6 +138,17 @@ load _helpers
[ "${actual}" = "true" ]
}

@test "injector/role: namespace is set" {
cd `chart_dir`
local actual=$( (helm template \
--show-only templates/injector-role.yaml \
--set "injector.replicas=2" \
--namespace foo \
. || echo "---") | tee /dev/stderr |
yq '.metadata.namespace' | tee /dev/stderr)
[ "${actual}" = "\"foo\"" ]
}

@test "injector/rolebinding: created/skipped as appropriate" {
cd `chart_dir`
local actual=$( (helm template \
Expand Down Expand Up @@ -166,3 +188,14 @@ load _helpers
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "injector/rolebinding: namespace is set" {
cd `chart_dir`
local actual=$( (helm template \
--show-only templates/injector-rolebinding.yaml \
--set "injector.replicas=2" \
--namespace foo \
. || echo "---") | tee /dev/stderr |
yq '.metadata.namespace' | tee /dev/stderr)
[ "${actual}" = "\"foo\"" ]
}

0 comments on commit f59f3d4

Please sign in to comment.