Skip to content

Commit

Permalink
Merge pull request #548 from furkatgofurov7/bump-kustomize-v5
Browse files Browse the repository at this point in the history
Bump kustomize to v5
  • Loading branch information
furkatgofurov7 authored Jan 8, 2025
2 parents a497614 + 5c9fa2c commit be2aab1
Show file tree
Hide file tree
Showing 24 changed files with 255 additions and 159 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ endif
GO_INSTALL := ./scripts/go-install.sh

# Binaries
KUSTOMIZE_VER := v4.5.2
KUSTOMIZE_VER := v5.5.0
KUSTOMIZE_BIN := kustomize
KUSTOMIZE := $(abspath $(TOOLS_BIN_DIR)/$(KUSTOMIZE_BIN)-$(KUSTOMIZE_VER))
KUSTOMIZE_PKG := sigs.k8s.io/kustomize/kustomize/v4
KUSTOMIZE_PKG := sigs.k8s.io/kustomize/kustomize/v5

# This is a commit from CR main (22.05.2024).
# Intentionally using a commit from main to use a setup-envtest version
Expand Down Expand Up @@ -105,7 +105,7 @@ GOLANGCI_LINT_VER := v1.55.1
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN))

GINKGO_VER := v2.20.1
GINKGO_VER := v2.22.0
GINKGO_BIN := ginkgo
GINKGO := $(abspath $(TOOLS_BIN_DIR)/$(GINKGO_BIN)-$(GINKGO_VER))
GINKGO_PKG := github.com/onsi/ginkgo/v2/ginkgo
Expand Down
8 changes: 4 additions & 4 deletions bootstrap/config/certmanager/certificate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ metadata:
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
namespace: system
spec:
# $(SERVICE_NAME) and $(SERVICE_NAMESPACE) will be substituted by kustomize
# SERVICE_NAME and SERVICE_NAMESPACE will be substituted by kustomize
dnsNames:
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local
- SERVICE_NAME.SERVICE_NAMESPACE.svc
- SERVICE_NAME.SERVICE_NAMESPACE.svc.cluster.local
issuerRef:
kind: Issuer
name: selfsigned-issuer
secretName: $(SERVICE_NAME)-cert # this secret will not be prefixed, since it's not managed by kustomize
secretName: rke2-bootstrap-webhook-service-cert # this secret will not be prefixed, since it's not managed by kustomize
subject:
organizations:
- Rancher by SUSE
13 changes: 1 addition & 12 deletions bootstrap/config/certmanager/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,4 @@ nameReference:
fieldSpecs:
- kind: Certificate
group: cert-manager.io
path: spec/issuerRef/name

varReference:
- kind: Certificate
group: cert-manager.io
path: spec/commonName
- kind: Certificate
group: cert-manager.io
path: spec/dnsNames
- kind: Certificate
group: cert-manager.io
path: spec/secretName
path: spec/issuerRef/name
18 changes: 9 additions & 9 deletions bootstrap/config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
commonLabels:
cluster.x-k8s.io/v1beta1: v1alpha1_v1beta1
labels:
- includeSelectors: true
pairs:
cluster.x-k8s.io/v1beta1: v1alpha1_v1beta1

# This kustomization.yaml is not intended to be run by itself,
# since it depends on service name and namespace that are out of this kustomize package.
Expand All @@ -9,19 +11,17 @@ resources:
- bases/bootstrap.cluster.x-k8s.io_rke2configtemplates.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
patches:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
- patches/webhook_in_rke2configs.yaml
- patches/webhook_in_rke2configtemplates.yaml
#- patches/webhook_in_rke2configtemplates.yaml
- path: patches/webhook_in_rke2configs.yaml
- path: patches/webhook_in_rke2configtemplates.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
- patches/cainjection_in_rke2configs.yaml
- patches/cainjection_in_rke2configtemplates.yaml
#- patches/cainjection_in_rke2configtemplates.yaml
- path: patches/cainjection_in_rke2configs.yaml
- path: patches/cainjection_in_rke2configtemplates.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
5 changes: 1 addition & 4 deletions bootstrap/config/crd/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,4 @@ namespace:
version: v1
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/namespace
create: false

varReference:
- path: metadata/annotations
create: false
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME
name: rke2configs.bootstrap.cluster.x-k8s.io
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME
name: rke2configtemplates.bootstrap.cluster.x-k8s.io
2 changes: 1 addition & 1 deletion bootstrap/config/crd/patches/webhook_in_rke2configs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
clientConfig:
service:
namespace: system
name: webhook-service
name: rke2-bootstrap-webhook-service
path: /convert
conversionReviewVersions:
- v1
Expand Down
149 changes: 109 additions & 40 deletions bootstrap/config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,122 @@ namespace: rke2-bootstrap-system
namePrefix: rke2-bootstrap-

# Labels to add to all resources and selectors.
commonLabels:
cluster.x-k8s.io/provider: "bootstrap-rke2"
labels:
- includeSelectors: true
pairs:
cluster.x-k8s.io/provider: bootstrap-rke2

resources:
- namespace.yaml

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

patchesStrategicMerge:
- manager_image_patch.yaml
- manager_pull_policy.yaml
- manager_webhook_patch.yaml
- 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:
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:
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:
kind: Service
version: v1
name: webhook-service
fieldref:
fieldpath: metadata.namespace
- name: SERVICE_NAME
objref:
kind: Service
version: v1
name: webhook-service
patches:
# Provide customizable hook for make targets.
- path: manager_image_patch.yaml
- path: manager_pull_policy.yaml
# Enable webhook.
- path: manager_webhook_patch.yaml
# Inject certificate in the webhook definition.
- path: webhookcainjection_patch.yaml

configurations:
- kustomizeconfig.yaml
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
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
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
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
3 changes: 0 additions & 3 deletions bootstrap/config/default/kustomizeconfig.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion bootstrap/config/default/manager_webhook_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ spec:
volumes:
- name: cert
secret:
secretName: $(SERVICE_NAME)-cert
secretName: rke2-bootstrap-webhook-service-cert
4 changes: 2 additions & 2 deletions bootstrap/config/default/webhookcainjection_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ kind: MutatingWebhookConfiguration
metadata:
name: mutating-webhook-configuration
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: validating-webhook-configuration
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
cert-manager.io/inject-ca-from: CERTIFICATE_NAMESPACE/CERTIFICATE_NAME
3 changes: 0 additions & 3 deletions bootstrap/config/webhook/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,3 @@ namespace:
group: admissionregistration.k8s.io
path: webhooks/clientConfig/service/namespace
create: true

varReference:
- path: metadata/annotations
8 changes: 4 additions & 4 deletions controlplane/config/certmanager/certificate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ metadata:
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
namespace: system
spec:
# $(SERVICE_NAME) and $(SERVICE_NAMESPACE) will be substituted by kustomize
# SERVICE_NAME and SERVICE_NAMESPACE will be substituted by kustomize
dnsNames:
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local
- SERVICE_NAME.SERVICE_NAMESPACE.svc
- SERVICE_NAME.SERVICE_NAMESPACE.svc.cluster.local
issuerRef:
kind: Issuer
name: selfsigned-issuer
secretName: $(SERVICE_NAME)-cert # this secret will not be prefixed, since it's not managed by kustomize
secretName: rke2-controlplane-webhook-service-cert # this secret will not be prefixed, since it's not managed by kustomize
subject:
organizations:
- Rancher by SUSE
11 changes: 0 additions & 11 deletions controlplane/config/certmanager/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,3 @@ nameReference:
- kind: Certificate
group: cert-manager.io
path: spec/issuerRef/name

varReference:
- kind: Certificate
group: cert-manager.io
path: spec/commonName
- kind: Certificate
group: cert-manager.io
path: spec/dnsNames
- kind: Certificate
group: cert-manager.io
path: spec/secretName
16 changes: 9 additions & 7 deletions controlplane/config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
commonLabels:
cluster.x-k8s.io/v1beta1: v1alpha1_v1beta1
labels:
- includeSelectors: true
pairs:
cluster.x-k8s.io/v1beta1: v1alpha1_v1beta1

# This kustomization.yaml is not intended to be run by itself,
# since it depends on service name and namespace that are out of this kustomize package.
Expand All @@ -9,17 +11,17 @@ resources:
- bases/controlplane.cluster.x-k8s.io_rke2controlplanetemplates.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
patches:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
- patches/webhook_in_rke2controlplanes.yaml
- patches/webhook_in_rke2controlplanetemplates.yaml
- path: patches/webhook_in_rke2controlplanes.yaml
- path: patches/webhook_in_rke2controlplanetemplates.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
- patches/cainjection_in_rke2controlplanes.yaml
- patches/cainjection_in_rke2controlplanetemplates.yaml
- path: patches/cainjection_in_rke2controlplanes.yaml
- path: patches/cainjection_in_rke2controlplanetemplates.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
3 changes: 0 additions & 3 deletions controlplane/config/crd/kustomizeconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,3 @@ namespace:
group: apiextensions.k8s.io
path: spec/conversion/webhook/clientConfig/service/namespace
create: false

varReference:
- path: metadata/annotations
Loading

0 comments on commit be2aab1

Please sign in to comment.