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

⚠️ : (kustomize/v2, go/v4): Stop to scaffold CA patch injection since it is unnecessary #3555

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ patches:
#- path: patches/webhook_in_projectconfigs.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
#- path: patches/cainjection_in_projectconfigs.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
configurations:
- kustomizeconfig.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ patches:
- path: patches/webhook_in_cronjobs.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
- path: patches/cainjection_in_cronjobs.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
configurations:
- kustomizeconfig.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions hack/docs/internal/cronjob-tutorial/generate_cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -586,11 +586,6 @@ func updateKustomization(sp *Sample) {
filepath.Join(sp.ctx.Dir, "config/crd/kustomization.yaml"),
`#- path: patches/webhook_in_cronjobs.yaml`, `#`)
CheckError("fixing crd/kustomization", err)

err = pluginutil.UncommentCode(
filepath.Join(sp.ctx.Dir, "config/crd/kustomization.yaml"),
`#- path: patches/cainjection_in_cronjobs.yaml`, `#`)
CheckError("fixing crd/kustomization", err)
}

func updateExample(sp *Sample) {
Expand Down
1 change: 0 additions & 1 deletion pkg/plugins/common/kustomize/v2/scaffolds/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func (s *apiScaffolder) Scaffold() error {
&rbac.CRDEditorRole{},
&rbac.CRDViewerRole{},
&patches.EnableWebhookPatch{},
&patches.EnableCAInjectionPatch{},
&crd.Kustomization{},
&crd.KustomizeConfig{},
); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,33 +44,28 @@ func (f *Kustomization) SetTemplateDefaults() error {
f.TemplateBody = fmt.Sprintf(kustomizationTemplate,
machinery.NewMarkerFor(f.Path, resourceMarker),
machinery.NewMarkerFor(f.Path, webhookPatchMarker),
machinery.NewMarkerFor(f.Path, caInjectionPatchMarker),
)

return nil
}

const (
resourceMarker = "crdkustomizeresource"
webhookPatchMarker = "crdkustomizewebhookpatch"
caInjectionPatchMarker = "crdkustomizecainjectionpatch"
resourceMarker = "crdkustomizeresource"
webhookPatchMarker = "crdkustomizewebhookpatch"
)

// GetMarkers implements file.Inserter
func (f *Kustomization) GetMarkers() []machinery.Marker {
return []machinery.Marker{
machinery.NewMarkerFor(f.Path, resourceMarker),
machinery.NewMarkerFor(f.Path, webhookPatchMarker),
machinery.NewMarkerFor(f.Path, caInjectionPatchMarker),
}
}

const (
resourceCodeFragment = `- bases/%s_%s.yaml
`
webhookPatchCodeFragment = `#- path: patches/webhook_in_%s.yaml
`
caInjectionPatchCodeFragment = `#- path: patches/cainjection_in_%s.yaml
`
)

Expand All @@ -86,20 +81,13 @@ func (f *Kustomization) GetCodeFragments() machinery.CodeFragmentsMap {
webhookPatch := make([]string, 0)
webhookPatch = append(webhookPatch, fmt.Sprintf(webhookPatchCodeFragment, f.Resource.Plural))

// Generate resource code fragments
caInjectionPatch := make([]string, 0)
caInjectionPatch = append(caInjectionPatch, fmt.Sprintf(caInjectionPatchCodeFragment, f.Resource.Plural))

// Only store code fragments in the map if the slices are non-empty
if len(res) != 0 {
fragments[machinery.NewMarkerFor(f.Path, resourceMarker)] = res
}
if len(webhookPatch) != 0 {
fragments[machinery.NewMarkerFor(f.Path, webhookPatchMarker)] = webhookPatch
}
if len(caInjectionPatch) != 0 {
fragments[machinery.NewMarkerFor(f.Path, caInjectionPatchMarker)] = caInjectionPatch
}

return fragments
}
Expand All @@ -115,10 +103,6 @@ patches:
# patches here are for enabling the conversion webhook for each CRD
%s

# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
# patches here are for enabling the CA injection for each CRD
%s

# the following config is for teaching kustomize how to do kustomization for CRDs.
configurations:
- kustomizeconfig.yaml
Expand Down

This file was deleted.

6 changes: 0 additions & 6 deletions test/e2e/v4/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ Count int `+"`"+`json:"count,omitempty"`+"`"+`
ExpectWithOffset(1, pluginutil.UncommentCode(
filepath.Join(kbc.Dir, "config", "crd", "kustomization.yaml"),
fmt.Sprintf("#- path: patches/webhook_in_%s.yaml", kbc.Resources), "#")).To(Succeed())
ExpectWithOffset(1, pluginutil.UncommentCode(
filepath.Join(kbc.Dir, "config", "crd", "kustomization.yaml"),
fmt.Sprintf("#- path: patches/cainjection_in_%s.yaml", kbc.Resources), "#")).To(Succeed())
ExpectWithOffset(1, pluginutil.UncommentCode(
filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
"#- ../webhook", "#")).To(Succeed())
Expand All @@ -101,9 +98,6 @@ Count int `+"`"+`json:"count,omitempty"`+"`"+`
ExpectWithOffset(1, pluginutil.UncommentCode(
filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
"#- manager_webhook_patch.yaml", "#")).To(Succeed())
ExpectWithOffset(1, pluginutil.UncommentCode(
filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
"#- webhookcainjection_patch.yaml", "#")).To(Succeed())
ExpectWithOffset(1, pluginutil.UncommentCode(filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
`#replacements:
# - source: # Add cert-manager annotation to ValidatingWebhookConfiguration, MutatingWebhookConfiguration and CRDs
Expand Down
15 changes: 0 additions & 15 deletions testdata/project-v4-multigroup/config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,6 @@ patches:
#- path: patches/webhook_in_busyboxes.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
#- path: patches/cainjection_in_captains.yaml
#- path: patches/cainjection_in_frigates.yaml
#- path: patches/cainjection_in_destroyers.yaml
#- path: patches/cainjection_in_cruisers.yaml
#- path: patches/cainjection_in_krakens.yaml
#- path: patches/cainjection_in_leviathans.yaml
#- path: patches/cainjection_in_healthcheckpolicies.yaml
#- path: patches/cainjection_in_bars.yaml
#- path: patches/cainjection_in_lakers.yaml
#- path: patches/cainjection_in_memcacheds.yaml
#- path: patches/cainjection_in_busyboxes.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
configurations:
- kustomizeconfig.yaml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ patches:
#- path: patches/webhook_in_busyboxes.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
#- path: patches/cainjection_in_memcacheds.yaml
#- path: patches/cainjection_in_busyboxes.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
configurations:
- kustomizeconfig.yaml

This file was deleted.

This file was deleted.

7 changes: 0 additions & 7 deletions testdata/project-v4/config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,6 @@ patches:
#- path: patches/webhook_in_admirales.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
#- path: patches/cainjection_in_captains.yaml
#- path: patches/cainjection_in_firstmates.yaml
#- path: patches/cainjection_in_admirales.yaml
#+kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
configurations:
- kustomizeconfig.yaml

This file was deleted.

This file was deleted.

This file was deleted.

Loading