diff --git a/Makefile b/Makefile index 5f7d2fa21..4d8f6b622 100644 --- a/Makefile +++ b/Makefile @@ -191,10 +191,10 @@ update-tools: clean-tools install-golangci-lint install-gotestsum install-boiler .PHONY: lint lint: install-golangci-lint install-logcheck ## Run golangci-lint @if [ -n "$(WHAT)" ]; then \ - $(GOLANGCI_LINT) run $(GOLANGCI_LINT_FLAGS) -c $(ROOT_DIR)/.golangci.yaml --timeout 20m $(WHAT); \ + $(GOLANGCI_LINT) run $(GOLANGCI_LINT_FLAGS) -c $(ROOT_DIR)/.golangci.yaml --timeout 20m $(WHAT) --fix; \ else \ for MOD in $(GOMODS); do \ - (cd $$MOD; echo "Linting $$MOD"; $(GOLANGCI_LINT) run $(GOLANGCI_LINT_FLAGS) -c $(ROOT_DIR)/.golangci.yaml --timeout 20m); \ + (cd $$MOD; echo "Linting $$MOD"; $(GOLANGCI_LINT) run $(GOLANGCI_LINT_FLAGS) -c $(ROOT_DIR)/.golangci.yaml --timeout 20m --fix); \ done; \ fi diff --git a/README.md b/README.md index 105ba4ab4..4b72fe84d 100644 --- a/README.md +++ b/README.md @@ -69,3 +69,4 @@ These limitations are part of the roadmap and will be addressed in the future. * Currently we don't support related resources, like ConfigMaps, Secrets. * We don't support lifecycle of `BoundSchema` resources, like schema changes. +* The backend currently does not support running with replicas > 1 due to missing external session storage implementation. Session storage is currently in-memory only, which prevents proper session sharing across multiple backend instances. diff --git a/backend/auth/handler.go b/backend/auth/handler.go index 006654241..4c83746c7 100644 --- a/backend/auth/handler.go +++ b/backend/auth/handler.go @@ -49,14 +49,16 @@ type AuthHandler struct { jwtService *JWTService cookieSigningKey []byte cookieEncryptionKey []byte + sessionStore session.Store } -func NewAuthHandler(oidc OIDCProvider, jwtService *JWTService, cookieSigningKey, cookieEncryptionKey []byte) *AuthHandler { +func NewAuthHandler(oidc OIDCProvider, jwtService *JWTService, cookieSigningKey, cookieEncryptionKey []byte, sessionStore session.Store) *AuthHandler { return &AuthHandler{ oidc: oidc, jwtService: jwtService, cookieSigningKey: cookieSigningKey, cookieEncryptionKey: cookieEncryptionKey, + sessionStore: sessionStore, } } @@ -87,7 +89,7 @@ func (ah *AuthHandler) HandleAuthorize(w http.ResponseWriter, r *http.Request) { return } - scopes := []string{"openid", "profile", "email", "offline_access"} + scopes := []string{"openid", "profile", "email", "offline_access", "groups"} dataCode, err := json.Marshal(authReq) if err != nil { logger.Info("failed to marshal auth code", "error", err) @@ -181,6 +183,13 @@ func (ah *AuthHandler) HandleCallback(w http.ResponseWriter, r *http.Request) { http.Error(w, "internal error", http.StatusInternalServerError) return } + // Set session expiration and store in middleware + err = ah.sessionStore.Save(sessionState) + if err != nil { + logger.Error(err, "failed to save session state") + http.Error(w, "internal error", http.StatusInternalServerError) + return + } // Detect client type from redirect URL or user agent clientType := authCode.ClientType @@ -224,6 +233,7 @@ func (ah *AuthHandler) HandleCallback(w http.ResponseWriter, r *http.Request) { // UI flow - set cookie and redirect to UI cookieName := ah.generateCookieName(authCode.ClusterID) + s := securecookie.New(ah.cookieSigningKey, ah.cookieEncryptionKey) encoded, err := s.Encode(cookieName, sessionState) if err != nil { @@ -282,22 +292,26 @@ func (ah *AuthHandler) createSessionState(authCode *AuthorizeRequest, token *oau } var idToken struct { - Subject string `json:"sub"` - Issuer string `json:"iss"` + Subject string `json:"sub"` + Issuer string `json:"iss"` + Groups []string `json:"groups,omitempty"` } if err := json.Unmarshal(jwt, &idToken); err != nil { return nil, fmt.Errorf("failed to parse ID token: %w", err) } - return &session.State{ + s := &session.State{ Token: session.TokenInfo{ Subject: idToken.Subject, Issuer: idToken.Issuer, + Groups: idToken.Groups, }, SessionID: authCode.SessionID, ClusterID: authCode.ClusterID, RedirectURL: authCode.RedirectURL, - }, nil + } + s.SetExpiration(time.Hour) + return s, nil } func (ah *AuthHandler) unwrapJWT(p string) ([]byte, error) { diff --git a/backend/auth/middleware.go b/backend/auth/middleware.go index d377d8d11..8548baaba 100644 --- a/backend/auth/middleware.go +++ b/backend/auth/middleware.go @@ -21,11 +21,15 @@ import ( "encoding/json" "net/http" "strings" + "time" "github.com/gorilla/securecookie" + apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/klog/v2" + "github.com/kube-bind/kube-bind/backend/kubernetes" "github.com/kube-bind/kube-bind/backend/session" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) type contextKey string @@ -49,19 +53,65 @@ type AuthContext struct { type AuthMiddleware struct { jwtService *JWTService + kubernetesMananger *kubernetes.Manager cookieSigningKey []byte cookieEncryptionKey []byte + sessionStore session.Store } -func NewAuthMiddleware(jwtService *JWTService, cookieSigningKey, cookieEncryptionKey []byte) *AuthMiddleware { +// writeErrorResponse writes a structured error response to the HTTP response writer +func writeErrorResponse(w http.ResponseWriter, statusCode int, code, message, details string) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(statusCode) + + errorResponse := kubebindv1alpha2.NewError(code, message, details) + if err := json.NewEncoder(w).Encode(errorResponse); err != nil { + // Fallback to plain text if JSON encoding fails + http.Error(w, message, statusCode) + } +} + +// mapErrorToCode maps common errors to structured error codes +func mapErrorToCode(err error) (statusCode int, code string, details string) { + if apierrors.IsNotFound(err) { + return http.StatusNotFound, kubebindv1alpha2.ErrorCodeResourceNotFound, err.Error() + } + if apierrors.IsUnauthorized(err) { + return http.StatusUnauthorized, kubebindv1alpha2.ErrorCodeAuthenticationFailed, err.Error() + } + if apierrors.IsForbidden(err) { + return http.StatusForbidden, kubebindv1alpha2.ErrorCodeAuthorizationFailed, err.Error() + } + if apierrors.IsBadRequest(err) { + return http.StatusBadRequest, kubebindv1alpha2.ErrorCodeBadRequest, err.Error() + } + // Default to internal server error + return http.StatusInternalServerError, kubebindv1alpha2.ErrorCodeInternalError, err.Error() +} + +func NewAuthMiddleware( + jwtService *JWTService, + cookieSigningKey, cookieEncryptionKey []byte, + kubernetesMananger *kubernetes.Manager, + sessionStore session.Store, +) *AuthMiddleware { return &AuthMiddleware{ jwtService: jwtService, cookieSigningKey: cookieSigningKey, cookieEncryptionKey: cookieEncryptionKey, + kubernetesMananger: kubernetesMananger, + sessionStore: sessionStore, } } func (am *AuthMiddleware) AuthenticateRequest(next http.Handler) http.Handler { + return am.authenticate( + am.verifyState( + am.authorizeK8S(next)), + ) +} + +func (am *AuthMiddleware) authenticate(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { logger := klog.FromContext(r.Context()) @@ -84,7 +134,6 @@ func (am *AuthMiddleware) AuthenticateRequest(next http.Handler) http.Handler { ClusterID: claims.ClusterID, RedirectURL: claims.RedirectURL, } - authCtx.IsValid = true authCtx.ClientType = ClientTypeCLI } else { logger.V(2).Info("Invalid JWT token", "error", err) @@ -93,7 +142,7 @@ func (am *AuthMiddleware) AuthenticateRequest(next http.Handler) http.Handler { } // Fall back to cookie authentication (for UI clients) - if !authCtx.IsValid { + if authCtx.SessionState == nil { cookieName := "kube-bind" if r.URL.Query().Get("cluster_id") != "" { cookieName = "kube-bind-" + r.URL.Query().Get("cluster_id") @@ -102,12 +151,12 @@ func (am *AuthMiddleware) AuthenticateRequest(next http.Handler) http.Handler { s := securecookie.New(am.cookieSigningKey, am.cookieEncryptionKey) state := &session.State{} if err := s.Decode(cookieName, cookie.Value, state); err == nil { + // Only set as valid after all checks pass authCtx.SessionState = state - authCtx.IsValid = true authCtx.ClientType = ClientTypeUI - } else { - logger.V(2).Info("Failed to decode session cookie", "error", err) } + } else { + logger.V(2).Info("Failed to decode session cookie", "error", err) } } @@ -117,6 +166,74 @@ func (am *AuthMiddleware) AuthenticateRequest(next http.Handler) http.Handler { }) } +func (am *AuthMiddleware) verifyState(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + logger := klog.FromContext(r.Context()) + + authCtx := GetAuthContext(r.Context()) + if authCtx.SessionState == nil { + logger.V(2).Info("No session state found in auth context") + writeErrorResponse(w, http.StatusUnauthorized, kubebindv1alpha2.ErrorCodeAuthenticationFailed, "Authentication required", "No valid session found") + return + } + + state := authCtx.SessionState + // Validate session fields are present + switch { + case state.Token.Subject == "" || state.Token.Issuer == "" || state.SessionID == "": + logger.V(2).Info("Invalid session state: missing required fields") + writeErrorResponse(w, http.StatusUnauthorized, kubebindv1alpha2.ErrorCodeAuthenticationFailed, "Authentication required", "Invalid session state: missing required fields") + return + case state.IsExpired(): + logger.V(2).Info("Session expired", "sessionID", state.SessionID) + writeErrorResponse(w, http.StatusUnauthorized, kubebindv1alpha2.ErrorCodeAuthenticationFailed, "Authentication required", "Session has expired") + return + case !am.isValidSession(state.SessionID): + logger.V(2).Info("Session ID not found or expired", "sessionID", state.SessionID) + writeErrorResponse(w, http.StatusUnauthorized, kubebindv1alpha2.ErrorCodeAuthenticationFailed, "Authentication required", "Session ID not found or expired") + return + default: + // Session is valid + authCtx.IsValid = true + } + ctx := context.WithValue(r.Context(), AuthContextKey, authCtx) + next.ServeHTTP(w, r.WithContext(ctx)) + }) +} + +// isValidSession checks if a session ID exists and hasn't expired +func (am *AuthMiddleware) isValidSession(sessionID string) bool { + sessionInfo, err := am.sessionStore.Load(sessionID) + if err != nil { + return false + } + return time.Now().Before(sessionInfo.ExpiresAt) +} + +func (am *AuthMiddleware) authorizeK8S(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + logger := klog.FromContext(r.Context()) + + authCtx := GetAuthContext(r.Context()) + if !authCtx.IsValid { // should not happen if AuthenticateRequest is used before + logger.V(2).Info("Authentication context is not valid") + writeErrorResponse(w, http.StatusUnauthorized, kubebindv1alpha2.ErrorCodeAuthenticationFailed, "Authentication required", "Authentication context is not valid") + return + } + + // Authorize against Kubernetes RBAC + err := am.kubernetesMananger.AuthorizeRequest(r.Context(), authCtx.SessionState.Token.Subject, authCtx.SessionState.Token.Groups, authCtx.SessionState.ClusterID, r.Method, r.URL.Path) + if err != nil { + logger.V(2).Info("Kubernetes RBAC authorization failed", "error", err) + statusCode, code, details := mapErrorToCode(err) + writeErrorResponse(w, statusCode, code, "Cluster authorization failed. Missing required permissions in the cluster to access bindings.", details) + return + } + + next.ServeHTTP(w, r) + }) +} + func GetAuthContext(ctx context.Context) *AuthContext { if authCtx, ok := ctx.Value(AuthContextKey).(*AuthContext); ok { return authCtx @@ -129,14 +246,9 @@ func RequireAuth(next http.Handler) http.Handler { authCtx := GetAuthContext(r.Context()) if !authCtx.IsValid { if authCtx.ClientType == ClientTypeCLI { - w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusUnauthorized) - err := json.NewEncoder(w).Encode(map[string]string{"error": "unauthorized", "message": "Valid JWT token required"}) - if err != nil { - http.Error(w, "internal error", http.StatusInternalServerError) - } + writeErrorResponse(w, http.StatusUnauthorized, kubebindv1alpha2.ErrorCodeAuthenticationFailed, "Authentication required", "Valid JWT token required") } else { - http.Error(w, "unauthorized", http.StatusUnauthorized) + writeErrorResponse(w, http.StatusUnauthorized, kubebindv1alpha2.ErrorCodeAuthenticationFailed, "Authentication required", "Valid authentication credentials required") } return } diff --git a/backend/config.go b/backend/config.go index e0a0cce26..a5858e402 100644 --- a/backend/config.go +++ b/backend/config.go @@ -22,9 +22,9 @@ import ( "net/url" "strings" - apisv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1" - apisv1alpha2 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha2" "github.com/kcp-dev/multicluster-provider/apiexport" + apisv1alpha1 "github.com/kcp-dev/sdk/apis/apis/v1alpha1" + apisv1alpha2 "github.com/kcp-dev/sdk/apis/apis/v1alpha2" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" @@ -39,6 +39,7 @@ import ( kuberesources "github.com/kube-bind/kube-bind/backend/kubernetes/resources" "github.com/kube-bind/kube-bind/backend/options" + kcpprovider "github.com/kube-bind/kube-bind/backend/provider/kcp" kubebindv1alpha1 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha1" kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) @@ -70,10 +71,6 @@ func NewConfig(options *options.CompletedOptions) (*Config, error) { config.ClientConfig = rest.CopyConfig(config.ClientConfig) config.ClientConfig = rest.AddUserAgent(config.ClientConfig, "kube-bind-backend") - if options.ServerURL != "" { - config.ClientConfig.Host = options.ServerURL - } - // Set up controller-runtime manager scheme := runtime.NewScheme() if err := clientgoscheme.AddToScheme(scheme); err != nil { @@ -93,13 +90,16 @@ func NewConfig(options *options.CompletedOptions) (*Config, error) { switch options.Provider { case "kcp": + if options.ProviderKcp == nil { + return nil, fmt.Errorf("kcp provider options must be provided when provider is kcp") + } if err := apisv1alpha1.AddToScheme(scheme); err != nil { return nil, fmt.Errorf("error adding apis scheme: %w", err) } if err := apisv1alpha2.AddToScheme(scheme); err != nil { return nil, fmt.Errorf("error adding apis scheme: %w", err) } - provider, err := apiexport.New(config.ClientConfig, apiexport.Options{ + provider, err := kcpprovider.New(config.ClientConfig, options.ProviderKcp.APIExportEndpointSliceName, apiexport.Options{ Scheme: scheme, }) if err != nil { diff --git a/backend/controllers/cluster/cluster_controller.go b/backend/controllers/cluster/cluster_controller.go new file mode 100644 index 000000000..b46f1348e --- /dev/null +++ b/backend/controllers/cluster/cluster_controller.go @@ -0,0 +1,128 @@ +/* +Copyright 2025 The Kube Bind Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster + +import ( + "context" + "fmt" + "reflect" + + rbacv1 "k8s.io/api/rbac/v1" + "k8s.io/apimachinery/pkg/api/errors" + ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/controller" + "sigs.k8s.io/controller-runtime/pkg/log" + mcbuilder "sigs.k8s.io/multicluster-runtime/pkg/builder" + mcmanager "sigs.k8s.io/multicluster-runtime/pkg/manager" + mcreconcile "sigs.k8s.io/multicluster-runtime/pkg/reconcile" + + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" +) + +const ( + controllerName = "kube-bind-backend-cluster" +) + +// ClusterReconciler reconciles a Cluster object. +type ClusterReconciler struct { + manager mcmanager.Manager + opts controller.TypedOptions[mcreconcile.Request] + reconciler reconciler +} + +// NewClusterReconciler returns a new ClusterReconciler to reconcile Clusters +// ands its resources. +func NewClusterReconciler( + _ context.Context, + mgr mcmanager.Manager, + opts controller.TypedOptions[mcreconcile.Request], + allowedGroups []string, + allowedUsers []string, +) (*ClusterReconciler, error) { + r := &ClusterReconciler{ + manager: mgr, + opts: opts, + reconciler: reconciler{ + allowedGroups: allowedGroups, + allowedUsers: allowedUsers, + }, + } + + return r, nil +} + +//+kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterroles,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=clusterrolebindings,verbs=get;list;watch;create;update;patch;delete + +// Reconcile is part of the main kubernetes reconciliation loop which aims to +// move the current state of the cluster closer to the desired state. +func (r *ClusterReconciler) Reconcile(ctx context.Context, req mcreconcile.Request) (ctrl.Result, error) { + logger := log.FromContext(ctx) + logger.Info("Reconciling Cluster", "request", req) + + cl, err := r.manager.GetCluster(ctx, req.ClusterName) + if err != nil { + return ctrl.Result{}, fmt.Errorf("failed to get client for cluster %q: %w", req.ClusterName, err) + } + + client := cl.GetClient() + cache := cl.GetCache() + + // Fetch the Cluster instance + cluster := &kubebindv1alpha2.Cluster{} + if err := client.Get(ctx, req.NamespacedName, cluster); err != nil { + if errors.IsNotFound(err) { + // Request object not found, could have been deleted after reconcile request. + logger.Info("Cluster not found, skipping reconciliation") + return ctrl.Result{}, nil + } + // Error reading the object - requeue the request. + return ctrl.Result{}, fmt.Errorf("failed to get Cluster: %w", err) + } + + // Create a copy to modify + original := cluster.DeepCopy() + // Run the reconciliation logic + if err := r.reconciler.reconcile(ctx, client, cache, cluster); err != nil { + logger.Error(err, "Failed to reconcile Cluster") + return ctrl.Result{}, err + } + + // Update status if it has changed + if !reflect.DeepEqual(original, cluster) { + err := client.Update(ctx, cluster) + if err != nil { + logger.Error(err, "Failed to update Cluster status") + return ctrl.Result{}, fmt.Errorf("failed to update Cluster status: %w", err) + } + logger.Info("Cluster status updated") + } + + return ctrl.Result{}, nil +} + +// SetupWithManager sets up the controller with the Manager. +func (r *ClusterReconciler) SetupWithManager(mgr mcmanager.Manager) error { + return mcbuilder.ControllerManagedBy(mgr). + For(&kubebindv1alpha2.Cluster{}). + Owns(&rbacv1.ClusterRole{}). + Owns(&rbacv1.ClusterRoleBinding{}). + Owns(&rbacv1.RoleBinding{}). + WithOptions(r.opts). + Named(controllerName). + Complete(r) +} diff --git a/backend/controllers/cluster/cluster_reconcile.go b/backend/controllers/cluster/cluster_reconcile.go new file mode 100644 index 000000000..ca946a7fa --- /dev/null +++ b/backend/controllers/cluster/cluster_reconcile.go @@ -0,0 +1,135 @@ +/* +Copyright 2025 The Kube Bind Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cluster + +import ( + "context" + + rbacv1 "k8s.io/api/rbac/v1" + "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/types" + utilerrors "k8s.io/apimachinery/pkg/util/errors" + "sigs.k8s.io/controller-runtime/pkg/cache" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" + + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" +) + +type reconciler struct { + allowedGroups []string + allowedUsers []string +} + +func (r *reconciler) reconcile(ctx context.Context, client client.Client, _ cache.Cache, cluster *kubebindv1alpha2.Cluster) error { + var errs []error + + if err := r.ensureOIDCRBAC(ctx, client, cluster); err != nil { + errs = append(errs, err) + } + + return utilerrors.NewAggregate(errs) +} + +func (r *reconciler) ensureOIDCRBAC(ctx context.Context, client client.Client, cluster *kubebindv1alpha2.Cluster) error { + if err := r.ensureUserClusterRole(ctx, client, cluster); err != nil { + return err + } + return r.ensureUserClusterRoleBinding(ctx, client, cluster) +} + +func (r *reconciler) ensureUserClusterRole(ctx context.Context, client client.Client, cluster *kubebindv1alpha2.Cluster) error { + clusterRole := &rbacv1.ClusterRole{ + ObjectMeta: metav1.ObjectMeta{ + Name: "kube-bind-oidc-user", + }, + Rules: []rbacv1.PolicyRule{ + { + APIGroups: []string{"kube-bind.io"}, + Resources: []string{"*"}, + Verbs: []string{"bind"}, + }, + { + NonResourceURLs: []string{"/", "/api", "/api/*", "/apis", "/apis/*"}, + Verbs: []string{"access"}, + }, + }, + } + + if err := controllerutil.SetControllerReference(cluster, clusterRole, client.Scheme()); err != nil { + return err + } + + var existing rbacv1.ClusterRole + err := client.Get(ctx, types.NamespacedName{Name: "kube-bind-oidc-user"}, &existing) + if err != nil { + if errors.IsNotFound(err) { + return client.Create(ctx, clusterRole) + } + return err + } + + existing.Rules = clusterRole.Rules + existing.OwnerReferences = clusterRole.OwnerReferences + return client.Update(ctx, &existing) +} + +func (r *reconciler) ensureUserClusterRoleBinding(ctx context.Context, client client.Client, cluster *kubebindv1alpha2.Cluster) error { + clusterRoleBinding := &rbacv1.ClusterRoleBinding{ + ObjectMeta: metav1.ObjectMeta{ + Name: "kube-bind-oidc-user", + }, + RoleRef: rbacv1.RoleRef{ + APIGroup: "rbac.authorization.k8s.io", + Kind: "ClusterRole", + Name: "kube-bind-oidc-user", + }, + } + + for _, group := range r.allowedGroups { + clusterRoleBinding.Subjects = append(clusterRoleBinding.Subjects, rbacv1.Subject{ + Kind: "Group", + Name: group, + }) + } + + for _, user := range r.allowedUsers { + clusterRoleBinding.Subjects = append(clusterRoleBinding.Subjects, rbacv1.Subject{ + Kind: "User", + Name: user, + }) + } + + if err := controllerutil.SetControllerReference(cluster, clusterRoleBinding, client.Scheme()); err != nil { + return err + } + + var existing rbacv1.ClusterRoleBinding + err := client.Get(ctx, types.NamespacedName{Name: "kube-bind-oidc-user"}, &existing) + if err != nil { + if errors.IsNotFound(err) { + return client.Create(ctx, clusterRoleBinding) + } + return err + } + + existing.RoleRef = clusterRoleBinding.RoleRef + existing.Subjects = clusterRoleBinding.Subjects + existing.OwnerReferences = clusterRoleBinding.OwnerReferences + return client.Update(ctx, &existing) +} diff --git a/backend/http/handler.go b/backend/http/handler.go index cd696e46e..644e17557 100644 --- a/backend/http/handler.go +++ b/backend/http/handler.go @@ -26,6 +26,7 @@ import ( "time" "github.com/gorilla/mux" + apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" componentbaseversion "k8s.io/component-base/version" @@ -35,6 +36,7 @@ import ( "github.com/kube-bind/kube-bind/backend/client" "github.com/kube-bind/kube-bind/backend/kubernetes" "github.com/kube-bind/kube-bind/backend/oidc" + "github.com/kube-bind/kube-bind/backend/session" "github.com/kube-bind/kube-bind/backend/spaserver" bindversion "github.com/kube-bind/kube-bind/pkg/version" kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" @@ -48,6 +50,36 @@ var noCacheHeaders = map[string]string{ "X-Accel-Expires": "0", // https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/ } +// writeErrorResponse writes a structured error response to the HTTP response writer +func writeErrorResponse(w http.ResponseWriter, statusCode int, code, message, details string) { + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(statusCode) + + errorResponse := kubebindv1alpha2.NewError(code, message, details) + if err := json.NewEncoder(w).Encode(errorResponse); err != nil { + // Fallback to plain text if JSON encoding fails + http.Error(w, message, statusCode) + } +} + +// mapErrorToCode maps common errors to structured error codes +func mapErrorToCode(err error) (statusCode int, code string, details string) { + if apierrors.IsNotFound(err) { + return http.StatusNotFound, kubebindv1alpha2.ErrorCodeResourceNotFound, err.Error() + } + if apierrors.IsUnauthorized(err) { + return http.StatusUnauthorized, kubebindv1alpha2.ErrorCodeAuthenticationFailed, err.Error() + } + if apierrors.IsForbidden(err) { + return http.StatusForbidden, kubebindv1alpha2.ErrorCodeAuthorizationFailed, err.Error() + } + if apierrors.IsBadRequest(err) { + return http.StatusBadRequest, kubebindv1alpha2.ErrorCodeBadRequest, err.Error() + } + // Default to internal server error + return http.StatusInternalServerError, kubebindv1alpha2.ErrorCodeInternalError, err.Error() +} + type handler struct { oidcProvider auth.OIDCProvider authHandler auth.AuthHandlerInterface @@ -86,11 +118,13 @@ func NewHandler( return nil, fmt.Errorf("failed to create JWT service: %w", err) } - // Create auth handler with OIDC provider - authHandler := auth.NewAuthHandler(oidcProvider, jwtService, cookieSigningKey, cookieEncryptionKey) + sessionStore := session.NewInMemoryStore() // Create auth middleware for request authentication - authMiddleware := auth.NewAuthMiddleware(jwtService, cookieSigningKey, cookieEncryptionKey) + authMiddleware := auth.NewAuthMiddleware(jwtService, cookieSigningKey, cookieEncryptionKey, mgr, sessionStore) + + // Create auth handler with OIDC provider + authHandler := auth.NewAuthHandler(oidcProvider, jwtService, cookieSigningKey, cookieEncryptionKey, sessionStore) return &handler{ oidcProvider: oidcProvider, @@ -239,7 +273,7 @@ func (h *handler) handleServiceExport(w http.ResponseWriter, r *http.Request) { bs, err := json.Marshal(provider) if err != nil { logger.Error(err, "failed to marshal provider") - http.Error(w, err.Error(), http.StatusInternalServerError) + writeErrorResponse(w, http.StatusInternalServerError, kubebindv1alpha2.ErrorCodeInternalError, "Failed to marshal provider information", err.Error()) return } @@ -252,13 +286,20 @@ func (h *handler) handleTemplates(w http.ResponseWriter, r *http.Request) { prepareNoCache(w) logger.Info("getting templates") + authenticated := auth.GetAuthContext(r.Context()).IsValid + if !authenticated { + logger.Info("unauthenticated request to get templates") + writeErrorResponse(w, http.StatusUnauthorized, kubebindv1alpha2.ErrorCodeAuthenticationFailed, "Authentication required", "Valid authentication credentials are required to access templates") + return + } + params := client.GetQueryParams(r) templates, err := h.listTemplates(r.Context(), params.ClusterID) if err != nil { logger.Error(err, "failed to get template resources") - http.Error(w, "internal error", http.StatusInternalServerError) - + statusCode, code, details := mapErrorToCode(err) + writeErrorResponse(w, statusCode, code, "Failed to retrieve templates", details) return } @@ -266,7 +307,7 @@ func (h *handler) handleTemplates(w http.ResponseWriter, r *http.Request) { // For UI, return direct result as before if err := json.NewEncoder(w).Encode(templates); err != nil { logger.Error(err, "failed to encode JSON response") - http.Error(w, "internal error", http.StatusInternalServerError) + writeErrorResponse(w, http.StatusInternalServerError, kubebindv1alpha2.ErrorCodeInternalError, "Failed to encode response", err.Error()) } } @@ -280,7 +321,8 @@ func (h *handler) handleCollections(w http.ResponseWriter, r *http.Request) { collections, err := h.listCollections(r.Context(), params.ClusterID) if err != nil { logger.Error(err, "failed to get collection resources") - http.Error(w, "internal error", http.StatusInternalServerError) + statusCode, code, details := mapErrorToCode(err) + writeErrorResponse(w, statusCode, code, "Failed to retrieve collections", details) return } @@ -288,7 +330,7 @@ func (h *handler) handleCollections(w http.ResponseWriter, r *http.Request) { // For UI, return direct result as before if err := json.NewEncoder(w).Encode(collections); err != nil { logger.Error(err, "failed to encode JSON response") - http.Error(w, "internal error", http.StatusInternalServerError) + writeErrorResponse(w, http.StatusInternalServerError, kubebindv1alpha2.ErrorCodeInternalError, "Failed to encode response", err.Error()) } } @@ -305,7 +347,8 @@ func (h *handler) handleBind(w http.ResponseWriter, r *http.Request) { kfg, err := h.kubeManager.HandleResources(r.Context(), state.Token.Subject+"#"+state.ClusterID, params.ClusterID) if err != nil { logger.Error(err, "failed to handle resources") - http.Error(w, "internal error", http.StatusInternalServerError) + statusCode, code, details := mapErrorToCode(err) + writeErrorResponse(w, statusCode, code, "Failed to handle cluster resources", details) return } @@ -317,9 +360,9 @@ func (h *handler) handleBind(w http.ResponseWriter, r *http.Request) { logger.Error(err, "failed to parse JSON request body") var maxBytesError *http.MaxBytesError if errors.As(err, &maxBytesError) { - http.Error(w, "request body too large", http.StatusRequestEntityTooLarge) + writeErrorResponse(w, http.StatusRequestEntityTooLarge, kubebindv1alpha2.ErrorCodeBadRequest, "Request body too large", "The request body exceeds the maximum allowed size") } else { - http.Error(w, "invalid JSON request body", http.StatusBadRequest) + writeErrorResponse(w, http.StatusBadRequest, kubebindv1alpha2.ErrorCodeBadRequest, "Invalid JSON request body", err.Error()) } return } @@ -328,7 +371,8 @@ func (h *handler) handleBind(w http.ResponseWriter, r *http.Request) { template, err := h.kubeManager.GetTemplates(r.Context(), params.ClusterID, bindRequest.TemplateRef.Name) if err != nil { logger.Error(err, "failed to get template", "template", bindRequest.TemplateRef.Name, "cluster", params.ClusterID) - http.Error(w, "internal error", http.StatusInternalServerError) + statusCode, code, details := mapErrorToCode(err) + writeErrorResponse(w, statusCode, code, "Failed to retrieve template", details) return } @@ -351,7 +395,7 @@ func (h *handler) handleBind(w http.ResponseWriter, r *http.Request) { requestBytes, err := json.Marshal(&request) if err != nil { logger.Error(err, "failed to marshal request") - http.Error(w, "internal error", http.StatusInternalServerError) + writeErrorResponse(w, http.StatusInternalServerError, kubebindv1alpha2.ErrorCodeInternalError, "Failed to marshal request", err.Error()) return } @@ -373,7 +417,7 @@ func (h *handler) handleBind(w http.ResponseWriter, r *http.Request) { payload, err := json.Marshal(&response) if err != nil { logger.Error(err, "failed to marshal binding response") - http.Error(w, "internal error", http.StatusInternalServerError) + writeErrorResponse(w, http.StatusInternalServerError, kubebindv1alpha2.ErrorCodeInternalError, "Failed to marshal binding response", err.Error()) return } @@ -408,7 +452,7 @@ func (h *handler) handleBindableResources(w http.ResponseWriter, r *http.Request bs, err := json.Marshal(&kubebindv1alpha2.ClaimableAPIs) if err != nil { logger.Error(err, "failed to marshal resources") - http.Error(w, "internal error", http.StatusInternalServerError) + writeErrorResponse(w, http.StatusInternalServerError, kubebindv1alpha2.ErrorCodeInternalError, "Failed to marshal bindable resources", err.Error()) return } diff --git a/backend/kubernetes/manager.go b/backend/kubernetes/manager.go index d7846e5fd..cf5cc8a27 100644 --- a/backend/kubernetes/manager.go +++ b/backend/kubernetes/manager.go @@ -21,13 +21,16 @@ import ( "fmt" "strings" + authzv1 "k8s.io/api/authorization/v1" corev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" + authorizationv1 "k8s.io/client-go/kubernetes/typed/authorization/v1" "k8s.io/klog/v2" "sigs.k8s.io/controller-runtime/pkg/client" mcmanager "sigs.k8s.io/multicluster-runtime/pkg/manager" @@ -240,3 +243,71 @@ func (m *Manager) ListDynamicResources(ctx context.Context, cluster string, gvk return list, nil } + +func (m *Manager) AuthorizeRequest(ctx context.Context, subject string, groups []string, cluster, method, path string) error { + logger := klog.FromContext(ctx).WithValues("subject", subject, "cluster", cluster, "method", method, "path", path, "groups", groups) + + cl, err := m.manager.GetCluster(ctx, cluster) + if err != nil { + return err + } + cfg := cl.GetConfig() + + // Create the authorization clientset + authClient, err := authorizationv1.NewForConfig(cfg) + if err != nil { + return err + } + + groups = append(groups, "system:authenticated") + + // Check if user has access to create pods (basic permission test) + sar := &authzv1.SubjectAccessReview{ + Spec: authzv1.SubjectAccessReviewSpec{ + User: subject, + Groups: groups, + ResourceAttributes: &authzv1.ResourceAttributes{ + Verb: "bind", + Group: "kube-bind.io", + }, + }, + } + // Perform the SubjectAccessReview using the specific clientset + sarResponse, err := authClient.SubjectAccessReviews().Create(ctx, sar, metav1.CreateOptions{}) + if err != nil { + logger.Error(err, "Failed to create SubjectAccessReview") + return err + } + + if sarResponse.Status.Allowed { + logger.Info("User is allowed to bind", "user", subject) + // Proceed with your controller logic + } else { + logger.Info("User is not allowed to bind", "user", subject, "reason", sarResponse.Status) + // Return a structured authorization error + return errors.NewForbidden( + schema.GroupResource{Group: "kube-bind.io", Resource: "bind"}, + "", + fmt.Errorf("user %q is not authorized to bind resources: %s", subject, sarResponse.Status.Reason), + ) + } + return nil +} + +func (m *Manager) SeedDefaultCluster(ctx context.Context) error { + logger := klog.FromContext(ctx) + + cl, err := m.manager.GetCluster(ctx, "") + if err != nil { + return err + } + c := cl.GetClient() + + _, err = kuberesources.CreateDefaultCluster(ctx, c) + if err != nil && !errors.IsAlreadyExists(err) { + logger.Error(err, "Failed to create default Cluster resource") + return err + } + logger.Info("Default Cluster resource ensured") + return nil +} diff --git a/backend/kubernetes/resources/cluster.go b/backend/kubernetes/resources/cluster.go new file mode 100644 index 000000000..c449739ec --- /dev/null +++ b/backend/kubernetes/resources/cluster.go @@ -0,0 +1,43 @@ +/* +Copyright 2025 The Kube Bind Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package resources + +import ( + "context" + + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "sigs.k8s.io/controller-runtime/pkg/client" + + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" +) + +func CreateDefaultCluster(ctx context.Context, c client.Client) (*kubebindv1alpha2.Cluster, error) { + cluster := &kubebindv1alpha2.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: kubebindv1alpha2.DefaultClusterName, + }, + Spec: kubebindv1alpha2.ClusterSpec{}, + } + + err := c.Create(ctx, cluster) + if err != nil && !apierrors.IsAlreadyExists(err) { + return nil, err + } + + return cluster, nil +} diff --git a/backend/oidc/oidc.go b/backend/oidc/oidc.go index a617b6047..bf2b8c914 100644 --- a/backend/oidc/oidc.go +++ b/backend/oidc/oidc.go @@ -47,15 +47,28 @@ func New(caBundleFile string, listener net.Listener, addrOverride string) (*Serv s.tlsConfig = tlsConfig } + statisUserProvider := NewStaticUserProvider() + statisUserProvider.Set(&mockoidc.MockUser{ + Subject: "kube-bind-embedded-user", + Email: "embedded@kube-bind.io", + PreferredUsername: "kube-bind", + Phone: "+1234567890", + Address: "123 Kube St, Bind City, KB 12345", + Groups: []string{"engineering", "devops"}, + EmailVerified: true, + }) + server, err := mockoidc.NewServer(&mockoidc.ServerConfig{ TLSConfig: tlsConfig, Listener: listener, AddrOverride: addrOverride, + UserProvider: statisUserProvider, }) if err != nil { return nil, fmt.Errorf("failed to create mock OIDC server: %w", err) } s.server = server + return s, nil } diff --git a/backend/oidc/oidc_test.go b/backend/oidc/oidc_test.go index 329360658..8467e8cdd 100644 --- a/backend/oidc/oidc_test.go +++ b/backend/oidc/oidc_test.go @@ -23,7 +23,7 @@ import ( "strings" "testing" - "github.com/kcp-dev/kcp/sdk/testing/third_party/library-go/crypto" + "github.com/kcp-dev/sdk/testing/third_party/library-go/crypto" "github.com/xrstf/mockoidc" ) diff --git a/backend/oidc/user.go b/backend/oidc/user.go new file mode 100644 index 000000000..f60c47c62 --- /dev/null +++ b/backend/oidc/user.go @@ -0,0 +1,39 @@ +/* +Copyright 2025 The Kube Bind Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package oidc + +import "github.com/xrstf/mockoidc" + +var _ mockoidc.UserProvider = (*staticUserProvider)(nil) + +type staticUserProvider struct { + user mockoidc.User +} + +func (s *staticUserProvider) Get() mockoidc.User { + return s.user +} + +func (s *staticUserProvider) Set(user mockoidc.User) { + s.user = user +} + +func NewStaticUserProvider() *staticUserProvider { + return &staticUserProvider{ + user: &mockoidc.MockUser{}, + } +} diff --git a/backend/options/oidc.go b/backend/options/oidc.go index 5e3bc8c61..ab36540fa 100644 --- a/backend/options/oidc.go +++ b/backend/options/oidc.go @@ -24,13 +24,7 @@ import ( "github.com/spf13/pflag" "github.com/kube-bind/kube-bind/backend/oidc" -) - -type OIDCType string - -const ( - OIDCTypeEmbedded OIDCType = "embedded" - OIDCTypeExternal OIDCType = "external" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) type OIDC struct { @@ -45,11 +39,19 @@ type OIDC struct { // TLSConfig is set if an embedded OIDC server is used. TLSConfig *tls.Config OIDCServer *oidc.Server + + // If specified, bindings will be provisioned for these permissions in each cluster kube-bind manages. + // In additon, if type is embedded, embedded groups will added automatically. + + // AllowedGroups is a list of groups allowed to access bindings inside the cluster + AllowedGroups []string + // AllowedUsers is a list of users allowed to access bindings inside the cluster + AllowedUsers []string } func NewOIDC() *OIDC { return &OIDC{ - Type: string(OIDCTypeExternal), + Type: string(kubebindv1alpha2.OIDCProviderTypeExternal), } } @@ -61,10 +63,12 @@ func (options *OIDC) AddFlags(fs *pflag.FlagSet) { fs.StringVar(&options.AuthorizeURL, "oidc-authorize-url", options.AuthorizeURL, "OpenID authorize URL") fs.StringVar(&options.CAFile, "oidc-ca-file", options.CAFile, "Path to a CA bundle to use when verifying the OIDC provider's TLS certificate.") fs.StringVar(&options.Type, "oidc-type", options.Type, "Type of OIDC provider (embedded or external)") + fs.StringSliceVar(&options.AllowedGroups, "oidc-allowed-groups", options.AllowedGroups, "List of groups allowed to access bindings inside the cluster. If using embedded OIDC provider, system:authenticated will be added automatically.") + fs.StringSliceVar(&options.AllowedUsers, "oidc-allowed-users", options.AllowedUsers, "List of users allowed to access bindings inside the cluster") } func (options *OIDC) Complete(listener net.Listener) error { - if options.Type == string(OIDCTypeEmbedded) { + if options.Type == string(kubebindv1alpha2.OIDCProviderTypeEmbedded) { oidcServer, err := oidc.New(options.CAFile, listener, options.IssuerURL) if err != nil { return err @@ -81,6 +85,8 @@ func (options *OIDC) Complete(listener net.Listener) error { options.IssuerClientSecret = cfg.ClientSecret // This should be provided from outside, but in embedded - we detect. options.CallbackURL = cfg.CallbackURL + + options.AllowedGroups = append(options.AllowedGroups, "system:authenticated") } if options.CAFile != "" { @@ -111,5 +117,13 @@ func (options *OIDC) Validate() error { return fmt.Errorf("cannot use both CA file and embedded OIDC server") } + if options.Type != string(kubebindv1alpha2.OIDCProviderTypeEmbedded) && options.Type != string(kubebindv1alpha2.OIDCProviderTypeExternal) { + return fmt.Errorf("invalid OIDC provider type: %s", options.Type) + } + + if options.Type == string(kubebindv1alpha2.OIDCProviderTypeExternal) && len(options.AllowedGroups) == 0 && len(options.AllowedUsers) == 0 { + return fmt.Errorf("when using external OIDC provider, at least one of allowed groups or allowed users must be specified") + } + return nil } diff --git a/backend/options/options.go b/backend/options/options.go index d4d1eb1cf..18ba5bbc6 100644 --- a/backend/options/options.go +++ b/backend/options/options.go @@ -27,6 +27,7 @@ import ( "k8s.io/component-base/logs" logsv1 "k8s.io/component-base/logs/api/v1" + providerkcp "github.com/kube-bind/kube-bind/backend/provider/kcp/options" kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" ) @@ -36,14 +37,15 @@ type Options struct { Cookie *Cookie Serve *Serve + ProviderKcp *providerkcp.Options + ExtraOptions } type ExtraOptions struct { KubeConfig string - Provider string - ServerURL string + Provider string NamespacePrefix string PrettyName string @@ -73,6 +75,9 @@ type completedOptions struct { Cookie *Cookie Serve *Serve + // Provider specific options + ProviderKcp *providerkcp.CompletedOptions + ExtraOptions } @@ -85,11 +90,12 @@ func NewOptions() *Options { logs := logs.NewOptions() logs.Verbosity = logsv1.VerbosityLevel(2) - return &Options{ - Logs: logs, - OIDC: NewOIDC(), - Cookie: NewCookie(), - Serve: NewServe(), + opts := &Options{ + Logs: logs, + OIDC: NewOIDC(), + Cookie: NewCookie(), + Serve: NewServe(), + ProviderKcp: providerkcp.NewOptions(), ExtraOptions: ExtraOptions{ Provider: "kubernetes", @@ -97,11 +103,11 @@ func NewOptions() *Options { PrettyName: "Backend", ConsumerScope: string(kubebindv1alpha2.NamespacedScope), ClusterScopedIsolation: string(kubebindv1alpha2.IsolationPrefixed), - ServerURL: "", SchemaSource: CustomResourceDefinitionSource.String(), Frontend: "embedded", // Not used, but indicates to use embedded frontend using SPA. }, } + return opts } var providerAliases = map[string]string{ @@ -135,6 +141,7 @@ func (options *Options) AddFlags(fs *pflag.FlagSet) { options.OIDC.AddFlags(fs) options.Cookie.AddFlags(fs) options.Serve.AddFlags(fs) + options.ProviderKcp.AddFlags(fs) fs.StringVar(&options.KubeConfig, "kubeconfig", options.KubeConfig, "path to a kubeconfig. Only required if out-of-cluster") fs.StringVar(&options.NamespacePrefix, "namespace-prefix", options.NamespacePrefix, "The prefix to use for cluster namespaces") @@ -160,8 +167,6 @@ func (options *Options) AddFlags(fs *pflag.FlagSet) { values), ) - fs.StringVar(&options.ServerURL, "server-url", options.ServerURL, "The URL of the backend server. If not specified, it will be derived from the kubeconfig or service account's hosts.") - fs.StringVar(&options.TestingAutoSelect, "testing-auto-select", options.TestingAutoSelect, ". that is automatically selected on th bind screen for testing") fs.MarkHidden("testing-auto-select") //nolint:errcheck } @@ -209,7 +214,7 @@ func (options *Options) Complete() (*CompletedOptions, error) { } options.ExternalCA = ca } - return &CompletedOptions{ + co := &CompletedOptions{ completedOptions: &completedOptions{ Logs: options.Logs, OIDC: options.OIDC, @@ -217,7 +222,16 @@ func (options *Options) Complete() (*CompletedOptions, error) { Serve: options.Serve, ExtraOptions: options.ExtraOptions, }, - }, nil + } + + if options.Provider == "kcp" { + opts, err := options.ProviderKcp.Complete() + if err != nil { + return nil, err + } + co.completedOptions.ProviderKcp = opts + } + return co, nil } func (options *CompletedOptions) Validate() error { diff --git a/backend/provider/kcp/options/options.go b/backend/provider/kcp/options/options.go new file mode 100644 index 000000000..a7d6e551d --- /dev/null +++ b/backend/provider/kcp/options/options.go @@ -0,0 +1,61 @@ +/* +Copyright 2025 The Kube Bind Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package options + +import ( + "github.com/spf13/pflag" +) + +type Options struct { + ExtraOptions +} + +type ExtraOptions struct { + APIExportEndpointSliceName string +} + +type completedOptions struct { + ExtraOptions +} + +type CompletedOptions struct { + *completedOptions +} + +func NewOptions() *Options { + return &Options{ + ExtraOptions: ExtraOptions{ + APIExportEndpointSliceName: "kube-bind.io", + }, + } +} + +func (options *Options) AddFlags(fs *pflag.FlagSet) { + fs.StringVar(&options.ExtraOptions.APIExportEndpointSliceName, "apiexport-endpointslice-name", options.ExtraOptions.APIExportEndpointSliceName, "name of the APIExport EndpointSlice to watch") +} + +func (options *Options) Complete() (*CompletedOptions, error) { + return &CompletedOptions{ + completedOptions: &completedOptions{ + ExtraOptions: options.ExtraOptions, + }, + }, nil +} + +func (options *CompletedOptions) Validate() error { + return nil +} diff --git a/backend/provider/kcp/provider.go b/backend/provider/kcp/provider.go new file mode 100644 index 000000000..4be8f1ef8 --- /dev/null +++ b/backend/provider/kcp/provider.go @@ -0,0 +1,178 @@ +/* +Copyright 2025 The Kube Bind Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package kcp + +import ( + "context" + "math" + "time" + + "github.com/kcp-dev/logicalcluster/v3" + provider "github.com/kcp-dev/multicluster-provider/apiexport" + "github.com/kcp-dev/multicluster-provider/pkg/handlers" + "github.com/kcp-dev/multicluster-provider/pkg/paths" + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/rest" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/controller-runtime/pkg/cluster" + "sigs.k8s.io/multicluster-runtime/pkg/multicluster" + + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" +) + +var _ multicluster.Provider = &Provider{} +var _ multicluster.ProviderRunnable = &Provider{} +var _ handlers.Handler = &pathHandler{} + +const ( + // LogicalClusterPathAnnotationKey is the annotation key for the logical cluster path + // put on objects that are referenced by path by other objects. + // + // If this annotation exists, the system will maintain the annotation value. + LogicalClusterPathAnnotationKey = "kcp.io/path" +) + +// Provider is a [sigs.k8s.io/multicluster-runtime/pkg/multicluster.Provider] that represents each [logical cluster] +// (in the kcp sense) exposed via a APIExport virtual workspace as a cluster in the [sigs.k8s.io/multicluster-runtime] sense. +// +// Core functionality is delegated to the apiexport.Provider, this wrapper just adds best effort path-awareness index to it via hooks. +// +// [logical cluster]: https://docs.kcp.io/kcp/latest/concepts/terminology/#logical-cluster +type Provider struct { + *provider.Provider + // pathStore maps logical cluster paths to cluster names. + pathStore *paths.Store +} + +// New creates a new kcp virtual workspace provider. The provided [rest.Config] +// must point to a virtual workspace apiserver base path, i.e. up to but without +// the '/clusters/*' suffix. This information can be extracted from an APIExportEndpointSlice status. +func New(cfg *rest.Config, endpointSliceName string, options provider.Options) (*Provider, error) { + store := paths.New() + + h := &pathHandler{ + pathStore: store, + } + options.Handlers = append(options.Handlers, h) + + p, err := provider.New(cfg, endpointSliceName, options) + if err != nil { + return nil, err + } + + return &Provider{ + Provider: p, + pathStore: store, + }, nil +} + +// Get returns the cluster with the given name as a cluster.Cluster. +func (p *Provider) Get(ctx context.Context, clusterName string) (cluster.Cluster, error) { + if p.pathStore != nil { + if lcName, exists := p.pathStore.Get(clusterName); exists { + clusterName = lcName.String() + } + } + return p.Provider.Get(ctx, clusterName) +} + +// IndexField adds an indexer to the clusters managed by this provider. +func (p *Provider) IndexField(ctx context.Context, obj client.Object, field string, extractValue client.IndexerFunc) error { + return p.Provider.IndexField(ctx, obj, field, extractValue) +} + +// Start starts the provider and blocks. +func (p *Provider) Start(ctx context.Context, aware multicluster.Aware) error { + return p.Provider.Start(ctx, &awareWrapper{Aware: aware}) +} + +// awareWrapper wraps a multicluster.Aware to create kube-bind Cluster objects +// so we could bootstrap RBAC for them. +type awareWrapper struct { + multicluster.Aware +} + +func (a *awareWrapper) Engage(ctx context.Context, name string, cluster cluster.Cluster) error { + err := a.Aware.Engage(ctx, name, cluster) + if err != nil { + return err + } + + cl := cluster.GetClient() + + obj := &kubebindv1alpha2.Cluster{ + ObjectMeta: metav1.ObjectMeta{ + Name: kubebindv1alpha2.DefaultClusterName, + }, + Spec: kubebindv1alpha2.ClusterSpec{}, + } + + const maxRetries = 3 + for attempt := 0; attempt < maxRetries; attempt++ { + err = cl.Create(ctx, obj) + if err == nil || apierrors.IsAlreadyExists(err) { + break + } + + if !apierrors.IsForbidden(err) { + return err + } + + if attempt < maxRetries-1 { + backoff := time.Duration(math.Pow(2, float64(attempt))) * time.Second + select { + case <-time.After(backoff): + case <-ctx.Done(): + return ctx.Err() + } + } + } + + if err != nil && !apierrors.IsAlreadyExists(err) { + return err + } + return nil +} + +type pathHandler struct { + pathStore *paths.Store +} + +func (p *pathHandler) OnAdd(obj client.Object) { + cluster := logicalcluster.From(obj) + + path := obj.GetAnnotations()[LogicalClusterPathAnnotationKey] + if path == "" { + return + } + + p.pathStore.Add(path, cluster) +} + +func (p *pathHandler) OnUpdate(oldObj, newObj client.Object) { + // Not used. +} + +func (p *pathHandler) OnDelete(obj client.Object) { + path, ok := obj.GetAnnotations()[LogicalClusterPathAnnotationKey] + if !ok { + return + } + + p.pathStore.Remove(path) +} diff --git a/backend/server.go b/backend/server.go index d17e985f4..da41855b5 100644 --- a/backend/server.go +++ b/backend/server.go @@ -29,6 +29,7 @@ import ( mcreconcile "sigs.k8s.io/multicluster-runtime/pkg/reconcile" "github.com/kube-bind/kube-bind/backend/auth" + "github.com/kube-bind/kube-bind/backend/controllers/cluster" "github.com/kube-bind/kube-bind/backend/controllers/clusterbinding" "github.com/kube-bind/kube-bind/backend/controllers/serviceexport" "github.com/kube-bind/kube-bind/backend/controllers/serviceexportrequest" @@ -55,6 +56,7 @@ type Controllers struct { ServiceExport *serviceexport.APIServiceExportReconciler ServiceExportRequest *serviceexportrequest.APIServiceExportRequestReconciler ServiceNamespace *servicenamespace.APIServiceNamespaceReconciler + Cluster *cluster.ClusterReconciler } func NewServer(ctx context.Context, c *Config) (*Server, error) { @@ -185,6 +187,7 @@ func NewServer(ctx context.Context, c *Config) (*Server, error) { if err := s.ServiceNamespace.SetupWithManager(s.Config.Manager); err != nil { return nil, fmt.Errorf("error setting up APIServiceNamespace controller with manager: %w", err) } + s.ServiceExportRequest, err = serviceexportrequest.NewAPIServiceExportRequestReconciler( ctx, s.Config.Manager, @@ -196,12 +199,24 @@ func NewServer(ctx context.Context, c *Config) (*Server, error) { if err != nil { return nil, fmt.Errorf("error setting up ServiceExportRequest Controller: %w", err) } - - // Register the ServiceExportRequest controller with the manager if err := s.ServiceExportRequest.SetupWithManager(s.Config.Manager); err != nil { return nil, fmt.Errorf("error setting up ServiceExportRequest controller with manager: %w", err) } + s.Cluster, err = cluster.NewClusterReconciler( + ctx, + s.Config.Manager, + opts, + c.Options.OIDC.AllowedGroups, + c.Options.OIDC.AllowedUsers, + ) + if err != nil { + return nil, fmt.Errorf("error setting up LogicalCluster Controller: %w", err) + } + if err := s.Cluster.SetupWithManager(s.Config.Manager); err != nil { + return nil, fmt.Errorf("error setting up LogicalCluster controller with manager: %w", err) + } + return s, nil } @@ -269,9 +284,25 @@ func (s *Server) Run(ctx context.Context) error { } }() + go func() { + // When using native k8s provider/singelton cluster - provider is set to nil + // so we need to seed the default cluster. If provider is set - it is provider responsibility + // to seed the default cluster in each managed cluster either via provider machinery or via provider + // wrapper (see kcp example). + if s.Config.Provider == nil { + if err := s.seedCluster(ctx); err != nil { + logger.Error(err, "Failed to seed default cluster") + } + } + }() + go func() { <-ctx.Done() logger.Info("Context done") }() return s.WebServer.Start(ctx) } + +func (s *Server) seedCluster(ctx context.Context) error { + return s.Kubernetes.SeedDefaultCluster(ctx) +} diff --git a/backend/session/session.go b/backend/session/session.go index ab38cd97b..404a1d39b 100644 --- a/backend/session/session.go +++ b/backend/session/session.go @@ -17,6 +17,8 @@ limitations under the License. package session import ( + "time" + "github.com/vmihailenco/msgpack/v4" ) @@ -31,13 +33,27 @@ type State struct { SessionID string `msgpack:"sid,omitempty"` ClusterID string `msgpack:"cid,omitempty"` RedirectURL string `msgpack:"red,omitempty"` + CreatedAt time.Time `msgpack:"cat,omitempty"` + ExpiresAt time.Time `msgpack:"eat,omitempty"` } type TokenInfo struct { - Subject string `msgpack:"sub,omitempty"` - Issuer string `msgpack:"iss,omitempty"` + Subject string `msgpack:"sub,omitempty"` + Issuer string `msgpack:"iss,omitempty"` + Groups []string `msgpack:"grp,omitempty"` } func (s *State) Encode() ([]byte, error) { return msgpack.Marshal(s) } + +// IsExpired checks if the session has expired +func (s *State) IsExpired() bool { + return !s.ExpiresAt.IsZero() && time.Now().After(s.ExpiresAt) +} + +// SetExpiration sets the session expiration time +func (s *State) SetExpiration(duration time.Duration) { + s.CreatedAt = time.Now() + s.ExpiresAt = s.CreatedAt.Add(duration) +} diff --git a/backend/session/store.go b/backend/session/store.go new file mode 100644 index 000000000..8845f7fc9 --- /dev/null +++ b/backend/session/store.go @@ -0,0 +1,66 @@ +/* +Copyright 2025 The Kube Bind Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package session + +import ( + "fmt" + "sync" +) + +var ErrSessionNotFound = fmt.Errorf("session not found") + +type Store interface { + Save(state *State) error + Load(sessionID string) (*State, error) + Delete(sessionID string) error +} + +type InMemoryStore struct { + lock sync.Mutex + sessions map[string]*State +} + +func NewInMemoryStore() *InMemoryStore { + return &InMemoryStore{ + lock: sync.Mutex{}, + sessions: make(map[string]*State), + } +} + +func (s *InMemoryStore) Save(state *State) error { + s.lock.Lock() + defer s.lock.Unlock() + s.sessions[state.SessionID] = state + return nil +} + +func (s *InMemoryStore) Load(sessionID string) (*State, error) { + s.lock.Lock() + defer s.lock.Unlock() + state, exists := s.sessions[sessionID] + if !exists { + return nil, ErrSessionNotFound + } + return state, nil +} + +func (s *InMemoryStore) Delete(sessionID string) error { + s.lock.Lock() + defer s.lock.Unlock() + delete(s.sessions, sessionID) + return nil +} diff --git a/cli/bind-cli b/cli/bind-cli new file mode 100755 index 000000000..4e9ab7a6a Binary files /dev/null and b/cli/bind-cli differ diff --git a/cli/go.mod b/cli/go.mod index 496f5f5e4..c7b82260e 100644 --- a/cli/go.mod +++ b/cli/go.mod @@ -19,12 +19,12 @@ require ( github.com/spf13/pflag v1.0.9 github.com/stretchr/testify v1.11.1 helm.sh/helm/v3 v3.19.0 - k8s.io/api v0.34.0 - k8s.io/apiextensions-apiserver v0.34.0 - k8s.io/apimachinery v0.34.0 + k8s.io/api v0.34.2 + k8s.io/apiextensions-apiserver v0.34.2 + k8s.io/apimachinery v0.34.2 k8s.io/cli-runtime v0.34.0 - k8s.io/client-go v0.34.0 - k8s.io/component-base v0.34.0 + k8s.io/client-go v0.34.2 + k8s.io/component-base v0.34.2 k8s.io/klog/v2 v2.130.1 sigs.k8s.io/kind v0.30.0 sigs.k8s.io/yaml v1.6.0 @@ -148,7 +148,7 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.2 // indirect - k8s.io/apiserver v0.34.0 // indirect + k8s.io/apiserver v0.34.2 // indirect k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect k8s.io/kubectl v0.34.0 // indirect k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect diff --git a/cli/go.sum b/cli/go.sum index 14b86ad84..ba33b5015 100644 --- a/cli/go.sum +++ b/cli/go.sum @@ -444,20 +444,20 @@ gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= helm.sh/helm/v3 v3.19.0 h1:krVyCGa8fa/wzTZgqw0DUiXuRT5BPdeqE/sQXujQ22k= helm.sh/helm/v3 v3.19.0/go.mod h1:Lk/SfzN0w3a3C3o+TdAKrLwJ0wcZ//t1/SDXAvfgDdc= -k8s.io/api v0.34.0 h1:L+JtP2wDbEYPUeNGbeSa/5GwFtIA662EmT2YSLOkAVE= -k8s.io/api v0.34.0/go.mod h1:YzgkIzOOlhl9uwWCZNqpw6RJy9L2FK4dlJeayUoydug= -k8s.io/apiextensions-apiserver v0.34.0 h1:B3hiB32jV7BcyKcMU5fDaDxk882YrJ1KU+ZSkA9Qxoc= -k8s.io/apiextensions-apiserver v0.34.0/go.mod h1:hLI4GxE1BDBy9adJKxUxCEHBGZtGfIg98Q+JmTD7+g0= -k8s.io/apimachinery v0.34.0 h1:eR1WO5fo0HyoQZt1wdISpFDffnWOvFLOOeJ7MgIv4z0= -k8s.io/apimachinery v0.34.0/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw= -k8s.io/apiserver v0.34.0 h1:Z51fw1iGMqN7uJ1kEaynf2Aec1Y774PqU+FVWCFV3Jg= -k8s.io/apiserver v0.34.0/go.mod h1:52ti5YhxAvewmmpVRqlASvaqxt0gKJxvCeW7ZrwgazQ= +k8s.io/api v0.34.2 h1:fsSUNZhV+bnL6Aqrp6O7lMTy6o5x2C4XLjnh//8SLYY= +k8s.io/api v0.34.2/go.mod h1:MMBPaWlED2a8w4RSeanD76f7opUoypY8TFYkSM+3XHw= +k8s.io/apiextensions-apiserver v0.34.2 h1:WStKftnGeoKP4AZRz/BaAAEJvYp4mlZGN0UCv+uvsqo= +k8s.io/apiextensions-apiserver v0.34.2/go.mod h1:398CJrsgXF1wytdaanynDpJ67zG4Xq7yj91GrmYN2SE= +k8s.io/apimachinery v0.34.2 h1:zQ12Uk3eMHPxrsbUJgNF8bTauTVR2WgqJsTmwTE/NW4= +k8s.io/apimachinery v0.34.2/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw= +k8s.io/apiserver v0.34.2 h1:2/yu8suwkmES7IzwlehAovo8dDE07cFRC7KMDb1+MAE= +k8s.io/apiserver v0.34.2/go.mod h1:gqJQy2yDOB50R3JUReHSFr+cwJnL8G1dzTA0YLEqAPI= k8s.io/cli-runtime v0.34.0 h1:N2/rUlJg6TMEBgtQ3SDRJwa8XyKUizwjlOknT1mB2Cw= k8s.io/cli-runtime v0.34.0/go.mod h1:t/skRecS73Piv+J+FmWIQA2N2/rDjdYSQzEE67LUUs8= -k8s.io/client-go v0.34.0 h1:YoWv5r7bsBfb0Hs2jh8SOvFbKzzxyNo0nSb0zC19KZo= -k8s.io/client-go v0.34.0/go.mod h1:ozgMnEKXkRjeMvBZdV1AijMHLTh3pbACPvK7zFR+QQY= -k8s.io/component-base v0.34.0 h1:bS8Ua3zlJzapklsB1dZgjEJuJEeHjj8yTu1gxE2zQX8= -k8s.io/component-base v0.34.0/go.mod h1:RSCqUdvIjjrEm81epPcjQ/DS+49fADvGSCkIP3IC6vg= +k8s.io/client-go v0.34.2 h1:Co6XiknN+uUZqiddlfAjT68184/37PS4QAzYvQvDR8M= +k8s.io/client-go v0.34.2/go.mod h1:2VYDl1XXJsdcAxw7BenFslRQX28Dxz91U9MWKjX97fE= +k8s.io/component-base v0.34.2 h1:HQRqK9x2sSAsd8+R4xxRirlTjowsg6fWCPwWYeSvogQ= +k8s.io/component-base v0.34.2/go.mod h1:9xw2FHJavUHBFpiGkZoKuYZ5pdtLKe97DEByaA+hHbM= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b h1:MloQ9/bdJyIu9lb1PzujOPolHyvO06MXG5TUIj2mNAA= diff --git a/contrib/kcp/Makefile b/contrib/kcp/Makefile index bfa19dc1a..24262e73a 100644 --- a/contrib/kcp/Makefile +++ b/contrib/kcp/Makefile @@ -18,14 +18,14 @@ export UGET_DIRECTORY := $(ROOT_DIR)/hack/tools export UGET_CHECKSUMS := $(ROOT_DIR)/hack/tools.checksums export UGET_VERSIONED_BINARIES = true -KCP_APIGEN_VERSION := v0.28.0 +KCP_APIGEN_VERSION := 11364df3071c021e96b4ed8c48aa9cd63e8f0115 .PHONY: all all: build .PHONY: install-apigen install-apigen: - @GO_MODULE=true $(ROOT_DIR)/hack/uget.sh github.com/kcp-dev/kcp/sdk/cmd/apigen apigen $(KCP_APIGEN_VERSION) + @GO_MODULE=true $(ROOT_DIR)/hack/uget.sh github.com/kcp-dev/sdk/cmd/apigen apigen $(KCP_APIGEN_VERSION) codegen: ## Generate KCP API resources from CRDs ./hack/update-kcp-codegen.sh diff --git a/contrib/kcp/README.md b/contrib/kcp/README.md index 05fc942da..fccc83614 100644 --- a/contrib/kcp/README.md +++ b/contrib/kcp/README.md @@ -45,7 +45,7 @@ k ws use :root:kube-bind ./bin/backend \ --multicluster-runtime-provider kcp \ - --server-url=$(kubectl get apiexportendpointslice kube-bind.io -o jsonpath="{.status.endpoints[0].url}") \ + --apiexport-endpointslice-name=kube-bind.io \ --pretty-name="BigCorp.com" \ --oidc-type=embedded \ --oidc-issuer-url=http://127.0.0.1:8080/oidc \ diff --git a/contrib/kcp/bootstrap/config.go b/contrib/kcp/bootstrap/config.go index 7ac931f27..cdb874344 100644 --- a/contrib/kcp/bootstrap/config.go +++ b/contrib/kcp/bootstrap/config.go @@ -21,7 +21,7 @@ import ( kcpapiextensionsclientset "github.com/kcp-dev/client-go/apiextensions/client" kcpdynamic "github.com/kcp-dev/client-go/dynamic" - kcpclusterclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster" + kcpclusterclientset "github.com/kcp-dev/sdk/client/clientset/versioned/cluster" "k8s.io/client-go/rest" "k8s.io/client-go/tools/clientcmd" diff --git a/contrib/kcp/bootstrap/config/config/bootstrap.go b/contrib/kcp/bootstrap/config/config/bootstrap.go index 0e168511e..aa1639a4b 100644 --- a/contrib/kcp/bootstrap/config/config/bootstrap.go +++ b/contrib/kcp/bootstrap/config/config/bootstrap.go @@ -23,9 +23,9 @@ import ( kcpapiextensionsclientset "github.com/kcp-dev/client-go/apiextensions/client" kcpdynamic "github.com/kcp-dev/client-go/dynamic" confighelpers "github.com/kcp-dev/kcp/config/helpers" - "github.com/kcp-dev/kcp/sdk/apis/core" - kcpclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster" "github.com/kcp-dev/logicalcluster/v3" + "github.com/kcp-dev/sdk/apis/core" + kcpclientset "github.com/kcp-dev/sdk/client/clientset/versioned/cluster" "k8s.io/apimachinery/pkg/util/sets" ) diff --git a/contrib/kcp/bootstrap/config/core/bootstrap.go b/contrib/kcp/bootstrap/config/core/bootstrap.go index 2512482c8..ec42d3806 100644 --- a/contrib/kcp/bootstrap/config/core/bootstrap.go +++ b/contrib/kcp/bootstrap/config/core/bootstrap.go @@ -21,8 +21,8 @@ import ( kcpapiextensionsclientset "github.com/kcp-dev/client-go/apiextensions/client" kcpdynamic "github.com/kcp-dev/client-go/dynamic" - kcpclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster" "github.com/kcp-dev/logicalcluster/v3" + kcpclientset "github.com/kcp-dev/sdk/client/clientset/versioned/cluster" "k8s.io/apimachinery/pkg/util/sets" "github.com/kube-bind/kube-bind/contrib/kcp/bootstrap/config/core/resources" diff --git a/contrib/kcp/bootstrap/config/core/resources/bootstrap.go b/contrib/kcp/bootstrap/config/core/resources/bootstrap.go index ba05aa175..0fba788a6 100644 --- a/contrib/kcp/bootstrap/config/core/resources/bootstrap.go +++ b/contrib/kcp/bootstrap/config/core/resources/bootstrap.go @@ -21,7 +21,7 @@ import ( "embed" confighelpers "github.com/kcp-dev/kcp/config/helpers" - kcpclientcluster "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster" + kcpclientcluster "github.com/kcp-dev/sdk/client/clientset/versioned/cluster" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/client-go/discovery" diff --git a/contrib/kcp/deploy/bootstrap.go b/contrib/kcp/deploy/bootstrap.go index 8d270d7db..23e8c91cb 100644 --- a/contrib/kcp/deploy/bootstrap.go +++ b/contrib/kcp/deploy/bootstrap.go @@ -23,10 +23,10 @@ import ( kcpapiextensionsclientset "github.com/kcp-dev/client-go/apiextensions/client" kcpdynamic "github.com/kcp-dev/client-go/dynamic" - apisv1alpha2 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha2" - kcpclient "github.com/kcp-dev/kcp/sdk/client/clientset/versioned" - kcpclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster" "github.com/kcp-dev/logicalcluster/v3" + apisv1alpha2 "github.com/kcp-dev/sdk/apis/apis/v1alpha2" + kcpclient "github.com/kcp-dev/sdk/client/clientset/versioned" + kcpclientset "github.com/kcp-dev/sdk/client/clientset/versioned/cluster" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/sets" diff --git a/contrib/kcp/deploy/examples/apiresourceschema-cowboys.yaml b/contrib/kcp/deploy/examples/apiresourceschema-cowboys.yaml index 72f922f5a..e6845bafb 100644 --- a/contrib/kcp/deploy/examples/apiresourceschema-cowboys.yaml +++ b/contrib/kcp/deploy/examples/apiresourceschema-cowboys.yaml @@ -34,9 +34,9 @@ spec: properties: intent: type: string - weapons: + secretRefs: type: array - description: "Array of references to Secrets containing weapon permits and licenses" + description: "Array of references to Secrets containing cowboy credentials" items: type: object properties: diff --git a/contrib/kcp/deploy/examples/rbac-embedded-user.yaml b/contrib/kcp/deploy/examples/rbac-embedded-user.yaml new file mode 100644 index 000000000..1647419dc --- /dev/null +++ b/contrib/kcp/deploy/examples/rbac-embedded-user.yaml @@ -0,0 +1,23 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: kube-bind-embedded-user +rules: +- apiGroups: ["kube-bind.io"] + resources: ["*"] + verbs: ["bind"] +- nonResourceURLs: ["/", "/api", "/api/*", "/apis", "/apis/*"] + verbs: ["access"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: kube-bind-embedded-user +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: kube-bind-embedded-user +subjects: +- kind: User + name: kube-bind-embedded-user + apiGroup: rbac.authorization.k8s.io \ No newline at end of file diff --git a/contrib/kcp/deploy/resources/apiexport-kube-bind.io.yaml b/contrib/kcp/deploy/resources/apiexport-kube-bind.io.yaml index 3a2d03801..6985b44e4 100644 --- a/contrib/kcp/deploy/resources/apiexport-kube-bind.io.yaml +++ b/contrib/kcp/deploy/resources/apiexport-kube-bind.io.yaml @@ -1,7 +1,6 @@ apiVersion: apis.kcp.io/v1alpha2 kind: APIExport metadata: - creationTimestamp: null name: kube-bind.io spec: permissionClaims: @@ -30,6 +29,10 @@ spec: - resource: secrets verbs: - '*' + - group: authorization.k8s.io + resource: subjectaccessreviews + verbs: + - '*' - resource: namespaces verbs: - '*' @@ -87,6 +90,11 @@ spec: schema: v250925-56669b8.clusterbindings.kube-bind.io storage: crd: {} + - group: kube-bind.io + name: clusters + schema: v251215-7d342944.clusters.kube-bind.io + storage: + crd: {} - group: kube-bind.io name: collections schema: v251106-640871f.collections.kube-bind.io diff --git a/contrib/kcp/deploy/resources/apiresourceschema-apiconversions.kube-bind.io.yaml b/contrib/kcp/deploy/resources/apiresourceschema-apiconversions.kube-bind.io.yaml index 31e61fece..9a0b586c0 100644 --- a/contrib/kcp/deploy/resources/apiresourceschema-apiconversions.kube-bind.io.yaml +++ b/contrib/kcp/deploy/resources/apiresourceschema-apiconversions.kube-bind.io.yaml @@ -1,7 +1,6 @@ apiVersion: apis.kcp.io/v1alpha1 kind: APIResourceSchema metadata: - creationTimestamp: null name: v250809-5ed76a1.apiconversions.kube-bind.io spec: conversion: diff --git a/contrib/kcp/deploy/resources/apiresourceschema-apiservicebindings.kube-bind.io.yaml b/contrib/kcp/deploy/resources/apiresourceschema-apiservicebindings.kube-bind.io.yaml index 6139df944..45b826f0a 100644 --- a/contrib/kcp/deploy/resources/apiresourceschema-apiservicebindings.kube-bind.io.yaml +++ b/contrib/kcp/deploy/resources/apiresourceschema-apiservicebindings.kube-bind.io.yaml @@ -1,7 +1,6 @@ apiVersion: apis.kcp.io/v1alpha1 kind: APIResourceSchema metadata: - creationTimestamp: null name: v251112-503d98b.apiservicebindings.kube-bind.io spec: conversion: diff --git a/contrib/kcp/deploy/resources/apiresourceschema-apiserviceexportrequests.kube-bind.io.yaml b/contrib/kcp/deploy/resources/apiresourceschema-apiserviceexportrequests.kube-bind.io.yaml index cda0a2e29..86311c057 100644 --- a/contrib/kcp/deploy/resources/apiresourceschema-apiserviceexportrequests.kube-bind.io.yaml +++ b/contrib/kcp/deploy/resources/apiresourceschema-apiserviceexportrequests.kube-bind.io.yaml @@ -1,7 +1,6 @@ apiVersion: apis.kcp.io/v1alpha1 kind: APIResourceSchema metadata: - creationTimestamp: null name: v251112-503d98b.apiserviceexportrequests.kube-bind.io spec: conversion: diff --git a/contrib/kcp/deploy/resources/apiresourceschema-apiserviceexports.kube-bind.io.yaml b/contrib/kcp/deploy/resources/apiresourceschema-apiserviceexports.kube-bind.io.yaml index 8f07aa0d9..199d1c24b 100644 --- a/contrib/kcp/deploy/resources/apiresourceschema-apiserviceexports.kube-bind.io.yaml +++ b/contrib/kcp/deploy/resources/apiresourceschema-apiserviceexports.kube-bind.io.yaml @@ -1,7 +1,6 @@ apiVersion: apis.kcp.io/v1alpha1 kind: APIResourceSchema metadata: - creationTimestamp: null name: v251112-503d98b.apiserviceexports.kube-bind.io spec: conversion: diff --git a/contrib/kcp/deploy/resources/apiresourceschema-apiserviceexporttemplates.kube-bind.io.yaml b/contrib/kcp/deploy/resources/apiresourceschema-apiserviceexporttemplates.kube-bind.io.yaml index b8388fe0e..d1b35a8fc 100644 --- a/contrib/kcp/deploy/resources/apiresourceschema-apiserviceexporttemplates.kube-bind.io.yaml +++ b/contrib/kcp/deploy/resources/apiresourceschema-apiserviceexporttemplates.kube-bind.io.yaml @@ -1,7 +1,6 @@ apiVersion: apis.kcp.io/v1alpha1 kind: APIResourceSchema metadata: - creationTimestamp: null name: v251112-503d98b.apiserviceexporttemplates.kube-bind.io spec: group: kube-bind.io diff --git a/contrib/kcp/deploy/resources/apiresourceschema-apiservicenamespaces.kube-bind.io.yaml b/contrib/kcp/deploy/resources/apiresourceschema-apiservicenamespaces.kube-bind.io.yaml index 764e11fcc..4056e25a3 100644 --- a/contrib/kcp/deploy/resources/apiresourceschema-apiservicenamespaces.kube-bind.io.yaml +++ b/contrib/kcp/deploy/resources/apiresourceschema-apiservicenamespaces.kube-bind.io.yaml @@ -1,7 +1,6 @@ apiVersion: apis.kcp.io/v1alpha1 kind: APIResourceSchema metadata: - creationTimestamp: null name: v250809-5ed76a1.apiservicenamespaces.kube-bind.io spec: conversion: diff --git a/contrib/kcp/deploy/resources/apiresourceschema-bindableresourcesrequests.kube-bind.io.yaml b/contrib/kcp/deploy/resources/apiresourceschema-bindableresourcesrequests.kube-bind.io.yaml index fe5baa68e..d6259f254 100644 --- a/contrib/kcp/deploy/resources/apiresourceschema-bindableresourcesrequests.kube-bind.io.yaml +++ b/contrib/kcp/deploy/resources/apiresourceschema-bindableresourcesrequests.kube-bind.io.yaml @@ -1,7 +1,6 @@ apiVersion: apis.kcp.io/v1alpha1 kind: APIResourceSchema metadata: - creationTimestamp: null name: v251029-ff0a399.bindableresourcesrequests.kube-bind.io spec: group: kube-bind.io diff --git a/contrib/kcp/deploy/resources/apiresourceschema-boundschemas.kube-bind.io.yaml b/contrib/kcp/deploy/resources/apiresourceschema-boundschemas.kube-bind.io.yaml index a764341d1..ea39d01f1 100644 --- a/contrib/kcp/deploy/resources/apiresourceschema-boundschemas.kube-bind.io.yaml +++ b/contrib/kcp/deploy/resources/apiresourceschema-boundschemas.kube-bind.io.yaml @@ -1,7 +1,6 @@ apiVersion: apis.kcp.io/v1alpha1 kind: APIResourceSchema metadata: - creationTimestamp: null name: v251106-640871f.boundschemas.kube-bind.io spec: conversion: diff --git a/contrib/kcp/deploy/resources/apiresourceschema-clusterbindings.kube-bind.io.yaml b/contrib/kcp/deploy/resources/apiresourceschema-clusterbindings.kube-bind.io.yaml index 85cd9bd1a..d9ac8b6b2 100644 --- a/contrib/kcp/deploy/resources/apiresourceschema-clusterbindings.kube-bind.io.yaml +++ b/contrib/kcp/deploy/resources/apiresourceschema-clusterbindings.kube-bind.io.yaml @@ -1,7 +1,6 @@ apiVersion: apis.kcp.io/v1alpha1 kind: APIResourceSchema metadata: - creationTimestamp: null name: v250925-56669b8.clusterbindings.kube-bind.io spec: conversion: diff --git a/contrib/kcp/deploy/resources/apiresourceschema-clusters.kube-bind.io.yaml b/contrib/kcp/deploy/resources/apiresourceschema-clusters.kube-bind.io.yaml new file mode 100644 index 000000000..a48f14fd8 --- /dev/null +++ b/contrib/kcp/deploy/resources/apiresourceschema-clusters.kube-bind.io.yaml @@ -0,0 +1,102 @@ +apiVersion: apis.kcp.io/v1alpha1 +kind: APIResourceSchema +metadata: + name: v251215-7d342944.clusters.kube-bind.io +spec: + group: kube-bind.io + names: + categories: + - kube-bind + kind: Cluster + listKind: ClusterList + plural: clusters + singular: cluster + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + name: v1alpha2 + schema: + description: Cluster represents a cluster, managed by kube-bind. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: spec represents the data in the newly created ClusterBinding. + type: object + status: + description: status contains reconciliation information for the service + binding. + properties: + conditions: + description: |- + conditions is a list of conditions that apply to the ClusterBinding. It is + updated by the konnector and the service provider. + items: + description: Condition defines an observation of a object operational + state. + properties: + lastTransitionTime: + description: |- + Last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + A human readable message indicating details about the transition. + This field may be empty. + type: string + reason: + description: |- + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may not be empty. + type: string + severity: + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: |- + Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/contrib/kcp/deploy/resources/apiresourceschema-collections.kube-bind.io.yaml b/contrib/kcp/deploy/resources/apiresourceschema-collections.kube-bind.io.yaml index 8e051195d..870463fba 100644 --- a/contrib/kcp/deploy/resources/apiresourceschema-collections.kube-bind.io.yaml +++ b/contrib/kcp/deploy/resources/apiresourceschema-collections.kube-bind.io.yaml @@ -1,7 +1,6 @@ apiVersion: apis.kcp.io/v1alpha1 kind: APIResourceSchema metadata: - creationTimestamp: null name: v251106-640871f.collections.kube-bind.io spec: group: kube-bind.io diff --git a/contrib/kcp/deploy/resources/bootstrap.go b/contrib/kcp/deploy/resources/bootstrap.go index b27177f69..a19da2555 100644 --- a/contrib/kcp/deploy/resources/bootstrap.go +++ b/contrib/kcp/deploy/resources/bootstrap.go @@ -21,7 +21,7 @@ import ( "embed" confighelpers "github.com/kcp-dev/kcp/config/helpers" - kcpclientcluster "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster" + kcpclientcluster "github.com/kcp-dev/sdk/client/clientset/versioned/cluster" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/client-go/discovery" diff --git a/contrib/kcp/go.mod b/contrib/kcp/go.mod index 815f165c5..89bfb67e1 100644 --- a/contrib/kcp/go.mod +++ b/contrib/kcp/go.mod @@ -9,35 +9,32 @@ replace ( github.com/kube-bind/kube-bind/web => ../../web ) -// kcp pinned to a commit on main as sdk/testing requires -// features not in the latest release -// Can use versioned when v0.28.2 releases -replace github.com/kcp-dev/kcp/sdk => github.com/kcp-dev/kcp/sdk v0.28.1-0.20251003164010-742ce0ea6b8c - -// k/k 1.34 is leaking from main repo. This pins some deps to force dependency tree to be on 1.34 +// kcp pre-release replace ( - github.com/google/gnostic-models => github.com/google/gnostic-models v0.6.9 - k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff - sigs.k8s.io/kustomize/api => sigs.k8s.io/kustomize/api v0.19.0 // indirect - sigs.k8s.io/kustomize/kyaml => sigs.k8s.io/kustomize/kyaml v0.19.0 // indirect + github.com/kcp-dev/client-go => github.com/kcp-dev/client-go v0.0.0-20251211053925-0c25555f33dd + github.com/kcp-dev/kcp => github.com/kcp-dev/kcp v0.0.0-20251211081525-180afa9d0125 + github.com/kcp-dev/sdk => github.com/kcp-dev/sdk v0.0.0-20251210172228-11364df3071c ) +// https://github.com/xrstf/mockoidc/pull/3 +replace github.com/xrstf/mockoidc => github.com/mjudeikis/mockoidc v0.0.0-20251215121937-c75f164e38b5 + require ( - github.com/kcp-dev/client-go v0.0.0-20250728134101-0355faa9361b - github.com/kcp-dev/kcp v0.28.3 - github.com/kcp-dev/kcp/sdk v0.28.1 + github.com/kcp-dev/client-go v0.28.1-0.20251112153209-b37f4c1ff9a2 + github.com/kcp-dev/kcp v0.0.0-00010101000000-000000000000 github.com/kcp-dev/logicalcluster/v3 v3.0.5 + github.com/kcp-dev/sdk v0.28.1-0.20251209130449-436a0347809b github.com/kube-bind/kube-bind v0.0.0-00010101000000-000000000000 github.com/kube-bind/kube-bind/cli v0.0.0-20250515145715-d9f20e7c840d github.com/kube-bind/kube-bind/sdk v0.4.1 github.com/spf13/pflag v1.0.9 github.com/stretchr/testify v1.11.1 - k8s.io/apiextensions-apiserver v0.34.0 - k8s.io/apimachinery v0.34.0 - k8s.io/apiserver v0.34.0 + k8s.io/apiextensions-apiserver v0.34.2 + k8s.io/apimachinery v0.34.2 + k8s.io/apiserver v0.34.2 k8s.io/cli-runtime v0.34.0 - k8s.io/client-go v0.34.0 - k8s.io/component-base v0.34.0 + k8s.io/client-go v0.34.2 + k8s.io/component-base v0.34.2 k8s.io/klog/v2 v2.130.1 ) @@ -78,7 +75,6 @@ require ( github.com/google/cel-go v0.26.0 // indirect github.com/google/gnostic-models v0.7.0 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/mux v1.8.1 // indirect github.com/gorilla/securecookie v1.1.1 // indirect @@ -89,9 +85,8 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250728122101-adbf20db3e51 // indirect - github.com/kcp-dev/kcp/pkg/apis v0.11.0 // indirect - github.com/kcp-dev/multicluster-provider v0.2.1-0.20251002133408-9a8d21dc2872 // indirect + github.com/kcp-dev/apimachinery/v2 v2.29.1-0.20251209121225-cf3c0b624983 // indirect + github.com/kcp-dev/multicluster-provider v0.3.3 // indirect github.com/kube-bind/kube-bind/web v0.0.0-00010101000000-000000000000 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect @@ -137,15 +132,15 @@ require ( go.uber.org/zap v1.27.0 // indirect go.yaml.in/yaml/v2 v2.4.2 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/crypto v0.45.0 // indirect - golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect - golang.org/x/net v0.47.0 // indirect - golang.org/x/oauth2 v0.30.0 // indirect - golang.org/x/sync v0.18.0 // indirect - golang.org/x/sys v0.38.0 // indirect - golang.org/x/term v0.37.0 // indirect - golang.org/x/text v0.31.0 // indirect - golang.org/x/time v0.12.0 // indirect + golang.org/x/crypto v0.46.0 // indirect + golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39 // indirect + golang.org/x/net v0.48.0 // indirect + golang.org/x/oauth2 v0.34.0 // indirect + golang.org/x/sync v0.19.0 // indirect + golang.org/x/sys v0.39.0 // indirect + golang.org/x/term v0.38.0 // indirect + golang.org/x/text v0.32.0 // indirect + golang.org/x/time v0.14.0 // indirect gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb // indirect @@ -155,52 +150,51 @@ require ( gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/api v0.34.0 // indirect + k8s.io/api v0.34.2 // indirect k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 // indirect - sigs.k8s.io/controller-runtime v0.21.0 // indirect + sigs.k8s.io/controller-runtime v0.22.4 // indirect sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect sigs.k8s.io/kustomize/api v0.20.1 // indirect sigs.k8s.io/kustomize/kyaml v0.20.1 // indirect - sigs.k8s.io/multicluster-runtime v0.21.0-alpha.9.0.20251002124257-36facc7fbe82 // indirect + sigs.k8s.io/multicluster-runtime v0.22.4-beta.1 // indirect sigs.k8s.io/randfill v1.0.0 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.6.0 // indirect + sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect sigs.k8s.io/yaml v1.6.0 // indirect ) replace ( - github.com/google/cel-go => github.com/google/cel-go v0.22.1 - k8s.io/api => github.com/kcp-dev/kubernetes/staging/src/k8s.io/api v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/apiextensions-apiserver => github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiextensions-apiserver v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/apimachinery => github.com/kcp-dev/kubernetes/staging/src/k8s.io/apimachinery v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/apiserver => github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/cli-runtime => github.com/kcp-dev/kubernetes/staging/src/k8s.io/cli-runtime v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/client-go => github.com/kcp-dev/kubernetes/staging/src/k8s.io/client-go v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/cloud-provider => github.com/kcp-dev/kubernetes/staging/src/k8s.io/cloud-provider v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/cluster-bootstrap => github.com/kcp-dev/kubernetes/staging/src/k8s.io/cluster-bootstrap v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/code-generator => github.com/kcp-dev/kubernetes/staging/src/k8s.io/code-generator v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/component-base => github.com/kcp-dev/kubernetes/staging/src/k8s.io/component-base v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/component-helpers => github.com/kcp-dev/kubernetes/staging/src/k8s.io/component-helpers v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/controller-manager => github.com/kcp-dev/kubernetes/staging/src/k8s.io/controller-manager v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/cri-api => github.com/kcp-dev/kubernetes/staging/src/k8s.io/cri-api v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/cri-client => github.com/kcp-dev/kubernetes/staging/src/k8s.io/cri-client v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/csi-translation-lib => github.com/kcp-dev/kubernetes/staging/src/k8s.io/csi-translation-lib v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/dynamic-resource-allocation => github.com/kcp-dev/kubernetes/staging/src/k8s.io/dynamic-resource-allocation v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/endpointslice => github.com/kcp-dev/kubernetes/staging/src/k8s.io/endpointslice v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/externaljwt => github.com/kcp-dev/kubernetes/staging/src/k8s.io/externaljwt v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/kms => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kms v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/kube-aggregator => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kube-aggregator v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/kube-controller-manager => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kube-controller-manager v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/kube-proxy => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kube-proxy v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/kube-scheduler => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kube-scheduler v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/kubectl => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kubectl v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/kubelet => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kubelet v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/kubernetes => github.com/kcp-dev/kubernetes v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/metrics => github.com/kcp-dev/kubernetes/staging/src/k8s.io/metrics v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/mount-utils => github.com/kcp-dev/kubernetes/staging/src/k8s.io/mount-utils v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/pod-security-admission => github.com/kcp-dev/kubernetes/staging/src/k8s.io/pod-security-admission v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/sample-apiserver => github.com/kcp-dev/kubernetes/staging/src/k8s.io/sample-apiserver v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/sample-cli-plugin => github.com/kcp-dev/kubernetes/staging/src/k8s.io/sample-cli-plugin v0.0.0-20250816165010-ffe1d7c8649b - k8s.io/sample-controller => github.com/kcp-dev/kubernetes/staging/src/k8s.io/sample-controller v0.0.0-20250816165010-ffe1d7c8649b + k8s.io/api => github.com/kcp-dev/kubernetes/staging/src/k8s.io/api v0.0.0-20251209073509-71e0f2506325 + k8s.io/apiextensions-apiserver => github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiextensions-apiserver v0.0.0-20251209073509-71e0f2506325 + k8s.io/apimachinery => github.com/kcp-dev/kubernetes/staging/src/k8s.io/apimachinery v0.0.0-20251209073509-71e0f2506325 + k8s.io/apiserver => github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver v0.0.0-20251209073509-71e0f2506325 + k8s.io/cli-runtime => github.com/kcp-dev/kubernetes/staging/src/k8s.io/cli-runtime v0.0.0-20251209073509-71e0f2506325 + k8s.io/client-go => github.com/kcp-dev/kubernetes/staging/src/k8s.io/client-go v0.0.0-20251209073509-71e0f2506325 + k8s.io/cloud-provider => github.com/kcp-dev/kubernetes/staging/src/k8s.io/cloud-provider v0.0.0-20251209073509-71e0f2506325 + k8s.io/cluster-bootstrap => github.com/kcp-dev/kubernetes/staging/src/k8s.io/cluster-bootstrap v0.0.0-20251209073509-71e0f2506325 + k8s.io/code-generator => github.com/kcp-dev/kubernetes/staging/src/k8s.io/code-generator v0.0.0-20251209073509-71e0f2506325 + k8s.io/component-base => github.com/kcp-dev/kubernetes/staging/src/k8s.io/component-base v0.0.0-20251209073509-71e0f2506325 + k8s.io/component-helpers => github.com/kcp-dev/kubernetes/staging/src/k8s.io/component-helpers v0.0.0-20251209073509-71e0f2506325 + k8s.io/controller-manager => github.com/kcp-dev/kubernetes/staging/src/k8s.io/controller-manager v0.0.0-20251209073509-71e0f2506325 + k8s.io/cri-api => github.com/kcp-dev/kubernetes/staging/src/k8s.io/cri-api v0.0.0-20251209073509-71e0f2506325 + k8s.io/cri-client => github.com/kcp-dev/kubernetes/staging/src/k8s.io/cri-client v0.0.0-20251209073509-71e0f2506325 + k8s.io/csi-translation-lib => github.com/kcp-dev/kubernetes/staging/src/k8s.io/csi-translation-lib v0.0.0-20251209073509-71e0f2506325 + k8s.io/dynamic-resource-allocation => github.com/kcp-dev/kubernetes/staging/src/k8s.io/dynamic-resource-allocation v0.0.0-20251209073509-71e0f2506325 + k8s.io/endpointslice => github.com/kcp-dev/kubernetes/staging/src/k8s.io/endpointslice v0.0.0-20251209073509-71e0f2506325 + k8s.io/externaljwt => github.com/kcp-dev/kubernetes/staging/src/k8s.io/externaljwt v0.0.0-20251209073509-71e0f2506325 + k8s.io/kms => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kms v0.0.0-20251209073509-71e0f2506325 + k8s.io/kube-aggregator => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kube-aggregator v0.0.0-20251209073509-71e0f2506325 + k8s.io/kube-controller-manager => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kube-controller-manager v0.0.0-20251209073509-71e0f2506325 + k8s.io/kube-proxy => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kube-proxy v0.0.0-20251209073509-71e0f2506325 + k8s.io/kube-scheduler => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kube-scheduler v0.0.0-20251209073509-71e0f2506325 + k8s.io/kubectl => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kubectl v0.0.0-20251209073509-71e0f2506325 + k8s.io/kubelet => github.com/kcp-dev/kubernetes/staging/src/k8s.io/kubelet v0.0.0-20251209073509-71e0f2506325 + k8s.io/kubernetes => github.com/kcp-dev/kubernetes v0.0.0-20251209073509-71e0f2506325 + k8s.io/metrics => github.com/kcp-dev/kubernetes/staging/src/k8s.io/metrics v0.0.0-20251209073509-71e0f2506325 + k8s.io/mount-utils => github.com/kcp-dev/kubernetes/staging/src/k8s.io/mount-utils v0.0.0-20251209073509-71e0f2506325 + k8s.io/pod-security-admission => github.com/kcp-dev/kubernetes/staging/src/k8s.io/pod-security-admission v0.0.0-20251209073509-71e0f2506325 + k8s.io/sample-apiserver => github.com/kcp-dev/kubernetes/staging/src/k8s.io/sample-apiserver v0.0.0-20251209073509-71e0f2506325 + k8s.io/sample-cli-plugin => github.com/kcp-dev/kubernetes/staging/src/k8s.io/sample-cli-plugin v0.0.0-20251209073509-71e0f2506325 + k8s.io/sample-controller => github.com/kcp-dev/kubernetes/staging/src/k8s.io/sample-controller v0.0.0-20251209073509-71e0f2506325 ) diff --git a/contrib/kcp/go.sum b/contrib/kcp/go.sum index 039895bba..1f54343b2 100644 --- a/contrib/kcp/go.sum +++ b/contrib/kcp/go.sum @@ -71,8 +71,6 @@ github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZ github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang-jwt/jwt/v4 v4.5.2 h1:YtQM7lnr8iZ+j5q71MGKkNw9Mn7AjHM68uc9g5fXeUI= -github.com/golang-jwt/jwt/v4 v4.5.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang-jwt/jwt/v5 v5.3.0 h1:pv4AsKCKKZuqlgs5sUmn4x8UlGa0kEVt/puTpKx9vvo= github.com/golang-jwt/jwt/v5 v5.3.0/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -81,10 +79,10 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/btree v1.1.3 h1:CVpQJjYgC4VbzxeGVHfvZrv1ctoYCAI8vbl07Fcxlyg= github.com/google/btree v1.1.3/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/cel-go v0.22.1 h1:AfVXx3chM2qwoSbM7Da8g8hX8OVSkBFwX+rz2+PcK40= -github.com/google/cel-go v0.22.1/go.mod h1:BuznPXXfQDpXKWQ9sPW3TzlAJN5zzFe+i9tIs0yC4s8= -github.com/google/gnostic-models v0.6.9 h1:MU/8wDLif2qCXZmzncUQ/BOfxWfthHi63KqpoNbWqVw= -github.com/google/gnostic-models v0.6.9/go.mod h1:CiWsm0s6BSQd1hRn8/QmxqB6BesYcbSZxsz9b0KuDBw= +github.com/google/cel-go v0.26.0 h1:DPGjXackMpJWH680oGY4lZhYjIameYmR+/6RBdDGmaI= +github.com/google/cel-go v0.26.0/go.mod h1:A9O8OU9rdvrK5MQyrqfIxo1a0u4g3sF8KB6PUIaryMM= +github.com/google/gnostic-models v0.7.0 h1:qwTtogB15McXDaNqTZdzPJRHvaVJlAl+HVQnLmJEJxo= +github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7OUGxBlw57miDrQ= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= @@ -94,8 +92,6 @@ github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad h1:a6HEuzUHeKH6hwfN/ZoQgRgVIWFJljSWa/zetS2WTvg= github.com/google/pprof v0.0.0-20241210010833-40e02aabc2ad/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= @@ -106,12 +102,12 @@ github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 h1:JeSE6pjso5T github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674/go.mod h1:r4w70xmWCQKmi1ONH4KIaBptdivuRPyosB9RmPlGEwA= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 h1:+ngKgrYPPJrOjhax5N+uePQ0Fh1Z7PheYoUI/0nzkPA= github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= -github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= +github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 h1:qnpSQwGEnkcRpTqNOIR6bJbR0gAorgP9CSALpRcKoAA= +github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1/go.mod h1:lXGCsh6c22WGtjr+qGHj1otzZpV/1kwTMAqkwZsnWRU= +github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.0 h1:FbSCl+KggFl+Ocym490i/EyXF4lPgLoUtcSWquBM0Rs= +github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.0/go.mod h1:qOchhhIlmRcqk/O9uCo/puJlyo07YINaIqdZfZG3Jkc= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= -github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 h1:5ZPtiqj0JL5oKWmcsq4VMaAW5ukBEgSGXEN89zeH1Jo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3/go.mod h1:ndYquD05frm2vACXE1nsccT4oJzjhw2arTS2cpUD1PI= github.com/headzoo/surf v1.0.1 h1:wk3+LT8gjnCxEwfBJl6MhaNg154En5KjgmgzAG9uMS0= @@ -120,42 +116,40 @@ github.com/headzoo/ut v0.0.0-20181013193318-a13b5a7a02ca h1:utFgFwgxaqx5OthzE3DS github.com/headzoo/ut v0.0.0-20181013193318-a13b5a7a02ca/go.mod h1:8926sG02TCOX4RFRzIMFIzRw4xuc/TwO2gtN7teMJZ4= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/jonboulle/clockwork v0.4.0 h1:p4Cf1aMWXnXAUh8lVfewRBx1zaTSYKrKMF2g3ST4RZ4= -github.com/jonboulle/clockwork v0.4.0/go.mod h1:xgRqUGwRcjKCO1vbZUEtSLrqKoPSsUpK7fnezOII0kc= +github.com/jonboulle/clockwork v0.5.0 h1:Hyh9A8u51kptdkR+cqRpT1EebBwTn1oK9YfGYbdFz6I= +github.com/jonboulle/clockwork v0.5.0/go.mod h1:3mZlmanh0g2NDKO5TWZVJAfofYk64M7XN3SzBPjZF60= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250728122101-adbf20db3e51 h1:l38RDS+VUMx9etvyaCgJIZa4nM7FaNevNubWN0kDZY4= -github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250728122101-adbf20db3e51/go.mod h1:rF1jfvUfPjFXs+HV/LN1BtPzAz1bfjJOwVa+hAVfroQ= -github.com/kcp-dev/client-go v0.0.0-20250728134101-0355faa9361b h1:2LGrXvY9sc4l5yjKIbMZ86GEou7NyrHhA4qBPaeFfxs= -github.com/kcp-dev/client-go v0.0.0-20250728134101-0355faa9361b/go.mod h1:QdO8AaGAZPr/rIZ1iVanCM3tUOiiuX897GWv7WTByLE= -github.com/kcp-dev/kcp v0.28.3 h1:KUpPTt3xjbUgPCsi4EmLtOyCHEJtCU/Sm17H+MtkQFw= -github.com/kcp-dev/kcp v0.28.3/go.mod h1:9Ww0Ex8K0hBuIVpOFX9WsnDbuxtiiNPRgz5ReJyhqUo= -github.com/kcp-dev/kcp/pkg/apis v0.11.0 h1:K6p+tNHNcvfACCPLcHgY0EMLeaIwR1jS491FyLfXMII= -github.com/kcp-dev/kcp/pkg/apis v0.11.0/go.mod h1:8cUAmfMJcksauz53UtsLYG8Phhx62rvuCnd/5t/Zihk= -github.com/kcp-dev/kcp/sdk v0.28.1-0.20251003164010-742ce0ea6b8c h1:6XXxfEOmm7teNQuHnkUi7AEhPyFFPGs77wOKmzUumhI= -github.com/kcp-dev/kcp/sdk v0.28.1-0.20251003164010-742ce0ea6b8c/go.mod h1:aC2BPGPvy8QtkI2gQNH9NfW6xpfGIKZkR93gy9O02BE= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/api v0.0.0-20250816165010-ffe1d7c8649b h1:CyQuxPfhWg8KdwfmY5aE6KABsh/QhkDXTH2msezxCFY= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/api v0.0.0-20250816165010-ffe1d7c8649b/go.mod h1:uiagPCm7MlCfQpIm2xwPTRf8727wbCZCMgHI9uHcMpg= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiextensions-apiserver v0.0.0-20250816165010-ffe1d7c8649b h1:5SZfhKCAqq6lu+tOOf33CDGhSty9guXc90CAfQXk3bw= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiextensions-apiserver v0.0.0-20250816165010-ffe1d7c8649b/go.mod h1:nIZXHR86Y+pIXu55PyfrUKhx5ISDzW/kjHpdOr2tKgY= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/apimachinery v0.0.0-20250816165010-ffe1d7c8649b h1:cJfP+GeRW8O1/49MKUoJ6xbiFiMMOEr/DSrt2y9r0hc= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/apimachinery v0.0.0-20250816165010-ffe1d7c8649b/go.mod h1:6XMZJoNYwuMArBvS2acFkTR1KqyHSp2QXRLRx9eTk5w= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver v0.0.0-20250816165010-ffe1d7c8649b h1:C21pLvKT2MUE38+ZNDXeucEbRdb7rewRpBp4C5lzz6M= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver v0.0.0-20250816165010-ffe1d7c8649b/go.mod h1:STCgTiD+xCCHsfLOPHn5sNVsyktakX/ctW3dMv3erh0= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/cli-runtime v0.0.0-20250816165010-ffe1d7c8649b h1:sQ7otAwO/YMn5cFt4Fftzt6P0cz2gmW7OnTx2i1Qfis= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/cli-runtime v0.0.0-20250816165010-ffe1d7c8649b/go.mod h1:m/w/xSuYRnkX3ocgdBKM/TX7B8aNzScl6qCp1Z3XIGw= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/client-go v0.0.0-20250816165010-ffe1d7c8649b h1:kEieYK/XCUycPf5DCEUZNPvDVHr4ao+rxZvdOQXlMQk= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/client-go v0.0.0-20250816165010-ffe1d7c8649b/go.mod h1:omt22adyHpxAelVTfG1bssg+xoAUc+Cg+0CXn0Oaim0= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/component-base v0.0.0-20250816165010-ffe1d7c8649b h1:OazHpbyl1+WvViAUEZw2PxMZNrd5LOPDD+bhnfL5cQM= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/component-base v0.0.0-20250816165010-ffe1d7c8649b/go.mod h1:Z+AmCbP/esJzSqF5Otj149NR+8fqJHWBgokGrRp0a1c= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/kms v0.0.0-20250816165010-ffe1d7c8649b h1:Rs46P65F5+hroq+W8r+XGH1aO1j+PvibWgePmUXykAM= -github.com/kcp-dev/kubernetes/staging/src/k8s.io/kms v0.0.0-20250816165010-ffe1d7c8649b/go.mod h1:kwWmCq21qHjyuqQeIaShb3CUcfgX89fWTgjEbDle9XM= +github.com/kcp-dev/apimachinery/v2 v2.29.1-0.20251209121225-cf3c0b624983 h1:4hCauFTFMwvIhwL9fqZ5omjeZ+vsOUNO1tLsrCeprxM= +github.com/kcp-dev/apimachinery/v2 v2.29.1-0.20251209121225-cf3c0b624983/go.mod h1:DOv0iw5tcgzFBhudwLFe2WHCLqtlgNkuO4AcqbZ4zVo= +github.com/kcp-dev/client-go v0.0.0-20251211053925-0c25555f33dd h1:jFb6BJ1msx8hyfN32O2u9JpI5Ar+fxHAKMbMtqAaSUk= +github.com/kcp-dev/client-go v0.0.0-20251211053925-0c25555f33dd/go.mod h1:SWYbL1dVmUvLQ8DpcQq+tIH14R1i5e4wh1NTW4YaUYc= +github.com/kcp-dev/kcp v0.0.0-20251211081525-180afa9d0125 h1:nu7sZ9EXtA94cyZ82iLE/30AgWIwhoat3uT+Dyikagc= +github.com/kcp-dev/kcp v0.0.0-20251211081525-180afa9d0125/go.mod h1:wltrdBFiWiEu+IpM94pe8zl/Ubq4re5ENbEpjbfYfJI= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/api v0.0.0-20251209073509-71e0f2506325 h1:xjt3y1Uw+x1LQbtBesGohvyoQ2YRzz4c0rv3BwG0vkA= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/api v0.0.0-20251209073509-71e0f2506325/go.mod h1:3Y5V97lz2MrKYzHlUaXejkj+coCmqde9E9WwVFuWRXE= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiextensions-apiserver v0.0.0-20251209073509-71e0f2506325 h1:MmzvuhedtyTW49qG0VWf9X54OwaRslUk6KyC7vhsuI4= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiextensions-apiserver v0.0.0-20251209073509-71e0f2506325/go.mod h1:NL2CyapDmJ+5XVVY8qr6niVA3UHVF17kPl0zh6ohkVM= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/apimachinery v0.0.0-20251209073509-71e0f2506325 h1:nu1GCQxCQ18IyBtrY9i6qwA1Pk8dr3ErNTDs5vDdUqo= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/apimachinery v0.0.0-20251209073509-71e0f2506325/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver v0.0.0-20251209073509-71e0f2506325 h1:YhSbN6w0bbxt0kKS7yIUivV9KBo1488HG0pPnYojP9U= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/apiserver v0.0.0-20251209073509-71e0f2506325/go.mod h1:msyjTyI8TyfhYybEkao5LA8bUrVqz1xhic5zxsfejoM= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/cli-runtime v0.0.0-20251209073509-71e0f2506325 h1:9xB0Rj669L8eAAZYAr60VHmMdQHNmXOVpg1h90FQnb4= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/cli-runtime v0.0.0-20251209073509-71e0f2506325/go.mod h1:YG2E7QGSDJu46hJmox8R9hFxYzpzn23xVNEfzXY4I70= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/client-go v0.0.0-20251209073509-71e0f2506325 h1:DcaY2DZCLZfQ2/0MfdArT8LZuWP7r3qLNO7mxd/f+oo= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/client-go v0.0.0-20251209073509-71e0f2506325/go.mod h1:EA6EHLX97x5H59hA02pKPLlZBMQEYnYMsIMglrufpFo= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/component-base v0.0.0-20251209073509-71e0f2506325 h1:a2cdebBcc0N3IjIm44fPtMDYS2NBlT9DJOoVHNTXmtc= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/component-base v0.0.0-20251209073509-71e0f2506325/go.mod h1:ji6LERznCQ/l4DKb74Vd/5W8Q89b7SvBen7B4AMY0Oo= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/kms v0.0.0-20251209073509-71e0f2506325 h1:LDvVhQaX9MIB/ODAi5GJHWkRZKbDlrz5dGyQFRUDmbQ= +github.com/kcp-dev/kubernetes/staging/src/k8s.io/kms v0.0.0-20251209073509-71e0f2506325/go.mod h1:s1CFkLG7w9eaTYvctOxosx88fl4spqmixnNpys0JAtM= github.com/kcp-dev/logicalcluster/v3 v3.0.5 h1:JbYakokb+5Uinz09oTXomSUJVQsqfxEvU4RyHUYxHOU= github.com/kcp-dev/logicalcluster/v3 v3.0.5/go.mod h1:EWBUBxdr49fUB1cLMO4nOdBWmYifLbP1LfoL20KkXYY= -github.com/kcp-dev/multicluster-provider v0.2.1-0.20251002133408-9a8d21dc2872 h1:8lXF2+AwZL1BpWTUVwO/32lzzQ8ggTPSlHlN3Mm9qCA= -github.com/kcp-dev/multicluster-provider v0.2.1-0.20251002133408-9a8d21dc2872/go.mod h1:sDD7nNBNjZLE43280MkDiU7djR+0Ru4N5lAw+b4KQvM= +github.com/kcp-dev/multicluster-provider v0.3.3 h1:wTu1Zbk6+kVlB/d/K9TM7KPjUEe/Dg8SYzKQsVDiDFY= +github.com/kcp-dev/multicluster-provider v0.3.3/go.mod h1:4QGU39wyNztoYNatdWqbdOV6/R9ZzaIh4DdSj30dm9o= +github.com/kcp-dev/sdk v0.0.0-20251210172228-11364df3071c h1:ZyBY4E+loLt7fsQ6uDovEJAu0DSDYrX/OUauMfFzcxQ= +github.com/kcp-dev/sdk v0.0.0-20251210172228-11364df3071c/go.mod h1:IcSuKkvMTJ8Igt95mc0nERhsz/Wf+ECTYg2TKdncgOc= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= @@ -175,6 +169,8 @@ github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4 github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= github.com/martinlindhe/base36 v1.1.1 h1:1F1MZ5MGghBXDZ2KJ3QfxmiydlWOGB8HCEtkap5NkVg= github.com/martinlindhe/base36 v1.1.1/go.mod h1:vMS8PaZ5e/jV9LwFKlm0YLnXl/hpOihiBxKkIoc3g08= +github.com/mjudeikis/mockoidc v0.0.0-20251215121937-c75f164e38b5 h1:79Blv5YDyGQDi2qE2z4BJVoCJOU8vlkydvFqnBM3Wnc= +github.com/mjudeikis/mockoidc v0.0.0-20251215121937-c75f164e38b5/go.mod h1:1S3+yz/sau3wSTpmFOwg+JmOudpq6KA6vTuvmP5VReM= github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ= github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -251,27 +247,23 @@ github.com/xiang90/probing v0.0.0-20221125231312-a49e3df8f510 h1:S2dVYn90KE98chq github.com/xiang90/probing v0.0.0-20221125231312-a49e3df8f510/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ= github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0= -github.com/xrstf/mockoidc v0.0.0-20251110222947-8618052ad848 h1:a+htA0+gdDXONEhY2dSCtz3AuUjbM6ZpRXl8qL0dC5I= -github.com/xrstf/mockoidc v0.0.0-20251110222947-8618052ad848/go.mod h1:1S3+yz/sau3wSTpmFOwg+JmOudpq6KA6vTuvmP5VReM= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.etcd.io/bbolt v1.3.11 h1:yGEzV1wPz2yVCLsD8ZAiGHhHVlczyC9d1rP43/VCRJ0= -go.etcd.io/bbolt v1.3.11/go.mod h1:dksAq7YMXoljX0xu6VF5DMZGbhYYoLUalEiSySYAS4I= +go.etcd.io/bbolt v1.4.2 h1:IrUHp260R8c+zYx/Tm8QZr04CX+qWS5PGfPdevhdm1I= +go.etcd.io/bbolt v1.4.2/go.mod h1:Is8rSHO/b4f3XigBC0lL0+4FwAQv3HXEEIgFMuKHceM= go.etcd.io/etcd/api/v3 v3.6.4 h1:7F6N7toCKcV72QmoUKa23yYLiiljMrT4xCeBL9BmXdo= go.etcd.io/etcd/api/v3 v3.6.4/go.mod h1:eFhhvfR8Px1P6SEuLT600v+vrhdDTdcfMzmnxVXXSbk= go.etcd.io/etcd/client/pkg/v3 v3.6.4 h1:9HBYrjppeOfFjBjaMTRxT3R7xT0GLK8EJMVC4xg6ok0= go.etcd.io/etcd/client/pkg/v3 v3.6.4/go.mod h1:sbdzr2cl3HzVmxNw//PH7aLGVtY4QySjQFuaCgcRFAI= -go.etcd.io/etcd/client/v2 v2.305.21 h1:eLiFfexc2mE+pTLz9WwnoEsX5JTTpLCYVivKkmVXIRA= -go.etcd.io/etcd/client/v2 v2.305.21/go.mod h1:OKkn4hlYNf43hpjEM3Ke3aRdUkhSl8xjKjSf8eCq2J8= go.etcd.io/etcd/client/v3 v3.6.4 h1:YOMrCfMhRzY8NgtzUsHl8hC2EBSnuqbR3dh84Uryl7A= go.etcd.io/etcd/client/v3 v3.6.4/go.mod h1:jaNNHCyg2FdALyKWnd7hxZXZxZANb0+KGY+YQaEMISo= -go.etcd.io/etcd/pkg/v3 v3.5.21 h1:jUItxeKyrDuVuWhdh0HtjUANwyuzcb7/FAeUfABmQsk= -go.etcd.io/etcd/pkg/v3 v3.5.21/go.mod h1:wpZx8Egv1g4y+N7JAsqi2zoUiBIUWznLjqJbylDjWgU= -go.etcd.io/etcd/raft/v3 v3.5.21 h1:dOmE0mT55dIUsX77TKBLq+RgyumsQuYeiRQnW/ylugk= -go.etcd.io/etcd/raft/v3 v3.5.21/go.mod h1:fmcuY5R2SNkklU4+fKVBQi2biVp5vafMrWUEj4TJ4Cs= -go.etcd.io/etcd/server/v3 v3.5.21 h1:9w0/k12majtgarGmlMVuhwXRI2ob3/d1Ik3X5TKo0yU= -go.etcd.io/etcd/server/v3 v3.5.21/go.mod h1:G1mOzdwuzKT1VRL7SqRchli/qcFrtLBTAQ4lV20sXXo= +go.etcd.io/etcd/pkg/v3 v3.6.4 h1:fy8bmXIec1Q35/jRZ0KOes8vuFxbvdN0aAFqmEfJZWA= +go.etcd.io/etcd/pkg/v3 v3.6.4/go.mod h1:kKcYWP8gHuBRcteyv6MXWSN0+bVMnfgqiHueIZnKMtE= +go.etcd.io/etcd/server/v3 v3.6.4 h1:LsCA7CzjVt+8WGrdsnh6RhC0XqCsLkBly3ve5rTxMAU= +go.etcd.io/etcd/server/v3 v3.6.4/go.mod h1:aYCL/h43yiONOv0QIR82kH/2xZ7m+IWYjzRmyQfnCAg= +go.etcd.io/raft/v3 v3.6.0 h1:5NtvbDVYpnfZWcIHgGRk9DyzkBIXOi8j+DDp1IcnUWQ= +go.etcd.io/raft/v3 v3.6.0/go.mod h1:nLvLevg6+xrVtHUmVaTcTz603gQPHfh7kUAwV6YpfGo= go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.60.0 h1:x7wzEgXfnzJcHDwStJT+mxOz4etr2EcexjqhBvmoakw= @@ -294,8 +286,8 @@ go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc= go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU/3i4= go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4= -go.uber.org/goleak v1.3.1-0.20241121203838-4ff5fa6529ee h1:uOMbcH1Dmxv45VkkpZQYoerZFeDncWpjbN7ATiQOO7c= -go.uber.org/goleak v1.3.1-0.20241121203838-4ff5fa6529ee/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= +go.uber.org/goleak v1.3.1-0.20251210191316-2b7fd8a0d244 h1:OdZ8e4E9yDUGiis9x2ta/Ec5yhMAKT6ZivRvakyxC7E= +go.uber.org/goleak v1.3.1-0.20251210191316-2b7fd8a0d244/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= @@ -312,10 +304,10 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= -golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q= -golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4= -golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 h1:R84qjqJb5nVJMxqWYb3np9L5ZsaDtB+a39EqjV0JSUM= -golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0/go.mod h1:S9Xr4PYopiDyqSyp5NjCrhFrqg6A5zA2E/iPHPhqnS8= +golang.org/x/crypto v0.46.0 h1:cKRW/pmt1pKAfetfu+RCEvjvZkA9RimPbh7bhFjGVBU= +golang.org/x/crypto v0.46.0/go.mod h1:Evb/oLKmMraqjZ2iQTwDwvCtJkczlDuTmdJXoZVzqU0= +golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39 h1:DHNhtq3sNNzrvduZZIiFyXWOL9IWaDPHqTnLJp+rCBY= +golang.org/x/exp v0.0.0-20251125195548-87e1e737ad39/go.mod h1:46edojNIoXTNOhySWIWdix628clX9ODXwPsQuG6hsK0= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= @@ -337,10 +329,10 @@ golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= -golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= -golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI= -golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU= +golang.org/x/net v0.48.0 h1:zyQRTTrjc33Lhh0fBgT/H3oZq9WuvRR5gPC70xpDiQU= +golang.org/x/net v0.48.0/go.mod h1:+ndRgGjkh8FGtu1w1FGbEC31if4VrNVMuKTgcAAnQRY= +golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw= +golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -350,8 +342,8 @@ golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= -golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= +golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -366,8 +358,8 @@ golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= -golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +golang.org/x/sys v0.39.0 h1:CvCKL8MeisomCi6qNZ+wbb0DN9E5AATixKsvNtMoMFk= +golang.org/x/sys v0.39.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -377,8 +369,8 @@ golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= -golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU= -golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254= +golang.org/x/term v0.38.0 h1:PQ5pkm/rLO6HnxFR7N2lJHOZX6Kez5Y1gDSJla6jo7Q= +golang.org/x/term v0.38.0/go.mod h1:bSEAKrOT1W+VSu9TSCMtoGEOUcKxOKgl3LE5QEF/xVg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -389,10 +381,10 @@ golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= -golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= -golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE= -golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg= +golang.org/x/text v0.32.0 h1:ZD01bjUt1FQ9WJ0ClOL5vxgxOI/sVCNgX1YtKwcY0mU= +golang.org/x/text v0.32.0/go.mod h1:o/rUWzghvpD5TXrTIBuJU77MTaN0ljMWE47kxGJQ7jY= +golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI= +golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -401,8 +393,8 @@ golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= -golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ= -golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs= +golang.org/x/tools v0.40.0 h1:yLkxfA+Qnul4cs9QA3KnlFu0lVmd8JJfoq+E41uSutA= +golang.org/x/tools v0.40.0/go.mod h1:Ik/tzLRlbscWpqqMRjyWYDisX8bG13FrdXp3o4Sr9lc= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -412,8 +404,6 @@ gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuB google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 h1:9+tzLLstTlPTRyJTh+ah5wIMsBW5c4tQwGTN3thOW9Y= -google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:mqHbVIp48Muh7Ywss/AD6I5kNVKZMmAa/QEW58Gxp2s= google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb h1:p31xT4yrYrSM/G4Sn2+TNUkVhFCbG9y8itM2S6Th950= google.golang.org/genproto/googleapis/api v0.0.0-20250303144028-a0af3efb3deb/go.mod h1:jbe3Bkdp+Dh2IrslsFCklNhweNTBgSYanP1UXhJDhKg= google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb h1:TLPQVbx1GJ8VKZxz52VAxl1EBgKXXbTiU9Fc5fZeLn4= @@ -437,27 +427,25 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff h1:/usPimJzUKKu+m+TE36gUyGcf03XZEP0ZIKgKj35LS4= -k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff/go.mod h1:5jIi+8yX4RIb8wk3XwBo5Pq2ccx4FP10ohkbSKCZoK8= +k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b h1:MloQ9/bdJyIu9lb1PzujOPolHyvO06MXG5TUIj2mNAA= +k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b/go.mod h1:UZ2yyWbFTpuhSbFhv24aGNOdoRdJZgsIObGBUaYVsts= k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 h1:hwvWFiBzdWw1FhfY1FooPn3kzWuJ8tmbZBHi4zVsl1Y= k8s.io/utils v0.0.0-20250604170112-4c0f3b243397/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 h1:jpcvIRr3GLoUoEKRkHKSmGjxb6lWwrBlJsXc+eUYQHM= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= -sigs.k8s.io/controller-runtime v0.21.0 h1:CYfjpEuicjUecRk+KAeyYh+ouUBn4llGyDYytIGcJS8= -sigs.k8s.io/controller-runtime v0.21.0/go.mod h1:OSg14+F65eWqIu4DceX7k/+QRAbTTvxeQSNSOQpukWM= +sigs.k8s.io/controller-runtime v0.22.4 h1:GEjV7KV3TY8e+tJ2LCTxUTanW4z/FmNB7l327UfMq9A= +sigs.k8s.io/controller-runtime v0.22.4/go.mod h1:+QX1XUpTXN4mLoblf4tqr5CQcyHPAki2HLXqQMY6vh8= sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE= sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= -sigs.k8s.io/kustomize/api v0.19.0 h1:F+2HB2mU1MSiR9Hp1NEgoU2q9ItNOaBJl0I4Dlus5SQ= -sigs.k8s.io/kustomize/api v0.19.0/go.mod h1:/BbwnivGVcBh1r+8m3tH1VNxJmHSk1PzP5fkP6lbL1o= -sigs.k8s.io/kustomize/kyaml v0.19.0 h1:RFge5qsO1uHhwJsu3ipV7RNolC7Uozc0jUBC/61XSlA= -sigs.k8s.io/kustomize/kyaml v0.19.0/go.mod h1:FeKD5jEOH+FbZPpqUghBP8mrLjJ3+zD3/rf9NNu1cwY= -sigs.k8s.io/multicluster-runtime v0.21.0-alpha.9.0.20251002124257-36facc7fbe82 h1:RRenMVUCSVrxcLb5y84IrF4q6dxcaBW/xfq3rxkdhwM= -sigs.k8s.io/multicluster-runtime v0.21.0-alpha.9.0.20251002124257-36facc7fbe82/go.mod h1:CpBzLMLQKdm+UCchd2FiGPiDdCxM5dgCCPKuaQ6Fsv0= -sigs.k8s.io/randfill v0.0.0-20250304075658-069ef1bbf016/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= +sigs.k8s.io/kustomize/api v0.20.1 h1:iWP1Ydh3/lmldBnH/S5RXgT98vWYMaTUL1ADcr+Sv7I= +sigs.k8s.io/kustomize/api v0.20.1/go.mod h1:t6hUFxO+Ph0VxIk1sKp1WS0dOjbPCtLJ4p8aADLwqjM= +sigs.k8s.io/kustomize/kyaml v0.20.1 h1:PCMnA2mrVbRP3NIB6v9kYCAc38uvFLVs8j/CD567A78= +sigs.k8s.io/kustomize/kyaml v0.20.1/go.mod h1:0EmkQHRUsJxY8Ug9Niig1pUMSCGHxQ5RklbpV/Ri6po= +sigs.k8s.io/multicluster-runtime v0.22.4-beta.1 h1:0XWbDINepM9UOyLkqhG4g7BtGBFKCDvZFyPsw1vufKE= +sigs.k8s.io/multicluster-runtime v0.22.4-beta.1/go.mod h1:zSMb4mC8MAZK42l8eE1ywkeX6vjuNRenYzJ1w+GPdfI= sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= -sigs.k8s.io/structured-merge-diff/v4 v4.6.0 h1:IUA9nvMmnKWcj5jl84xn+T5MnlZKThmUW1TdblaLVAc= -sigs.k8s.io/structured-merge-diff/v4 v4.6.0/go.mod h1:dDy58f92j70zLsuZVuUX5Wp9vtxXpaZnkPGWeqDfCps= -sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= +sigs.k8s.io/structured-merge-diff/v6 v6.3.0 h1:jTijUJbW353oVOd9oTlifJqOGEkUw2jB/fXCbTiQEco= +sigs.k8s.io/structured-merge-diff/v6 v6.3.0/go.mod h1:M3W8sfWvn2HhQDIbGWj3S099YozAsymCo/wrT5ohRUE= sigs.k8s.io/yaml v1.6.0 h1:G8fkbMSAFqgEFgh4b1wmtzDnioxFCUgTZhlbj5P9QYs= sigs.k8s.io/yaml v1.6.0/go.mod h1:796bPqUfzR/0jLAl6XjHl3Ck7MiyVv8dbTdyT3/pMf4= diff --git a/contrib/kcp/test/e2e/backend.go b/contrib/kcp/test/e2e/backend.go index e36be7e26..6c445c530 100644 --- a/contrib/kcp/test/e2e/backend.go +++ b/contrib/kcp/test/e2e/backend.go @@ -23,9 +23,9 @@ import ( "testing" "time" - kcpclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster" - kcptestinghelpers "github.com/kcp-dev/kcp/sdk/testing/helpers" "github.com/kcp-dev/logicalcluster/v3" + kcpclientset "github.com/kcp-dev/sdk/client/clientset/versioned/cluster" + kcptestinghelpers "github.com/kcp-dev/sdk/testing/helpers" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" @@ -67,7 +67,7 @@ func bootstrapBackend(t *testing.T, rest *rest.Config, scope kubebindv1alpha2.In addr, _ := framework.StartBackend(t, "--kubeconfig="+backendKubeconfig, "--multicluster-runtime-provider=kcp", - "--server-url="+exportUrl, + "--apiexport-endpointslice-name=kube-bind.io", "--pretty-name=BigCorp.com", "--namespace-prefix=kube-bind-", "--schema-source=apiresourceschemas", diff --git a/contrib/kcp/test/e2e/kcp.go b/contrib/kcp/test/e2e/kcp.go index 4512aef5a..31bc6ced4 100644 --- a/contrib/kcp/test/e2e/kcp.go +++ b/contrib/kcp/test/e2e/kcp.go @@ -22,10 +22,10 @@ import ( "testing" "time" - kcpapisv1alpha2 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha2" - kcpclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster" - kcptestinghelpers "github.com/kcp-dev/kcp/sdk/testing/helpers" "github.com/kcp-dev/logicalcluster/v3" + kcpapisv1alpha2 "github.com/kcp-dev/sdk/apis/apis/v1alpha2" + kcpclientset "github.com/kcp-dev/sdk/client/clientset/versioned/cluster" + kcptestinghelpers "github.com/kcp-dev/sdk/testing/helpers" "github.com/spf13/pflag" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/contrib/kcp/test/e2e/kcp_test.go b/contrib/kcp/test/e2e/kcp_test.go index 5ed7c74c9..5f249e095 100644 --- a/contrib/kcp/test/e2e/kcp_test.go +++ b/contrib/kcp/test/e2e/kcp_test.go @@ -23,9 +23,9 @@ import ( "testing" "time" - kcpclientset "github.com/kcp-dev/kcp/sdk/client/clientset/versioned/cluster" - kcptestinghelpers "github.com/kcp-dev/kcp/sdk/testing/helpers" "github.com/kcp-dev/logicalcluster/v3" + kcpclientset "github.com/kcp-dev/sdk/client/clientset/versioned/cluster" + kcptestinghelpers "github.com/kcp-dev/sdk/testing/helpers" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -103,6 +103,7 @@ func testKcpIntegration(t *testing.T, name string, scope kubebindv1alpha2.Inform "namespaces.core", "roles.rbac.authorization.k8s.io", "rolebindings.rbac.authorization.k8s.io", + "subjectaccessreviews.authorization.k8s.io", "apiresourceschemas.apis.kcp.io", ), ) diff --git a/deploy/charts/backend/crds/kube-bind.io_clusters.yaml b/deploy/charts/backend/crds/kube-bind.io_clusters.yaml new file mode 100644 index 000000000..7dba0d0e9 --- /dev/null +++ b/deploy/charts/backend/crds/kube-bind.io_clusters.yaml @@ -0,0 +1,106 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.17.3 + name: clusters.kube-bind.io +spec: + group: kube-bind.io + names: + categories: + - kube-bind + kind: Cluster + listKind: ClusterList + plural: clusters + singular: cluster + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + name: v1alpha2 + schema: + openAPIV3Schema: + description: Cluster represents a cluster, managed by kube-bind. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: spec represents the data in the newly created ClusterBinding. + type: object + status: + description: status contains reconciliation information for the service + binding. + properties: + conditions: + description: |- + conditions is a list of conditions that apply to the ClusterBinding. It is + updated by the konnector and the service provider. + items: + description: Condition defines an observation of a object operational + state. + properties: + lastTransitionTime: + description: |- + Last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + A human readable message indicating details about the transition. + This field may be empty. + type: string + reason: + description: |- + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may not be empty. + type: string + severity: + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: |- + Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/deploy/config/cluster.yaml b/deploy/config/cluster.yaml new file mode 100644 index 000000000..37b20939e --- /dev/null +++ b/deploy/config/cluster.yaml @@ -0,0 +1,5 @@ +apiVersion: kube-bind.io/v1alpha2 +kind: Cluster +metadata: + name: default +spec: {} \ No newline at end of file diff --git a/deploy/crd/kube-bind.io_clusters.yaml b/deploy/crd/kube-bind.io_clusters.yaml new file mode 100644 index 000000000..7dba0d0e9 --- /dev/null +++ b/deploy/crd/kube-bind.io_clusters.yaml @@ -0,0 +1,106 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.17.3 + name: clusters.kube-bind.io +spec: + group: kube-bind.io + names: + categories: + - kube-bind + kind: Cluster + listKind: ClusterList + plural: clusters + singular: cluster + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=="Ready")].status + name: Ready + type: string + name: v1alpha2 + schema: + openAPIV3Schema: + description: Cluster represents a cluster, managed by kube-bind. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: spec represents the data in the newly created ClusterBinding. + type: object + status: + description: status contains reconciliation information for the service + binding. + properties: + conditions: + description: |- + conditions is a list of conditions that apply to the ClusterBinding. It is + updated by the konnector and the service provider. + items: + description: Condition defines an observation of a object operational + state. + properties: + lastTransitionTime: + description: |- + Last time the condition transitioned from one status to another. + This should be when the underlying condition changed. If that is not known, then using the time when + the API field changed is acceptable. + format: date-time + type: string + message: + description: |- + A human readable message indicating details about the transition. + This field may be empty. + type: string + reason: + description: |- + The reason for the condition's last transition in CamelCase. + The specific API may choose whether or not this field is considered a guaranteed API. + This field may not be empty. + type: string + severity: + description: |- + Severity provides an explicit classification of Reason code, so the users or machines can immediately + understand the current situation and act accordingly. + The Severity field MUST be set only when Status=False. + type: string + status: + description: Status of the condition, one of True, False, Unknown. + type: string + type: + description: |- + Type of condition in CamelCase or in foo.example.com/CamelCase. + Many .condition.type values are consistent across resources like Available, but because arbitrary conditions + can be useful (see .node.status.conditions), the ability to deconflict is important. + type: string + required: + - lastTransitionTime + - status + - type + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} diff --git a/docs/content/developers/backend/index.md b/docs/content/developers/backend/index.md index 5542288d9..f4de208b6 100644 --- a/docs/content/developers/backend/index.md +++ b/docs/content/developers/backend/index.md @@ -24,7 +24,7 @@ The backend can be configured to use different providers: ```bash ./bin/backend \ --multicluster-runtime-provider kcp \ - --server-url=$(kubectl get apiexportendpointslice kube-bind.io -o jsonpath="{.status.endpoints[0].url}") \ + --apiexport-endpointslice-name=kube-bind.io \ # ... other options ``` @@ -63,3 +63,17 @@ The backend includes several controllers for managing the export/binding lifecyc - **ServiceExport Controller**: Handles APIServiceExport resources - **ServiceExportRequest Controller**: Processes export requests - **ServiceNamespace Controller**: Manages namespace isolation + +## Deployment Limitations + +### Session Storage + +The backend currently uses in-memory session storage for OIDC authentication sessions. This creates the following limitation: + +- **Single Replica Constraint**: The backend cannot be run with replicas > 1 due to the lack of external session storage implementation +- **Session Persistence**: Sessions are not persisted across backend restarts +- **Load Balancer Issues**: If deployed behind a load balancer with multiple replicas, users may lose their sessions when requests are routed to different backend instances + +**Workaround**: Deploy the backend as a single replica (replicas: 1) until external session storage support is implemented. + +**Future Enhancement**: Implementation of external session storage (Redis, database, etc.) would resolve this limitation and enable high availability deployments. diff --git a/docs/content/developers/backend/oidc/index.md b/docs/content/developers/backend/oidc/index.md index 596167a29..c54395ced 100644 --- a/docs/content/developers/backend/oidc/index.md +++ b/docs/content/developers/backend/oidc/index.md @@ -29,8 +29,12 @@ Configure the backend to use an external OIDC provider with these flags: --oidc-callback-url=https://your-backend.com/callback --oidc-authorize-url=https://your-oidc-provider.com/auth --oidc-ca-file=/path/to/ca-bundle.pem # Optional: for custom CA certificates +--oidc-allowed-groups=group1,group2,group3 # Optional: restrict access to specific groups +--oidc-allowed-users=user1,user2,user3 # Optional: restrict access to specific users ``` +**Note**: When using external OIDC providers, at least one of `--oidc-allowed-groups` or `--oidc-allowed-users` must be specified for security reasons. + ### External OIDC Flow 1. User initiates authentication by accessing a protected endpoint @@ -53,6 +57,8 @@ Configure the backend to use the embedded OIDC provider: --oidc-type=embedded --oidc-callback-url=https://your-backend.com/callback --oidc-issuer-url=https://your-backend.com # The backend serves as the OIDC provider +--oidc-allowed-groups=group1,group2,group3 # Optional: restrict access to specific groups +--oidc-allowed-users=user1,user2,user3 # Optional: restrict access to specific users ``` ### Embedded OIDC Flow @@ -88,6 +94,42 @@ When using embedded OIDC, the backend displays a prominent warning message at st - Intended only for local development and testing - Does not persist user data between restarts +## Access Control + +The kube-bind backend provides fine-grained access control through OIDC group and user-based authorization. When a user successfully authenticates via OIDC, the backend automatically creates RBAC resources to control access to cluster binding operations. + +### Access Control Flags + +- `--oidc-allowed-groups`: List of OIDC groups allowed to access bindings inside the cluster. Users must be members of at least one of these groups to gain access. +- `--oidc-allowed-users`: List of specific OIDC users allowed to access bindings inside the cluster. + +**Important**: For external OIDC providers, at least one of these flags must be specified. This validation ensures that access control is properly configured in production environments. + +### How Access Control Works + +1. **RBAC Resource Creation**: For each cluster, the controller automatically creates: + - A `ClusterRole` named `kube-bind-oidc-user` with permissions to perform binding operations + - A `ClusterRoleBinding` that binds the role to the specified groups and users + +2. **Group-based Access**: Users who are members of groups listed in `--oidc-allowed-groups` are granted access via RBAC subject entries of kind `Group`. + +3. **User-based Access**: Individual users listed in `--oidc-allowed-users` are granted access via RBAC subject entries of kind `User`. + +4. **Embedded OIDC Special Behavior**: When using embedded OIDC (`--oidc-type=embedded`), the `system:authenticated` group is automatically added to the allowed groups list, providing access to all authenticated users during development. + +### Example Configuration + +```bash +# Restrict access to specific groups and users +--oidc-allowed-groups=kube-bind-admins,platform-team +--oidc-allowed-users=admin@example.com,operator@example.com +``` + +This configuration would create RBAC bindings allowing: +- All members of the `kube-bind-admins` group +- All members of the `platform-team` group +- The specific users `admin@example.com` and `operator@example.com` + ## Troubleshooting ### Common Issues @@ -96,6 +138,7 @@ When using embedded OIDC, the backend displays a prominent warning message at st 2. **Callback URL mismatches**: Ensure the callback URL matches what's configured in your OIDC provider 3. **Token validation errors**: Check that the issuer URL matches between provider and backend configuration 4. **Network connectivity**: Verify the backend can reach the external OIDC provider +5. **Access control validation errors**: When using external OIDC, ensure at least one of `--oidc-allowed-groups` or `--oidc-allowed-users` is specified ### Debug Logging diff --git a/docs/content/developers/dev-environments.md b/docs/content/developers/dev-environments.md index 2def8249b..e6452e0c5 100644 --- a/docs/content/developers/dev-environments.md +++ b/docs/content/developers/dev-environments.md @@ -53,9 +53,8 @@ All the instructions assume you have already cloned the kube-bind repository and ``` k ws use :root:kube-bind - ./bin/backend \ + go run ./cmd/backend \ --multicluster-runtime-provider kcp \ - --server-url=$(kubectl get apiexportendpointslice kube-bind.io -o jsonpath="{.status.endpoints[0].url}") \ --oidc-issuer-url=http://127.0.0.1:8080/oidc \ --oidc-callback-url=http://127.0.0.1:8080/api/callback \ --oidc-type=embedded \ @@ -64,6 +63,7 @@ All the instructions assume you have already cloned the kube-bind repository and --schema-source apiresourceschemas \ --consumer-scope=cluster ``` + optionally add `--fronend=http://localhost:3000` to point to local frontend (must be running separately). This process will keep running, so open a new terminal. @@ -86,6 +86,7 @@ All the instructions assume you have already cloned the kube-bind repository and --accept-permission-claim serviceaccounts.core \ --accept-permission-claim configmaps.core \ --accept-permission-claim secrets.core \ + --accept-permission-claim subjectaccessreviews.authorization.k8s.io \ --accept-permission-claim namespaces.core \ --accept-permission-claim roles.rbac.authorization.k8s.io \ --accept-permission-claim rolebindings.rbac.authorization.k8s.io \ @@ -125,7 +126,7 @@ All the instructions assume you have already cloned the kube-bind repository and 10. Bind the thing: ```bash - ./bin/kubectl-bind login http://127.0.0.1:8080 --cluster 2myqz7lt9i0u5kzb + ./bin/kubectl-bind login http://127.0.0.1:8080 --cluster 1xiy1uyh4qckje8z ./bin/kubectl-bind --dry-run -o yaml > apiserviceexport.yaml # Extract secret for binding process. Note that secret name is not the same as output from command above. Check secret diff --git a/docs/content/setup/kcp-setup.md b/docs/content/setup/kcp-setup.md index 01dc53886..717373abd 100644 --- a/docs/content/setup/kcp-setup.md +++ b/docs/content/setup/kcp-setup.md @@ -52,7 +52,7 @@ bin/backend \ --oidc-type=embedded \ --pretty-name="BigCorp.com" \ --namespace-prefix="kube-bind-" \ - --consumer-scope=cluster + --consumer-scope=cluster --frontend http://localhost:3000 ``` This process will keep running, so open a new terminal. diff --git a/docs/generators/cli-doc/go.mod b/docs/generators/cli-doc/go.mod index 2908773e3..2df64dbbb 100644 --- a/docs/generators/cli-doc/go.mod +++ b/docs/generators/cli-doc/go.mod @@ -137,13 +137,13 @@ require ( gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect helm.sh/helm/v3 v3.19.0 // indirect - k8s.io/api v0.34.0 // indirect - k8s.io/apiextensions-apiserver v0.34.0 // indirect - k8s.io/apimachinery v0.34.0 // indirect - k8s.io/apiserver v0.34.0 // indirect + k8s.io/api v0.34.2 // indirect + k8s.io/apiextensions-apiserver v0.34.2 // indirect + k8s.io/apimachinery v0.34.2 // indirect + k8s.io/apiserver v0.34.2 // indirect k8s.io/cli-runtime v0.34.0 // indirect - k8s.io/client-go v0.34.0 // indirect - k8s.io/component-base v0.34.0 // indirect + k8s.io/client-go v0.34.2 // indirect + k8s.io/component-base v0.34.2 // indirect k8s.io/klog/v2 v2.130.1 // indirect k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect k8s.io/kubectl v0.34.0 // indirect diff --git a/docs/generators/cli-doc/go.sum b/docs/generators/cli-doc/go.sum index b04ce3284..36253af08 100644 --- a/docs/generators/cli-doc/go.sum +++ b/docs/generators/cli-doc/go.sum @@ -441,20 +441,20 @@ gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= helm.sh/helm/v3 v3.19.0 h1:krVyCGa8fa/wzTZgqw0DUiXuRT5BPdeqE/sQXujQ22k= helm.sh/helm/v3 v3.19.0/go.mod h1:Lk/SfzN0w3a3C3o+TdAKrLwJ0wcZ//t1/SDXAvfgDdc= -k8s.io/api v0.34.0 h1:L+JtP2wDbEYPUeNGbeSa/5GwFtIA662EmT2YSLOkAVE= -k8s.io/api v0.34.0/go.mod h1:YzgkIzOOlhl9uwWCZNqpw6RJy9L2FK4dlJeayUoydug= -k8s.io/apiextensions-apiserver v0.34.0 h1:B3hiB32jV7BcyKcMU5fDaDxk882YrJ1KU+ZSkA9Qxoc= -k8s.io/apiextensions-apiserver v0.34.0/go.mod h1:hLI4GxE1BDBy9adJKxUxCEHBGZtGfIg98Q+JmTD7+g0= -k8s.io/apimachinery v0.34.0 h1:eR1WO5fo0HyoQZt1wdISpFDffnWOvFLOOeJ7MgIv4z0= -k8s.io/apimachinery v0.34.0/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw= -k8s.io/apiserver v0.34.0 h1:Z51fw1iGMqN7uJ1kEaynf2Aec1Y774PqU+FVWCFV3Jg= -k8s.io/apiserver v0.34.0/go.mod h1:52ti5YhxAvewmmpVRqlASvaqxt0gKJxvCeW7ZrwgazQ= +k8s.io/api v0.34.2 h1:fsSUNZhV+bnL6Aqrp6O7lMTy6o5x2C4XLjnh//8SLYY= +k8s.io/api v0.34.2/go.mod h1:MMBPaWlED2a8w4RSeanD76f7opUoypY8TFYkSM+3XHw= +k8s.io/apiextensions-apiserver v0.34.2 h1:WStKftnGeoKP4AZRz/BaAAEJvYp4mlZGN0UCv+uvsqo= +k8s.io/apiextensions-apiserver v0.34.2/go.mod h1:398CJrsgXF1wytdaanynDpJ67zG4Xq7yj91GrmYN2SE= +k8s.io/apimachinery v0.34.2 h1:zQ12Uk3eMHPxrsbUJgNF8bTauTVR2WgqJsTmwTE/NW4= +k8s.io/apimachinery v0.34.2/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw= +k8s.io/apiserver v0.34.2 h1:2/yu8suwkmES7IzwlehAovo8dDE07cFRC7KMDb1+MAE= +k8s.io/apiserver v0.34.2/go.mod h1:gqJQy2yDOB50R3JUReHSFr+cwJnL8G1dzTA0YLEqAPI= k8s.io/cli-runtime v0.34.0 h1:N2/rUlJg6TMEBgtQ3SDRJwa8XyKUizwjlOknT1mB2Cw= k8s.io/cli-runtime v0.34.0/go.mod h1:t/skRecS73Piv+J+FmWIQA2N2/rDjdYSQzEE67LUUs8= -k8s.io/client-go v0.34.0 h1:YoWv5r7bsBfb0Hs2jh8SOvFbKzzxyNo0nSb0zC19KZo= -k8s.io/client-go v0.34.0/go.mod h1:ozgMnEKXkRjeMvBZdV1AijMHLTh3pbACPvK7zFR+QQY= -k8s.io/component-base v0.34.0 h1:bS8Ua3zlJzapklsB1dZgjEJuJEeHjj8yTu1gxE2zQX8= -k8s.io/component-base v0.34.0/go.mod h1:RSCqUdvIjjrEm81epPcjQ/DS+49fADvGSCkIP3IC6vg= +k8s.io/client-go v0.34.2 h1:Co6XiknN+uUZqiddlfAjT68184/37PS4QAzYvQvDR8M= +k8s.io/client-go v0.34.2/go.mod h1:2VYDl1XXJsdcAxw7BenFslRQX28Dxz91U9MWKjX97fE= +k8s.io/component-base v0.34.2 h1:HQRqK9x2sSAsd8+R4xxRirlTjowsg6fWCPwWYeSvogQ= +k8s.io/component-base v0.34.2/go.mod h1:9xw2FHJavUHBFpiGkZoKuYZ5pdtLKe97DEByaA+hHbM= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b h1:MloQ9/bdJyIu9lb1PzujOPolHyvO06MXG5TUIj2mNAA= diff --git a/go.mod b/go.mod index 1c701de2e..a634cffdd 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,12 @@ replace ( github.com/kube-bind/kube-bind/web => ./web ) +// kcp pre-release +replace github.com/kcp-dev/sdk => github.com/kcp-dev/sdk v0.0.0-20251210172228-11364df3071c + +// https://github.com/xrstf/mockoidc/pull/3 +replace github.com/xrstf/mockoidc => github.com/mjudeikis/mockoidc v0.0.0-20251215121937-c75f164e38b5 + require ( github.com/coreos/go-oidc/v3 v3.16.0 github.com/dexidp/dex/api/v2 v2.3.0 @@ -25,9 +31,9 @@ require ( github.com/gorilla/mux v1.8.1 github.com/gorilla/securecookie v1.1.1 github.com/headzoo/surf v1.0.1 - github.com/kcp-dev/kcp/pkg/apis v0.11.0 - github.com/kcp-dev/kcp/sdk v0.28.1 - github.com/kcp-dev/multicluster-provider v0.2.1-0.20251002133408-9a8d21dc2872 + github.com/kcp-dev/logicalcluster/v3 v3.0.5 + github.com/kcp-dev/multicluster-provider v0.3.3 + github.com/kcp-dev/sdk v0.28.1-0.20251209130449-436a0347809b github.com/kube-bind/kube-bind/cli v0.0.0-20250515145715-d9f20e7c840d github.com/kube-bind/kube-bind/sdk v0.4.1 github.com/kube-bind/kube-bind/web v0.0.0-00010101000000-000000000000 @@ -41,18 +47,18 @@ require ( golang.org/x/oauth2 v0.30.0 google.golang.org/grpc v1.72.1 gopkg.in/yaml.v3 v3.0.1 - k8s.io/api v0.34.0 - k8s.io/apiextensions-apiserver v0.34.0 - k8s.io/apimachinery v0.34.0 - k8s.io/apiserver v0.34.0 + k8s.io/api v0.34.2 + k8s.io/apiextensions-apiserver v0.34.2 + k8s.io/apimachinery v0.34.2 + k8s.io/apiserver v0.34.2 k8s.io/cli-runtime v0.34.0 - k8s.io/client-go v0.34.0 - k8s.io/code-generator v0.34.0 - k8s.io/component-base v0.34.0 + k8s.io/client-go v0.34.2 + k8s.io/code-generator v0.34.2 + k8s.io/component-base v0.34.2 k8s.io/klog/v2 v2.130.1 k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 - sigs.k8s.io/controller-runtime v0.21.0 - sigs.k8s.io/multicluster-runtime v0.21.0-alpha.9.0.20251002124257-36facc7fbe82 + sigs.k8s.io/controller-runtime v0.22.4 + sigs.k8s.io/multicluster-runtime v0.22.4-beta.1 sigs.k8s.io/yaml v1.6.0 ) @@ -96,8 +102,7 @@ require ( github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250728122101-adbf20db3e51 // indirect - github.com/kcp-dev/logicalcluster/v3 v3.0.5 // indirect + github.com/kcp-dev/apimachinery/v2 v2.29.1-0.20251209121225-cf3c0b624983 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect github.com/mailru/easyjson v0.9.0 // indirect diff --git a/go.sum b/go.sum index a91df585f..7407a2256 100644 --- a/go.sum +++ b/go.sum @@ -122,16 +122,14 @@ github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8Hm github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250728122101-adbf20db3e51 h1:l38RDS+VUMx9etvyaCgJIZa4nM7FaNevNubWN0kDZY4= -github.com/kcp-dev/apimachinery/v2 v2.0.1-0.20250728122101-adbf20db3e51/go.mod h1:rF1jfvUfPjFXs+HV/LN1BtPzAz1bfjJOwVa+hAVfroQ= -github.com/kcp-dev/kcp/pkg/apis v0.11.0 h1:K6p+tNHNcvfACCPLcHgY0EMLeaIwR1jS491FyLfXMII= -github.com/kcp-dev/kcp/pkg/apis v0.11.0/go.mod h1:8cUAmfMJcksauz53UtsLYG8Phhx62rvuCnd/5t/Zihk= -github.com/kcp-dev/kcp/sdk v0.28.1 h1:bTtuHVjFRjbwFEqXTPxc1J1JP2Hc3mTYqQ2xfJsi16M= -github.com/kcp-dev/kcp/sdk v0.28.1/go.mod h1:8oZpWxkoMu2TDpx5DgdIGDigByKHKkeqVMA4GiWneoI= +github.com/kcp-dev/apimachinery/v2 v2.29.1-0.20251209121225-cf3c0b624983 h1:4hCauFTFMwvIhwL9fqZ5omjeZ+vsOUNO1tLsrCeprxM= +github.com/kcp-dev/apimachinery/v2 v2.29.1-0.20251209121225-cf3c0b624983/go.mod h1:DOv0iw5tcgzFBhudwLFe2WHCLqtlgNkuO4AcqbZ4zVo= github.com/kcp-dev/logicalcluster/v3 v3.0.5 h1:JbYakokb+5Uinz09oTXomSUJVQsqfxEvU4RyHUYxHOU= github.com/kcp-dev/logicalcluster/v3 v3.0.5/go.mod h1:EWBUBxdr49fUB1cLMO4nOdBWmYifLbP1LfoL20KkXYY= -github.com/kcp-dev/multicluster-provider v0.2.1-0.20251002133408-9a8d21dc2872 h1:8lXF2+AwZL1BpWTUVwO/32lzzQ8ggTPSlHlN3Mm9qCA= -github.com/kcp-dev/multicluster-provider v0.2.1-0.20251002133408-9a8d21dc2872/go.mod h1:sDD7nNBNjZLE43280MkDiU7djR+0Ru4N5lAw+b4KQvM= +github.com/kcp-dev/multicluster-provider v0.3.3 h1:wTu1Zbk6+kVlB/d/K9TM7KPjUEe/Dg8SYzKQsVDiDFY= +github.com/kcp-dev/multicluster-provider v0.3.3/go.mod h1:4QGU39wyNztoYNatdWqbdOV6/R9ZzaIh4DdSj30dm9o= +github.com/kcp-dev/sdk v0.0.0-20251210172228-11364df3071c h1:ZyBY4E+loLt7fsQ6uDovEJAu0DSDYrX/OUauMfFzcxQ= +github.com/kcp-dev/sdk v0.0.0-20251210172228-11364df3071c/go.mod h1:IcSuKkvMTJ8Igt95mc0nERhsz/Wf+ECTYg2TKdncgOc= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo= @@ -151,6 +149,8 @@ github.com/mailru/easyjson v0.9.0 h1:PrnmzHw7262yW8sTBwxi1PdJA3Iw/EKBa8psRf7d9a4 github.com/mailru/easyjson v0.9.0/go.mod h1:1+xMtQp2MRNVL/V1bOzuP3aP8VNwRW55fQUto+XFtTU= github.com/martinlindhe/base36 v1.1.1 h1:1F1MZ5MGghBXDZ2KJ3QfxmiydlWOGB8HCEtkap5NkVg= github.com/martinlindhe/base36 v1.1.1/go.mod h1:vMS8PaZ5e/jV9LwFKlm0YLnXl/hpOihiBxKkIoc3g08= +github.com/mjudeikis/mockoidc v0.0.0-20251215121937-c75f164e38b5 h1:79Blv5YDyGQDi2qE2z4BJVoCJOU8vlkydvFqnBM3Wnc= +github.com/mjudeikis/mockoidc v0.0.0-20251215121937-c75f164e38b5/go.mod h1:1S3+yz/sau3wSTpmFOwg+JmOudpq6KA6vTuvmP5VReM= github.com/moby/term v0.5.2 h1:6qk3FJAFDs6i/q3W/pQ97SX192qKfZgGjCQqfCJkgzQ= github.com/moby/term v0.5.2/go.mod h1:d3djjFCrjnB+fl8NJux+EJzu0msscUP+f8it8hPkFLc= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -227,8 +227,6 @@ github.com/xiang90/probing v0.0.0-20221125231312-a49e3df8f510 h1:S2dVYn90KE98chq github.com/xiang90/probing v0.0.0-20221125231312-a49e3df8f510/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ= github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0= -github.com/xrstf/mockoidc v0.0.0-20251110222947-8618052ad848 h1:a+htA0+gdDXONEhY2dSCtz3AuUjbM6ZpRXl8qL0dC5I= -github.com/xrstf/mockoidc v0.0.0-20251110222947-8618052ad848/go.mod h1:1S3+yz/sau3wSTpmFOwg+JmOudpq6KA6vTuvmP5VReM= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= @@ -413,44 +411,44 @@ gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYs gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.34.0 h1:L+JtP2wDbEYPUeNGbeSa/5GwFtIA662EmT2YSLOkAVE= -k8s.io/api v0.34.0/go.mod h1:YzgkIzOOlhl9uwWCZNqpw6RJy9L2FK4dlJeayUoydug= -k8s.io/apiextensions-apiserver v0.34.0 h1:B3hiB32jV7BcyKcMU5fDaDxk882YrJ1KU+ZSkA9Qxoc= -k8s.io/apiextensions-apiserver v0.34.0/go.mod h1:hLI4GxE1BDBy9adJKxUxCEHBGZtGfIg98Q+JmTD7+g0= -k8s.io/apimachinery v0.34.0 h1:eR1WO5fo0HyoQZt1wdISpFDffnWOvFLOOeJ7MgIv4z0= -k8s.io/apimachinery v0.34.0/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw= -k8s.io/apiserver v0.34.0 h1:Z51fw1iGMqN7uJ1kEaynf2Aec1Y774PqU+FVWCFV3Jg= -k8s.io/apiserver v0.34.0/go.mod h1:52ti5YhxAvewmmpVRqlASvaqxt0gKJxvCeW7ZrwgazQ= +k8s.io/api v0.34.2 h1:fsSUNZhV+bnL6Aqrp6O7lMTy6o5x2C4XLjnh//8SLYY= +k8s.io/api v0.34.2/go.mod h1:MMBPaWlED2a8w4RSeanD76f7opUoypY8TFYkSM+3XHw= +k8s.io/apiextensions-apiserver v0.34.2 h1:WStKftnGeoKP4AZRz/BaAAEJvYp4mlZGN0UCv+uvsqo= +k8s.io/apiextensions-apiserver v0.34.2/go.mod h1:398CJrsgXF1wytdaanynDpJ67zG4Xq7yj91GrmYN2SE= +k8s.io/apimachinery v0.34.2 h1:zQ12Uk3eMHPxrsbUJgNF8bTauTVR2WgqJsTmwTE/NW4= +k8s.io/apimachinery v0.34.2/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw= +k8s.io/apiserver v0.34.2 h1:2/yu8suwkmES7IzwlehAovo8dDE07cFRC7KMDb1+MAE= +k8s.io/apiserver v0.34.2/go.mod h1:gqJQy2yDOB50R3JUReHSFr+cwJnL8G1dzTA0YLEqAPI= k8s.io/cli-runtime v0.34.0 h1:N2/rUlJg6TMEBgtQ3SDRJwa8XyKUizwjlOknT1mB2Cw= k8s.io/cli-runtime v0.34.0/go.mod h1:t/skRecS73Piv+J+FmWIQA2N2/rDjdYSQzEE67LUUs8= -k8s.io/client-go v0.34.0 h1:YoWv5r7bsBfb0Hs2jh8SOvFbKzzxyNo0nSb0zC19KZo= -k8s.io/client-go v0.34.0/go.mod h1:ozgMnEKXkRjeMvBZdV1AijMHLTh3pbACPvK7zFR+QQY= -k8s.io/code-generator v0.34.0 h1:Ze2i1QsvUprIlX3oHiGv09BFQRLCz+StA8qKwwFzees= -k8s.io/code-generator v0.34.0/go.mod h1:Py2+4w2HXItL8CGhks8uI/wS3Y93wPKO/9mBQUYNua0= -k8s.io/component-base v0.34.0 h1:bS8Ua3zlJzapklsB1dZgjEJuJEeHjj8yTu1gxE2zQX8= -k8s.io/component-base v0.34.0/go.mod h1:RSCqUdvIjjrEm81epPcjQ/DS+49fADvGSCkIP3IC6vg= +k8s.io/client-go v0.34.2 h1:Co6XiknN+uUZqiddlfAjT68184/37PS4QAzYvQvDR8M= +k8s.io/client-go v0.34.2/go.mod h1:2VYDl1XXJsdcAxw7BenFslRQX28Dxz91U9MWKjX97fE= +k8s.io/code-generator v0.34.2 h1:9bG6jTxmsU3HXE5BNYJTC8AZ1D6hVVfkm8yYSkdkGY0= +k8s.io/code-generator v0.34.2/go.mod h1:dnDDEd6S/z4uZ+PG1aE58ySCi/lR4+qT3a4DddE4/2I= +k8s.io/component-base v0.34.2 h1:HQRqK9x2sSAsd8+R4xxRirlTjowsg6fWCPwWYeSvogQ= +k8s.io/component-base v0.34.2/go.mod h1:9xw2FHJavUHBFpiGkZoKuYZ5pdtLKe97DEByaA+hHbM= k8s.io/gengo/v2 v2.0.0-20250604051438-85fd79dbfd9f h1:SLb+kxmzfA87x4E4brQzB33VBbT2+x7Zq9ROIHmGn9Q= k8s.io/gengo/v2 v2.0.0-20250604051438-85fd79dbfd9f/go.mod h1:EJykeLsmFC60UQbYJezXkEsG2FLrt0GPNkU5iK5GWxU= k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kms v0.34.0 h1:u+/rcxQ3Jr7gC9AY5nXuEnBcGEB7ZOIJ9cdLdyHyEjQ= -k8s.io/kms v0.34.0/go.mod h1:s1CFkLG7w9eaTYvctOxosx88fl4spqmixnNpys0JAtM= +k8s.io/kms v0.34.2 h1:91rj4MDZLyIT9KxG8J5/CcMH666Z88CF/xJQeuPfJc8= +k8s.io/kms v0.34.2/go.mod h1:s1CFkLG7w9eaTYvctOxosx88fl4spqmixnNpys0JAtM= k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b h1:MloQ9/bdJyIu9lb1PzujOPolHyvO06MXG5TUIj2mNAA= k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b/go.mod h1:UZ2yyWbFTpuhSbFhv24aGNOdoRdJZgsIObGBUaYVsts= k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 h1:hwvWFiBzdWw1FhfY1FooPn3kzWuJ8tmbZBHi4zVsl1Y= k8s.io/utils v0.0.0-20250604170112-4c0f3b243397/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2 h1:jpcvIRr3GLoUoEKRkHKSmGjxb6lWwrBlJsXc+eUYQHM= sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.31.2/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw= -sigs.k8s.io/controller-runtime v0.21.0 h1:CYfjpEuicjUecRk+KAeyYh+ouUBn4llGyDYytIGcJS8= -sigs.k8s.io/controller-runtime v0.21.0/go.mod h1:OSg14+F65eWqIu4DceX7k/+QRAbTTvxeQSNSOQpukWM= +sigs.k8s.io/controller-runtime v0.22.4 h1:GEjV7KV3TY8e+tJ2LCTxUTanW4z/FmNB7l327UfMq9A= +sigs.k8s.io/controller-runtime v0.22.4/go.mod h1:+QX1XUpTXN4mLoblf4tqr5CQcyHPAki2HLXqQMY6vh8= sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 h1:gBQPwqORJ8d8/YNZWEjoZs7npUVDpVXUUOFfW6CgAqE= sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= sigs.k8s.io/kustomize/api v0.20.1 h1:iWP1Ydh3/lmldBnH/S5RXgT98vWYMaTUL1ADcr+Sv7I= sigs.k8s.io/kustomize/api v0.20.1/go.mod h1:t6hUFxO+Ph0VxIk1sKp1WS0dOjbPCtLJ4p8aADLwqjM= sigs.k8s.io/kustomize/kyaml v0.20.1 h1:PCMnA2mrVbRP3NIB6v9kYCAc38uvFLVs8j/CD567A78= sigs.k8s.io/kustomize/kyaml v0.20.1/go.mod h1:0EmkQHRUsJxY8Ug9Niig1pUMSCGHxQ5RklbpV/Ri6po= -sigs.k8s.io/multicluster-runtime v0.21.0-alpha.9.0.20251002124257-36facc7fbe82 h1:RRenMVUCSVrxcLb5y84IrF4q6dxcaBW/xfq3rxkdhwM= -sigs.k8s.io/multicluster-runtime v0.21.0-alpha.9.0.20251002124257-36facc7fbe82/go.mod h1:CpBzLMLQKdm+UCchd2FiGPiDdCxM5dgCCPKuaQ6Fsv0= +sigs.k8s.io/multicluster-runtime v0.22.4-beta.1 h1:0XWbDINepM9UOyLkqhG4g7BtGBFKCDvZFyPsw1vufKE= +sigs.k8s.io/multicluster-runtime v0.22.4-beta.1/go.mod h1:zSMb4mC8MAZK42l8eE1ywkeX6vjuNRenYzJ1w+GPdfI= sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= sigs.k8s.io/randfill v1.0.0/go.mod h1:XeLlZ/jmk4i1HRopwe7/aU3H5n1zNUcX6TM94b3QxOY= sigs.k8s.io/structured-merge-diff/v6 v6.3.0 h1:jTijUJbW353oVOd9oTlifJqOGEkUw2jB/fXCbTiQEco= diff --git a/hack/tools.checksums b/hack/tools.checksums index d13423a16..af558850b 100644 --- a/hack/tools.checksums +++ b/hack/tools.checksums @@ -1,9 +1,11 @@ golangci-lint|GOARCH=amd64;GOOS=linux|7009324a8aad93c1f84dce1c3cf61181bdd6b68e5f1b8b5d6971662258255050 +golangci-lint|GOARCH=arm64;GOOS=darwin|96dc1dbbb686fc7982b9ea4b800f3d234a2d9fb78b0344f287e8d28ee11bc72b golangci-lint|GOARCH=arm64;GOOS=linux|c51ff5b21be688b043baea44de7dd855cf07b855c14f0de405bfaf922b1d7634 goreleaser|ARCH=x86_64;OS=Linux|8de4a7d97d9b2b62e8186bcd28f7a203ba55ecfaaa4329e14264d3235095faed gotestsum|GOARCH=amd64;GOOS=linux|ee25248e6f5073cad0b7a712c97ed473adb7420f7eefad534177de0113a8a505 gotestsum|GOARCH=arm64;GOOS=linux|7a5e7f8cb5e2126be563b7c7182cc4522fbc65408a99df82d156d30e997b8705 helm|GOARCH=amd64;GOOS=linux|c153fd9c1173f39aefe8e9aa9f00fd3daf6b40c8ea01e94a0d2f2c1787fc60e0 kcp|GOARCH=amd64;GOOS=linux|41149ef78d2092243b14164a363dfdacc3e0f2bece8c00b715457c21c423a80b +kcp|GOARCH=arm64;GOOS=darwin|3ce40db499e2bc06eb383cde94be553c0b587b1c99997663bf31877be3fd45d0 kcp|GOARCH=arm64;GOOS=linux|bd2412179c1e3294dc81641630e0a2184892d4b45c6ef5bed7dc15fbd2c333fe verify_boilerplate.py||6928a807e2ffc2e6902de705ce7a7cddbbbf5ef61a43901432c4f4551b4e9a7b diff --git a/sdk/apis/kubebind/v1alpha2/cluster_types.go b/sdk/apis/kubebind/v1alpha2/cluster_types.go new file mode 100644 index 000000000..821f49b7a --- /dev/null +++ b/sdk/apis/kubebind/v1alpha2/cluster_types.go @@ -0,0 +1,85 @@ +/* +Copyright 2025 The Kube Bind Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + conditionsapi "github.com/kube-bind/kube-bind/sdk/apis/third_party/conditions/apis/conditions/v1alpha1" +) + +const ( + // ClusterConditionHealthy is set when the cluster is healthy. + ClusterConditionHealthy = "Healthy" +) + +const ( + // DefaultClusterName is the name of the default cluster. + DefaultClusterName = "default" +) + +// Cluster represents a cluster, managed by kube-bind. +// +// +crd +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:scope=Cluster,categories=kube-bind +// +kubebuilder:storageversion +// +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=`.status.conditions[?(@.type=="Ready")].status`,priority=0 +type Cluster struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata"` + + // spec represents the data in the newly created ClusterBinding. + // +required + // +kubebuilder:validation:Required + Spec ClusterSpec `json:"spec"` + + // status contains reconciliation information for the service binding. + Status ClusterStatus `json:"status"` +} + +func (in *Cluster) GetConditions() conditionsapi.Conditions { + return in.Status.Conditions +} + +func (in *Cluster) SetConditions(conditions conditionsapi.Conditions) { + in.Status.Conditions = conditions +} + +// ClusterSpec represents the data in the newly created Cluster. +type ClusterSpec struct { +} + +// ClusterStatus stores status information about a service binding. It is +// updated by both the konnector and the service provider. +type ClusterStatus struct { + // conditions is a list of conditions that apply to the ClusterBinding. It is + // updated by the konnector and the service provider. + Conditions conditionsapi.Conditions `json:"conditions,omitempty"` +} + +// ClusterList is the objects list that represents the Cluster. +// +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +type ClusterList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Cluster `json:"items"` +} diff --git a/sdk/apis/kubebind/v1alpha2/error_types.go b/sdk/apis/kubebind/v1alpha2/error_types.go new file mode 100644 index 000000000..50263452f --- /dev/null +++ b/sdk/apis/kubebind/v1alpha2/error_types.go @@ -0,0 +1,67 @@ +/* +Copyright 2025 The Kube Bind Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1alpha2 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// Error represents a structured error response from the kube-bind backend +// +kubebuilder:object:root=true +type Error struct { + metav1.TypeMeta `json:",inline"` + // Message is the human-readable error message + Message string `json:"message"` + // Code is the error code that can be used for programmatic handling + Code string `json:"code"` + // Details provides additional context about the error + Details string `json:"details,omitempty"` +} + +// Common error codes +const ( + // ErrorCodeAuthenticationFailed indicates authentication failure + ErrorCodeAuthenticationFailed = "AUTHENTICATION_FAILED" + // ErrorCodeAuthorizationFailed indicates authorization failure + ErrorCodeAuthorizationFailed = "AUTHORIZATION_FAILED" + // ErrorCodeResourceNotFound indicates a requested resource was not found + ErrorCodeResourceNotFound = "RESOURCE_NOT_FOUND" + // ErrorCodeInternalError indicates an internal server error + ErrorCodeInternalError = "INTERNAL_ERROR" + // ErrorCodeBadRequest indicates a malformed request + ErrorCodeBadRequest = "BAD_REQUEST" + // ErrorCodeClusterConnectionFailed indicates failure to connect to cluster + ErrorCodeClusterConnectionFailed = "CLUSTER_CONNECTION_FAILED" +) + +// NewError creates a new Error with the specified code, message and optional details +func NewError(code, message, details string) *Error { + return &Error{ + TypeMeta: metav1.TypeMeta{ + APIVersion: SchemeGroupVersion.String(), + Kind: "Error", + }, + Code: code, + Message: message, + Details: details, + } +} + +// Error implements the error interface +func (e *Error) Error() string { + return e.Message +} \ No newline at end of file diff --git a/sdk/apis/kubebind/v1alpha2/register.go b/sdk/apis/kubebind/v1alpha2/register.go index 8f71322f8..b4a6e683e 100644 --- a/sdk/apis/kubebind/v1alpha2/register.go +++ b/sdk/apis/kubebind/v1alpha2/register.go @@ -64,6 +64,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { &APIServiceExportTemplateList{}, &Collection{}, &CollectionList{}, + &Cluster{}, + &ClusterList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) diff --git a/backend/provider/provider.go b/sdk/apis/kubebind/v1alpha2/types.go similarity index 66% rename from backend/provider/provider.go rename to sdk/apis/kubebind/v1alpha2/types.go index 1428b1ea7..8ef71cbb4 100644 --- a/backend/provider/provider.go +++ b/sdk/apis/kubebind/v1alpha2/types.go @@ -14,4 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. */ -package provider +package v1alpha2 + +const ( + // OIDCProviderTypeEmbedded represents an embedded OIDC provider managed by kube-bind. + OIDCProviderTypeEmbedded = "embedded" + // OIDCProviderTypeExternal represents an external OIDC provider managed outside of kube-bind. + OIDCProviderTypeExternal = "external" +) diff --git a/sdk/apis/kubebind/v1alpha2/zz_generated.deepcopy.go b/sdk/apis/kubebind/v1alpha2/zz_generated.deepcopy.go index 4f96c56ee..87fe4ea83 100644 --- a/sdk/apis/kubebind/v1alpha2/zz_generated.deepcopy.go +++ b/sdk/apis/kubebind/v1alpha2/zz_generated.deepcopy.go @@ -1001,6 +1001,34 @@ func (in *BoundSchemaStatus) DeepCopy() *BoundSchemaStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Cluster) DeepCopyInto(out *Cluster) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Cluster. +func (in *Cluster) DeepCopy() *Cluster { + if in == nil { + return nil + } + out := new(Cluster) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Cluster) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterBinding) DeepCopyInto(out *ClusterBinding) { *out = *in @@ -1105,6 +1133,39 @@ func (in *ClusterBindingStatus) DeepCopy() *ClusterBindingStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterList) DeepCopyInto(out *ClusterList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Cluster, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterList. +func (in *ClusterList) DeepCopy() *ClusterList { + if in == nil { + return nil + } + out := new(ClusterList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterSecretKeyRef) DeepCopyInto(out *ClusterSecretKeyRef) { *out = *in @@ -1122,6 +1183,45 @@ func (in *ClusterSecretKeyRef) DeepCopy() *ClusterSecretKeyRef { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSpec. +func (in *ClusterSpec) DeepCopy() *ClusterSpec { + if in == nil { + return nil + } + out := new(ClusterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterStatus) DeepCopyInto(out *ClusterStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make(v1alpha1.Conditions, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterStatus. +func (in *ClusterStatus) DeepCopy() *ClusterStatus { + if in == nil { + return nil + } + out := new(ClusterStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Collection) DeepCopyInto(out *Collection) { *out = *in @@ -1248,6 +1348,23 @@ func (in *CustomResourceConversion) DeepCopy() *CustomResourceConversion { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Error) DeepCopyInto(out *Error) { + *out = *in + out.TypeMeta = in.TypeMeta + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Error. +func (in *Error) DeepCopy() *Error { + if in == nil { + return nil + } + out := new(Error) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in ExportedSchemas) DeepCopyInto(out *ExportedSchemas) { { diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/cluster.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/cluster.go new file mode 100644 index 000000000..9a61c664b --- /dev/null +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/cluster.go @@ -0,0 +1,70 @@ +/* +Copyright The Kube Bind Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + context "context" + + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + scheme "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned/scheme" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" +) + +// ClustersGetter has a method to return a ClusterInterface. +// A group's client should implement this interface. +type ClustersGetter interface { + Clusters(namespace string) ClusterInterface +} + +// ClusterInterface has methods to work with Cluster resources. +type ClusterInterface interface { + Create(ctx context.Context, cluster *kubebindv1alpha2.Cluster, opts v1.CreateOptions) (*kubebindv1alpha2.Cluster, error) + Update(ctx context.Context, cluster *kubebindv1alpha2.Cluster, opts v1.UpdateOptions) (*kubebindv1alpha2.Cluster, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, cluster *kubebindv1alpha2.Cluster, opts v1.UpdateOptions) (*kubebindv1alpha2.Cluster, error) + Delete(ctx context.Context, name string, opts v1.DeleteOptions) error + DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error + Get(ctx context.Context, name string, opts v1.GetOptions) (*kubebindv1alpha2.Cluster, error) + List(ctx context.Context, opts v1.ListOptions) (*kubebindv1alpha2.ClusterList, error) + Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) + Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *kubebindv1alpha2.Cluster, err error) + ClusterExpansion +} + +// clusters implements ClusterInterface +type clusters struct { + *gentype.ClientWithList[*kubebindv1alpha2.Cluster, *kubebindv1alpha2.ClusterList] +} + +// newClusters returns a Clusters +func newClusters(c *KubeBindV1alpha2Client, namespace string) *clusters { + return &clusters{ + gentype.NewClientWithList[*kubebindv1alpha2.Cluster, *kubebindv1alpha2.ClusterList]( + "clusters", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *kubebindv1alpha2.Cluster { return &kubebindv1alpha2.Cluster{} }, + func() *kubebindv1alpha2.ClusterList { return &kubebindv1alpha2.ClusterList{} }, + ), + } +} diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_cluster.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_cluster.go new file mode 100644 index 000000000..43e366d24 --- /dev/null +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_cluster.go @@ -0,0 +1,50 @@ +/* +Copyright The Kube Bind Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by client-gen. DO NOT EDIT. + +package fake + +import ( + v1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned/typed/kubebind/v1alpha2" + gentype "k8s.io/client-go/gentype" +) + +// fakeClusters implements ClusterInterface +type fakeClusters struct { + *gentype.FakeClientWithList[*v1alpha2.Cluster, *v1alpha2.ClusterList] + Fake *FakeKubeBindV1alpha2 +} + +func newFakeClusters(fake *FakeKubeBindV1alpha2, namespace string) kubebindv1alpha2.ClusterInterface { + return &fakeClusters{ + gentype.NewFakeClientWithList[*v1alpha2.Cluster, *v1alpha2.ClusterList]( + fake.Fake, + namespace, + v1alpha2.SchemeGroupVersion.WithResource("clusters"), + v1alpha2.SchemeGroupVersion.WithKind("Cluster"), + func() *v1alpha2.Cluster { return &v1alpha2.Cluster{} }, + func() *v1alpha2.ClusterList { return &v1alpha2.ClusterList{} }, + func(dst, src *v1alpha2.ClusterList) { dst.ListMeta = src.ListMeta }, + func(list *v1alpha2.ClusterList) []*v1alpha2.Cluster { return gentype.ToPointerSlice(list.Items) }, + func(list *v1alpha2.ClusterList, items []*v1alpha2.Cluster) { + list.Items = gentype.FromPointerSlice(items) + }, + ), + fake, + } +} diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_kubebind_client.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_kubebind_client.go index 17d65407f..ac2d7310d 100644 --- a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_kubebind_client.go +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/fake/fake_kubebind_client.go @@ -48,6 +48,10 @@ func (c *FakeKubeBindV1alpha2) BoundSchemas(namespace string) v1alpha2.BoundSche return newFakeBoundSchemas(c, namespace) } +func (c *FakeKubeBindV1alpha2) Clusters(namespace string) v1alpha2.ClusterInterface { + return newFakeClusters(c, namespace) +} + func (c *FakeKubeBindV1alpha2) ClusterBindings(namespace string) v1alpha2.ClusterBindingInterface { return newFakeClusterBindings(c, namespace) } diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/generated_expansion.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/generated_expansion.go index 3be2b1782..182625159 100644 --- a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/generated_expansion.go +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/generated_expansion.go @@ -28,6 +28,8 @@ type APIServiceNamespaceExpansion interface{} type BoundSchemaExpansion interface{} +type ClusterExpansion interface{} + type ClusterBindingExpansion interface{} type CollectionExpansion interface{} diff --git a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/kubebind_client.go b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/kubebind_client.go index d31e864bb..92189fb0b 100644 --- a/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/kubebind_client.go +++ b/sdk/client/clientset/versioned/typed/kubebind/v1alpha2/kubebind_client.go @@ -33,6 +33,7 @@ type KubeBindV1alpha2Interface interface { APIServiceExportRequestsGetter APIServiceNamespacesGetter BoundSchemasGetter + ClustersGetter ClusterBindingsGetter CollectionsGetter } @@ -62,6 +63,10 @@ func (c *KubeBindV1alpha2Client) BoundSchemas(namespace string) BoundSchemaInter return newBoundSchemas(c, namespace) } +func (c *KubeBindV1alpha2Client) Clusters(namespace string) ClusterInterface { + return newClusters(c, namespace) +} + func (c *KubeBindV1alpha2Client) ClusterBindings(namespace string) ClusterBindingInterface { return newClusterBindings(c, namespace) } diff --git a/sdk/client/informers/externalversions/generic.go b/sdk/client/informers/externalversions/generic.go index fa39a9633..9fedd751b 100644 --- a/sdk/client/informers/externalversions/generic.go +++ b/sdk/client/informers/externalversions/generic.go @@ -76,6 +76,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().APIServiceNamespaces().Informer()}, nil case v1alpha2.SchemeGroupVersion.WithResource("boundschemas"): return &genericInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().BoundSchemas().Informer()}, nil + case v1alpha2.SchemeGroupVersion.WithResource("clusters"): + return &genericInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().Clusters().Informer()}, nil case v1alpha2.SchemeGroupVersion.WithResource("clusterbindings"): return &genericInformer{resource: resource.GroupResource(), informer: f.KubeBind().V1alpha2().ClusterBindings().Informer()}, nil case v1alpha2.SchemeGroupVersion.WithResource("collections"): diff --git a/sdk/client/informers/externalversions/kubebind/v1alpha2/cluster.go b/sdk/client/informers/externalversions/kubebind/v1alpha2/cluster.go new file mode 100644 index 000000000..a0157b4aa --- /dev/null +++ b/sdk/client/informers/externalversions/kubebind/v1alpha2/cluster.go @@ -0,0 +1,102 @@ +/* +Copyright The Kube Bind Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by informer-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + context "context" + time "time" + + apiskubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + versioned "github.com/kube-bind/kube-bind/sdk/client/clientset/versioned" + internalinterfaces "github.com/kube-bind/kube-bind/sdk/client/informers/externalversions/internalinterfaces" + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/client/listers/kubebind/v1alpha2" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" +) + +// ClusterInformer provides access to a shared informer and lister for +// Clusters. +type ClusterInformer interface { + Informer() cache.SharedIndexInformer + Lister() kubebindv1alpha2.ClusterLister +} + +type clusterInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewClusterInformer constructs a new informer for Cluster type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewClusterInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredClusterInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredClusterInformer constructs a new informer for Cluster type. +// Always prefer using an informer factory to get a shared informer instead of getting an independent +// one. This reduces memory footprint and number of connections to the server. +func NewFilteredClusterInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { + return cache.NewSharedIndexInformer( + &cache.ListWatch{ + ListFunc: func(options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().Clusters(namespace).List(context.Background(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().Clusters(namespace).Watch(context.Background(), options) + }, + ListWithContextFunc: func(ctx context.Context, options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().Clusters(namespace).List(ctx, options) + }, + WatchFuncWithContext: func(ctx context.Context, options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.KubeBindV1alpha2().Clusters(namespace).Watch(ctx, options) + }, + }, + &apiskubebindv1alpha2.Cluster{}, + resyncPeriod, + indexers, + ) +} + +func (f *clusterInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredClusterInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *clusterInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&apiskubebindv1alpha2.Cluster{}, f.defaultInformer) +} + +func (f *clusterInformer) Lister() kubebindv1alpha2.ClusterLister { + return kubebindv1alpha2.NewClusterLister(f.Informer().GetIndexer()) +} diff --git a/sdk/client/informers/externalversions/kubebind/v1alpha2/interface.go b/sdk/client/informers/externalversions/kubebind/v1alpha2/interface.go index 1e7187ba9..9f6cebe08 100644 --- a/sdk/client/informers/externalversions/kubebind/v1alpha2/interface.go +++ b/sdk/client/informers/externalversions/kubebind/v1alpha2/interface.go @@ -34,6 +34,8 @@ type Interface interface { APIServiceNamespaces() APIServiceNamespaceInformer // BoundSchemas returns a BoundSchemaInformer. BoundSchemas() BoundSchemaInformer + // Clusters returns a ClusterInformer. + Clusters() ClusterInformer // ClusterBindings returns a ClusterBindingInformer. ClusterBindings() ClusterBindingInformer // Collections returns a CollectionInformer. @@ -76,6 +78,11 @@ func (v *version) BoundSchemas() BoundSchemaInformer { return &boundSchemaInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} } +// Clusters returns a ClusterInformer. +func (v *version) Clusters() ClusterInformer { + return &clusterInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // ClusterBindings returns a ClusterBindingInformer. func (v *version) ClusterBindings() ClusterBindingInformer { return &clusterBindingInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/sdk/client/listers/kubebind/v1alpha2/cluster.go b/sdk/client/listers/kubebind/v1alpha2/cluster.go new file mode 100644 index 000000000..6bba81e5a --- /dev/null +++ b/sdk/client/listers/kubebind/v1alpha2/cluster.go @@ -0,0 +1,70 @@ +/* +Copyright The Kube Bind Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Code generated by lister-gen. DO NOT EDIT. + +package v1alpha2 + +import ( + kubebindv1alpha2 "github.com/kube-bind/kube-bind/sdk/apis/kubebind/v1alpha2" + labels "k8s.io/apimachinery/pkg/labels" + listers "k8s.io/client-go/listers" + cache "k8s.io/client-go/tools/cache" +) + +// ClusterLister helps list Clusters. +// All objects returned here must be treated as read-only. +type ClusterLister interface { + // List lists all Clusters in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.Cluster, err error) + // Clusters returns an object that can list and get Clusters. + Clusters(namespace string) ClusterNamespaceLister + ClusterListerExpansion +} + +// clusterLister implements the ClusterLister interface. +type clusterLister struct { + listers.ResourceIndexer[*kubebindv1alpha2.Cluster] +} + +// NewClusterLister returns a new ClusterLister. +func NewClusterLister(indexer cache.Indexer) ClusterLister { + return &clusterLister{listers.New[*kubebindv1alpha2.Cluster](indexer, kubebindv1alpha2.Resource("cluster"))} +} + +// Clusters returns an object that can list and get Clusters. +func (s *clusterLister) Clusters(namespace string) ClusterNamespaceLister { + return clusterNamespaceLister{listers.NewNamespaced[*kubebindv1alpha2.Cluster](s.ResourceIndexer, namespace)} +} + +// ClusterNamespaceLister helps list and get Clusters. +// All objects returned here must be treated as read-only. +type ClusterNamespaceLister interface { + // List lists all Clusters in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*kubebindv1alpha2.Cluster, err error) + // Get retrieves the Cluster from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*kubebindv1alpha2.Cluster, error) + ClusterNamespaceListerExpansion +} + +// clusterNamespaceLister implements the ClusterNamespaceLister +// interface. +type clusterNamespaceLister struct { + listers.ResourceIndexer[*kubebindv1alpha2.Cluster] +} diff --git a/sdk/client/listers/kubebind/v1alpha2/expansion_generated.go b/sdk/client/listers/kubebind/v1alpha2/expansion_generated.go index fc8aa4060..08932cb79 100644 --- a/sdk/client/listers/kubebind/v1alpha2/expansion_generated.go +++ b/sdk/client/listers/kubebind/v1alpha2/expansion_generated.go @@ -54,6 +54,14 @@ type BoundSchemaListerExpansion interface{} // BoundSchemaNamespaceLister. type BoundSchemaNamespaceListerExpansion interface{} +// ClusterListerExpansion allows custom methods to be added to +// ClusterLister. +type ClusterListerExpansion interface{} + +// ClusterNamespaceListerExpansion allows custom methods to be added to +// ClusterNamespaceLister. +type ClusterNamespaceListerExpansion interface{} + // ClusterBindingListerExpansion allows custom methods to be added to // ClusterBindingLister. type ClusterBindingListerExpansion interface{} diff --git a/test/e2e/framework/backend.go b/test/e2e/framework/backend.go index a98e94ec4..fc63c1454 100644 --- a/test/e2e/framework/backend.go +++ b/test/e2e/framework/backend.go @@ -46,6 +46,7 @@ func InstallKubeBindCRDs(t testing.TB, clientConfig *rest.Config) { metav1.GroupResource{Group: kubebindv1alpha2.GroupName, Resource: "boundschemas"}, metav1.GroupResource{Group: kubebindv1alpha2.GroupName, Resource: "apiserviceexporttemplates"}, metav1.GroupResource{Group: kubebindv1alpha2.GroupName, Resource: "collections"}, + metav1.GroupResource{Group: kubebindv1alpha2.GroupName, Resource: "clusters"}, ) require.NoError(t, err) } @@ -66,7 +67,7 @@ func StartBackend(t testing.TB, args ...string) (net.Addr, *backend.Server) { require.NoError(t, err) addr := opts.Serve.Listener.Addr() - opts.OIDC.Type = string(options.OIDCTypeEmbedded) + opts.OIDC.Type = string(kubebindv1alpha2.OIDCProviderTypeEmbedded) opts.OIDC.IssuerURL = fmt.Sprintf("http://%s/oidc", addr.String()) opts.OIDC.CallbackURL = fmt.Sprintf("http://%s/api/callback", addr.String()) diff --git a/test/e2e/framework/kcp.go b/test/e2e/framework/kcp.go index f9945834c..cb06e8755 100644 --- a/test/e2e/framework/kcp.go +++ b/test/e2e/framework/kcp.go @@ -26,8 +26,8 @@ import ( "testing" "time" - corev1alpha1 "github.com/kcp-dev/kcp/pkg/apis/core/v1alpha1" - tenancyv1alpha1 "github.com/kcp-dev/kcp/pkg/apis/tenancy/v1alpha1" + corev1alpha1 "github.com/kcp-dev/sdk/apis/core/v1alpha1" + tenancyv1alpha1 "github.com/kcp-dev/sdk/apis/tenancy/v1alpha1" "github.com/martinlindhe/base36" "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/api/errors" @@ -126,8 +126,14 @@ func NewWorkspace(t *testing.T, config *rest.Config, options ...ClusterWorkspace for _, opt := range options { opt(ws) } - err = tenancyClient.Create(ctx, ws) - require.NoError(t, err) + // retry as on startup kcp might be busy + require.Eventually(t, func() bool { + err = tenancyClient.Create(ctx, ws) + if err != nil && !errors.IsAlreadyExists(err) { + return false + } + return true + }, wait.ForeverTestTimeout, time.Millisecond*100, "failed to create workspace %s", ws.Name) ret := rest.CopyConfig(config) ret.Host += ":" + ws.Name diff --git a/web/src/App.vue b/web/src/App.vue index 50480a3a0..b062ce6ee 100644 --- a/web/src/App.vue +++ b/web/src/App.vue @@ -32,8 +32,18 @@

Authentication Required

-

Please authenticate to access resources.

- +
+
⚠️
+
+

Authentication Error

+

{{ authStatus.error }}

+
+
+

Please authenticate to access resources.

+
@@ -44,7 +54,7 @@ @@ -264,4 +291,38 @@ onMounted(() => { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4); } + +.auth-error { + display: flex; + align-items: flex-start; + gap: 1rem; + padding: 1rem 1.5rem; + margin: 1.5rem 0; + background: #fef2f2; + border: 1px solid #fecaca; + border-radius: 12px; + max-width: 500px; + text-align: left; + box-shadow: 0 2px 8px rgba(239, 68, 68, 0.1); +} + +.error-icon { + font-size: 1.5rem; + line-height: 1; + margin-top: 0.125rem; +} + +.error-content h3 { + margin: 0 0 0.5rem 0; + color: #dc2626; + font-size: 1rem; + font-weight: 600; +} + +.error-content p { + margin: 0; + color: #991b1b; + font-size: 0.875rem; + line-height: 1.5; +} \ No newline at end of file diff --git a/web/src/services/auth.ts b/web/src/services/auth.ts index 87753697a..10834c6eb 100644 --- a/web/src/services/auth.ts +++ b/web/src/services/auth.ts @@ -1,12 +1,25 @@ +import { httpClient, StructuredError } from './http' +import { ErrorCodes } from '../types/binding' + export interface AuthStatus { isAuthenticated: boolean sessionId?: string clusterId?: string } +export interface AuthCheckResult { + isAuthenticated: boolean + error?: string +} + class AuthService { async isAuthenticated(): Promise { + const result = await this.checkAuthentication() + return result.isAuthenticated + } + + async checkAuthentication(): Promise { try { // Since cookies are HTTP-only, we need to check authentication by making an API call const urlParams = new URLSearchParams(window.location.search) @@ -15,18 +28,40 @@ class AuthService { // Make a simple API call to check if we're authenticated const authCheckUrl = clusterId ? `/ping?cluster_id=${clusterId}` : '/ping' - const response = await fetch(`/api${authCheckUrl}`, { - method: 'GET', - credentials: 'include' // Include cookies - }) + const response = await httpClient.get(authCheckUrl) const isAuth = response.status === 200 console.log('Auth check:', { clusterId, status: response.status, isAuth }) - return isAuth + return { isAuthenticated: isAuth } } catch (error) { + // Handle structured errors + if (error instanceof StructuredError) { + const kubeError = error.kubeBindError + + // Return structured error message for auth/authorization failures + if (kubeError.code === ErrorCodes.AUTHENTICATION_FAILED || kubeError.code === ErrorCodes.AUTHORIZATION_FAILED) { + return { + isAuthenticated: false, + error: kubeError.message + } + } + } + + // Handle cases where we get 401/403 but don't have the expected structured error + if ((error as any)?.response?.status === 401 || (error as any)?.response?.status === 403) { + console.log('Auth check failed with authentication error but no structured response') + return { + isAuthenticated: false, + error: 'Authentication required' + } + } + console.error('Auth check error:', error) - return false + return { + isAuthenticated: false, + error: 'Authentication check failed' + } } } @@ -65,10 +100,7 @@ class AuthService { : '/api/logout' // Make POST request to logout endpoint - const response = await fetch(logoutUrl, { - method: 'POST', - credentials: 'include' // Include cookies in the request - }) + const response = await httpClient.post(logoutUrl) console.log('Logout response:', { status: response.status, clusterId }) @@ -76,6 +108,7 @@ class AuthService { window.location.href = window.location.origin + window.location.pathname } catch (error) { console.error('Logout error:', error) + // Still try to reload even if there was an error window.location.reload() } diff --git a/web/src/services/http.ts b/web/src/services/http.ts index 996cb6ea2..f61db4b9d 100644 --- a/web/src/services/http.ts +++ b/web/src/services/http.ts @@ -1,5 +1,18 @@ import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios' -import { authService } from './auth' +import { isKubeBindError, type KubeBindError, ErrorCodes } from '../types/binding' + +// Custom error class for structured errors +export class StructuredError extends Error { + public readonly kubeBindError: KubeBindError + public readonly httpStatus: number + + constructor(kubeBindError: KubeBindError, httpStatus: number) { + super(kubeBindError.message) + this.kubeBindError = kubeBindError + this.httpStatus = httpStatus + this.name = 'StructuredError' + } +} class HttpClient { private client: AxiosInstance @@ -30,15 +43,26 @@ class HttpClient { } ) - // Response interceptor to handle auth errors + // Response interceptor to handle structured errors this.client.interceptors.response.use( (response) => response, (error) => { - if (error.response?.status === 401) { - // Session expired or invalid - emit event for App.vue to handle - console.warn('Authentication expired, need to re-authenticate') - window.dispatchEvent(new CustomEvent('auth-expired')) + const status = error.response?.status + const responseData = error.response?.data + + // Check if we received a structured error from the backend + if (responseData && isKubeBindError(responseData)) { + // Handle specific error codes + if (responseData.code === ErrorCodes.AUTHENTICATION_FAILED) { + // Session expired or invalid - emit event for App.vue to handle + console.warn('Authentication expired, need to re-authenticate') + window.dispatchEvent(new CustomEvent('auth-expired')) + } + + // Throw our custom structured error + return Promise.reject(new StructuredError(responseData, status)) } + return Promise.reject(error) } ) diff --git a/web/src/types/binding.ts b/web/src/types/binding.ts index be9c675e0..f8393cfa4 100644 --- a/web/src/types/binding.ts +++ b/web/src/types/binding.ts @@ -42,4 +42,30 @@ export interface BindingResult { data?: BindingResponse message?: string error?: string +} + +// Structured error response from backend +export interface KubeBindError { + kind: 'Error' + apiVersion: string + message: string + code: string + details?: string +} + +// Common error codes from backend +export const ErrorCodes = { + AUTHENTICATION_FAILED: 'AUTHENTICATION_FAILED', + AUTHORIZATION_FAILED: 'AUTHORIZATION_FAILED', + RESOURCE_NOT_FOUND: 'RESOURCE_NOT_FOUND', + INTERNAL_ERROR: 'INTERNAL_ERROR', + BAD_REQUEST: 'BAD_REQUEST', + CLUSTER_CONNECTION_FAILED: 'CLUSTER_CONNECTION_FAILED' +} as const + +export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes] + +// Helper function to check if an error response is a structured KubeBindError +export function isKubeBindError(error: any): error is KubeBindError { + return error && typeof error === 'object' && error.kind === 'Error' && error.apiVersion && error.message && error.code } \ No newline at end of file diff --git a/web/src/views/Resources.vue b/web/src/views/Resources.vue index ffa5aa9ed..7bf8ad053 100644 --- a/web/src/views/Resources.vue +++ b/web/src/views/Resources.vue @@ -149,6 +149,7 @@ import { ref, computed, onMounted } from 'vue' import { useRoute } from 'vue-router' import { httpClient } from '../services/http' import type { BindableResourcesRequest, BindingResponse } from '../types/binding' +import { StructuredError } from '../services/http' import BindingResult from '../components/BindingResult.vue' import TemplateBindingModal from '../components/TemplateBindingModal.vue' import { authService } from '../services/auth' @@ -235,13 +236,37 @@ const loadResources = async () => { collections.value = collectionsResponse.data.items || [] } catch (err: any) { console.error('Failed to load resources:', err) - // Don't show generic error for auth failures - let the HTTP interceptor handle them - if (err.response?.status === 401) { - // Authentication error - the HTTP interceptor will handle logout/redirect - // Don't set error state, just let the auth flow take over - return + + // Handle structured errors + if (err instanceof StructuredError) { + const kubeError = err.kubeBindError + + // Don't show error for auth failures - let the HTTP interceptor handle them + if (kubeError.code === 'AUTHENTICATION_FAILED') { + return + } + + // Show specific error messages based on error code + switch (kubeError.code) { + case 'AUTHORIZATION_FAILED': + error.value = `Authorization failed: ${kubeError.details || kubeError.message}` + break + case 'CLUSTER_CONNECTION_FAILED': + error.value = `Could not connect to cluster: ${kubeError.details || kubeError.message}` + break + case 'RESOURCE_NOT_FOUND': + error.value = `Resources not found: ${kubeError.details || kubeError.message}` + break + default: + error.value = `Error: ${kubeError.message}` + } + } else { + // Fallback for non-structured errors + if (err.response?.status === 401) { + return + } + error.value = 'Failed to load resources. Please try again.' } - error.value = 'Failed to load resources. Please try again.' } finally { loading.value = false } @@ -298,12 +323,40 @@ const handleBind = async (templateName: string, bindingName: string) => { } } catch (err: any) { console.error('Failed to bind template:', err) - // Don't show alert for auth failures - let the HTTP interceptor handle them - if (err.response?.status === 401) { - // Authentication error - the HTTP interceptor will handle logout/redirect - return + + // Handle structured errors + if (err instanceof StructuredError) { + const kubeError = err.kubeBindError + + // Don't show alert for auth failures - let the HTTP interceptor handle them + if (kubeError.code === 'AUTHENTICATION_FAILED') { + return + } + + // Show specific error messages based on error code + let errorMessage: string + switch (kubeError.code) { + case 'AUTHORIZATION_FAILED': + errorMessage = `Authorization failed: You don't have permission to bind resources in this cluster.\n\nDetails: ${kubeError.details || kubeError.message}` + break + case 'CLUSTER_CONNECTION_FAILED': + errorMessage = `Cluster connection failed: Unable to connect to the target cluster.\n\nDetails: ${kubeError.details || kubeError.message}` + break + case 'RESOURCE_NOT_FOUND': + errorMessage = `Template not found: The requested template could not be found.\n\nDetails: ${kubeError.details || kubeError.message}` + break + default: + errorMessage = `Failed to bind template: ${kubeError.message}\n\nDetails: ${kubeError.details || 'No additional details available'}` + } + + alert(errorMessage) + } else { + // Fallback for non-structured errors + if (err.response?.status === 401) { + return + } + alert(`Failed to bind template: ${templateName}. Check console for details.`) } - alert(`Failed to bind template: ${templateName}. Check console for details.`) } }