-
Notifications
You must be signed in to change notification settings - Fork 25
Synchronize operator source code with kubebuilder scafolding project #395
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
.changes/unreleased/charts-operator-Removed-20250226-182037.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| project: charts/operator | ||
| kind: Removed | ||
| body: | | ||
| `gcr.io/kubebuilder/kube-rbac-proxy` container is deprecated and has been removed from the Redpanda | ||
| operator helm chart. The same ports will continue to serve metrics using kubebuilder's built in RBAC. | ||
|
|
||
| Any existing prometheus rules don't need to be adjusted. | ||
|
|
||
| For more details see: https://github.com/kubernetes-sigs/kubebuilder/discussions/3907 | ||
| time: 2025-02-26T18:20:37.65853+01:00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| project: operator | ||
| kind: Removed | ||
| body: | | ||
| `gcr.io/kubebuilder/kube-rbac-proxy` container is deprecated and has been removed from the Redpanda | ||
| operator helm chart. The same ports will continue to serve metrics using kubebuilder's built in RBAC. | ||
|
|
||
| Any existing prometheus rules don't need to be adjusted. | ||
|
|
||
| For more details see: https://github.com/kubernetes-sigs/kubebuilder/discussions/3907 | ||
| time: 2025-02-26T18:20:37.658528+01:00 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| Feature: Metrics endpoint has authentication and authorization | ||
|
|
||
| @skip:gke @skip:aks @skip:eks | ||
| Scenario: Reject request without TLS | ||
| Given the operator is running | ||
| Then its metrics endpoint should reject http request with status code "400" | ||
|
|
||
| @skip:gke @skip:aks @skip:eks | ||
| Scenario: Reject unauthenticated token | ||
| Given the operator is running | ||
| Then its metrics endpoint should reject authorization random token request with status code "500" | ||
|
|
||
| @skip:gke @skip:aks @skip:eks | ||
| Scenario: Accept request | ||
| Given the operator is running | ||
| When I apply Kubernetes manifest: | ||
| """ | ||
| apiVersion: v1 | ||
| kind: ServiceAccount | ||
| metadata: | ||
| name: testing | ||
| """ | ||
| And "testing" service account has bounded "redpanda-operator-metrics-reader" cluster role | ||
| Then its metrics endpoint should accept https request with "testing" service account token | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| // Copyright 2025 Redpanda Data, Inc. | ||
| // | ||
| // Use of this software is governed by the Business Source License | ||
| // included in the file licenses/BSL.md | ||
| // | ||
| // As of the Change Date specified in that file, in accordance with | ||
| // the Business Source License, use of this software will be governed | ||
| // by the Apache License, Version 2.0 | ||
|
|
||
| package steps | ||
|
|
||
| import ( | ||
| "context" | ||
|
|
||
| "github.com/stretchr/testify/require" | ||
| appsv1 "k8s.io/api/apps/v1" | ||
| rbacv1 "k8s.io/api/rbac/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
|
|
||
| framework "github.com/redpanda-data/redpanda-operator/harpoon" | ||
| ) | ||
|
|
||
| func operatorIsRunning(ctx context.Context, t framework.TestingT) { | ||
| var dep appsv1.Deployment | ||
| require.NoError(t, t.Get(ctx, t.ResourceKey("redpanda-operator"), &dep)) | ||
|
|
||
| // make sure the resource is stable | ||
| checkStableResource(ctx, t, &dep) | ||
|
|
||
| require.Equal(t, dep.Status.AvailableReplicas, int32(1)) | ||
| require.Equal(t, dep.Status.Replicas, int32(1)) | ||
| require.Equal(t, dep.Status.ReadyReplicas, int32(1)) | ||
| require.Equal(t, dep.Status.UnavailableReplicas, int32(0)) | ||
| } | ||
|
|
||
| func requestMetricsEndpointPlainHTTP(ctx context.Context, statusCode string) { | ||
| clientsForOperator(ctx, false, "", statusCode).ExpectRequestRejected(ctx) | ||
| } | ||
|
|
||
| func requestMetricsEndpointWithTLSAndRandomToken(ctx context.Context, statusCode string) { | ||
| clientsForOperator(ctx, true, "", statusCode).ExpectRequestRejected(ctx) | ||
| } | ||
|
|
||
| func acceptServiceAccountMetricsRequest(ctx context.Context, serviceAccountName string) { | ||
| clientsForOperator(ctx, true, serviceAccountName, "").ExpectCorrectMetricsResponse(ctx) | ||
| } | ||
|
|
||
| func createClusterRoleBinding(ctx context.Context, serviceAccountName, clusterRoleName string) { | ||
| t := framework.T(ctx) | ||
|
|
||
| require.NoError(t, t.Create(ctx, &rbacv1.ClusterRoleBinding{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: serviceAccountName, | ||
| Namespace: t.Namespace(), | ||
| }, | ||
| RoleRef: rbacv1.RoleRef{ | ||
| APIGroup: rbacv1.GroupName, | ||
| Kind: "ClusterRole", | ||
| Name: clusterRoleName, | ||
| }, | ||
| Subjects: []rbacv1.Subject{ | ||
| { | ||
| Kind: "ServiceAccount", | ||
| Name: serviceAccountName, | ||
| Namespace: t.Namespace(), | ||
| }, | ||
| }, | ||
| })) | ||
|
|
||
| t.Cleanup(func(ctx context.Context) { | ||
| require.NoError(t, t.Delete(ctx, &rbacv1.ClusterRoleBinding{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: serviceAccountName, | ||
| Namespace: t.Namespace(), | ||
| }, | ||
| })) | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, can you not use the
client.Clientfor this? These resources are always a bit weird... Is it a subresource?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only
client.Clienthave typed client that implementsCreateTokenfunction.