Skip to content

Commit daa0584

Browse files
feat(controller): add flag for rbac reflector (#847)
Signed-off-by: Oliver Bähler <[email protected]>
1 parent d5570f4 commit daa0584

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

charts/capsule-proxy/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ If you only need to make minor customizations, you can specify them on the comma
178178
| options.certificateVolumeName | string | `""` | Specify an override for the Secret containing the certificate for SSL. Default value is empty and referring to the generated certificate. |
179179
| options.clientConnectionBurst | int | `30` | Burst to use for interacting with kubernetes API Server. |
180180
| options.clientConnectionQPS | int | `20` | QPS to use for interacting with Kubernetes API Server. |
181-
| options.disableCaching | bool | `false` | Disable the go-client caching to hit directly the Kubernetes API Server, it disables any local caching as the rolebinding reflector |
181+
| options.disableCaching | bool | `false` | Disable the go-client caching to hit directly the Kubernetes API Server, it disables any local caching as the rolebinding reflector. |
182182
| options.enableSSL | bool | `true` | Specify if capsule-proxy will use SSL |
183183
| options.extraArgs | list | `[]` | A list of extra arguments to add to the capsule-proxy. |
184184
| options.generateCertificates | bool | `true` | Specify if capsule-proxy will generate self-signed SSL certificates |
@@ -188,6 +188,7 @@ If you only need to make minor customizations, you can specify them on the comma
188188
| options.logLevel | int | `4` | Set the log verbosity of the capsule-proxy with a value from 1 to 10 |
189189
| options.oidcUsernameClaim | string | `"preferred_username"` | Specify if capsule-proxy will use SSL |
190190
| options.pprof | bool | `false` | Enable Pprof for profiling |
191+
| options.roleBindingReflector | bool | `false` | Enable the rolebinding reflector, which allows to list the namespaces, where a rolebinding mentions a user. |
191192
| options.rolebindingsResyncPeriod | string | `"10h"` | Set the role bindings reflector resync period, a local cache to store mappings between users and their namespaces. [Use a lower value in case of flaky etcd server connections.](https://github.com/projectcapsule/capsule-proxy/issues/174) |
192193
| options.webhookPort | int | `9443` | Webhook port |
193194

charts/capsule-proxy/values.schema.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@
547547
"type": "integer"
548548
},
549549
"disableCaching": {
550-
"description": "Disable the go-client caching to hit directly the Kubernetes API Server, it disables any local caching as the rolebinding reflector",
550+
"description": "Disable the go-client caching to hit directly the Kubernetes API Server, it disables any local caching as the rolebinding reflector.",
551551
"type": "boolean"
552552
},
553553
"enableSSL": {
@@ -586,6 +586,10 @@
586586
"description": "Enable Pprof for profiling",
587587
"type": "boolean"
588588
},
589+
"roleBindingReflector": {
590+
"description": "Enable the rolebinding reflector, which allows to list the namespaces, where a rolebinding mentions a user.",
591+
"type": "boolean"
592+
},
589593
"rolebindingsResyncPeriod": {
590594
"description": "Set the role bindings reflector resync period, a local cache to store mappings between users and their namespaces. [Use a lower value in case of flaky etcd server connections.](https://github.com/projectcapsule/capsule-proxy/issues/174)",
591595
"type": "string"

charts/capsule-proxy/values.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,10 @@ options:
272272
certificateVolumeName: ""
273273
# -- Set the role bindings reflector resync period, a local cache to store mappings between users and their namespaces. [Use a lower value in case of flaky etcd server connections.](https://github.com/projectcapsule/capsule-proxy/issues/174)
274274
rolebindingsResyncPeriod: 10h
275-
# -- Disable the go-client caching to hit directly the Kubernetes API Server, it disables any local caching as the rolebinding reflector
275+
# -- Disable the go-client caching to hit directly the Kubernetes API Server, it disables any local caching as the rolebinding reflector.
276276
disableCaching: false
277+
# -- Enable the rolebinding reflector, which allows to list the namespaces, where a rolebinding mentions a user.
278+
roleBindingReflector: false
277279
# -- Authentication types to be used for requests. Possible Auth Types: [BearerToken, TLSCertificate]
278280
authPreferredTypes: "BearerToken,TLSCertificate"
279281
# -- QPS to use for interacting with Kubernetes API Server.

main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func main() {
6464
namespace, certPath, keyPath, usernameClaimField, capsuleConfigurationName, impersonationGroupsRegexp, metricsAddr string
6565
capsuleUserGroups, ignoredUserGroups, ignoreImpersonationGroups []string
6666
listeningPort uint
67-
bindSsl, disableCaching, enablePprof, enableLeaderElection bool
67+
bindSsl, disableCaching, enablePprof, enableLeaderElection, roleBindingReflector bool
6868
rolebindingsResyncPeriod time.Duration
6969
clientConnectionQPS float32
7070
clientConnectionBurst int32
@@ -119,6 +119,7 @@ func main() {
119119
flag.StringVar(&impersonationGroupsRegexp, "impersonation-group-regexp", "", "Regular expression to match the groups which are considered for impersonation")
120120
flag.UintVar(&listeningPort, "listening-port", 9001, "HTTP port the proxy listens to (default: 9001)")
121121
flag.StringVar(&usernameClaimField, "oidc-username-claim", "preferred_username", "The OIDC field name used to identify the user (default: preferred_username)")
122+
flag.BoolVar(&roleBindingReflector, "enable-reflector", false, "Enable rolebinding reflector. The reflector allows to list the namespaces, where a rolebinding mentions a user")
122123
flag.BoolVar(&enablePprof, "enable-pprof", false, "Enables Pprof endpoint for profiling (not recommend in production)")
123124
flag.BoolVar(&bindSsl, "enable-ssl", true, "Enable the bind on HTTPS for secure communication (default: true)")
124125
flag.StringVar(&certPath, "ssl-cert-path", "", "Path to the TLS certificate (default: /opt/capsule-proxy/tls.crt)")
@@ -237,7 +238,7 @@ First match is used and can be specified multiple times as comma separated value
237238

238239
var rbReflector *controllers.RoleBindingReflector
239240

240-
if !disableCaching {
241+
if !disableCaching && roleBindingReflector {
241242
log.Info("Creating the Rolebindings reflector")
242243

243244
if rbReflector, err = controllers.NewRoleBindingReflector(config, rolebindingsResyncPeriod); err != nil {
@@ -252,7 +253,7 @@ First match is used and can be specified multiple times as comma separated value
252253
os.Exit(1)
253254
}
254255
} else {
255-
log.Info("Cache is disabled, cannot create Rolebindings reflector")
256+
log.Info("Rolebinding reflector disabled")
256257
}
257258

258259
ctx := ctrl.SetupSignalHandler()

0 commit comments

Comments
 (0)