cluster-api: cluster creation with numeric number name fails

What steps did you take and what happened:

  1. create the KIND cluster and deploy CRDs
  2. Set the AWS credentials
  3. Install infrastructure CRDs
  4. Create cluster with below configuration
apiVersion: cluster.x-k8s.io/v1alpha2
kind: Cluster
metadata:
  name: 1947
spec:
  clusterNetwork:
    pods:
      cidrBlocks: ["192.168.0.0/16"]
  infrastructureRef:
    apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
    kind: AWSCluster
    name: 1947
---
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
kind: AWSCluster
metadata:
  name: 1947
spec:
  # Change this value to the region you want to deploy the cluster in.
  region: us-east-2
  # Change this value to a valid SSH Key Pair present in your AWS Account.
  sshKeyName: default

What did you expect to happen: If the name is not following the naming convention it should give the suggestion rather than error message as below

error when retrieving current configuration of:
Resource: "cluster.x-k8s.io/v1alpha2, Resource=clusters", GroupVersionKind: "cluster.x-k8s.io/v1alpha2, Kind=Cluster"
Name: "", Namespace: "default"
Object: &{map["apiVersion":"cluster.x-k8s.io/v1alpha2" "kind":"Cluster" "metadata":map["namespace":"default" "annotations":map["kubectl.kubernetes.io/last-applied-configuration":""] "name":'\u079b'] "spec":map["clusterNetwork":map["pods":map["cidrBlocks":["192.168.0.0/16"]]] "infrastructureRef":map["apiVersion":"infrastructure.cluster.x-k8s.io/v1alpha2" "kind":"AWSCluster" "name":'\u079b']]]}
from server for: "../docs/cluster-numeric-name.yaml": resource name may not be empty
error when retrieving current configuration of:
Resource: "infrastructure.cluster.x-k8s.io/v1alpha2, Resource=awsclusters", GroupVersionKind: "infrastructure.cluster.x-k8s.io/v1alpha2, Kind=AWSCluster"
Name: "", Namespace: "default"
Object: &{map["apiVersion":"infrastructure.cluster.x-k8s.io/v1alpha2" "kind":"AWSCluster" "metadata":map["name":'\u079b' "namespace":"default" "annotations":map["kubectl.kubernetes.io/last-applied-configuration":""]] "spec":map["region":"us-east-2" "sshKeyName":"default"]]}
from server for: "../docs/cluster-numeric-name.yaml": resource name may not be empty

Anything else you would like to add: [Miscellaneous information that will assist in solving the issue.]

Environment:

  • Cluster-api version: v0.4.3
  • Minikube/KIND version: v0.5.1
  • Kubernetes version: (use kubectl version): v1.13.3(client) v.1.15.3(server)
  • OS (e.g. from /etc/os-release): Darwin x64

/kind bug

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

@nader-ziada ah, that’s a good point. It would be really nice if there was automated support for this (either in controller-tools or the Kubernetes built in CRD support).

+1 to webhook for validation.