Skip to content

Commit

Permalink
bundle: remove usage of kube-rbac-proxy image
Browse files Browse the repository at this point in the history
kube-rbac-proxy image is deprecated. We wont be able to pull it from
early 2025 as gcr.io/kubebuilder will be unavailable.

Protect metrics endpoint with WithAuthenticationAndAuthorization method.

Ref:
kubernetes-sigs/kubebuilder#3907
red-hat-storage/ocs-operator#2912

Signed-off-by: Nitin Goyal <[email protected]>
  • Loading branch information
iamniting committed Dec 4, 2024
1 parent 7897655 commit b348073
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 36 deletions.
2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ install-odf: operator-sdk ## install odf using the hack/install-odf.sh script

deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
cd config/default && $(KUSTOMIZE) edit set image rbac-proxy=$(RBAC_PROXY_IMG)
cd config/console && $(KUSTOMIZE) edit set image odf-console=$(ODF_CONSOLE_IMG)
$(KUSTOMIZE) build config/default | kubectl apply -f -

Expand Down Expand Up @@ -195,7 +194,6 @@ bundle: manifests kustomize operator-sdk ## Generate bundle manifests and metada
# Main odf-operator bundle
$(OPERATOR_SDK) generate kustomize manifests -q
cd config/manager && $(KUSTOMIZE) edit set image controller=$(IMG)
cd config/default && $(KUSTOMIZE) edit set image rbac-proxy=$(RBAC_PROXY_IMG)
cd config/console && $(KUSTOMIZE) edit set image odf-console=$(ODF_CONSOLE_IMG)
cd config/manifests/bases && $(KUSTOMIZE) edit add annotation --force \
'olm.skipRange':"$(SKIP_RANGE)" \
Expand Down
4 changes: 0 additions & 4 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,3 @@ resources:
- ../rbac
- ../manager
- ../prometheus
images:
- name: rbac-proxy
newName: registry.redhat.io/openshift4/ose-kube-rbac-proxy
newTag: v4.11.0
18 changes: 1 addition & 17 deletions config/default/manager_auth_proxy_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,9 @@ spec:
template:
spec:
containers:
- name: kube-rbac-proxy
image: rbac-proxy:latest
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8080/"
- "--logtostderr=true"
- "--v=0"
ports:
- containerPort: 8443
name: https
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
- name: manager
args:
- "--health-probe-bind-address=:8081"
- "--metrics-bind-address=127.0.0.1:8080"
- "--metrics-bind-address=:8443"
- "--leader-elect"
- "--odf-console-port=9001"
11 changes: 0 additions & 11 deletions hack/make-bundle-vars.mk
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,3 @@ RECIPE_SUBSCRIPTION_CATALOGSOURCE_NAMESPACE ?= $(OPERATOR_CATALOGSOURCE_NAMESPAC
STARTING_CSVS ?= "$(IMAGE_NAME).v$(VERSION) $(ODF_DEPS_SUBSCRIPTION_STARTINGCSV) $(OCS_SUBSCRIPTION_STARTINGCSV) $(ROOK_SUBSCRIPTION_STARTINGCSV) \
$(NOOBAA_SUBSCRIPTION_STARTINGCSV) $(CSIADDONS_SUBSCRIPTION_STARTINGCSV) $(CEPHCSI_SUBSCRIPTION_STARTINGCSV) \
$(OCS_CLIENT_SUBSCRIPTION_STARTINGCSV) $(PROMETHEUS_SUBSCRIPTION_STARTINGCSV) $(RECIPE_SUBSCRIPTION_STARTINGCSV)"

# kube rbac proxy image variables
CLUSTER_ENV ?= openshift
KUBE_RBAC_PROXY_IMG ?= gcr.io/kubebuilder/kube-rbac-proxy:v0.16.0
OSE_KUBE_RBAC_PROXY_IMG ?= registry.redhat.io/openshift4/ose-kube-rbac-proxy:v4.11.0

ifeq ($(CLUSTER_ENV), openshift)
RBAC_PROXY_IMG ?= $(OSE_KUBE_RBAC_PROXY_IMG)
else ifeq ($(CLUSTER_ENV), kubernetes)
RBAC_PROXY_IMG ?= $(KUBE_RBAC_PROXY_IMG)
endif
9 changes: 7 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/healthz"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"sigs.k8s.io/controller-runtime/pkg/metrics/filters"

operatorv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
operatorv2 "github.com/operator-framework/api/pkg/operators/v2"
Expand Down Expand Up @@ -102,8 +103,12 @@ func main() {
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
Metrics: metrics.Options{BindAddress: metricsAddr},
Scheme: scheme,
Metrics: metrics.Options{
BindAddress: metricsAddr,
SecureServing: true,
FilterProvider: filters.WithAuthenticationAndAuthorization,
},
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "4fd470de.openshift.io",
Expand Down

0 comments on commit b348073

Please sign in to comment.