Skip to content

Commit e2c5dfb

Browse files
CorentinPtrloliverbaehler
authored andcommitted
feat(proxysetting): simplify proxy tenant handling (#980)
* feat(proxysetting): simplify proxy tenant handling Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com> * fix(e2e): remove feature gate ProxyClusterScoped Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com> * fix(lint): middleware, lease, pod, webserver Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com> * fix(lint): middleware gci Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com> * feat(proxysettings): deprecate ProxyClusterScoped feature Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com> * feat(proxysettings): remove ProxyClusterScoped from options Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com> --------- Signed-off-by: CorentinPtrl <pitrel.corentin@gmail.com> Signed-off-by: Oliver Baehler <oliver@sudo-i.net>
1 parent 3700512 commit e2c5dfb

29 files changed

Lines changed: 110 additions & 1613 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ ifeq ($(CAPSULE_PROXY_MODE),http)
190190
--set "serviceMonitor.enabled=false" \
191191
--set "options.generateCertificates=false" \
192192
--set "certManager.generateCertificates=false" \
193-
--set "options.extraArgs={--feature-gates=ProxyClusterScoped=true,--feature-gates=ProxyAllNamespaced=true}"
193+
--set "options.extraArgs={--feature-gates=ProxyAllNamespaced=true}"
194194
else
195195
@echo "Running in HTTPS mode"
196196
@echo "Installing Capsule-Proxy using HELM..."
@@ -206,7 +206,7 @@ else
206206
--set "serviceMonitor.enabled=false" \
207207
--set "options.generateCertificates=false" \
208208
--set "certManager.certificate.ipAddresses={127.0.0.1}" \
209-
--set "options.extraArgs={--feature-gates=ProxyClusterScoped=true,--feature-gates=ProxyAllNamespaced=true}"
209+
--set "options.extraArgs={--feature-gates=ProxyAllNamespaced=true}"
210210
endif
211211
@kubectl rollout restart ds capsule-proxy -n capsule-system || true
212212
$(MAKE) generate-kubeconfigs

api/v1beta1/proxysettings_types.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ type OwnerSpec struct {
1313
Kind capsuleapi.OwnerKind `json:"kind"`
1414
// Name of tenant owner.
1515
Name string `json:"name"`
16-
// Proxy settings for tenant owner.
17-
ProxyOperations []capsuleapi.ProxySettings `json:"proxySettings,omitempty"`
1816
// Cluster Resources for tenant Owner.
1917
ClusterResources []ClusterResource `json:"clusterResources,omitempty"`
18+
// Deprecated: Use Global Proxy Settings instead (https://projectcapsule.dev/docs/proxy/proxysettings/#globalproxysettings)
19+
//
20+
// Proxy settings for tenant owner.
21+
ProxyOperations []capsuleapi.ProxySettings `json:"proxySettings,omitempty"`
2022
}
2123

2224
// ProxySettingSpec defines the additional Capsule Proxy settings for additional users of the Tenant.

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

charts/capsule-proxy/crds/capsule.clastix.io_proxysettings.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ spec:
142142
description: Name of tenant owner.
143143
type: string
144144
proxySettings:
145-
description: Proxy settings for tenant owner.
145+
description: |-
146+
Deprecated: Use Global Proxy Settings instead (https://projectcapsule.dev/docs/proxy/proxysettings/#globalproxysettings)
147+
148+
Proxy settings for tenant owner.
146149
items:
147150
properties:
148151
kind:

internal/authorization/middleware.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/projectcapsule/capsule-proxy/internal/tenant"
1313
)
1414

15-
func MutateAuthorization(proxyClusterScoped bool, proxyTenants []*tenant.ProxyTenant, obj *runtime.Object, gvk schema.GroupVersionKind) error {
15+
func MutateAuthorization(proxyTenants []*tenant.ProxyTenant, obj *runtime.Object, gvk schema.GroupVersionKind) error {
1616
switch gvk.Kind {
1717
case "SelfSubjectAccessReview":
1818
//nolint:forcetypeassert
@@ -21,10 +21,6 @@ func MutateAuthorization(proxyClusterScoped bool, proxyTenants []*tenant.ProxyTe
2121
accessReview.Status.Allowed = true
2222
}
2323

24-
if !proxyClusterScoped {
25-
return nil
26-
}
27-
2824
accessReviewGvk := schema.GroupVersionKind{
2925
Group: accessReview.Spec.ResourceAttributes.Group,
3026
Version: accessReview.Spec.ResourceAttributes.Version,
@@ -48,11 +44,8 @@ func MutateAuthorization(proxyClusterScoped bool, proxyTenants []*tenant.ProxyTe
4844
rules := (*obj).(*authorizationv1.SelfSubjectRulesReview)
4945

5046
var resourceRules []authorizationv1.ResourceRule
51-
if proxyClusterScoped {
52-
resourceRules = getAllResourceRules(proxyTenants)
53-
} else {
54-
resourceRules = []authorizationv1.ResourceRule{}
55-
}
47+
48+
resourceRules = getAllResourceRules(proxyTenants)
5649

5750
resourceRules = append(resourceRules, authorizationv1.ResourceRule{
5851
APIGroups: []string{""},

internal/features/features.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const (
1919
// essentially bypassing any authorization. Only use this option in trusted environments
2020
// where authorization/authentication is offloaded to external systems.
2121
SkipImpersonationReview = "SkipImpersonationReview"
22-
22+
// Deprecated: Use Global Proxy Settings instead (https://projectcapsule.dev/docs/proxy/proxysettings/#globalproxysettings)
23+
//
2324
// ProxyClusterScoped allows to proxy all clusterScoped objects
2425
// for all tenant users.
2526
ProxyClusterScoped = "ProxyClusterScoped"

internal/indexer/tenant_owner.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2020-2026 Project Capsule Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package indexer
5+
6+
import (
7+
"fmt"
8+
9+
capsulev1beta2 "github.com/projectcapsule/capsule/api/v1beta2"
10+
"sigs.k8s.io/controller-runtime/pkg/client"
11+
)
12+
13+
const (
14+
TenantOwnerKindField = ".status.owner.ownerkind"
15+
)
16+
17+
// TenantOwnerReference indexes Tenants by their status.owners (Kind:Name).
18+
type TenantOwnerReference struct{}
19+
20+
func (o TenantOwnerReference) Object() client.Object {
21+
return &capsulev1beta2.Tenant{}
22+
}
23+
24+
func (o TenantOwnerReference) Field() string {
25+
return TenantOwnerKindField
26+
}
27+
28+
func (o TenantOwnerReference) Func() client.IndexerFunc {
29+
return func(object client.Object) []string {
30+
tnt, ok := object.(*capsulev1beta2.Tenant)
31+
if !ok {
32+
panic(fmt.Errorf("expected type *capsulev1beta2.Tenant, got %T", object))
33+
}
34+
35+
var owners []string
36+
for _, owner := range tnt.Status.Owners {
37+
owners = append(owners, fmt.Sprintf("%s:%s", owner.Kind.String(), owner.Name))
38+
}
39+
40+
return owners
41+
}
42+
}

internal/modules/ingressclass/get.go

Lines changed: 0 additions & 95 deletions
This file was deleted.

internal/modules/ingressclass/list.go

Lines changed: 0 additions & 84 deletions
This file was deleted.

0 commit comments

Comments
 (0)