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

Automate Uncommenting Webhook Blocks in kustomize.yaml When Scaffolding Webhooks #4422

Open
camilamacedo86 opened this issue Dec 11, 2024 · 4 comments
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence.

Comments

@camilamacedo86
Copy link
Member

What do you want to happen?

Currently, when scaffolding webhooks (default or conversion or validation), users need to manually uncomment the relevant blocks in the config/default/kustomization.yaml file. This process can be automated to improve the user experience.

Problem

  • When scaffolding default webhooks, users must manually uncomment the corresponding sections in the kustomization.yaml file.
  • For conversion webhooks, the injected code requires further manual adjustments to uncomment specific blocks.
  • In the e2e tests, the uncommenting is handled via shell scripts (example here), which could be avoided if the tool itself handles this step during scaffolding.

Solution

  1. Automate Uncommenting:

  2. Raise Warnings:

    • If the tool cannot automatically uncomment the code (e.g., file issues or other constraints), it should raise a warning instead of throwing an error. This ensures the user knows what to fix manually without blocking the workflow.
  3. Remove Shell Script Dependencies in CI:

    • Remove references in GitHub Actions that use shell scripts to uncomment blocks during e2e tests (example here).
    • Update CI workflows to validate the new behavior where the tool handles uncommenting automatically.

Benefits

  • Users will no longer need to manually uncomment code in kustomization.yaml when scaffolding webhooks.
  • Cleaner and more automated CI processes.
  • Improved developer experience for kubebuilder users.
  • Improve maintainability for our ci

Extra Labels

No response

@camilamacedo86 camilamacedo86 added kind/feature Categorizes issue or PR as related to a new feature. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. labels Dec 11, 2024
@camilamacedo86 camilamacedo86 changed the title utomate Uncommenting Webhook Blocks in kustomize.yaml When Scaffolding Webhooks Automate Uncommenting Webhook Blocks in kustomize.yaml When Scaffolding Webhooks Dec 11, 2024
@camilamacedo86 camilamacedo86 added the priority/backlog Higher priority than priority/awaiting-more-evidence. label Dec 13, 2024
@Dhairya-Dudhatra
Copy link

Hey @camilamacedo86 , can you please assign this to me ?

@mateusoliveira43
Copy link
Contributor

@Dhairya-Dudhatra you can comment /assign and bot will do this for you :)

@Dhairya-Dudhatra
Copy link

/assign

@camilamacedo86
Copy link
Member Author

camilamacedo86 commented Dec 14, 2024

What we must do:

If we run create webhook:

The, we will uncomment (if not yet) in the config/default/kustomize.ymal

#- ../certmanager
#- path: cert_metrics_manager_patch.yaml
#  target:
#    kind: Deployment
- path: manager_webhook_patch.yaml
#replacements:
# - source: # Uncomment the following block if you enable [METRICS-WITH-CERTS]
#     kind: Service
#     version: v1
#     name: controller-manager-metrics-service
#     fieldPath: metadata.name
#   targets:
#     - select:
#         kind: Certificate
#         group: cert-manager.io
#         version: v1
#         name: metrics-certs
#       fieldPaths:
#         - spec.dnsNames.0
#         - spec.dnsNames.1
#       options:
#         delimiter: '.'
#         index: 0
#         create: true
#
# - source:
#     kind: Service
#     version: v1
#     name: controller-manager-metrics-service
#     fieldPath: metadata.namespace
#   targets:
#     - select:
#         kind: Certificate
#         group: cert-manager.io
#         version: v1
#         name: metrics-certs
#       fieldPaths:
#         - spec.dnsNames.0
#         - spec.dnsNames.1
#       options:
#         delimiter: '.'
#         index: 1
#         create: true
#
# - source: # Uncomment the following block if you have any webhook
#     kind: Service
#     version: v1
#     name: webhook-service
#     fieldPath: .metadata.name # Name of the service
#   targets:
#     - select:
#         kind: Certificate
#         group: cert-manager.io
#         version: v1
#         name: serving-cert
#       fieldPaths:
#         - .spec.dnsNames.0
#         - .spec.dnsNames.1
#       options:
#         delimiter: '.'
#         index: 0
#         create: true
# - source:
#     kind: Service
#     version: v1
#     name: webhook-service
#     fieldPath: .metadata.namespace # Namespace of the service
#   targets:
#     - select:
#         kind: Certificate
#         group: cert-manager.io
#         version: v1
#         name: serving-cert
#       fieldPaths:
#         - .spec.dnsNames.0
#         - .spec.dnsNames.1
#       options:
#         delimiter: '.'
#         index: 1
#         create: true

Then:

Since when it happens the project will need to have the dependency with webhooks and we are uncomment the metrics as well, we need to uncomment the following in the config/prometheus/kustomization.yaml

# [PROMETHEUS WITH CERTMANAGER] The following patch configures the ServiceMonitor in ../prometheus
# to securely reference certificates created and managed by cert-manager.
# Additionally, ensure that you uncomment the [METRICS WITH CERTMANAGER] patch under config/default/kustomization.yaml
# to mount the "metrics-server-cert" secret in the Manager Deployment.
#patches:
#  - path: monitor_tls_patch.yaml
#    target:
#      kind: ServiceMonitor

So that we ensure that all places that will benefit from using cert-manager will be uncommented, and we are making the process easier for our users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/feature Categorizes issue or PR as related to a new feature. priority/backlog Higher priority than priority/awaiting-more-evidence.
Projects
None yet
Development

No branches or pull requests

3 participants