Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Remove Redundancy and duplication, check for same naming pattern on Kustomize #1721

Merged
merged 22 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/actions/deploy-lifecycle-manager-e2e/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ runs:
path: /spec/duration
value: 1h">> certificate_renewal.yaml
cat certificate_renewal.yaml
kustomize edit add patch --path certificate_renewal.yaml --kind Certificate --group cert-manager.io --version v1 --name watcher-serving-cert
kustomize edit add patch --path certificate_renewal.yaml --kind Certificate --group cert-manager.io --version v1 --name watcher-serving
popd
- name: Deploy LM local testing kustomize
uses: ./lifecycle-manager/.github/actions/deploy-lifecycle-manager
Expand All @@ -88,4 +88,4 @@ runs:
}}
shell: bash
run: |
kubectl patch svc klm-metrics-service -p '{"spec": {"type": "LoadBalancer"}}' -n kcp-system
kubectl patch svc klm-controller-manager-metrics -p '{"spec": {"type": "LoadBalancer"}}' -n kcp-system
2 changes: 1 addition & 1 deletion .github/workflows/test-smoke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
name: kyma-cli-provisioned-wildcard
subjects:
- kind: ServiceAccount
name: lifecycle-manager-controller-manager
name: klm-controller-manager
namespace: kcp-system
EOF
kubectl apply -f tests/moduletemplates/moduletemplate_template_operator_v1_regular.yaml
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ help: ## Display this help.

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases output:rbac:dir=config/rbac/common
$(CONTROLLER_GEN) rbac:roleName=controller-manager crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases output:rbac:dir=config/rbac/common

.PHONY: test-crd
test-crd: controller-gen ## Generate crd for test
Expand Down
8 changes: 4 additions & 4 deletions config/certmanager/certificate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: selfsigned-issuer
name: controller-manager-selfsigned
spec:
selfSigned: {}
---
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
name: controller-manager-webhook-serving # this name should match the one appeared in kustomizeconfig.yaml
spec:
# $(SERVICE_NAME) and $(SERVICE_NAMESPACE) will be substituted by kustomize
dnsNames:
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc
- $(SERVICE_NAME).$(SERVICE_NAMESPACE).svc.cluster.local
issuerRef:
kind: Issuer
name: selfsigned-issuer
secretName: webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize
name: controller-manager-selfsigned
secretName: klm-controller-manager-webhook # this secret will not be prefixed, since it's not managed by kustomize
4 changes: 2 additions & 2 deletions config/control-plane/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ transformers:
metadata:
name: add-ca-inject-annotation
annotations:
cert-manager.io/inject-ca-from: kcp-system/klm-serving-cert
cert-manager.io/inject-ca-from: kcp-system/klm-controller-manager-webhook-serving
fieldSpecs:
- kind: CustomResourceDefinition
path: metadata/annotations
Expand Down Expand Up @@ -164,7 +164,7 @@ transformers:
patch: '[{"op": "replace", "path": "/spec/dnsNames/0", "value": "klm-webhook-service.kcp-system.svc"}, {"op": "replace", "path": "/spec/dnsNames/1", "value": "klm-webhook-service.kcp-system.svc.cluster.local"}]'
target:
kind: Certificate
name: klm-serving-cert
name: klm-controller-manager-webhook-serving
version: v1
group: cert-manager.io
- |-
Expand Down
2 changes: 1 addition & 1 deletion config/control-plane/patches/service_monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: ServiceMonitor
metadata:
labels:
app.kubernetes.io/component: lifecycle-manager.kyma-project.io
name: controller-manager-metrics-monitor
name: controller-manager-metrics
spec:
endpoints:
- path: /metrics
Expand Down
4 changes: 2 additions & 2 deletions config/control-plane/patches/unique_certificate_name.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: serving-cert # this name should match the one appeared in kustomizeconfig.yaml
name: controller-manager-webhook-serving # this name should match the one appeared in kustomizeconfig.yaml
spec:
secretName: lifecycle-manager-webhook-server-cert # this secret will not be prefixed, since it's not managed by kustomize
secretName: klm-controller-manager-webhook # this secret will not be prefixed, since it's not managed by kustomize
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ spec:
- name: cert
secret:
defaultMode: 420
secretName: lifecycle-manager-webhook-server-cert
secretName: klm-controller-manager-webhook
10 changes: 5 additions & 5 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ kind: Kustomization
# "wordpress" becomes "alices-wordpress".
# Note that it should also match with the prefix (text before '-') of the namespace
# field above.
namePrefix: lifecycle-manager-
namePrefix: klm-

# Labels to add to all resources and selectors.
commonLabels:
Expand Down Expand Up @@ -61,7 +61,7 @@ transformers:
metadata:
name: add-ca-inject-annotation
annotations:
cert-manager.io/inject-ca-from: kcp-system/lifecycle-manager-serving-cert
cert-manager.io/inject-ca-from: kcp-system/klm-controller-manager-webhook-serving
fieldSpecs:
- kind: CustomResourceDefinition
path: metadata/annotations
Expand All @@ -72,10 +72,10 @@ transformers:
kind: PatchTransformer
metadata:
name: fix-cert-dns-names
patch: '[{"op": "replace", "path": "/spec/dnsNames/0", "value": "lifecycle-manager-webhook-service.kcp-system.svc"}, {"op": "replace", "path": "/spec/dnsNames/1", "value": "lifecycle-manager-webhook-service.kcp-system.svc.cluster.local"}]'
patch: '[{"op": "replace", "path": "/spec/dnsNames/0", "value": "klm-webhook-service.kcp-system.svc"}, {"op": "replace", "path": "/spec/dnsNames/1", "value": "klm-webhook-service.kcp-system.svc.cluster.local"}]'
target:
kind: Certificate
name: lifecycle-manager-serving-cert
name: klm-controller-manager-webhook-serving
version: v1
group: cert-manager.io
- |-
Expand All @@ -86,6 +86,6 @@ transformers:
patch: '[{"op": "replace", "path": "/webhooks/0/clientConfig/service/namespace", "value": "kcp-system"}]'
target:
kind: ValidatingWebhookConfiguration
name: lifecycle-manager-validating-webhook-configuration
name: klm-validating-webhook-configuration
version: v1
group: admissionregistration.k8s.io
2 changes: 1 addition & 1 deletion config/default/manager_webhook_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ spec:
- name: cert
secret:
defaultMode: 420
secretName: webhook-server-cert
secretName: klm-controller-manager-webhook
48 changes: 24 additions & 24 deletions config/grafana/overview.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "sum(rate(rest_client_requests_total{job=\"klm-metrics-service\", code=~\"2..\"}[$__rate_interval]))",
"expr": "sum(rate(rest_client_requests_total{job=\"klm-controller-manager-metrics\", code=~\"2..\"}[$__rate_interval]))",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
Expand All @@ -105,7 +105,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "sum(rate(rest_client_requests_total{job=\"klm-metrics-service\", code=~\"3..\"}[$__rate_interval]))",
"expr": "sum(rate(rest_client_requests_total{job=\"klm-controller-manager-metrics\", code=~\"3..\"}[$__rate_interval]))",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
Expand All @@ -118,7 +118,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "sum(rate(rest_client_requests_total{job=\"klm-metrics-service\", code=~\"4..\"}[$__rate_interval]))",
"expr": "sum(rate(rest_client_requests_total{job=\"klm-controller-manager-metrics\", code=~\"4..\"}[$__rate_interval]))",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
Expand All @@ -131,7 +131,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "sum(rate(rest_client_requests_total{job=\"klm-metrics-service\", code=~\"5..\"}[$__rate_interval]))",
"expr": "sum(rate(rest_client_requests_total{job=\"klm-controller-manager-metrics\", code=~\"5..\"}[$__rate_interval]))",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
Expand Down Expand Up @@ -230,7 +230,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "process_resident_memory_bytes{job=\"klm-metrics-service\"}",
"expr": "process_resident_memory_bytes{job=\"klm-controller-manager-metrics\"}",
"hide": false,
"interval": "",
"legendFormat": "Lifecycle Manager",
Expand Down Expand Up @@ -330,7 +330,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "rate(process_cpu_seconds_total{job=\"klm-metrics-service\"}[$__rate_interval])",
"expr": "rate(process_cpu_seconds_total{job=\"klm-controller-manager-metrics\"}[$__rate_interval])",
"interval": "",
"legendFormat": "{{job}}",
"refId": "A"
Expand Down Expand Up @@ -460,7 +460,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "rate(controller_runtime_reconcile_total{controller=~\"kyma|watcher|purge|manifest|mandatory-module-installation|mandatory-module-deletion\",job=\"klm-metrics-service\"}[$__rate_interval])",
"expr": "rate(controller_runtime_reconcile_total{controller=~\"kyma|watcher|purge|manifest|mandatory-module-installation|mandatory-module-deletion\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])",
"hide": false,
"instant": false,
"interval": "",
Expand Down Expand Up @@ -547,7 +547,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "rate(controller_runtime_reconcile_errors_total{controller=~\"kyma|watcher|purge|manifest|mandatory-module-installation|mandatory-module-deletion\",job=\"klm-metrics-service\"}[$__rate_interval])",
"expr": "rate(controller_runtime_reconcile_errors_total{controller=~\"kyma|watcher|purge|manifest|mandatory-module-installation|mandatory-module-deletion\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])",
"interval": "",
"legendFormat": "{{controller}}",
"refId": "A"
Expand Down Expand Up @@ -714,7 +714,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "rate(controller_runtime_reconcile_time_seconds_sum{controller=\"manifest\",job=\"klm-metrics-service\"}[$__rate_interval])\n/\nrate(controller_runtime_reconcile_time_seconds_count{controller=\"manifest\",job=\"klm-metrics-service\"}[$__rate_interval])",
"expr": "rate(controller_runtime_reconcile_time_seconds_sum{controller=\"manifest\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])\n/\nrate(controller_runtime_reconcile_time_seconds_count{controller=\"manifest\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])",
"interval": "",
"legendFormat": "{{controller}}",
"refId": "A"
Expand All @@ -725,7 +725,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "rate(controller_runtime_reconcile_time_seconds_sum{controller=\"kyma\",job=\"klm-metrics-service\"}[$__rate_interval])\n/\nrate(controller_runtime_reconcile_time_seconds_count{controller=\"kyma\",job=\"klm-metrics-service\"}[$__rate_interval])",
"expr": "rate(controller_runtime_reconcile_time_seconds_sum{controller=\"kyma\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])\n/\nrate(controller_runtime_reconcile_time_seconds_count{controller=\"kyma\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])",
"hide": false,
"interval": "",
"legendFormat": "{{controller}}",
Expand Down Expand Up @@ -920,7 +920,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "controller_runtime_active_workers{controller=\"kyma\",job=\"klm-metrics-service\"}",
"expr": "controller_runtime_active_workers{controller=\"kyma\",job=\"klm-controller-manager-metrics\"}",
"interval": "",
"legendFormat": "{{controller}}",
"refId": "A"
Expand All @@ -931,7 +931,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "controller_runtime_active_workers{controller=\"manifest\",job=\"klm-metrics-service\"}",
"expr": "controller_runtime_active_workers{controller=\"manifest\",job=\"klm-controller-manager-metrics\"}",
"hide": false,
"interval": "",
"legendFormat": "{{controller}}",
Expand Down Expand Up @@ -1033,7 +1033,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "workqueue_longest_running_processor_seconds{job=\"klm-metrics-service\"}",
"expr": "workqueue_longest_running_processor_seconds{job=\"klm-controller-manager-metrics\"}",
"interval": "",
"legendFormat": "{{job}}",
"refId": "A"
Expand Down Expand Up @@ -1116,7 +1116,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "workqueue_unfinished_work_seconds{job=\"klm-metrics-service\"}",
"expr": "workqueue_unfinished_work_seconds{job=\"klm-controller-manager-metrics\"}",
"hide": false,
"interval": "",
"legendFormat": "{{job}}",
Expand Down Expand Up @@ -1182,7 +1182,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": " rate(workqueue_queue_duration_seconds_sum{name=\"manifest\",job=\"klm-metrics-service\"}[$__rate_interval])\n/\n rate(workqueue_queue_duration_seconds_count{name=\"manifest\",job=\"klm-metrics-service\"}[$__rate_interval])",
"expr": " rate(workqueue_queue_duration_seconds_sum{name=\"manifest\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])\n/\n rate(workqueue_queue_duration_seconds_count{name=\"manifest\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])",
"interval": "",
"legendFormat": "{{name}}",
"refId": "A"
Expand All @@ -1193,7 +1193,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": " rate(workqueue_queue_duration_seconds_sum{name=\"kyma\",job=\"klm-metrics-service\"}[$__rate_interval])\n/\n rate(workqueue_queue_duration_seconds_count{name=\"kyma\",job=\"klm-metrics-service\"}[$__rate_interval])",
"expr": " rate(workqueue_queue_duration_seconds_sum{name=\"kyma\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])\n/\n rate(workqueue_queue_duration_seconds_count{name=\"kyma\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])",
"hide": false,
"interval": "",
"legendFormat": "{{name}}",
Expand Down Expand Up @@ -1292,7 +1292,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "rate(workqueue_work_duration_seconds_sum{name=\"manifest\",job=\"klm-metrics-service\"}[$__rate_interval])\n/\nrate(workqueue_work_duration_seconds_count{name=\"manifest\",job=\"klm-metrics-service\"}[$__rate_interval])",
"expr": "rate(workqueue_work_duration_seconds_sum{name=\"manifest\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])\n/\nrate(workqueue_work_duration_seconds_count{name=\"manifest\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])",
"interval": "",
"legendFormat": "{{name}}",
"refId": "A"
Expand All @@ -1303,7 +1303,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "rate(workqueue_work_duration_seconds_sum{name=\"kyma\",job=\"klm-metrics-service\"}[$__rate_interval])\n/\nrate(workqueue_work_duration_seconds_count{name=\"kyma\",job=\"klm-metrics-service\"}[$__rate_interval])",
"expr": "rate(workqueue_work_duration_seconds_sum{name=\"kyma\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])\n/\nrate(workqueue_work_duration_seconds_count{name=\"kyma\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])",
"hide": false,
"interval": "",
"legendFormat": "{{name}}",
Expand Down Expand Up @@ -1402,7 +1402,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "workqueue_depth{name=\"manifest\",job=\"klm-metrics-service\"}",
"expr": "workqueue_depth{name=\"manifest\",job=\"klm-controller-manager-metrics\"}",
"interval": "",
"legendFormat": "{{name}}",
"refId": "A"
Expand All @@ -1413,7 +1413,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "workqueue_depth{name=\"kyma\",job=\"klm-metrics-service\"}",
"expr": "workqueue_depth{name=\"kyma\",job=\"klm-controller-manager-metrics\"}",
"hide": false,
"interval": "",
"legendFormat": "{{name}}",
Expand Down Expand Up @@ -1515,7 +1515,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "sum(rate(workqueue_adds_total{name=\"manifest\",job=\"klm-metrics-service\"}[$__rate_interval])) by (name)",
"expr": "sum(rate(workqueue_adds_total{name=\"manifest\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])) by (name)",
"format": "time_series",
"interval": "",
"intervalFactor": 2,
Expand All @@ -1528,7 +1528,7 @@
"uid": "P1809F7CD0C75ACF3"
},
"exemplar": true,
"expr": "sum(rate(workqueue_adds_total{name=\"kyma\",job=\"klm-metrics-service\"}[$__rate_interval])) by (name)",
"expr": "sum(rate(workqueue_adds_total{name=\"kyma\",job=\"klm-controller-manager-metrics\"}[$__rate_interval])) by (name)",
"hide": false,
"interval": "",
"legendFormat": "{{name}}",
Expand Down Expand Up @@ -1633,7 +1633,7 @@
"targets": [
{
"exemplar": true,
"expr": "lifecycle_mgr_self_signed_cert_not_renew{service=\"klm-metrics-service\"}",
"expr": "lifecycle_mgr_self_signed_cert_not_renew{service=\"klm-controller-manager-metrics\"}",
"interval": "",
"legendFormat": "{{kyma_name}}",
"refId": "A"
Expand Down Expand Up @@ -1837,7 +1837,7 @@
"targets": [
{
"exemplar": true,
"expr": "rate(lifecycle_mgr_purgectrl_requests_total{service=\"klm-metrics-service\"}[$__rate_interval])",
"expr": "rate(lifecycle_mgr_purgectrl_requests_total{service=\"klm-controller-manager-metrics\"}[$__rate_interval])",
"interval": "",
"legendFormat": "",
"refId": "A"
Expand Down
8 changes: 4 additions & 4 deletions config/load_test/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ replacements:
# substitutes CERTIFICATE_NAMESPACE, the namespace of the certificate CR
- source:
kind: Certificate
name: serving-cert # this name should match the one in certificate.yaml
name: controller-manager-webhook-serving # this name should match the one in certificate.yaml
fieldPath: metadata.namespace
targets:
- select:
Expand All @@ -47,7 +47,7 @@ replacements:
# substitutes CERTIFICATE_NAME, the name of the certificate CR
- source:
kind: Certificate
name: serving-cert # this name should match the one in certificate.yaml
name: controller-manager-webhook-serving # this name should match the one in certificate.yaml
fieldPath: metadata.name
targets:
- select:
Expand Down Expand Up @@ -76,7 +76,7 @@ replacements:
group: cert-manager.io
version: v1
kind: Certificate
name: serving-cert
name: controller-manager-webhook-serving
fieldpaths:
- spec.dnsNames.0
- spec.dnsNames.1
Expand All @@ -94,7 +94,7 @@ replacements:
group: cert-manager.io
version: v1
kind: Certificate
name: serving-cert
name: controller-manager-webhook-serving
fieldpaths:
- spec.dnsNames.0
- spec.dnsNames.1
Expand Down
Loading
Loading