Set these environment variables:
$ GCP_REGION=europe-west1; CLUSTER_NAME="pks-demo1"
Assign a public IP address for the load balancer (among master nodes):
$ gcloud compute addresses create ${CLUSTER_NAME}-master-api-ip --region ${GCP_REGION}
$ gcloud compute target-pools create ${CLUSTER_NAME}-master-api --region ${GCP_REGION}
$ MASTER_EXTERNAL_IP=$(gcloud compute addresses describe ${CLUSTER_NAME}-master-api-ip --region ${GCP_REGION} --format json | jq -r .address)
Create the cluster (choose a plan: small
, medium
or large
):
$ pks create-cluster ${CLUSTER_NAME} -e ${MASTER_EXTERNAL_IP} -p small
Name: pks-demo1
Plan Name: small
UUID: 9ca51581-cde9-4f5a-a8ba-5441129c68b3
Last Action: CREATE
Last Action State: in progress
Last Action Description: Creating cluster
Kubernetes Master Host: 104.155.66.64
Kubernetes Master Port: 8443
Worker Nodes: 1
Kubernetes Master IP(s): In Progress
Network Profile Name:
Use 'pks cluster pks-demo1' to monitor the state of your cluster
It takes some time before the cluster gets created:
$ pks cluster ${CLUSTER_NAME}
Name: pks-demo1
Plan Name: small
UUID: 9ca51581-cde9-4f5a-a8ba-5441129c68b3
Last Action: CREATE
Last Action State: in progress
Last Action Description: Instance provisioning in progress
Kubernetes Master Host: 104.155.66.64
Kubernetes Master Port: 8443
Worker Nodes: 1
Kubernetes Master IP(s): In Progress
Network Profile Name:
When the cluster is ready, create a load balancer for master nodes:
$ CLUSTER_UUID=$(pks cluster ${CLUSTER_NAME} --json | jq -r .uuid)
$ MASTER_INSTANCE_NAMES=$(gcloud compute instances list --filter "tags:service-instance-${CLUSTER_UUID}-master" --format "csv[no-heading](selfLink)" | tr '\n' ',' | sed 's/.$//')
$ gcloud compute target-pools add-instances ${CLUSTER_NAME}-master-api --instances ${MASTER_INSTANCE_NAMES}
$ gcloud compute forwarding-rules create ${CLUSTER_NAME}-master-api-8443 --region ${GCP_REGION} --address ${CLUSTER_NAME}-master-api-ip --target-pool ${CLUSTER_NAME}-master-api --ports 8443
Get the credentials for accessing the cluster:
$ pks get-credentials ${CLUSTER_NAME}
The cluster is now ready to use!