pulumi-kubernetes icon indicating copy to clipboard operation
pulumi-kubernetes copied to clipboard

Unable to delete a Chart default key

Open aureq opened this issue 3 years ago • 6 comments

What happened?

In a Helm Chart, it's possible to delete a default key (as provided by the chart defaults) using the null value. On the command line, this looks like this.

helm install stable/drupal --set image=my-registry/drupal:0.1.0 --set livenessProbe.httpGet=null

This feature is also documented.

However, when using this provider and the descheduler Chart, it doesn't seem to be possible to achieve the same by providing a null.

Here are the details below:

In the values.yaml default values we find RemovePodsViolatingNodeAffinity.

    RemovePodsViolatingNodeAffinity:
      enabled: true
      params:
        nodeAffinityType:
        - requiredDuringSchedulingIgnoredDuringExecution

Of this item, we want to remove the params keys. In TypeScript we construct the following object for the deschedulerPolicy and we set params: null.

deschedulerPolicy: {
            strategies: {
              RemoveDuplicates: {
                enabled: false,
                params: null,
              },
              LowNodeUtilization: {
                enabled: false,
                params: null,
              },
              HighNodeUtilization: {
                enabled: false,
                params: null,
              },
              RemovePodsViolatingInterPodAntiAffinity: {
                enabled: false,
                params: null,
              },
              RemovePodsViolatingNodeAffinity: {
                enabled: false,
                params: null,
              },
              RemovePodsViolatingNodeTaints: {
                enabled: false,
                params: null,
              },
              RemovePodsViolatingTopologySpreadConstraint: {
                enabled: false,
                params: null,
              },
              RemovePodsHavingTooManyRestarts: {
                enabled: false,
                params: null,
              },
              PodLifeTime: {
                enabled: false,
                params: null,
              },
              RemoveFailedPods: {
                enabled: false,
                params: null,
              },
            },
          },

Unfortunately, the resulting configMap is like this and still contains the params key.

strategies:
  HighNodeUtilization:
    enabled: false
  LowNodeUtilization:
    enabled: false
    params:
      nodeResourceUtilizationThresholds:
        targetThresholds:
          cpu: 50
          memory: 50
          pods: 50
        thresholds:
          cpu: 20
          memory: 20
          pods: 20
  PodLifeTime:
    enabled: false
  RemoveDuplicates:
    enabled: false
  RemoveFailedPods:
    enabled: false
  RemovePodsHavingTooManyRestarts:
    enabled: false
  RemovePodsViolatingInterPodAntiAffinity:
    enabled: false
  RemovePodsViolatingNodeAffinity:
    enabled: false
    params:
      nodeAffinityType:
      - requiredDuringSchedulingIgnoredDuringExecution
  RemovePodsViolatingNodeTaints:
    enabled: false
  RemovePodsViolatingTopologySpreadConstraint:
    enabled: false

Steps to reproduce

To reproduce, follow these steps

  1. Create a new Pulumi app for k8s
  2. Create a new Helm Chart object
  3. Set some keys as null like shown above or in the Helm documentation
  4. Check the resulting deployment

Expected Behavior

The params key is removed from the resulting configMap.

Actual Behavior

The params key is present in the configMap.

Versions used

➜ pulumi about

CLI
Version      3.34.1
Go Version   go1.17.11
Go Compiler  gc

Plugins
NAME               VERSION
kubernetes         3.19.2
internal/redacted-eks  0.0.1
nodejs             unknown

Host
OS       ubuntu
Version  20.04
Arch     x86_64

This project is written in nodejs: executable='/home/redacted/.nvm/versions/node/v16.15.0/bin/node' version='v16.15.0'

Current Stack: redacted/redacted

TYPE                                                         URN
[... some resources ...]

Found no pending operations associated with "redacted"

Backend
Name           pulumi.com
URL            https://app.pulumi.com/redacted
User           redacted
Organizations  redacted, redacted

Dependencies:
NAME                     VERSION
@pulumi/pulumi           3.33.2
@pulumi/kubernetes       3.19.2
@kubernetes/client-node  0.16.3
fast-glob                3.2.11
yaml                     2.1.1
@types/node              16.11.38

Pulumi locates its logs in /tmp by default

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

aureq avatar Jun 18 '22 03:06 aureq

Hi @aureq

Please can you also add a sample set of your Pulumi code (to get the resource that you need us to update) as it will help :)

Paul

stack72 avatar Jun 20 '22 14:06 stack72

I am running into this issue as well, it is preventing me from deploying the AWS cloud controller manager.

Here is my Pulumi code:

new k8s.helm.v3.Release(
  "aws-cloud-controller-manager",
  {
    chart: "aws-cloud-controller-manager",
    version: "0.0.6",
    repositoryOpts: { repo: "https://kubernetes.github.io/cloud-provider-aws" },
    values: {
      image: { tag: "v1.24.1" },
      nodeSelector: {
        "node-role.kubernetes.io/master": null,     
        "node-role.kubernetes.io/control-plane": "",                                      
      },
      args: ["--cloud-provider=aws", "--cluster-cidr=$CLUSTER_CIDR", "--cluster-name=$CLUSTER_NAME"],
    },
  },
);

Here is the output of helm get values aws-cloud-controller-manager-cb447920:

USER-SUPPLIED VALUES:
args:
- --cloud-provider=aws
- --cluster-cidr=$CLUSTER_CIDR
- --cluster-name=$CLUSTER_NAME
image:
  tag: v1.24.1
nodeSelector:
  node-role.kubernetes.io/control-plane: ""

Importantly, the "node-role.kubernetes.io/master": null key is missing entirely, when it should be present with a value of null (note not the string "null").

kwohlfahrt avatar Jul 10 '22 13:07 kwohlfahrt

This is happening as part of the OpenTelemetry Collector helm chart too.

A core part of the model is that you can disable/remove certain receivers which are in the default values by applying null to them. Unfortunately, this is being ignored by pulumi, which is very confusing.

Is there any documentation on what other API incompatibilities Pulumi has.

martinjt avatar Oct 13 '23 15:10 martinjt

@martinjt, I haven't tested it with null values, but empty lists work since #2220 with the allowNullValues flag. If this is set to true, does it work for you with null values?

kwohlfahrt avatar Oct 14 '23 14:10 kwohlfahrt