From 21d91e9f50c4ebfd9a2f797b061516955783a631 Mon Sep 17 00:00:00 2001 From: Mangirdas Judeikis Date: Thu, 23 Oct 2025 19:38:21 +0300 Subject: [PATCH 1/2] Add helm deployment & fixup generator --- .gitignore | 2 +- Makefile | 16 + .../clusterbinding_controller.go | 10 +- backend/controllers/rbac.go | 29 + .../serviceexport/serviceexport_controller.go | 10 +- .../serviceexportrequest_controller.go | 12 +- .../servicenamespace_controller.go | 10 +- backend/http/handler.go | 2 +- backend/template/resources.gohtml | 24 +- .../kubectl/bind-apiservice/plugin/bind.go | 33 + cli/pkg/kubectl/bind/plugin/bind.go | 2 + deploy/charts/backend/.helmignore | 23 + deploy/charts/backend/Chart.yaml | 24 + .../crds/kube-bind.io_apiservicebindings.yaml | 421 +++++++++++ ...kube-bind.io_apiserviceexportrequests.yaml | 458 ++++++++++++ .../crds/kube-bind.io_apiserviceexports.yaml | 691 ++++++++++++++++++ ...ube-bind.io_apiserviceexporttemplates.yaml | 272 +++++++ .../kube-bind.io_apiservicenamespaces.yaml | 124 ++++ .../crds/kube-bind.io_boundschemas.yaml | 466 ++++++++++++ .../crds/kube-bind.io_clusterbindings.yaml | 330 +++++++++ .../crds/kube-bind.io_collections.yaml | 132 ++++ .../examples/values-local-development.yaml | 57 ++ deploy/charts/backend/templates/_helpers.tpl | 62 ++ .../backend/templates/clusterrolebinding.yaml | 16 + .../charts/backend/templates/deployment.yaml | 130 ++++ deploy/charts/backend/templates/hpa.yaml | 32 + deploy/charts/backend/templates/role.yaml | 107 +++ deploy/charts/backend/templates/service.yaml | 22 + .../backend/templates/serviceaccount.yaml | 13 + .../templates/tests/test-connection.yaml | 15 + deploy/charts/backend/values.yaml | 136 ++++ .../insecure/example-backend.yaml | 137 ---- .../example-backend/letsencrypt/.gitignore | 2 - .../letsencrypt/cluster-issuer.yaml.tmpl | 15 - .../letsencrypt/dex-config-secret.yaml.tmpl | 34 - .../letsencrypt/example-backend.yaml | 235 ------ .../letsencrypt/oidc-secret.yaml.tmpl | 9 - docs/content/setup/helm.md | 237 +++++- hack/update-codegen.sh | 14 + 39 files changed, 3896 insertions(+), 468 deletions(-) create mode 100644 backend/controllers/rbac.go create mode 100644 deploy/charts/backend/.helmignore create mode 100644 deploy/charts/backend/Chart.yaml create mode 100644 deploy/charts/backend/crds/kube-bind.io_apiservicebindings.yaml create mode 100644 deploy/charts/backend/crds/kube-bind.io_apiserviceexportrequests.yaml create mode 100644 deploy/charts/backend/crds/kube-bind.io_apiserviceexports.yaml create mode 100644 deploy/charts/backend/crds/kube-bind.io_apiserviceexporttemplates.yaml create mode 100644 deploy/charts/backend/crds/kube-bind.io_apiservicenamespaces.yaml create mode 100644 deploy/charts/backend/crds/kube-bind.io_boundschemas.yaml create mode 100644 deploy/charts/backend/crds/kube-bind.io_clusterbindings.yaml create mode 100644 deploy/charts/backend/crds/kube-bind.io_collections.yaml create mode 100644 deploy/charts/backend/examples/values-local-development.yaml create mode 100644 deploy/charts/backend/templates/_helpers.tpl create mode 100644 deploy/charts/backend/templates/clusterrolebinding.yaml create mode 100644 deploy/charts/backend/templates/deployment.yaml create mode 100644 deploy/charts/backend/templates/hpa.yaml create mode 100644 deploy/charts/backend/templates/role.yaml create mode 100644 deploy/charts/backend/templates/service.yaml create mode 100644 deploy/charts/backend/templates/serviceaccount.yaml create mode 100644 deploy/charts/backend/templates/tests/test-connection.yaml create mode 100644 deploy/charts/backend/values.yaml delete mode 100644 deploy/manifests/example-backend/insecure/example-backend.yaml delete mode 100644 deploy/manifests/example-backend/letsencrypt/.gitignore delete mode 100644 deploy/manifests/example-backend/letsencrypt/cluster-issuer.yaml.tmpl delete mode 100644 deploy/manifests/example-backend/letsencrypt/dex-config-secret.yaml.tmpl delete mode 100644 deploy/manifests/example-backend/letsencrypt/example-backend.yaml delete mode 100644 deploy/manifests/example-backend/letsencrypt/oidc-secret.yaml.tmpl diff --git a/.gitignore b/.gitignore index f0d1aa73d..cde76d088 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,5 @@ coverage.* /dex /bin docs/generators/cli-doc/cli-doc -dex/ apiserviceexport.yaml +*.prod \ No newline at end of file diff --git a/Makefile b/Makefile index e30a4f474..899da2cf8 100644 --- a/Makefile +++ b/Makefile @@ -290,10 +290,26 @@ CONTRIBS_E2E := $(patsubst %,test-e2e-contrib-%,$(CONTRIBS)) .PHONY: test-e2e-contribs $(CONTRIBS_E2E) test-e2e-contribs: $(CONTRIBS_E2E) ## Run e2e tests for external integrations + +.PHONY: test-e2e-contrib-kcp test-e2e-contrib-kcp: $(DEX) $(KCP) $(CONTRIBS_E2E): cd contrib/$(patsubst test-e2e-contrib-%,%,$@) && $(GO_TEST) -race -count $(COUNT) $(E2E_PARALLELISM_FLAG) ./test/e2e/... +DESTROY_KIND_CLUSTER ?= true +REUSE_KIND_CLUSTER_SUFFIX ?= "" +KIND_CLUSTER_NAME ?= kube-bind + +.PHONY: test-e2e-kind +test-e2e-kind: build image-local + echo "Running kube-bind e2e tests" + KUBE_BIND_BACKEND_IMAGE=$(KO_DOCKER_REPO)/backend:$(REV) \ + KUBE_BIND_KONNECTOR_IMAGE=$(KO_DOCKER_REPO)/konnector:$(REV) \ + $(GO_TEST) -v ./test/e2e-kind/... \ + -destroy-kind-cluster=$(DESTROY_KIND_CLUSTER) \ + -collect-logs=true + echo "Kube-bind e2e tests completed" + .PHONY: test ifdef USE_GOTESTSUM test: $(GOTESTSUM) diff --git a/backend/controllers/clusterbinding/clusterbinding_controller.go b/backend/controllers/clusterbinding/clusterbinding_controller.go index d524d8c54..abd1c7853 100644 --- a/backend/controllers/clusterbinding/clusterbinding_controller.go +++ b/backend/controllers/clusterbinding/clusterbinding_controller.go @@ -147,10 +147,12 @@ func NewClusterBindingReconciler( return r, nil } -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=clusterbindings,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=clusterbindings/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=clusterbindings/finalizers,verbs=update -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=apiserviceexports,verbs=get;list;watch +//+kubebuilder:rbac:groups=kube-bind.io,resources=clusterbindings,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=kube-bind.io,resources=clusterbindings/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=kube-bind.io,resources=clusterbindings/finalizers,verbs=update +//+kubebuilder:rbac:groups=kube-bind.io,resources=apiserviceexports,verbs=get;list;watch +//+kubebuilder:rbac:groups=kube-bind.io,resources=collections,verbs=get;list;watch +//+kubebuilder:rbac:groups=kube-bind.io,resources=apiserviceexporttemplates,verbs=get;list;watch //+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 //+kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=rolebindings,verbs=get;list;watch;create;update;patch;delete diff --git a/backend/controllers/rbac.go b/backend/controllers/rbac.go new file mode 100644 index 000000000..7bd75c5ac --- /dev/null +++ b/backend/controllers/rbac.go @@ -0,0 +1,29 @@ +/* +Copyright 2022 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 controllers + +// This is Core access needed for backend controllers. +//+kubebuilder:rbac:groups=apiextensions.k8s.io,resources=customresourcedefinitions,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups="",resources=secrets,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups="",resources=configmaps,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups="",resources=namespaces,verbs=get;list;watch;create;update;patch;delete + +// Additional RBAC permissions for export functionality +// These permissions allow the backend to grant RBAC permissions for exported resources +//+kubebuilder:rbac:groups="",resources=configmaps,verbs=* +//+kubebuilder:rbac:groups="",resources=secrets,verbs=* diff --git a/backend/controllers/serviceexport/serviceexport_controller.go b/backend/controllers/serviceexport/serviceexport_controller.go index 21166e4ff..ab6124882 100644 --- a/backend/controllers/serviceexport/serviceexport_controller.go +++ b/backend/controllers/serviceexport/serviceexport_controller.go @@ -82,11 +82,11 @@ func NewAPIServiceExportReconciler( return r, nil } -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=apiserviceexports,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=apiserviceexports/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=apiserviceexports/finalizers,verbs=update -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=boundschemas,verbs=get;list;watch -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=boundschemas/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=kube-bind.io,resources=apiserviceexports,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=kube-bind.io,resources=apiserviceexports/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=kube-bind.io,resources=apiserviceexports/finalizers,verbs=update +//+kubebuilder:rbac:groups=kube-bind.io,resources=boundschemas,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=kube-bind.io,resources=boundschemas/status,verbs=get;update;patch;list // Reconcile is part of the main kubernetes reconciliation loop which aims to // move the current state of the cluster closer to the desired state. diff --git a/backend/controllers/serviceexportrequest/serviceexportrequest_controller.go b/backend/controllers/serviceexportrequest/serviceexportrequest_controller.go index 4330a7f78..3788d011b 100644 --- a/backend/controllers/serviceexportrequest/serviceexportrequest_controller.go +++ b/backend/controllers/serviceexportrequest/serviceexportrequest_controller.go @@ -177,12 +177,12 @@ func getBoundSchemaMapper(clusterName string, cl cluster.Cluster) handler.TypedE }) } -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=apiserviceexportrequests,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=apiserviceexportrequests/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=apiserviceexportrequests/finalizers,verbs=update -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=apiserviceexports,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=apiresourceschemas,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=resources=apiservicenamespaces,verbs=get;list;watch;create +//+kubebuilder:rbac:groups=kube-bind.io,resources=apiserviceexportrequests,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=kube-bind.io,resources=apiserviceexportrequests/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=kube-bind.io,resources=apiserviceexportrequests/finalizers,verbs=update +//+kubebuilder:rbac:groups=kube-bind.io,resources=apiserviceexports,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=kube-bind.io,resources=apiresourceschemas,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=kube-bind.io,resources=apiservicenamespaces,verbs=get;list;watch;create // Reconcile is part of the main kubernetes reconciliation loop which aims to // move the current state of the cluster closer to the desired state. diff --git a/backend/controllers/servicenamespace/servicenamespace_controller.go b/backend/controllers/servicenamespace/servicenamespace_controller.go index e9f4e52b0..0b28901b9 100644 --- a/backend/controllers/servicenamespace/servicenamespace_controller.go +++ b/backend/controllers/servicenamespace/servicenamespace_controller.go @@ -206,11 +206,11 @@ func getServiceExportMapper(clusterName string, cl cluster.Cluster) handler.Type }) } -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=apiservicenamespaces,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=apiservicenamespaces/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=apiservicenamespaces/finalizers,verbs=update -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=clusterbindings,verbs=get;list;watch -//+kubebuilder:rbac:groups=kubebind.k8s.io,resources=apiserviceexports,verbs=get;list;watch +//+kubebuilder:rbac:groups=kube-bind.io,resources=apiservicenamespaces,verbs=get;list;watch;create;update;patch;delete +//+kubebuilder:rbac:groups=kube-bind.io,resources=apiservicenamespaces/status,verbs=get;update;patch +//+kubebuilder:rbac:groups=kube-bind.io,resources=apiservicenamespaces/finalizers,verbs=update +//+kubebuilder:rbac:groups=kube-bind.io,resources=clusterbindings,verbs=get;list;watch +//+kubebuilder:rbac:groups=kube-bind.io,resources=apiserviceexports,verbs=get;list;watch //+kubebuilder:rbac:groups="",resources=namespaces,verbs=get;list;watch;create;update;patch;delete //+kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=rolebindings,verbs=get;list;watch;create;update;patch;delete diff --git a/backend/http/handler.go b/backend/http/handler.go index b4a0b1e3a..5fbd16fbf 100644 --- a/backend/http/handler.go +++ b/backend/http/handler.go @@ -205,7 +205,7 @@ func (h *handler) handleAuthorize(w http.ResponseWriter, r *http.Request) { ProviderClusterID: providerCluster, // used in multicluster-runtime providers } if callbackPort != "" && code.RedirectURL == "" { - code.RedirectURL = fmt.Sprintf("http://localhost:%s/callback", callbackPort) + code.RedirectURL = fmt.Sprintf("http://127.0.0.1:%s/callback", callbackPort) } if code.RedirectURL == "" || code.SessionID == "" || code.ClusterID == "" { diff --git a/backend/template/resources.gohtml b/backend/template/resources.gohtml index 1f653295c..67db1f76a 100644 --- a/backend/template/resources.gohtml +++ b/backend/template/resources.gohtml @@ -10,7 +10,7 @@ - Modules - Kube Bind + Services - Kube Bind