berops / claudie

Cloud-agnostic managed Kubernetes
https://docs.claudie.io/
Apache License 2.0
550 stars 39 forks source link

Bug: Bug with new 0.8.0 'DynamicNodePool.Name' Error:Field validation for 'Name' failed on the 'max' tag #1380

Closed yaronshanisima closed 3 months ago

yaronshanisima commented 3 months ago

with this config

apiVersion: claudie.io/v1beta1
kind: InputManifest
metadata:
  name: sima-k8s-04
  namespace: default
  labels:
    app.kubernetes.io/part-of: claudie
spec:
  providers:
    - name: hetzner-1
      providerType: hetzner
      secretRef:
        name: hetzner-secret-cloud
        namespace: default

  nodePools:
    dynamic:
      - name: control-hetzner
        providerSpec:
          # Name of the provider instance.
          name: hetzner-1
          # Region of the nodepool.
          region: fsn1
          # Datacenter of the nodepool.
          zone: fsn1-dc14
        count: 1
        # Machine type name.
        serverType: cpx11
        # OS image name.
        image: ubuntu-22.04
    static:
      - name: hertzner-1
        nodes:
          - endpoint: "10.0.1.2"
            secretRef:
              name: hertzner-key-01
              namespace: default

        labels:
          datacenter: hertzner-1
        annotations:
          node.longhorn.io/default-node-tags: '["hertzner-1"]' 

 clusters.
  kubernetes:
    clusters:
      - name: dev-cluster
        version: v1.27.3
        network: 192.168.2.0/24
        pools:
          control:
            - control-hetzner
          compute:
            - hertzner-1

I am getting

Error from server (Forbidden): error when creating "c.yaml": admission webhook "validate-manifest.claudie.io" denied the request: failed to validate nodepools section inside manifest: failed to validate DynamicNodePool "control-hetzner": Key: 'DynamicNodePool.Name' Error:Field validation for 'Name' failed on the 'max' tag

Did not happen with the previous Claudie version.

Thanks!

JKBGIT1 commented 3 months ago

Hi, we had to put a limit on nodepool names (14 characters) and cluster names (28 characters) in the manifest. Since control-hetzner is 15 characters long you got this error.

bernardhalas commented 3 months ago

Let's check if we can make the errors more descriptive.

vatroshkin commented 3 months ago

@bernardhalas @Despire Hi all! Is it possible to rename existing node pools that has invalid name after update to 0.8.0 without cluster recreation?

bernardhalas commented 3 months ago

Hi @vatroshkin , if the nodepool is dynamic: Add a new nodepool with the correct name (to have sufficient capacity in the cluster). Then remove the old nodepool. If the nodepool you're talking about is static: Add a new dynamic nodepool (to have sufficient capacity in the cluster). Then remove the wrong static nodepool. Then re-add the static nodepool, now with correct name.

Does this help?

Atrosh commented 3 months ago

@bernardhalas thanks for reply, I have tried that, but the problem that validation complains about name length for an old nodepool 🥲 - so I can't add a new nodepool with a short name

Despire commented 3 months ago

EDIT: If it's possible you could deploy the older Claudie version where there was no restriction on the name length. This way you could perform the changes @bernardhalas described (adding new nodepools with new names and then removing the old nodepool with invalid names), and then You should be able to upgrade back to 0.8.

Atrosh commented 3 months ago

@Despire Hi! Any suggestion how can I do that? When I apply previous release (kubectl apply -f ...), it stays 0.8.0. Thanks!

Despire commented 3 months ago

applying just kubectl apply -f https://github.com/berops/claudie/releases/download/v0.7.5/claudie.yaml should work (just tested it by deploying 0.8.0 then applying the command)