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

bundle: remove usage of kube-rbac-proxy image #514

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

iamniting
Copy link
Member

kube-rbac-proxy image is deprecated. We wont be able to pull it from
early 2025 as gcr.io/kubebuilder will be unavailable.

Protect metrics endpoint with WithAuthenticationAndAuthorization method.

Ref:
kubernetes-sigs/kubebuilder#3907
red-hat-storage/ocs-operator#2912

Signed-off-by: Nitin Goyal nigoyal@redhat.com

kube-rbac-proxy image is deprecated. We wont be able to pull it from
early 2025 as gcr.io/kubebuilder will be unavailable.

Protect metrics endpoint with WithAuthenticationAndAuthorization method.

Ref:
kubernetes-sigs/kubebuilder#3907
red-hat-storage/ocs-operator#2912

Signed-off-by: Nitin Goyal <nigoyal@redhat.com>
Signed-off-by: Nitin Goyal <nigoyal@redhat.com>
Signed-off-by: Nitin Goyal <nigoyal@redhat.com>
Copy link
Contributor

openshift-ci bot commented Dec 4, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: iamniting

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 4, 2024
@iamniting
Copy link
Member Author

cc @camilamacedo86

Can you pls take a look once?

Comment on lines -391 to -394
readOnlyRootFilesystem: true
- args:
- --health-probe-bind-address=:8081
- --metrics-bind-address=127.0.0.1:8080

Choose a reason for hiding this comment

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

You remove the image but you did not added the code to protect your metrics
Now, it is not protected at all. You must ensure that it is protected

please see: Check out the FAQ section: "How can I manually change my project to switch to Controller-Runtime's built-in auth protection?" for detailed instructions.**

Copy link
Member Author

Choose a reason for hiding this comment

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

I did in the first commit. I used the WithAuthenticationAndAuthorization method. I have not added the service because it was already included here.

https://github.com/red-hat-storage/odf-operator/blob/main/config/rbac/auth_proxy_service.yaml

Choose a reason for hiding this comment

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

OH I see here: https://github.com/red-hat-storage/odf-operator/pull/514/files#diff-2873f79a86c0d8b3335cd7731b0ecf7dd4301eb19a82ef7a1cba7589b5252261R106-R111

Sorry for the false alarm !!!!

Great !!

One thing to remember for a follow-up PR is to check if you cannot provide certs for the Metrics Server. It would be recommended to ensure security. See an example of the PR to introduce a helper in the next release: kubernetes-sigs/kubebuilder#4400

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we need these certs if we are only running in the OCP environments? Just the annotations are enough right?

Copy link

@camilamacedo86 camilamacedo86 Dec 6, 2024

Choose a reason for hiding this comment

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

Ideally, yes, you should provide your own certificates, regardless of whether you're running exclusively on OCP.

The reason for this is that if you don’t explicitly specify the certificates, the implementation in controller-runtime (or previously in rbac-kube-proxy) will generate them for you. However, these are typically self-signed certificates, which are not suitable for production environments.

That said, OpenShift (OCP) provides a solution for generating and managing certificates through an operator. With the changes introduced in this PR, you maintain the same level of protection as before, so you're good to proceed within its scope.

However, I would recommend tracking an issue or initiating an effort to evaluate OCP's certificate generation solution and pass it here. That is a very simple change after, you will only need to do something like

		if len(certDir) > 0 {
			setupLog.Info("using certificates for the metrics server",
				"cert-dir", certDir, "cert-name", certName, "cert-key", certKey)

			var err error
			certWatcher, err = certwatcher.New(filepath.Join(certDir, certName), filepath.Join(certDir, certKey))
			if err != nil {
				setupLog.Error(err, "to initialize certificate watcher", "error", err)
				os.Exit(1)
			}

			metricsServerOptions.TLSOpts = append(metricsServerOptions.TLSOpts, func(config *tls.Config) {
				config.GetCertificate = certWatcher.GetCertificate
			})
		}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants