Skip to content

Commit 8e7a76e

Browse files
Bug fixes for Pod Identity (#774)
* Bug fixes * Apply suggestion from @sabrina-ngrok * Remove role permissions for pods
1 parent aac9596 commit 8e7a76e

File tree

4 files changed

+54
-10
lines changed

4 files changed

+54
-10
lines changed

cmd/bindings-forwarder-manager.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ import (
3232
_ "k8s.io/client-go/plugin/pkg/client/auth"
3333

3434
"github.com/spf13/cobra"
35+
corev1 "k8s.io/api/core/v1"
3536
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3637
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3738
ctrl "sigs.k8s.io/controller-runtime"
3839
"sigs.k8s.io/controller-runtime/pkg/cache"
40+
"sigs.k8s.io/controller-runtime/pkg/client"
3941
"sigs.k8s.io/controller-runtime/pkg/healthz"
4042
"sigs.k8s.io/controller-runtime/pkg/log/zap"
4143
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
@@ -113,6 +115,9 @@ func runController(_ context.Context, opts bindingsForwarderManagerOpts) error {
113115
DefaultNamespaces: map[string]cache.Config{
114116
opts.namespace: {},
115117
},
118+
ByObject: map[client.Object]cache.ByObject{
119+
&corev1.Pod{}: {Namespaces: map[string]cache.Config{cache.AllNamespaces: {}}},
120+
},
116121
},
117122
Metrics: server.Options{
118123
BindAddress: opts.metricsAddr,

helm/ngrok-operator/templates/bindings-forwarder/rbac.yaml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ rules:
4848
verbs:
4949
- create
5050
- patch
51+
---
52+
apiVersion: rbac.authorization.k8s.io/v1
53+
kind: RoleBinding
54+
metadata:
55+
name: {{ include "ngrok-operator.fullname" . }}-bindings-forwarder-rolebinding
56+
roleRef:
57+
apiGroup: rbac.authorization.k8s.io
58+
kind: Role
59+
name: {{ $bindingForwarderRole }}
60+
subjects:
61+
- kind: ServiceAccount
62+
name: {{ template "ngrok-operator.bindings.forwarder.serviceAccountName" . }}
63+
namespace: {{ .Release.Namespace }}
64+
65+
---
66+
apiVersion: rbac.authorization.k8s.io/v1
67+
kind: ClusterRole
68+
metadata:
69+
name: {{ include "ngrok-operator.fullname" . }}-bindings-forwarder
70+
rules:
5171
- apiGroups:
5272
- ""
5373
resources:
@@ -58,13 +78,13 @@ rules:
5878
- watch
5979
---
6080
apiVersion: rbac.authorization.k8s.io/v1
61-
kind: RoleBinding
81+
kind: ClusterRoleBinding
6282
metadata:
63-
name: {{ include "ngrok-operator.fullname" . }}-bindings-forwarder-rolebinding
83+
name: {{ include "ngrok-operator.fullname" . }}-bindings-forwarder-clusterrolebinding
6484
roleRef:
6585
apiGroup: rbac.authorization.k8s.io
66-
kind: Role
67-
name: {{ $bindingForwarderRole }}
86+
kind: ClusterRole
87+
name: {{ include "ngrok-operator.fullname" . }}-bindings-forwarder
6888
subjects:
6989
- kind: ServiceAccount
7090
name: {{ template "ngrok-operator.bindings.forwarder.serviceAccountName" . }}

helm/ngrok-operator/tests/bindings-forwarder/__snapshot__/deployment_test.yaml.snap

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

helm/ngrok-operator/tests/bindings-forwarder/__snapshot__/rbac_test.yaml.snap

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

0 commit comments

Comments
 (0)