Skip to content

Commit 7a8ff1f

Browse files
authored
fix(control-plane): use project kube client for namespace provisioner (#1175)
## Summary When `PROJECT_KUBE_TOKEN_FILE` is set, the project kube client carries the TSA identity (`tenantaccess-ambient-control-plane`) which already has `namespace-admin` RoleBindings in `ambient-code--config` — including access to `tenantnamespaces.tenant.paas.redhat.com`. The main in-cluster SA does not. `buildNamespaceProvisioner` was receiving `kube` (the pod SA identity) unconditionally. The MPP `TenantNamespace` provisioner then failed with: ``` tenantnamespaces.tenant.paas.redhat.com "test" is forbidden: User "system:serviceaccount:ambient-code--ambient-s0:ambient-control-plane" cannot get resource "tenantnamespaces" in API group "tenant.paas.redhat.com" in the namespace "ambient-code--config" ``` ## Fix Three lines: prefer `projectKube` over `kube` when building the provisioner, since that IS the identity with the right permissions already in place. ## Test plan - [ ] Deploy to MPP cluster with `PROJECT_KUBE_TOKEN_FILE` set — CP logs show successful `TenantNamespace` get/create/delete without Forbidden errors 🤖 Generated with [Claude Code](https://claude.ai/code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Namespace provisioning now supports project-specific Kubernetes tokens when configured. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2 parents 43b33d1 + a83e9fb commit 7a8ff1f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

  • components/ambient-control-plane/cmd/ambient-control-plane

components/ambient-control-plane/cmd/ambient-control-plane/main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,11 @@ func runKubeMode(ctx context.Context, cfg *config.ControlPlaneConfig) error {
113113
log.Info().Str("token_file", cfg.ProjectKubeTokenFile).Msg("using separate project kube client")
114114
}
115115

116-
provisioner := buildNamespaceProvisioner(cfg, kube)
116+
provisionerKube := kube
117+
if projectKube != nil {
118+
provisionerKube = projectKube
119+
}
120+
provisioner := buildNamespaceProvisioner(cfg, provisionerKube)
117121
tokenProvider := buildTokenProvider(cfg, log.Logger)
118122

119123
factory := reconciler.NewSDKClientFactory(cfg.APIServerURL, tokenProvider, log.Logger)

0 commit comments

Comments
 (0)