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

chore: migrate use of deprecated kustomize features #141

Merged
merged 1 commit into from
Jun 30, 2024
Merged
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
8 changes: 4 additions & 4 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ resources:
- bases/accurate.cybozu.com_subnamespaces.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
- patches/cainjection_in_subnamespaces.yaml
- patches/fix-crd.yaml
- patches/webhook_in_subnamespaces.yaml
patches:
- path: patches/cainjection_in_subnamespaces.yaml
- path: patches/fix-crd.yaml
- path: patches/webhook_in_subnamespaces.yaml

# the following config is for teaching kustomize how to do kustomization for CRDs.
configurations:
Expand Down
112 changes: 92 additions & 20 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,117 @@ namespace: accurate
namePrefix: accurate-

# Labels to add to all resources and selectors.
commonLabels:
app.kubernetes.io/name: accurate
labels:
- includeSelectors: true
pairs:
app.kubernetes.io/name: accurate

bases:
resources:
- ../crd
- ../rbac
- ../manager
- ../webhook
- ../certmanager

patchesStrategicMerge:
- manager_webhook_patch.yaml
- webhookcainjection_patch.yaml
patches:
- path: manager_webhook_patch.yaml
- path: webhookcainjection_patch.yaml

# the following config is for teaching kustomize how to do var substitution
vars:
- name: CERTIFICATE_NAMESPACE # namespace of the certificate CR
objref:

replacements:
- source: # Add cert-manager annotation to ValidatingWebhookConfiguration, MutatingWebhookConfiguration and CRDs
kind: Certificate
group: cert-manager.io
version: v1
name: serving-cert # this name should match the one in certificate.yaml
fieldref:
fieldpath: metadata.namespace
- name: CERTIFICATE_NAME
objref:
fieldPath: .metadata.namespace # namespace of the certificate CR
targets:
- select:
kind: ValidatingWebhookConfiguration
fieldPaths:
- .metadata.annotations.[cert-manager.io/inject-ca-from]
options:
delimiter: '/'
index: 0
create: true
- select:
kind: MutatingWebhookConfiguration
fieldPaths:
- .metadata.annotations.[cert-manager.io/inject-ca-from]
options:
delimiter: '/'
index: 0
create: true
- select:
kind: CustomResourceDefinition
fieldPaths:
- .metadata.annotations.[cert-manager.io/inject-ca-from]
options:
delimiter: '/'
index: 0
create: true
- source:
kind: Certificate
group: cert-manager.io
version: v1
name: serving-cert # this name should match the one in certificate.yaml
- name: SERVICE_NAMESPACE # namespace of the service
objref:
fieldPath: .metadata.name
targets:
- select:
kind: ValidatingWebhookConfiguration
fieldPaths:
- .metadata.annotations.[cert-manager.io/inject-ca-from]
options:
delimiter: '/'
index: 1
create: true
- select:
kind: MutatingWebhookConfiguration
fieldPaths:
- .metadata.annotations.[cert-manager.io/inject-ca-from]
options:
delimiter: '/'
index: 1
create: true
- select:
kind: CustomResourceDefinition
fieldPaths:
- .metadata.annotations.[cert-manager.io/inject-ca-from]
options:
delimiter: '/'
index: 1
create: true
- source: # Add cert-manager annotation to the webhook Service
kind: Service
version: v1
name: webhook-service
fieldref:
fieldpath: metadata.namespace
- name: SERVICE_NAME
objref:
fieldPath: .metadata.name # namespace of the service
targets:
- select:
kind: Certificate
group: cert-manager.io
version: v1
fieldPaths:
- .spec.dnsNames.0
- .spec.dnsNames.1
options:
delimiter: '.'
index: 0
create: true
- source:
kind: Service
version: v1
name: webhook-service
fieldPath: .metadata.namespace # namespace of the service
targets:
- select:
kind: Certificate
group: cert-manager.io
version: v1
fieldPaths:
- .spec.dnsNames.0
- .spec.dnsNames.1
options:
delimiter: '.'
index: 1
create: true
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component

commonLabels:
app.kubernetes.io/name: '{{ include "accurate.name" . }}'

transformers:
- label-transformer.yaml
labels:
- includeSelectors: true
pairs:
app.kubernetes.io/name: '{{ include "accurate.name" . }}'
- pairs:
app.kubernetes.io/version: '{{ .Chart.AppVersion }}'
app.kubernetes.io/managed-by: '{{ .Release.Service }}'
helm.sh/chart: '{{ include "accurate.chart" . }}'

This file was deleted.

4 changes: 2 additions & 2 deletions config/kustomize-to-helm/overlays/crds/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resources:
- ../../../crd

patchesStrategicMerge:
- crd_conversion_patch.yaml
patches:
- path: crd_conversion_patch.yaml

components:
- ../../components/common-labels
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace: '{{ .Release.Namespace }}'

namePrefix: '{{ template "accurate.fullname" . }}-'

patchesStrategicMerge:
- webhookcainjection_patch.yaml
patches:
- path: webhookcainjection_patch.yaml

components:
- ../../components/common-labels
4 changes: 2 additions & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resources:
- manager.yaml

patchesStrategicMerge:
- config_patch.yaml
patches:
- path: config_patch.yaml
4 changes: 2 additions & 2 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ resources:
- subnamespace_editor_role.yaml
- subnamespace_viewer_role.yaml

patchesStrategicMerge:
- role_patch.yaml
patches:
- path: role_patch.yaml
Loading