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

Make all Deployment related Helm values global #387

Merged
merged 10 commits into from
Feb 29, 2024

Conversation

wallrj
Copy link
Member

@wallrj wallrj commented Feb 29, 2024

Some Deployment related Helm chart values are currently nested under app.webhook, which is confusing because the webhook and the controller are both part of a single Deployment.

It's inconsistent with other Deployment related global Helm values in this chart such as resources and volumes and volumeMounts.

It is also inconsistent with the same Helm values in trust-manager, which are global.

https://github.com/cert-manager/trust-manager/blob/34bb21e768695b4503e8e831e99f5d5ffb53f441/deploy/charts/trust-manager/values.yaml#L110-L135

Testing

Deprecation warnings

# values.yaml
image:
  tag: v0.12.1

replicaCount: 2

podDisruptionBudget:
  enabled: true

topologySpreadConstraints:
- maxSkew: 2
  topologyKey: topology.kubernetes.io/zone
  whenUnsatisfiable: ScheduleAnyway
  labelSelector:
    matchLabels:
      app.kubernetes.io/name: cert-manager-approver-policy
      app.kubernetes.io/instance: cert-manager-approver-policy

app:
  webhook:

    hostNetwork: true
    dnsPolicy: ClusterFirstWithHostNet

    nodeSelector:
      kubernetes.io/os: linux


    affinity:
      nodeAffinity:
       requiredDuringSchedulingIgnoredDuringExecution:
         nodeSelectorTerms:
         - matchExpressions:
           - key: node-restriction.kubernetes.io/reserved-for
             operator: In
             values:
             - platform

    tolerations:
    - key: node-restriction.kubernetes.io/reserved-for
      operator: Equal
      value: platform
$ helm upgrade cert-manager-approver-policy deploy/charts/approver-policy  --values values.yaml  --namespace venafi --create-namespace --install
Release "cert-manager-approver-policy" has been upgraded. Happy Helming!
NAME: cert-manager-approver-policy
LAST DEPLOYED: Thu Feb 29 17:02:22 2024
NAMESPACE: venafi
STATUS: deployed
REVISION: 5
TEST SUITE: None
NOTES:
⚠️  WARNING: The Helm value `.app.webhook.affinity` is deprecated. Use `.affinity` instead.
⚠️  WARNING: The Helm value `.app.webhook.nodeSelector` is deprecated. Use `.nodeSelector` instead.
⚠️  WARNING: The Helm value `.app.webhook.tolerations` is deprecated. Use `.tolerations` instead.
⚠️  WARNING: The Helm value `.app.webhook.hostNetwork` is deprecated. Use `.hostNetwork` instead.
⚠️  WARNING: The Helm value `.app.webhook.dnsPolicy` is deprecated. Use `.dnsPolicy` instead.

CHART NAME: cert-manager-approver-policy
CHART VERSION: v0.0.0
APP VERSION: v0.0.0

cert-manager-approver-policy is a cert-manager project.

If you're a new user, we recommend that you read the [cert-manager Approval Policy documentation] to learn more.

[cert-manager Approval Policy documentation]: https://cert-manager.io/docs/policy/approval/

Without values

$ helm template deploy/charts/approver-policy/ | grep -C 5 -e affinity -e tolerations -e nodeSelector -e hostNetwork -e dnsPolicy
        securityContext:
          allowPrivilegeEscalation: false
          capabilities: { drop: ["ALL"] }
          readOnlyRootFilesystem: true

      hostNetwork: false
      dnsPolicy: ClusterFirst
---
# Source: cert-manager-approver-policy/templates/webhook.yaml
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:

Using global values

$ helm template deploy/charts/approver-policy/ --set-json 'affinity={"foo": "bar"}' --set-json='tolerations=[{}]' --set-json='nodeSelector={"foo": "bar"}' --set hostNetwork=true --set dnsPolicy=foo | grep -C 5 -e affinity -e
tolerations -e nodeSelector -e hostNetwork -e dnsPolicy
        securityContext:
          allowPrivilegeEscalation: false
          capabilities: { drop: ["ALL"] }
          readOnlyRootFilesystem: true

      hostNetwork: true
      dnsPolicy: foo
      nodeSelector:
        foo: bar
      tolerations:
        - {}
      affinity:
        foo: bar
---
# Source: cert-manager-approver-policy/templates/webhook.yaml
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration

Using deprecated values

$ helm template deploy/charts/approver-policy/ --set-json 'app.webhook.affinity={"foo": "bar"}' --set-json='app.webhook.tolerations=[{}]' --set-json='app.webhook.nodeSelector={"foo": "bar"}' --set app.webhook.hostNetwork=true --set app.webhook.dnsPolicy=foo | grep -C 5 -e affinity -e tolerations -e nodeSelector -e hostNetwork -e dnsPolicy
        securityContext:
          allowPrivilegeEscalation: false
          capabilities: { drop: ["ALL"] }
          readOnlyRootFilesystem: true

      hostNetwork: true
      dnsPolicy: foo
      nodeSelector:
        foo: bar
      tolerations:
        - {}
      affinity:
        foo: bar
---
# Source: cert-manager-approver-policy/templates/webhook.yaml
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration

…l scope

Deprecate the original `app.webhook` scoped values.

Signed-off-by: Richard Wall <richard.wall@venafi.com>
Signed-off-by: Richard Wall <richard.wall@venafi.com>
Signed-off-by: Richard Wall <richard.wall@venafi.com>
@jetstack-bot jetstack-bot added dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Feb 29, 2024
…ped value

Signed-off-by: Richard Wall <richard.wall@venafi.com>
@wallrj wallrj force-pushed the make-all-helm-ha-values-global branch from 45c28a3 to 43c2348 Compare February 29, 2024 15:35
@wallrj
Copy link
Member Author

wallrj commented Feb 29, 2024

@inteon How can I fix this error?

/home/prow/go/src/github.com/cert-manager/approver-policy/_bin/tools/helm-tool lint -i deploy/charts/approver-policy/values.yaml -d deploy/charts/approver-policy/templates -e deploy/charts/approver-policy/values.linter.exceptions
value missing from templates: nodeSelector
value missing from templates: tolerations
value missing from templates: affinity
Could not lint: values.yaml and templates are not in sync
make: *** [make/_shared/helm///helm.mk:106: verify-helm-values] Error 1

Discussed with @inteon on slack and we think it's a problem with helm-tool lint. I've added some exceptions for the timebeing.

cert-manager/helm-tool#27

Signed-off-by: Richard Wall <richard.wall@venafi.com>
@@ -77,15 +77,15 @@ spec:

hostNetwork: {{ .Values.app.webhook.hostNetwork }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wallrj does it make sense that hostNetwork and dnsPolicy remain as options under the webhook value?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I noticed those. Probably not. I'll move those too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Deprecate the original `app.webhook` scoped values.

Signed-off-by: Richard Wall <richard.wall@venafi.com>
Signed-off-by: Richard Wall <richard.wall@venafi.com>
Signed-off-by: Richard Wall <richard.wall@venafi.com>
Signed-off-by: Richard Wall <richard.wall@venafi.com>
For backwards compatibility for users who are using the deprecated field values.

Signed-off-by: Richard Wall <richard.wall@venafi.com>
@wallrj wallrj changed the title Make all the Helm HA values global Make all Deployment related Helm values global Feb 29, 2024
@wallrj
Copy link
Member Author

wallrj commented Feb 29, 2024

@inteon PTAL

  • I've also made hostNetwork and dnsPolicy global as you suggested and retested. See PR description for new output.
  • The (or ...) now checks the app.webhook scoped values first, because dnsPolicy has a string default in the default values file, so we need to check the deprecated path to the value because users who have overridden the value will be using that. They will hopefully see the warning notice in the NOTES and change their values files....and then sometime in the future we can remove the old .app.webhook values.

@wallrj wallrj requested a review from inteon February 29, 2024 17:16
value missing from templates: tolerations
value missing from templates: affinity
value missing from templates: nodeSelector
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The helm-tool lint command did not have problems with hostNetwork or dnsPolicy for some reason. Perhaps because those variables are not used in with ... statements in the templates.

@wallrj
Copy link
Member Author

wallrj commented Feb 29, 2024

/retest

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@inteon inteon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @wallrj. I verified a few of the values, and it seems to work as expected.
/approve
/lgtm

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Feb 29, 2024
@jetstack-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: inteon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jetstack-bot jetstack-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 29, 2024
@jetstack-bot jetstack-bot merged commit 6e20fee into cert-manager:main Feb 29, 2024
5 checks passed
@wallrj wallrj deleted the make-all-helm-ha-values-global branch February 29, 2024 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants