ランチャーAPIを使用したEKS , AK , GAKの作成


ランチャーは、ランチャーのWebポータルまたはAPIを介してパブリッククラウド上でKubernetesクラスタを作成するために使用することができます.
新しいクラスタを作成することができない範囲でAPI トークンを作成する必要があります.
以下のコマンドでクラウドの資格情報を更新します
クリエイトeksクラスタ
curl -k -s 'https://rancher.example.com/v3/cluster' -H 'content-type: application/json' -H "Authorization: Bearer $TOKEN" --data-binary '{"dockerRootDir":"/var/lib/docker","enableClusterAlerting":false,"enableClusterMonitoring":false,"enableNetworkPolicy":false,"windowsPreferedCluster":false,"type":"cluster","name":"test","eksConfig":{"imported":false,"amazonCredentialSecret":"cattle-global-data:cc-XXXX","displayName":"test","kmsKey":"","kubernetesVersion":"1.21","loggingTypes":[],"nodeGroups":[{"desiredSize":2,"diskSize":20,"ec2SshKey":"","gpu":false,"imageId":"","instanceType":"t3.medium","labels":{},"maxSize":2,"minSize":2,"nodegroupName":"test","requestSpotInstances":false,"resourceTags":{},"spotInstanceTypes":[],"subnets":[],"tags":{},"type":"nodeGroup","userData":"","launchTemplate":null,"version":"1.21"}],"privateAccess":false,"publicAccess":true,"publicAccessSources":[],"region":"eu-central-1","secretsEncryption":false,"securityGroups":[],"serviceRole":"","subnets":[],"tags":{},"type":"eksclusterconfigspec"},"labels":{}}'
クラスター作成
curl -k -s 'https://rancher.example.com/v3/cluster' -H 'content-type: application/json' -H "Authorization: Bearer $TOKEN" --data-binary '{"dockerRootDir":"/var/lib/docker","enableClusterAlerting":false,"enableClusterMonitoring":false,"enableNetworkPolicy":false,"windowsPreferedCluster":false,"type":"cluster","name":"test","aksConfig":{"imported":false,"azureCredentialSecret":"cattle-global-data:cc-XXXXX","clusterName":"test","dnsPrefix":"test","kubernetesVersion":"1.21.9","linuxAdminUsername":"azureuser","loadBalancerSku":"Standard","networkPlugin":"kubenet","nodePools":[{"availabilityZones":["1","2","3"],"count":1,"enableAutoScaling":false,"maxPods":110,"mode":"System","name":"agentpool","orchestratorVersion":"1.21.9","osDiskSizeGB":128,"osDiskType":"Managed","osType":"Linux","type":"aksnodepool","vmSize":"Standard_DS2_v2","isNew":true}],"privateCluster":false,"resourceGroup":"test","resourceLocation":"northeurope","tags":{},"type":"aksclusterconfigspec"},"labels":{}}'
クラスタの作成
curl -k -s 'https://rancher.example.com/v3/cluster' -H 'content-type: application/json' -H "Authorization: Bearer $TOKEN" --data-binary '{"dockerRootDir":"/var/lib/docker","enableClusterAlerting":false,"enableClusterMonitoring":false,"enableNetworkPolicy":false,"windowsPreferedCluster":false,"type":"cluster","name":"test","gkeConfig":{"imported":false,"clusterAddons":{"horizontalPodAutoscaling":true,"httpLoadBalancing":true,"networkPolicyConfig":false},"clusterIpv4Cidr":"","clusterName":"test","description":"","enableKubernetesAlpha":false,"googleCredentialSecret":"cattle-global-data:cc-XXXX","ipAllocationPolicy":{"clusterIpv4CidrBlock":null,"clusterSecondaryRangeName":null,"createSubnetwork":false,"nodeIpv4CidrBlock":null,"servicesIpv4CidrBlock":null,"servicesSecondaryRangeName":null,"subnetworkName":null,"useIpAliases":true,"clusterIpv4Cidr":""},"kubernetesVersion":"1.21.6-gke.1500","labels":{},"locations":["europe-west3-a","europe-west3-b","europe-west3-c"],"loggingService":"logging.googleapis.com/kubernetes","maintenanceWindow":"","masterAuthorizedNetworks":{"enabled":false},"monitoringService":"monitoring.googleapis.com/kubernetes","network":"default","networkPolicyEnabled":false,"nodePools":[{"autoscaling":{"enabled":false,"maxNodeCount":null,"minNodeCount":null},"config":{"diskSizeGb":100,"diskType":"pd-standard","imageType":"COS","labels":{},"localSsdCount":0,"machineType":"n1-standard-2","oauthScopes":["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"],"preemptible":false,"taints":null,"tags":null},"initialNodeCount":1,"management":{"autoRepair":true,"autoUpgrade":true},"maxPodsConstraint":110,"name":"test","version":"1.21.6-gke.1500","type":"gkenodepoolconfig","isNew":true}],"privateClusterConfig":{"enablePrivateEndpoint":false,"enablePrivateNodes":false,"masterIpv4CidrBlock":null},"projectID":"XXXXXX","region":"europe-west3","subnetwork":"default","type":"gkeclusterconfigspec","zone":""},"labels":{},"annotations":{}}'
クラスタに関する情報を取得する
curl -k -s -u $TOKEN -H 'Content-Type: application/json' 'https://rancher.example.com/v3/clusters?name=test' | jq -r .data[]
クラスタの削除
curl -k -s -u $TOKEN -X DELETE -H 'Accept: application/json' 'https://rancher.example.com/v1/provisioning.cattle.io.clusters/fleet-default/CLUSTER-ID'