Skip to content

Commit

Permalink
⚠️ deprecate component config and no longer able to ensure that it is…
Browse files Browse the repository at this point in the history
… functioning as intended
  • Loading branch information
camilamacedo86 committed Jun 9, 2023
1 parent 81f65c2 commit 2c0d6b6
Show file tree
Hide file tree
Showing 82 changed files with 84 additions and 3,305 deletions.
12 changes: 12 additions & 0 deletions docs/book/src/component-config-tutorial/api-changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changing things up

<aside class="note warning">
<h1>Component Config is deprecated</h1>

The ComponentConfig has been deprecated in the Controller-Runtime since its version 0.15.0. [More info](https://github.com/kubernetes-sigs/controller-runtime/issues/895)
Moreover, it has undergone breaking changes and is no longer functioning as intended.
As a result, Kubebuilder, which heavily relies on the Controller Runtime, has also deprecated this feature,
no longer guaranteeing its functionality from version 3.11.0 onwards. You can find additional details on this issue [here](https://github.com/kubernetes-sigs/controller-runtime/issues/2370).

Please, be aware that it will force Kubebuilder remove this option in soon future release.

</aside>

This tutorial will show you how to create a custom configuration file for your
project by modifying a project generated with the `--component-config` flag
passed to the `init` command. The full tutorial's source can be found
Expand Down
12 changes: 12 additions & 0 deletions docs/book/src/component-config-tutorial/config-type.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Adding a new Config Type

<aside class="note warning">
<h1>Component Config is deprecated</h1>

The ComponentConfig has been deprecated in the Controller-Runtime since its version 0.15.0. [More info](https://github.com/kubernetes-sigs/controller-runtime/issues/895)
Moreover, it has undergone breaking changes and is no longer functioning as intended.
As a result, Kubebuilder, which heavily relies on the Controller Runtime, has also deprecated this feature,
no longer guaranteeing its functionality from version 3.11.0 onwards. You can find additional details on this issue [here](https://github.com/kubernetes-sigs/controller-runtime/issues/2370).

Please, be aware that it will force Kubebuilder remove this option in soon future release.

</aside>

To scaffold out a new config Kind, we can use `kubebuilder create api`.

```bash
Expand Down
12 changes: 12 additions & 0 deletions docs/book/src/component-config-tutorial/custom-type.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Using a Custom Type

<aside class="note warning">
<h1>Component Config is deprecated</h1>

The ComponentConfig has been deprecated in the Controller-Runtime since its version 0.15.0. [More info](https://github.com/kubernetes-sigs/controller-runtime/issues/895)
Moreover, it has undergone breaking changes and is no longer functioning as intended.
As a result, Kubebuilder, which heavily relies on the Controller Runtime, has also deprecated this feature,
no longer guaranteeing its functionality from version 3.11.0 onwards. You can find additional details on this issue [here](https://github.com/kubernetes-sigs/controller-runtime/issues/2370).

Please, be aware that it will force Kubebuilder remove this option in soon future release.

</aside>

<aside class="note warning">

<h1>Built-in vs Custom Type</h1>
Expand Down
12 changes: 12 additions & 0 deletions docs/book/src/component-config-tutorial/define-config.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Defining your Config

<aside class="note warning">
<h1>Component Config is deprecated</h1>

The ComponentConfig has been deprecated in the Controller-Runtime since its version 0.15.0. [More info](https://github.com/kubernetes-sigs/controller-runtime/issues/895)
Moreover, it has undergone breaking changes and is no longer functioning as intended.
As a result, Kubebuilder, which heavily relies on the Controller Runtime, has also deprecated this feature,
no longer guaranteeing its functionality from version 3.11.0 onwards. You can find additional details on this issue [here](https://github.com/kubernetes-sigs/controller-runtime/issues/2370).

Please, be aware that it will force Kubebuilder remove this option in soon future release.

</aside>

Now that you have a component config base project we need to customize the
values that are passed into the controller, to do this we can take a look at
`config/manager/controller_manager_config.yaml`.
Expand Down
12 changes: 12 additions & 0 deletions docs/book/src/component-config-tutorial/define-custom-config.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Defining your Custom Config

<aside class="note warning">
<h1>Component Config is deprecated</h1>

The ComponentConfig has been deprecated in the Controller-Runtime since its version 0.15.0. [More info](https://github.com/kubernetes-sigs/controller-runtime/issues/895)
Moreover, it has undergone breaking changes and is no longer functioning as intended.
As a result, Kubebuilder, which heavily relies on the Controller Runtime, has also deprecated this feature,
no longer guaranteeing its functionality from version 3.11.0 onwards. You can find additional details on this issue [here](https://github.com/kubernetes-sigs/controller-runtime/issues/2370).

Please, be aware that it will force Kubebuilder remove this option in soon future release.

</aside>

Now that you have a custom component config we change the
`config/manager/controller_manager_config.yaml` to use the new GVK you defined.

Expand Down
12 changes: 12 additions & 0 deletions docs/book/src/component-config-tutorial/tutorial.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Tutorial: ComponentConfig

<aside class="note warning">
<h1>Component Config is deprecated</h1>

The ComponentConfig has been deprecated in the Controller-Runtime since its version 0.15.0. [More info](https://github.com/kubernetes-sigs/controller-runtime/issues/895)
Moreover, it has undergone breaking changes and is no longer functioning as intended.
As a result, Kubebuilder, which heavily relies on the Controller Runtime, has also deprecated this feature,
no longer guaranteeing its functionality from version 3.11.0 onwards. You can find additional details on this issue [here](https://github.com/kubernetes-sigs/controller-runtime/issues/2370).

Please, be aware that it will force Kubebuilder remove this option in soon future release.

</aside>

Nearly every project that is built for Kubernetes will eventually need to
support passing in additional configurations into the controller. These could
be to enable better logging, turn on/off specific feature gates, set the sync
Expand Down
12 changes: 12 additions & 0 deletions docs/book/src/component-config-tutorial/updating-main.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Updating main

<aside class="note warning">
<h1>Component Config is deprecated</h1>

The ComponentConfig has been deprecated in the Controller-Runtime since its version 0.15.0. [More info](https://github.com/kubernetes-sigs/controller-runtime/issues/895)
Moreover, it has undergone breaking changes and is no longer functioning as intended.
As a result, Kubebuilder, which heavily relies on the Controller Runtime, has also deprecated this feature,
no longer guaranteeing its functionality from version 3.11.0 onwards. You can find additional details on this issue [here](https://github.com/kubernetes-sigs/controller-runtime/issues/2370).

Please, be aware that it will force Kubebuilder remove this option in soon future release.

</aside>

Once you have defined your new custom component config type we need to make
sure our new config type has been imported and the types are registered with
the scheme. _If you used `kubebuilder create api` this should have been
Expand Down
190 changes: 0 additions & 190 deletions test/e2e/v4/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ import (
"path/filepath"
"strings"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

pluginutil "sigs.k8s.io/kubebuilder/v3/pkg/plugin/util"

//nolint:golint
Expand Down Expand Up @@ -202,190 +199,3 @@ Count int `+"`"+`json:"count,omitempty"`+"`"+`
uncommentPodStandards(kbc)
}
}

// GenerateV4 implements a go/v4(-alpha) plugin project defined by a TestContext.
func GenerateV4ComponentConfig(kbc *utils.TestContext) {
var err error

By("initializing a project")
err = kbc.Init(
"--plugins", "go/v4",
"--project-version", "3",
"--domain", kbc.Domain,
"--component-config=true",
)
ExpectWithOffset(1, err).NotTo(HaveOccurred())

By("creating API definition")
err = kbc.CreateAPI(
"--group", kbc.Group,
"--version", kbc.Version,
"--kind", kbc.Kind,
"--namespaced",
"--resource",
"--controller",
"--make=false",
)
ExpectWithOffset(1, err).NotTo(HaveOccurred())

By("implementing the API")
ExpectWithOffset(1, pluginutil.InsertCode(
filepath.Join(kbc.Dir, "api", kbc.Version, fmt.Sprintf("%s_types.go", strings.ToLower(kbc.Kind))),
fmt.Sprintf(`type %sSpec struct {
`, kbc.Kind),
` // +optional
Count int `+"`"+`json:"count,omitempty"`+"`"+`
`)).Should(Succeed())

By("scaffolding mutating and validating webhooks")
err = kbc.CreateWebhook(
"--group", kbc.Group,
"--version", kbc.Version,
"--kind", kbc.Kind,
"--defaulting",
"--programmatic-validation",
)
ExpectWithOffset(1, err).NotTo(HaveOccurred())

By("implementing the mutating and validating webhooks")
err = pluginutil.ImplementWebhooks(filepath.Join(
kbc.Dir, "api", kbc.Version,
fmt.Sprintf("%s_webhook.go", strings.ToLower(kbc.Kind))))
ExpectWithOffset(1, err).NotTo(HaveOccurred())

By("uncomment kustomization.yaml to enable webhook and ca injection")
ExpectWithOffset(1, pluginutil.UncommentCode(
filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
"#- ../webhook", "#")).To(Succeed())
ExpectWithOffset(1, pluginutil.UncommentCode(
filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
"#- ../certmanager", "#")).To(Succeed())
ExpectWithOffset(1, pluginutil.UncommentCode(
filepath.Join(kbc.Dir, "config", "default", "kustomization.yaml"),
"#- ../prometheus", "#")).To(Succeed())
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
# 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`, "#")).To(Succeed())

if kbc.IsRestricted {
By("uncomment kustomize files to ensure that pods are restricted")
uncommentPodStandards(kbc)
}
}

func uncommentPodStandards(kbc *utils.TestContext) {
configManager := filepath.Join(kbc.Dir, "config", "manager", "manager.yaml")

//nolint:lll
if err := pluginutil.ReplaceInFile(configManager, `# TODO(user): For common cases that do not require escalating privileges
# it is recommended to ensure that all your Pods/Containers are restrictive.
# More info: https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted
# Please uncomment the following code if your project does NOT have to work on old Kubernetes
# versions < 1.19 or on vendors versions which do NOT support this field by default (i.e. Openshift < 4.11 ).
# seccompProfile:
# type: RuntimeDefault`, `seccompProfile:
type: RuntimeDefault`); err == nil {
ExpectWithOffset(1, err).NotTo(HaveOccurred())
}
}
11 changes: 0 additions & 11 deletions test/e2e/v4/plugin_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,8 @@ import (

//nolint:golint
//nolint:revive
. "github.com/onsi/ginkgo/v2"

//nolint:golint
//nolint:revive
. "github.com/onsi/gomega"

"sigs.k8s.io/kubebuilder/v3/test/e2e/utils"
)

Expand Down Expand Up @@ -87,13 +83,6 @@ var _ = Describe("kubebuilder", func() {
GenerateV4(kbc)
Run(kbc)
})

It("should generate a runnable project"+
" with restricted pods and with --component-config field enabled", func() {
kbc.IsRestricted = true
GenerateV4ComponentConfig(kbc)
Run(kbc)
})
})
})

Expand Down
1 change: 0 additions & 1 deletion test/testdata/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,5 @@ scaffold_test_project project-v3 --plugins="go/v3"
scaffold_test_project project-v4 --plugins="go/v4"
scaffold_test_project project-v4-multigroup --plugins="go/v4"
scaffold_test_project project-v4-declarative-v1 --plugins="go/v4,declarative"
scaffold_test_project project-v4-config --component-config --plugins="go/v4"
scaffold_test_project project-v4-with-deploy-image --plugins="go/v4"
scaffold_test_project project-v4-with-grafana --plugins="go/v4"
1 change: 0 additions & 1 deletion test/testdata/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@ build_kb
test_project project-v4
test_project project-v4-multigroup
test_project project-v4-declarative-v1
test_project project-v4-config
test_project project-v4-with-deploy-image
test_project project-v4-with-grafana
3 changes: 0 additions & 3 deletions testdata/project-v4-config/.dockerignore

This file was deleted.

25 changes: 0 additions & 25 deletions testdata/project-v4-config/.gitignore

This file was deleted.

Loading

0 comments on commit 2c0d6b6

Please sign in to comment.