Skip to content
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

Fix Kustomize deprecations #335

Open
wants to merge 1 commit into
base: master
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
23 changes: 23 additions & 0 deletions config/acceptance/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,26 @@ patchesStrategicMerge:
- overlays/rbac-manager.yaml
- overlays/vault-manager.yaml
- overlays/workloads-manager.yaml

# Sadly we must repeat the replacement as in our root Kustomization, because we've
# overriden the image field, and there's no way to get Kustomize to run the (merged) replacements
# after (merged) patches.
replacements:
- source:
fieldPath: spec.template.spec.containers.[name=manager].image
group: apps
version: v1
kind: StatefulSet
name: theatre-vault-manager
namespace: theatre-system
targets:
- select:
group: apps
kind: StatefulSet
name: vault-manager
version: v1
fieldPaths:
- spec.template.spec.containers.0.args.0
options:
delimiter: =
index: 1
3 changes: 0 additions & 3 deletions config/acceptance/overlays/vault-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ spec:
- name: manager
image: theatre:latest
imagePullPolicy: Never
args:
- --theatre-image=$(THEATRE_IMAGE)
- --metrics-address=0.0.0.0
resources:
requests:
cpu: "100m"
31 changes: 22 additions & 9 deletions config/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ kind: Kustomization
namespace: theatre-system
namePrefix: theatre-

commonLabels:
app: theatre
labels:
- includeSelectors: true
pairs:
app: theatre

resources:
- crds/rbac.crd.gocardless.com_directoryrolebindings.yaml
Expand All @@ -22,16 +24,27 @@ resources:
- rbac/leader-election.yaml
- cert-manager/certificate.yaml

vars:
replacements:
Copy link
Contributor

Choose a reason for hiding this comment

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

with the new approach of repeating this replacement in overlay kustomization, there is a slight risk of someone modifying this replacement code, but forgetting to mirror the modification in overlay, in which case the replacement could be buggy, and the tests would still pass.

I don't think there's an elegant way to solve this, but could you add a code comment that the replacement code needs to be mirrored in config/acceptance/kustomization.yaml?

# We want our mutating webhook to ensure it only ever configures pods to use
# the same image as it is running itself. If we ensure this, we don't need to
# worry about maintaining compatibility between versions of the webhook and
# theatre-secrets, as both will use the same version and be deployed
# atomically.
- name: THEATRE_IMAGE
objref:
apiVersion: apps/v1
- source:
fieldPath: spec.template.spec.containers.[name=manager].image
group: apps
version: v1
kind: StatefulSet
name: vault-manager
fieldref:
fieldpath: spec.template.spec.containers[0].image
name: theatre-vault-manager
namespace: theatre-system
targets:
- select:
group: apps
kind: StatefulSet
name: vault-manager
version: v1
fieldPaths:
- spec.template.spec.containers.0.args.0
options:
delimiter: =
index: 1
2 changes: 1 addition & 1 deletion config/base/managers/vault.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ spec:
- command:
- /usr/local/bin/vault-manager
args:
- --theatre-image=$(THEATRE_IMAGE)
- --theatre-image=THEATRE_IMAGE_PLACEHOLDER
- --metrics-address=0.0.0.0
image: eu.gcr.io/gc-containers/gocardless/theatre:latest
imagePullPolicy: Always
Expand Down