Skip to content

Commit

Permalink
Manual cherry-pick of metal3-io#2102
Browse files Browse the repository at this point in the history
❗ Following resources have been removed as part of this PR:

- ClusterRole: baremetal-operator-metrics-reader
- ClusterRole: baremetal-operator-proxy-role
- ClusterRoleBinding: baremetal-operator-proxy-rolebinding
- Service: baremetal-operator-controller-manager-metrics-service

Short description: kube-rbac-proxy was historically used to protect the metrics endpoint. However, its usage has been discontinued in Kubebuilder. The default scaffold now leverages the WithAuthenticationAndAuthorization feature provided by Controller-Runtime. This change is trigerred from the fact that the image gcr.io/kubebuilder/kube-rbac-proxy is deprecated and will become unavailable sometime from early 2025.

Signed-off-by: Kashif Khan <kashif.khan@est.tech>
  • Loading branch information
kashifest committed Dec 10, 2024
1 parent 1098d95 commit 9554430
Show file tree
Hide file tree
Showing 11 changed files with 83 additions and 162 deletions.
13 changes: 4 additions & 9 deletions config/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ configMapGenerator:
- controller_manager_config.yaml

patches:
# Protect the /metrics endpoint by putting it behind auth.
# If you want your controller-manager to expose the /metrics
# endpoint w/o any authn/z, please comment the following line.
- path: manager_auth_proxy_patch.yaml

# Mount the controller config file for loading manager configurations
# through a ComponentConfig type
#- manager_config_patch.yaml
Expand All @@ -62,15 +57,15 @@ replacements:
- select:
kind: ValidatingWebhookConfiguration
fieldPaths:
- metadata.annotations.[cert-manager.io/inject-ca-from]
- metadata.annotations.[cert-manager.io/inject-ca-from]
options:
delimiter: '/'
index: 0
- select:
kind: CustomResourceDefinition
name: baremetalhosts.metal3.io
fieldPaths:
- metadata.annotations.[cert-manager.io/inject-ca-from]
- metadata.annotations.[cert-manager.io/inject-ca-from]
options:
delimiter: '/'
index: 0
Expand All @@ -84,15 +79,15 @@ replacements:
- select:
kind: ValidatingWebhookConfiguration
fieldPaths:
- metadata.annotations.[cert-manager.io/inject-ca-from]
- metadata.annotations.[cert-manager.io/inject-ca-from]
options:
delimiter: '/'
index: 1
- select:
kind: CustomResourceDefinition
name: baremetalhosts.metal3.io
fieldPaths:
- metadata.annotations.[cert-manager.io/inject-ca-from]
- metadata.annotations.[cert-manager.io/inject-ca-from]
options:
delimiter: '/'
index: 1
Expand Down
25 changes: 0 additions & 25 deletions config/base/manager_auth_proxy_patch.yaml

This file was deleted.

9 changes: 0 additions & 9 deletions config/base/rbac/auth_proxy_client_clusterrole.yaml

This file was deleted.

17 changes: 0 additions & 17 deletions config/base/rbac/auth_proxy_role.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions config/base/rbac/auth_proxy_role_binding.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions config/base/rbac/auth_proxy_service.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions config/base/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,3 @@ resources:
- role_binding.yaml
- leader_election_role.yaml
- leader_election_role_binding.yaml
# Comment the following 4 lines if you want to disable
# the auth proxy (https://github.com/brancz/kube-rbac-proxy)
# which protects your /metrics endpoint.
- auth_proxy_service.yaml
- auth_proxy_role.yaml
- auth_proxy_role_binding.yaml
- auth_proxy_client_clusterrole.yaml
67 changes: 0 additions & 67 deletions config/render/capm3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2370,34 +2370,6 @@ rules:
- update
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: baremetal-operator-metrics-reader
rules:
- nonResourceURLs:
- /metrics
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: baremetal-operator-proxy-role
rules:
- apiGroups:
- authentication.k8s.io
resources:
- tokenreviews
verbs:
- create
- apiGroups:
- authorization.k8s.io
resources:
- subjectaccessreviews
verbs:
- create
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: baremetal-operator-leader-election-rolebinding
Expand All @@ -2424,19 +2396,6 @@ subjects:
name: baremetal-operator-controller-manager
namespace: baremetal-operator-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: baremetal-operator-proxy-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: baremetal-operator-proxy-role
subjects:
- kind: ServiceAccount
name: baremetal-operator-controller-manager
namespace: baremetal-operator-system
---
apiVersion: v1
data:
controller_manager_config.yaml: |
Expand Down Expand Up @@ -2472,21 +2431,6 @@ metadata:
---
apiVersion: v1
kind: Service
metadata:
labels:
control-plane: controller-manager
name: baremetal-operator-controller-manager-metrics-service
namespace: baremetal-operator-system
spec:
ports:
- name: https
port: 8443
targetPort: https
selector:
control-plane: controller-manager
---
apiVersion: v1
kind: Service
metadata:
name: baremetal-operator-webhook-service
namespace: baremetal-operator-system
Expand Down Expand Up @@ -2520,7 +2464,6 @@ spec:
spec:
containers:
- args:
- --metrics-addr=127.0.0.1:8085
- --enable-leader-election
command:
- /baremetal-operator
Expand Down Expand Up @@ -2573,16 +2516,6 @@ spec:
- mountPath: /tmp/k8s-webhook-server/serving-certs
name: cert
readOnly: true
- args:
- --secure-listen-address=0.0.0.0:8443
- --upstream=http://127.0.0.1:8085/
- --logtostderr=true
- --v=10
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.16.0
name: kube-rbac-proxy
ports:
- containerPort: 8443
name: https
securityContext:
runAsNonRoot: true
seccompProfile:
Expand Down
22 changes: 22 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,31 @@ require (
)

require (
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch v5.6.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.8.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/cel-go v0.17.7 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand All @@ -59,21 +66,36 @@ require (
github.com/prometheus/procfs v0.15.1 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stoewer/go-strcase v1.2.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.44.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/sdk v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
golang.org/x/net v0.28.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/time v0.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230726155614-23370e0ffb3e // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/grpc v1.58.3 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.29.3 // indirect
k8s.io/apiserver v0.29.3 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.28.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)
Expand Down
Loading

0 comments on commit 9554430

Please sign in to comment.