Skip to content

Commit a5b65ee

Browse files
committed
remove kube-rbac-proxy container from deployment
csi-operator is not exporting any metrics exclusively and orchestrated csi already exports metrics on it's own which isn't tunneled through the operator. kube-rbac-proxy prominently used to authenticate api access to metrics endpoint available on operator (manager) which isn't mandatory for us and this commit removes the same. note that controller-runtime itself exports some metrics and this commit doesn't bind any port for controller-runtime which disables inbuilt metrics being available. https://book.kubebuilder.io/reference/metrics-reference Signed-off-by: Leela Venkaiah G <lgangava@ibm.com>
1 parent 31a93b4 commit a5b65ee

File tree

11 files changed

+3
-341
lines changed

11 files changed

+3
-341
lines changed

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ WATCH_NAMESPACE ?= ""
1212

1313
IMG ?= $(IMAGE_REGISTRY)/$(REGISTRY_NAMESPACE)/$(IMAGE_NAME):$(IMAGE_TAG)
1414

15-
KUBE_RBAC_PROXY_IMG ?= gcr.io/kubebuilder/kube-rbac-proxy:v0.16.0
16-
1715
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
1816
ENVTEST_K8S_VERSION = 1.29.0
1917

@@ -45,7 +43,7 @@ namePrefix: $(NAME_PREFIX)
4543
patches:
4644
- patch: |-
4745
- op: add
48-
path: /spec/template/spec/containers/1/env/-
46+
path: /spec/template/spec/containers/0/env/-
4947
value:
5048
name: CSI_SERVICE_ACCOUNT_PREFIX
5149
value: $(NAME_PREFIX)
@@ -60,8 +58,6 @@ patches:
6058
images:
6159
- name: controller
6260
newName: ${IMG}
63-
- name: kube-rbac-proxy
64-
newName: ${KUBE_RBAC_PROXY_IMG}
6561
endef
6662
export BUILD_INSTALLER_OVERLAY
6763

cmd/main.go

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
package main
1818

