-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Synchronize operator source code with kubebuilder scafolding project
Clean the kustomization. Remove unused kustomization `default-with-metrics`. Remove `kube-rbac-proxy` container from kustomization and helm chart.
- Loading branch information
1 parent
d811c41
commit d61d4a2
Showing
34 changed files
with
668 additions
and
465 deletions.
There are no files selected for viewing
This file contains 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 operator is running | ||
Then metrics endpoint should reject http request with status code "400" | ||
|
||
@skip:gke @skip:aks @skip:eks | ||
Scenario: Reject unauthenticated token | ||
Given operator is running | ||
Then metrics endpoint should reject authorization random token request with status code "500" | ||
|
||
@skip:gke @skip:aks @skip:eks | ||
Scenario: Accept request | ||
Given 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 metrics endpoint should accept https request with "testing" service account token | ||
|
||
|
This file contains 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 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 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 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 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.