-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from tumblr/gabe/remove-default-token-mounts
make sure we remove any volumeMounts that were precreated when inject…
- Loading branch information
Showing
6 changed files
with
128 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
test/fixtures/k8s/admissioncontrol/patch/service-account-default-token.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[ | ||
{ | ||
"op": "replace", | ||
"path": "/spec/serviceAccountName", | ||
"value": "someaccount" | ||
}, | ||
{ | ||
"op": "remove", | ||
"path": "/spec/initContainers/0/volumeMounts/0" | ||
}, | ||
{ | ||
"op": "remove", | ||
"path": "/spec/containers/1/volumeMounts/1" | ||
}, | ||
{ | ||
"op" : "add", | ||
"path" : "/metadata/annotations/injector.unittest.com~1status", | ||
"value" : "injected" | ||
} | ||
] |
48 changes: 48 additions & 0 deletions
48
test/fixtures/k8s/admissioncontrol/request/service-account-default-token.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
# this is an AdmissionRequest object | ||
# https://godoc.org/k8s.io/api/admission/v1beta1#AdmissionRequest | ||
object: | ||
metadata: | ||
annotations: | ||
injector.unittest.com/request: "service-account-default-token" | ||
spec: | ||
serviceAccountName: "default" # this should get replaced | ||
volumes: | ||
- name: bogusvolume | ||
configMap: | ||
name: config-production | ||
defaultMode: 420 | ||
- name: default-token-wlfz2 | ||
secret: | ||
secretName: default-token-wlfz2 | ||
defaultMode: 420 | ||
initContainers: | ||
- name: init-ctr1-with-token | ||
volumeMounts: | ||
# this volume mount must be removed, because | ||
# by default, a serviceAccount will mount its token, | ||
# preventing the injected serviceAccount from settings up its mount | ||
- name: default-token-wlfz2 | ||
readOnly: true | ||
mountPath: /var/run/secrets/kubernetes.io/serviceaccount | ||
- name: init-ctr2 | ||
volumeMounts: [] | ||
containers: | ||
- name: ctr1 | ||
volumeMounts: | ||
- name: bogusvolume | ||
readOnly: true | ||
mountPath: /app/config | ||
- name: ctr2-with-token | ||
volumeMounts: | ||
- name: bogusvolume | ||
readOnly: true | ||
mountPath: /app/config | ||
# this volume mount must be removed, because | ||
# by default, a serviceAccount will mount its token, | ||
# preventing the injected serviceAccount from settings up its mount | ||
- name: default-token-wlfz2 | ||
readOnly: true | ||
mountPath: /var/run/secrets/kubernetes.io/serviceaccount | ||
- name: ctr3 | ||
volumeMounts: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
name: service-account-default-token | ||
serviceAccountName: someaccount |