1919
import (
20-
"crypto/tls"
2120
"flag"
2221
"fmt"
2322
"os"
@@ -35,7 +34,6 @@ import (
3534
"sigs.k8s.io/controller-runtime/pkg/healthz"
3635
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3736
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
38-
"sigs.k8s.io/controller-runtime/pkg/webhook"
3937

4038
csiv1alpha1 "github.com/ceph/ceph-csi-operator/api/v1alpha1"
4139
"github.com/ceph/ceph-csi-operator/internal/controller"
@@ -56,20 +54,12 @@ func init() {
5654
}
5755

5856
func main() {
59-
var metricsAddr string
6057
var enableLeaderElection bool
6158
var probeAddr string
62-
var secureMetrics bool
63-
var enableHTTP2 bool
64-
flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.")
6559
flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.")
6660
flag.BoolVar(&enableLeaderElection, "leader-elect", false,
6761
"Enable leader election for controller manager. "+
6862
"Enabling this will ensure there is only one active controller manager.")
69-
flag.BoolVar(&secureMetrics, "metrics-secure", false,
70-
"If set the metrics endpoint is served securely")
71-
flag.BoolVar(&enableHTTP2, "enable-http2", false,
72-
"If set, HTTP/2 will be enabled for the metrics and webhook servers")
7363
opts := zap.Options{
7464
Development: true,
7565
}
@@ -78,26 +68,6 @@ func main() {
7868

7969
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
8070

81-
// if the enable-http2 flag is false (the default), http/2 should be disabled
82-
// due to its vulnerabilities. More specifically, disabling http/2 will
83-
// prevent from being vulnerable to the HTTP/2 Stream Cancellation and
84-
// Rapid Reset CVEs. For more information see:
85-
// - https://github.com/advisories/GHSA-qppj-fm5r-hxr3
86-
// - https://github.com/advisories/GHSA-4374-p667-p6c8
87-
disableHTTP2 := func(c *tls.Config) {
88-
setupLog.Info("disabling http/2")
89-
c.NextProtos = []string{"http/1.1"}
90-
}
91-
92-
tlsOpts := []func(*tls.Config){}
93-
if !enableHTTP2 {
94-
tlsOpts = append(tlsOpts, disableHTTP2)
95-
}
96-
97-
webhookServer := webhook.NewServer(webhook.Options{
98-
TLSOpts: tlsOpts,
99-
})
100-
10171
defaultNamespaces := map[string]cache.Config{}
10272
operatorNamespace, err := utils.GetOperatorNamespace()
10373
if err != nil {
@@ -118,11 +88,9 @@ func main() {
11888
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
11989
Scheme: scheme,
12090
Metrics: metricsserver.Options{
121-
BindAddress: metricsAddr,
122-
SecureServing: secureMetrics,
123-
TLSOpts: tlsOpts,
91+
// disable metrics
92+
BindAddress: "0",
12493
},
125-
WebhookServer: webhookServer,
12694
HealthProbeBindAddress: probeAddr,
12795
LeaderElection: enableLeaderElection,
12896
LeaderElectionID: "0a62cc8a.ceph.io",

config/manager/kustomization.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,3 @@ resources:
22
- manager.yaml
33
apiVersion: kustomize.config.k8s.io/v1beta1
44
kind: Kustomization
5-
patches:
6-
# Protect the /metrics endpoint by putting it behind auth.
7-
# If you want your controller-manager to expose the /metrics
8-
# endpoint w/o any authn/z, please comment the following line.
9-
- path: manager_auth_proxy_patch.yaml

config/manager/manager_auth_proxy_patch.yaml

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

config/rbac/auth_proxy_client_clusterrole.yaml

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

config/rbac/auth_proxy_role.yaml

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

config/rbac/auth_proxy_role_binding.yaml

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

config/rbac/auth_proxy_service.yaml

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

config/rbac/kustomization.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ resources:
99
- role_binding.yaml
1010
- leader_election_role.yaml
1111
- leader_election_role_binding.yaml
12-
# Comment the following 4 lines if you want to disable
13-
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
14-
# which protects your /metrics endpoint.
15-
- auth_proxy_service.yaml
16-
- auth_proxy_role.yaml
17-
- auth_proxy_role_binding.yaml
18-
- auth_proxy_client_clusterrole.yaml
1912
# For each CRD, "Editor" and "Viewer" roles are scaffolded by
2013
# default, aiding admins in cluster management. Those roles are
2114
# not used by the Project itself. You can comment the following lines

deploy/all-in-one/install.yaml

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -14840,19 +14840,6 @@ rules:
1484014840
---
1484114841
apiVersion: rbac.authorization.k8s.io/v1
1484214842
kind: ClusterRole
14843-
metadata:
14844-
labels:
14845-
app.kubernetes.io/managed-by: kustomize
14846-
app.kubernetes.io/name: ceph-csi-operator
14847-
name: ceph-csi-operator-metrics-reader
14848-
rules:
14849-
- nonResourceURLs:
14850-
- /metrics
14851-
verbs:
14852-
- get
14853-
---
14854-
apiVersion: rbac.authorization.k8s.io/v1
14855-
kind: ClusterRole
1485614843
metadata:
1485714844
name: ceph-csi-operator-nfs-ctrlplugin-cr
1485814845
rules:
@@ -15048,27 +15035,6 @@ rules:
1504815035
---
1504915036
apiVersion: rbac.authorization.k8s.io/v1
1505015037
kind: ClusterRole
15051-
metadata:
15052-
labels:
15053-
app.kubernetes.io/managed-by: kustomize
15054-
app.kubernetes.io/name: ceph-csi-operator
15055-
name: ceph-csi-operator-proxy-role
15056-
rules:
15057-
- apiGroups:
15058-
- authentication.k8s.io
15059-
resources:
15060-
- tokenreviews
15061-
verbs:
15062-
- create
15063-
- apiGroups:
15064-
- authorization.k8s.io
15065-
resources:
15066-
- subjectaccessreviews
15067-
verbs:
15068-
- create
15069-
---
15070-
apiVersion: rbac.authorization.k8s.io/v1
15071-
kind: ClusterRole
1507215038
metadata:
1507315039
name: ceph-csi-operator-rbd-ctrlplugin-cr
1507415040
rules:
@@ -15428,22 +15394,6 @@ subjects:
1542815394
---
1542915395
apiVersion: rbac.authorization.k8s.io/v1
1543015396
kind: ClusterRoleBinding
15431-
metadata:
15432-
labels:
15433-
app.kubernetes.io/managed-by: kustomize
15434-
app.kubernetes.io/name: ceph-csi-operator
15435-
name: ceph-csi-operator-proxy-rolebinding
15436-
roleRef:
15437-
apiGroup: rbac.authorization.k8s.io
15438-
kind: ClusterRole
15439-
name: ceph-csi-operator-proxy-role
15440-
subjects:
15441-
- kind: ServiceAccount
15442-
name: ceph-csi-operator-controller-manager
15443-
namespace: ceph-csi-operator-system
15444-
---
15445-
apiVersion: rbac.authorization.k8s.io/v1
15446-
kind: ClusterRoleBinding
1544715397
metadata:
1544815398
name: ceph-csi-operator-rbd-ctrlplugin-crb
1544915399
roleRef:
@@ -15468,24 +15418,6 @@ subjects:
1546815418
name: ceph-csi-operator-rbd-nodeplugin-sa
1546915419
namespace: ceph-csi-operator-system
1547015420
---
15471-
apiVersion: v1
15472-
kind: Service
15473-
metadata:
15474-
labels:
15475-
app.kubernetes.io/managed-by: kustomize
15476-
app.kubernetes.io/name: ceph-csi-operator
15477-
control-plane: controller-manager
15478-
name: ceph-csi-operator-controller-manager-metrics-service
15479-
namespace: ceph-csi-operator-system
15480-
spec:
15481-
ports:
15482-
- name: https
15483-
port: 8443
15484-
protocol: TCP
15485-
targetPort: https
15486-
selector:
15487-
control-plane: controller-manager
15488-
---
1548915421
apiVersion: apps/v1
1549015422
kind: Deployment
1549115423
metadata:
@@ -15509,31 +15441,6 @@ spec:
1550915441
spec:
1551015442
containers:
1551115443
- args:
15512-
- --secure-listen-address=0.0.0.0:8443
15513-
- --upstream=http://127.0.0.1:8080/
15514-
- --v=0
15515-
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.16.0
15516-
name: kube-rbac-proxy
15517-
ports:
15518-
- containerPort: 8443
15519-
name: https
15520-
protocol: TCP
15521-
resources:
15522-
limits:
15523-
cpu: 500m
15524-
memory: 128Mi
15525-
requests:
15526-
cpu: 5m
15527-
memory: 64Mi
15528-
securityContext:
15529-
allowPrivilegeEscalation: false
15530-
capabilities:
15531-
drop:
15532-
- ALL
15533-
readOnlyRootFilesystem: true
15534-
- args:
15535-
- --health-probe-bind-address=:8081
15536-
- --metrics-bind-address=127.0.0.1:8080
1553715444
- --leader-elect
1553815445
command:
1553915446
- /manager

0 commit comments

Comments
 (0)