provider-gcp icon indicating copy to clipboard operation
provider-gcp copied to clipboard

Not possible to create multiple GKEClusters when using Class/Composition

Open muvaf opened this issue 4 years ago • 0 comments

What happened?

I have a GKEClusterClass that refers to a specific Network. In GCP, each GKECluster has to have a masterIpv4CidrBlock that must not overlap with any other GKECluster in the same Network because masterIpv4CidrBlock is valid in the whole Network; not like services or pod CIDR blocks that are valid in-cluster.

If I set a value for masterIpv4CidrBlock in GKEClusterClass, the first GKECluster provisions just fine but the subsequent ones do not and get stuck in creating because they'd get the same masterIpv4CidrBlock. If I leave it empty, GCP creates a cluster but I couldn't see what it assigned as masterIpv4CidrBlock. Then after creating a second KubernetesCluster with a GKEClusterClass that doesn't have masterIpv4CidrBlock filled, it's stuck in creating again.

I have created bunch and deleted one by one. What happens is that when I have 4 clusters in creating state, only one of them successfully provisions and when I delete that one, another one succeeds. I assume GCP has a static default that it applies and you can only use it for one GKECluster.

So, it's not really possible right now to create more than one GKECluster using the same template.

As of current implementation, this is true for Composition, too, since there is no mechanism to discover a new masterIpv4CidrBlock in the Network. Although it's possible to expose this field to the user so that they decide on the masterIpv4CidrBlock.

How can we reproduce it?

Install GCP Sample stack which creates the network: https://github.com/crossplane/stack-gcp-sample

Create following v1beta1 GKEClusterClass with proper replacements like providerRef, networkRef and subnetworkRef:

apiVersion: container.gcp.crossplane.io/v1beta1
kind: GKEClusterClass
metadata:
  labels:
    example: "true"
  name: gkecluster-standard
specTemplate:
  forProvider:
    ipAllocationPolicy:
      clusterSecondaryRangeName: pods
      servicesSecondaryRangeName: services
      useIpAliases: true
    location: us-west2
    networkRef:
      name: mvf-network
    subnetworkRef:
      name: mvf-subnetwork
  providerRef:
    name: mvf-gcp-provider
  reclaimPolicy: Delete
  writeConnectionSecretsToNamespace: crossplane-system

Then create the following 2 KubernetesClusters:

---
apiVersion: compute.crossplane.io/v1alpha1
kind: KubernetesCluster
metadata:
  name: mvf-gke1
  labels:
    example: "true"
spec:
  classSelector:
    matchLabels:
      example: "true"
  writeConnectionSecretToRef:
    name: k8scluster1
---
apiVersion: compute.crossplane.io/v1alpha1
kind: KubernetesCluster
metadata:
  name: mvf-gke2
  labels:
    example: "true2"
spec:
  classSelector:
    matchLabels:
      example: "true"
  writeConnectionSecretToRef:
    name: k8scluster2

One is created successfully while the other one is taking forever. No error, when I look at the console it says 31% - Cluster is being configured... forever.

What environment did it happen in?

Crossplane version: 0.10.0 GCP Provider: 0.9.0 GCP Sample Stack: 0.5.0

muvaf avatar May 12 '20 01:05 muvaf