Skip to content

Commit 18cec9f

Browse files
authored
Add namespaced isolation mode for cluster-scoped objects (#394)
1 parent f22a138 commit 18cec9f

29 files changed

Lines changed: 1235 additions & 701 deletions

File tree

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ OS := $(shell go env GOOS)
9797
KUBE_MAJOR_VERSION := 1
9898
KUBE_MINOR_VERSION := $(shell go mod edit -json | jq '.Require[] | select(.Path == "k8s.io/client-go") | .Version' --raw-output | sed "s/v[0-9]*\.\([0-9]*\).*/\1/")
9999
GIT_COMMIT := $(shell git rev-parse --short HEAD || echo 'local')
100-
GIT_DIRTY := $(shell git diff --quiet && echo 'clean' || echo 'dirty')
100+
# --quiet would still produces output when files are deleted
101+
GIT_DIRTY := $(shell git diff --quiet >/dev/null && echo 'clean' || echo 'dirty')
101102
GIT_VERSION := $(shell go mod edit -json | jq '.Require[] | select(.Path == "k8s.io/client-go") | .Version' --raw-output | sed 's/v0/v1/')+kube-bind-$(shell git describe --tags --match='v*' --abbrev=14 "$(GIT_COMMIT)^{commit}" 2>/dev/null || echo v0.0.0-$(GIT_COMMIT))
102103
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
103104
LDFLAGS := \

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $ kubectl krew index add bind https://github.com/kube-bind/krew-index.git
2626
$ kubectl krew install bind/bind
2727
$ kubectl bind login https://mangodb
2828
$ kubectl bind
29-
Redirect to the brower to authenticate via OIDC.
29+
Redirect to the browser to authenticate via OIDC.
3030
BOOM – the MangoDB API is available in the local cluster,
3131
without anything MangoDB-specific running.
3232
$ kubectl get mangodbs

backend/controllers/serviceexportrequest/serviceexportrequest_reconcile.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ func (r *reconciler) ensureBoundSchemas(ctx context.Context, cl client.Client, c
163163
continue
164164
}
165165

166+
// If namespaced isolation is configured for cluster-scoped objects,
167+
// we need to rewrite the BoundSchema's scope accordingly. For all
168+
// other isolation strategies, as well as for namespaced schemas,
169+
// no changes are necessary.
170+
if boundSchema.Spec.Scope == apiextensionsv1.NamespaceScoped && r.clusterScopedIsolation == kubebindv1alpha2.IsolationNamespaced {
171+
boundSchema.Spec.Scope = apiextensionsv1.ClusterScoped
172+
}
173+
166174
if err := r.createBoundSchema(ctx, cl, boundSchema); err != nil {
167175
return err
168176
}

backend/oidc/oidc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (s *Server) Config(callbackURL, issuerURL string) (*Config, error) {
9191
c := &Config{
9292
ClientID: s.server.Config().ClientID,
9393
ClientSecret: s.server.Config().ClientSecret,
94-
Issuer: issuerURL, // This overrided default fake OIDC issuer URL. Must match what it is served at.
94+
Issuer: issuerURL, // This overrides default fake OIDC issuer URL. Must match what it is served at.
9595

9696
AccessTTL: s.server.Config().AccessTTL,
9797
RefreshTTL: s.server.Config().RefreshTTL,

cli/cmd/kubectl-bind/cmd/kubectlBind_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func TestKubectlBindCommand(t *testing.T) {
3030

3131
require.Equal(t, "kubectl-bind", rootCmd.Use, "Unexpected one-line command description")
3232
require.Equal(t, "kubectl plugin for kube-bind, bind different remote types into the current cluster.", rootCmd.Short, "Unexpected short command description")
33-
require.Contains(t, rootCmd.Long, "To bind a remote service, use the 'kubectl bind' command.", "Unexpected lond command Long")
33+
require.Contains(t, rootCmd.Long, "To bind a remote service, use the 'kubectl bind' command.", "Unexpected long command")
3434
require.Equal(t, rootCmd.Example, fmt.Sprintf(bindcmd.BindExampleUses, "kubectl"), "Unexpected command Example")
3535
}
3636

cli/pkg/kubectl/bind-login/plugin/login.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ type LoginOptions struct {
5858
}
5959

6060
// TokenResponse represents the response from the OAuth callback
61-
// Important: this stuct must match one on backend/auth/types.go
61+
// Important: this struct must match one on backend/auth/types.go
6262
type TokenResponse struct {
6363
// OAuth2 token fields
6464
AccessToken string `json:"access_token"`

contrib/kcp/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ replace (
1414
// Can use versioned when v0.28.2 releases
1515
replace github.com/kcp-dev/kcp/sdk => github.com/kcp-dev/kcp/sdk v0.28.1-0.20251003164010-742ce0ea6b8c
1616

17-
// k/k 1.34 is leaking from main repo. This pins some deps to force depdendency tree to be on 1.34
17+
// k/k 1.34 is leaking from main repo. This pins some deps to force dependency tree to be on 1.34
1818
replace (
1919
github.com/google/gnostic-models => github.com/google/gnostic-models v0.6.9
2020
k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20250318190949-c8a335a9a2ff

contrib/kcp/test/e2e/kcp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func testKcpIntegration(t *testing.T, name string, scope kubebindv1alpha2.Inform
155155
// Can assume that the last entry is now the cluster-id, grab it and
156156
// sanity check that it's not empty
157157
providerClusterID := providerClusterSplit[len(providerClusterSplit)-1]
158-
require.NotEmpty(t, providerClusterID, "Retreived cluster id is empty, source URL: %s", providerCluster.Status.URL)
158+
require.NotEmpty(t, providerClusterID, "Retrieved cluster id is empty, source URL: %s", providerCluster.Status.URL)
159159

160160
// kube-bind process
161161
t.Log("Perform binding process with browser")

docs/content/usage/.pages

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
nav:
2-
- api-concepts.md
2+
- index.md
3+
- api-concepts.md
4+
- synchronization.md

docs/content/usage/index.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,60 +14,72 @@ This section provides comprehensive documentation on how to use kube-bind's core
1414
kube-bind operates on three fundamental concepts:
1515

1616
### Service Provider
17+
1718
The cluster that **exports** APIs and resources, making them available for other clusters to consume. Service providers create templates and handle permission claims.
1819

19-
### Service Consumer
20+
### Service Consumer
21+
2022
The cluster that **imports** and uses APIs from service providers. Consumers bind to templates and get access to resources through a secure, controlled process.
2123

2224
### Konnector Agent
25+
2326
The component that establishes and maintains the secure connection between provider and consumer clusters, synchronizing resources and handling permissions.
2427

2528
## Key API Types
2629

2730
### APIServiceExportTemplate
31+
2832
**Purpose**: Defines a reusable service template that groups related CRDs and permission claims.
2933
**Used by**: Service providers
3034
**Scope**: Template definition for multiple consumers
3135

3236
### APIServiceExport
37+
3338
**Purpose**: Represents an active export of a specific CRD to consumer clusters.
3439
**Used by**: Automatically created by konnector agents
3540
**Scope**: Per-CRD export instance
3641

3742
### APIServiceExportRequest
43+
3844
**Purpose**: Consumer's request to bind to a specific service template.
3945
**Used by**: Service consumers (via CLI/UI)
4046
**Scope**: Per-binding request
4147

4248
### APIServiceNamespace
49+
4350
**Purpose**: Manages namespace mapping and isolation between provider and consumer clusters.
4451
**Used by**: Automatically managed by konnector agents
4552
**Scope**: Per-namespace sync
4653

4754
## Documentation Structure
4855

4956
### [API Concepts](api-concepts.md)
57+
5058
Deep dive into the core API types, their relationships, and how they work together in the kube-bind ecosystem.
5159

5260
### [Template References](template-references.md)
61+
5362
Advanced guide for using dynamic resource selection through references in templates.
5463

5564
## Common Workflows
5665

5766
### For Service Providers
67+
5868
1. **Create templates** defining what APIs and resources to export, including permission claims
5969
2. **Implement service** to act on the synced/bound objects so it can be returned to the consumer/user.
6070

61-
### For Service Consumers
71+
### For Service Consumers
72+
6273
1. **Authenticate** to the kube-bind backend
6374
1. **Discover available templates** through the web UI or CLI
6475
2. **Request bindings** to specific templates
6576
3. **Authenticate and authorize** access through OAuth2 flows
6677
4. **Use imported APIs** in their local cluster
6778

6879
### For Platform Operators
80+
6981
1. **Deploy kube-bind infrastructure** on both provider and consumer sides (if using GitOps)
70-
2. **Configure authentication** and security policies
82+
2. **Configure authentication** and security policies
7183
3. **Monitor connections** and resource synchronization
7284

7385
## Getting Started
@@ -79,9 +91,9 @@ If you're new to kube-bind:
7991
3. **Explore [Template References](template-references.md)** for advanced use cases
8092
4. **Check the [Reference Documentation](../reference/)** for complete API specifications
8193

82-
8394
The konnector agents establish a secure, authenticated connection that allows:
95+
8496
- **API schema synchronization** from provider to consumer
8597
- **Resource data flow** based on permission claims
8698
- **Namespace isolation** and mapping
87-
- **Authentication and authorization** enforcement
99+
- **Authentication and authorization** enforcement

0 commit comments

Comments
 (0)