Skip to content

Instantly share code, notes, and snippets.

@Burekasim
Created June 17, 2020 23:33
Show Gist options
  • Save Burekasim/a4f4e684b4f39f66c24079344bcb6cd4 to your computer and use it in GitHub Desktop.
Save Burekasim/a4f4e684b4f39f66c24079344bcb6cd4 to your computer and use it in GitHub Desktop.
GKE api fails with cidr conflict
import string
import random
from google.cloud import container_v1
from google.api_core.retry import Retry
from pprint import pprint
cluster = {
"name": "cluster-" + ''.join(random.choice(string.ascii_lowercase) for i in range(8)),
"master_auth": {
},
"logging_service": "logging.googleapis.com/kubernetes",
"monitoring_service": "monitoring.googleapis.com/kubernetes",
"network": "default",
"node_pools": [
{
"name": "default-pool",
"config": {
"machine_type": "n1-standard-1",
"disk_size_gb": 100,
"oauth_scopes": [
"https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring",
"https://www.googleapis.com/auth/servicecontrol",
"https://www.googleapis.com/auth/service.management.readonly",
"https://www.googleapis.com/auth/trace.append"
],
"metadata": {
"disable-legacy-endpoints": "True",
"blablabla": "momomo"
},
"image_type": "COS",
"service_account": "default",
"preemptible": True,
"disk_type": "pd-standard",
"shielded_instance_config": {
"enable_integrity_monitoring": True
}
},
"initial_node_count": 1,
"autoscaling": {
"enabled": True,
"min_node_count": 1,
"max_node_count": 3
},
"management": {
"auto_upgrade": True,
"auto_repair": True
},
}],
"ip_allocation_policy": {
"use_ip_aliases": True,
"create_subnetwork": True,
"cluster_ipv4_cidr_block": "/19"
}
}
cm = container_v1.ClusterManagerClient()
operation = cm.create_cluster(
parent='projects/PRODUCT_ID/locations/europe-west2',
cluster=cluster, retry=Retry()
)
pprint(operation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment