Skip to content

Commit e1497bf

Browse files
šŸ› fix place where metrics service is scaffolded by moving from config/rbac to config/default (#3945)
fix place where metrics service is scaffolded by moving from config/rbac to config/default When we discontinued the usage of kube-rbac-proxy we placed the Metrics Service under config/rbac but it is not the best place to fit this resource. Furthermore, within those changes we are ensuring that the metrics service will only be applied if/when users enable the metrics.
1 parent 16d5cef commit e1497bf

File tree

35 files changed

+110
-166
lines changed

35 files changed

+110
-166
lines changed

ā€Ž.github/workflows/test-sample-go.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ jobs:
2424
run: |
2525
KUSTOMIZATION_FILE_PATH="testdata/project-v4/config/default/kustomization.yaml"
2626
sed -i '25s/^#//' $KUSTOMIZATION_FILE_PATH
27-
sed -i '39s/^#//' $KUSTOMIZATION_FILE_PATH
28-
sed -i '44s/^#//' $KUSTOMIZATION_FILE_PATH
29-
sed -i '48,144s/^#//' $KUSTOMIZATION_FILE_PATH
27+
sed -i '32s/^#//' $KUSTOMIZATION_FILE_PATH
28+
sed -i '47s/^#//' $KUSTOMIZATION_FILE_PATH
29+
sed -i '51,147s/^#//' $KUSTOMIZATION_FILE_PATH
3030
3131
- name: Test
3232
run: |

ā€Ždocs/book/src/cronjob-tutorial/testdata/project/config/default/kustomization.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ resources:
2525
- ../certmanager
2626
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
2727
- ../prometheus
28+
# [METRICS] To enable the controller manager metrics service, uncomment the following line.
29+
#- metrics_service.yaml
2830

31+
# Uncomment the patches line if you enable Metrics, and/or are using webhooks and cert-manager
2932
patches:
3033
# [METRICS] The following patch will enable the metrics endpoint. Ensure that you also protect this endpoint.
3134
# More info: https://book.kubebuilder.io/reference/metrics

ā€Ždocs/book/src/cronjob-tutorial/testdata/project/config/rbac/kustomization.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ resources:
99
- role_binding.yaml
1010
- leader_election_role.yaml
1111
- leader_election_role_binding.yaml
12-
- metrics_service.yaml
1312
# For each CRD, "Editor" and "Viewer" roles are scaffolded by
1413
# default, aiding admins in cluster management. Those roles are
1514
# not used by the Project itself. You can comment the following lines

ā€Ždocs/book/src/getting-started/testdata/project/config/default/kustomization.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ resources:
2525
#- ../certmanager
2626
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
2727
#- ../prometheus
28+
# [METRICS] To enable the controller manager metrics service, uncomment the following line.
29+
#- metrics_service.yaml
2830

29-
patches:
31+
# Uncomment the patches line if you enable Metrics, and/or are using webhooks and cert-manager
32+
#patches:
3033
# [METRICS] The following patch will enable the metrics endpoint. Ensure that you also protect this endpoint.
3134
# More info: https://book.kubebuilder.io/reference/metrics
3235
# If you want to expose the metric endpoint of your controller-manager uncomment the following line.

ā€Ždocs/book/src/getting-started/testdata/project/config/rbac/kustomization.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ resources:
99
- role_binding.yaml
1010
- leader_election_role.yaml
1111
- leader_election_role_binding.yaml
12-
- metrics_service.yaml
1312
# For each CRD, "Editor" and "Viewer" roles are scaffolded by
1413
# default, aiding admins in cluster management. Those roles are
1514
# not used by the Project itself. You can comment the following lines

ā€Ždocs/book/src/reference/metrics.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ Further information can be found bellow in this document.
4545
First, you will need enable the Metrics by uncommenting the following line
4646
in the file `config/default/kustomization.yaml`, see:
4747

48-
```sh
48+
```yaml
49+
# [METRICS] To enable the controller manager metrics service, uncomment the following line.
50+
#- metrics_service.yaml
51+
```
52+
53+
```yaml
4954
# [METRICS] The following patch will enable the metrics endpoint. Ensure that you also protect this endpoint.
5055
# More info: https://book.kubebuilder.io/reference/metrics
5156
# If you want to expose the metric endpoint of your controller-manager uncomment the following line.
@@ -79,7 +84,7 @@ Integrating `cert-manager` with your metrics service can secure the endpoint via
7984

8085
To modify your project setup to expose metrics using HTTPS with
8186
the help of cert-manager, you'll need to change the configuration of both
82-
the `Service` under `config/rbac/metrics_service.yaml` and
87+
the `Service` under `config/default/metrics_service.yaml` and
8388
the `ServiceMonitor` under `config/prometheus/monitor.yaml` to use a secure HTTPS port
8489
and ensure the necessary certificate is applied.
8590

ā€Žpkg/plugins/common/kustomize/v2/scaffolds/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (s *initScaffolder) Scaffold() error {
6464

6565
templates := []machinery.Builder{
6666
&rbac.Kustomization{},
67-
&rbac.MetricsService{},
67+
&kdefault.MetricsService{},
6868
&rbac.RoleBinding{},
6969
// We need to create a Role because if the project
7070
// has not CRD define the controller-gen will not generate this file

ā€Žpkg/plugins/common/kustomize/v2/scaffolds/internal/templates/config/kdefault/kustomization.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ resources:
7070
#- ../certmanager
7171
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
7272
#- ../prometheus
73+
# [METRICS] To enable the controller manager metrics service, uncomment the following line.
74+
#- metrics_service.yaml
7375
74-
patches:
76+
# Uncomment the patches line if you enable Metrics, and/or are using webhooks and cert-manager
77+
#patches:
7578
# [METRICS] The following patch will enable the metrics endpoint. Ensure that you also protect this endpoint.
7679
# More info: https://book.kubebuilder.io/reference/metrics
7780
# If you want to expose the metric endpoint of your controller-manager uncomment the following line.

0 commit comments

Comments
Ā (0)