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

Server-Side Apply field conflict with "cluster-proportional-autoscaler" with subresource "scale" using apps/v1: .spec.replicas #3312

Open
mattburgess opened this issue Nov 13, 2024 · 1 comment
Labels
awaiting-feedback Blocked on input from the author kind/bug Some behavior is incorrect or out of spec

Comments

@mattburgess
Copy link

What happened?

We deploy metrics-server using a Helm chart and have a cluster-proportional-autoscaler deployment alongside it to manage its scale. If CPA has scaled the metrics-server deployment we see this error when trying to run a pulumi up or pulumi preview:

error: Preview failed: 1 error occurred:
	* the Kubernetes API server reported that "kube-system/metrics-server" failed to fully initialize or become live: Server-Side Apply field conflict detected. See https://www.pulumi.com/registry/packages/kubernetes/how-to-guides/managing-resources-with-server-side-apply/#handle-field-conflicts-on-existing-resources for troubleshooting help
: Apply failed with 1 conflict: conflict with "cluster-proportional-autoscaler" with subresource "scale" using apps/v1: .spec.replicas

Example

This is our helm chart code, including the suggestion from the above ticket:

    const deployment = new k8s.helm.v3.Chart(
      "metrics-server",
      {
        namespace: "kube-system",
        path: helmPath(`metrics-server/v${args.chartVersion}`),
        values: {
          // https://github.com/kubernetes-sigs/metrics-server#scaling
          image: {
            repository: `${args.ECRMk8sBase}/release/k8s.gcr.io/metrics-server/metrics-server`,
          },
          resources: {
            requests: {
              memory: "200Mi",
              cpu: "100m",
            },
            limits: {
              memory: "1Gi",
            },
          },
          podDisruptionBudget: {
            enabled: true,
            minAvailable: 1,
          },
          replicas: minimumReplicas,
        },
        transformations: [
          // eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-shadow
          (obj: any, opts: pulumi.CustomResourceOptions) => {
            if (obj.kind === "Deployment" && obj.metadata.name === "metrics-server") {
              // eslint-disable-next-line no-param-reassign
              opts.ignoreChanges = ["spec.replicas"];
            }
          },
        ],
      },
      {
        parent: this,
      }
    );

Output of pulumi about

CLI
Version      3.133.0
Go Version   go1.23.1
Go Compiler  gc

Plugins
KIND      NAME        VERSION
resource  aws         6.56.1
resource  kubernetes  4.5.3
language  nodejs      unknown
resource  random      4.16.7

Host
OS       darwin
Version  14.7.1
Arch     arm64

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).

@mattburgess mattburgess added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Nov 13, 2024
@blampe
Copy link
Contributor

blampe commented Nov 14, 2024

@mattburgess I suggest adding some debug logging to confirm whether your transformation is actually getting applied. I suspect it might not be.

Do you see the same problem when using v4.Chart with a transform (not transformation)?

@blampe blampe added awaiting-feedback Blocked on input from the author and removed needs-triage Needs attention from the triage team labels Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-feedback Blocked on input from the author kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

2 participants