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

Fix several Helm YAML issues with extraModules and extraInitContainers #9709

Merged
merged 4 commits into from
Mar 21, 2023
Merged

Conversation

ajacques
Copy link
Contributor

@ajacques ajacques commented Mar 9, 2023

What this PR does / why we need it:

Prior to this fix, users are unable to use OpenTelemetry with DaemonSets due to several issues and not able to specify both values for both extraInitContainers and extraModules. The resulting template will be rejected because it's semantically invalid due to a YAML indention issue. In addition, there's a casing issue. The Deployment refers to image and name, but DaemonSet uses Image and Name.

Given the following values.yaml:

controller:
  extraInitContainers:
    - command:
        - /bin/chown
        - '101'
        - /mycache
      image: busybox:latest
      name: chmod
      volumeMounts:
        - mountPath: /mycache
          name: cache
  extraVolumeMounts:
    - mountPath: /var/cache/nginx
      name: cache
  extraVolumes:
    - hostPath:
        path: /var/cache/nginx-k8s
        type: ''
      name: cache
  kind: DaemonSet
  extraModules:
    - name: opentelemetry
      image: registry.k8s.io/ingress-nginx/opentelemetry:v20230107-helm-chart-4.4.2-2-g96b3d2165@sha256:331b9bebd6acfcd2d3048abbdd86555f5be76b7e3d0b5af4300b04235c6056c9

Prior to this change, the DaemonSet gets generated like this:

      initContainers:
        
        - command:
          - /bin/chown
          - "101"
          - /mycache
          image: busybox:latest
          name: chmod
          volumeMounts:
          - mountPath: /mycache
            name: cache
          - name:   # <--- Notice that this is aligned under the volumeMounts, not under initContainers
            image:   # <-- Also note the empty image and names
            command: ['sh', '-c', '/usr/local/bin/init_module.sh']
            volumeMounts:
              - name: modules
                mountPath: /modules_mount

After this change, it generates a correct YAML:

      initContainers:
        
        - command:
          - /bin/chown
          - "101"
          - /mycache
          image: busybox:latest
          name: chmod
          volumeMounts:
          - mountPath: /mycache
            name: cache
        - name: opentelemetry
          image: registry.k8s.io/ingress-nginx/opentelemetry:v20230107-helm-chart-4.4.2-2-g96b3d2165@sha256:331b9bebd6acfcd2d3048abbdd86555f5be76b7e3d0b5af4300b04235c6056c9
          command: ['sh', '-c', '/usr/local/bin/init_module.sh']
          volumeMounts:
            - name: modules
              mountPath: /modules_mount

Honestly, I'm not sure if extraModules even works in the Deployment case. I wasn't able to do Helm template if I generated a Deployment or DaemonSet. Trying to generate a Deployment gave me:

error: template: ingress-nginx/templates/controller-deployment.yaml:188:134: executing "ingress-nginx/templates/controller-deployment.yaml" at <8>: wrong type for value; expected string; got map[string]interface {}
helm.go:84: [debug] template: ingress-nginx/templates/controller-deployment.yaml:188:134: executing "ingress-nginx/templates/controller-deployment.yaml" at <8>: wrong type for value; expected string; got map[string]interface {}

I only discovered this issue because the DaemonSet didn't support specifying controller.opentelemetry.enabled=true

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • CVE Report (Scanner found CVE and adding report)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation only

Which issue/s this PR fixes

How Has This Been Tested?

I manually reviewed the generated template (see above) and deployed this commit to my cluster and verified the DaemonSet looks correct.

Are there any Helm tests that actually assert anything? I see the files in charts/ingress-nginx/ci, but I didn't see any expected values to make sure that's correct.

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have added unit and/or e2e tests to cover my changes.
  • All new and existing tests passed.
  • Added Release Notes.

Does my pull request need a release note?

Any user-visible or operator-visible change qualifies for a release note. This could be a:

  • fix of a previous Known Issue

No release notes are required for changes to the following:

  • Tests
  • Build infrastructure
  • Fixes for unreleased bugs

For more tips on writing good release notes, check out the Release Notes Handbook

Fixed Helm template issue when specifying extraModules and allow OpenTelemetry to be enabled on DaemonSets

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Mar 9, 2023
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot
Copy link
Contributor

Welcome @ajacques!

It looks like this is your first PR to kubernetes/ingress-nginx 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/ingress-nginx has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 9, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @ajacques. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 9, 2023
@k8s-ci-robot k8s-ci-robot added the area/helm Issues or PRs related to helm charts label Mar 9, 2023
@longwuyuan
Copy link
Contributor

@ajacques thanks for the contribution

@esigo Is this PR only for OTEL or is the code change going to enable any/every possible extraModule that comes to any user's mind. And if its only for OTEL, then how does this play with your PR

@longwuyuan
Copy link
Contributor

I am still checking but allowing any/every possible container as initContainer or sideCar etc is a security concern.

@ajacques
Copy link
Contributor Author

ajacques commented Mar 9, 2023

For context: I don't have any custom modules, just trying to use the OTEL one. This came up because I tried to enable OTEL on a DaemonSet and found a few different bugs that prevented me from doing that and I just fixed them all.

allowing any/every possible container as initContainer or sideCar etc is a security concern.

Can you clarify why this is something to protect the user against? This is the current state since there's no restrictions on extraInitContainers or extraContainers.

@longwuyuan
Copy link
Contributor

@ajacques sorry for confusion

  • Please wait for comments from @esigo on OTEL
  • The current state leaves much to be desired and work is in progress to change current state
  • Much hardening & securing is work-in-progress so I asked if there is a hint of allowing any/all initContainer/sideCar because that changes security

@longwuyuan
Copy link
Contributor

@ajacques the controller as a daemonset with OTEL would also require tests

@longwuyuan
Copy link
Contributor

@ajacques also, there is a much broader impact when it comes the process of integration with extraModules. We have discussed it and there are changes needed in the core of the controller image. Hence I pinged @esigo .

@k8s-triage-robot
Copy link

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-contributor-experience at kubernetes/community.

/check-cla
/easycla

@esigo
Copy link
Member

esigo commented Mar 9, 2023

@longwuyuan, Otel doesn't rely on extra modules anymore. daemonset changes for Otel looks fine, I haven't tested daemonset with Otel module though.
If there is no other use case for extra modules maybe it can be removed?

@k8s-triage-robot
Copy link

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-contributor-experience at kubernetes/community.

/check-cla
/easycla

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 10, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Mar 10, 2023
@tao12345666333
Copy link
Member

/check-cla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 11, 2023
@ajacques
Copy link
Contributor Author

ajacques commented Mar 12, 2023

Are these changes valuable? Should I remove extraModules or change anything? At the very minimum, I'd suggest we fix the extraModules indention issue, but I'm not really blocked on this change getting merged.

@strongjz
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 21, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ajacques, strongjz

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 21, 2023
@k8s-ci-robot k8s-ci-robot merged commit 00bfb2e into kubernetes:main Mar 21, 2023
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. area/helm Issues or PRs related to helm charts cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants