Create a New GCP Cluster
Prerequisites
Before you begin, ensure you create a Bootstrap cluster.
Name your Cluster
Give your cluster a unique name suitable for your environment.
In GCP it is critical that the name is unique, as no two clusters in the same GCP account can have the same name.
Set the environment variable:
CODEexport CLUSTER_NAME=gcp-example
The cluster name may only contain the following characters: a-z
, 0-9
, .
, and -
. Cluster creation will fail if the name has capital letters. See Kubernetes for more naming information.
To increase Docker Hub's rate limit use your Docker Hub credentials when creating the cluster, by setting the following flag --registry-mirror-url=https://registry-1.docker.io --registry-mirror-username=<username> --registry-mirror-password=<password>
on the dkp create cluster
command.
Create a New GCP Cluster
Availability zones (AZs) are isolated locations within data center regions from which public cloud services originate and operate. Because all the nodes in a node pool are deployed in a single Availability Zone, you may wish to create additional node pools is to ensure your cluster has nodes deployed in multiple Availability Zones.
By default, the control-plane Nodes will be created in 3 different zones. However, the default worker Nodes will reside in a single zone. You may create additional node pools in other zones with the dkp create nodepool
command. The default region for the availability zones is us-west1
.
Create an image using Konvoy Image Builder (KIB) and then export the image name:
BASHexport IMAGE_NAME=projects/${GCP_PROJECT}/global/images/<image_name_from_kib>
(Optional) You can modify the Control Plane Audit logs settings using the information contained in the page Configuring the Control Plane.
(Optional) Determine what VPC Network to use. All GCP accounts come with a preconfigured VPC Network named
default
, which will be used if you do not specify a different network.
To use a different VPC network for your cluster, create one by following these instructions for Create and Manage VPC Networks. Then specify the--network <new_vpc_network_name>
option on the create cluster command below. Follow the link for more information on GCP Cloud Nat and network flag.Create a Kubernetes cluster. During create a new cluster command, the user can add flags. One important flag is
--network
. If the default network is not cloud nat and you would like it to be, then the--network
flag needs to be set to true. This would enable a hidden or non-public IP address:BASHdkp create cluster gcp \ --cluster-name=${CLUSTER_NAME} \ --additional-tags=owner=$(whoami) \ --project=${GCP_PROJECT} \ --image=${IMAGE_NAME}
Wait for the cluster control-plane to be ready:
BASHkubectl wait --for=condition=ControlPlaneReady "clusters/${CLUSTER_NAME}" --timeout=20m
After the objects are created on the API server, the Cluster API controllers reconcile them. They create infrastructure and machines. As they progress, they update the Status of each object. Konvoy provides a command to describe the current status of the cluster:
BASHdkp describe cluster -c ${CLUSTER_NAME}
CODENAME READY SEVERITY REASON SINCE MESSAGE Cluster/gcp-example True 52s ├─ClusterInfrastructure - GCPCluster/gcp-example ├─ControlPlane - KubeadmControlPlane/gcp-example-control-plane True 52s │ ├─Machine/gcp-example-control-plane-6fbzn True 2m32s │ │ └─MachineInfrastructure - GCPMachine/gcp-example-control-plane-62g6s │ ├─Machine/gcp-example-control-plane-jf6s2 True 7m36s │ │ └─MachineInfrastructure - GCPMachine/gcp-example-control-plane-bsr2z │ └─Machine/gcp-example-control-plane-mnbfs True 54s │ └─MachineInfrastructure - GCPMachine/gcp-example-control-plane-s8xsx └─Workers └─MachineDeployment/gcp-example-md-0 True 78s ├─Machine/gcp-example-md-0-68b86fddb8-8glsw True 2m49s │ └─MachineInfrastructure - GCPMachine/gcp-example-md-0-zls8d ├─Machine/gcp-example-md-0-68b86fddb8-bvbm7 True 2m48s │ └─MachineInfrastructure - GCPMachine/gcp-example-md-0-5zcvc ├─Machine/gcp-example-md-0-68b86fddb8-k9499 True 2m49s │ └─MachineInfrastructure - GCPMachine/gcp-example-md-0-k8h5p └─Machine/gcp-example-md-0-68b86fddb8-l6vfb True 2m49s └─MachineInfrastructure - GCPMachine/gcp-example-md-0-9h5vn
Once the cluster creation process completes, move on to exploring your new cluster.