This step explains how to set up your shell environment and create a GKE cluster in your Google Cloud Platform (GCP) project.
Set up your terminal shell
gcloud tool provides the primary command-line interface
for GCP, and
kubectl provides the primary command-line interface for
running commands against Kubernetes clusters.
Be sure you have
kubectlinstalled in your local shell. The
gcloudtool provides the primary command-line interface for GCP, and
kubectlprovides the primary command-line interface for running commands against Kubernetes clusters.
- If you do not have these utilities installed, install them now:
- Install the Cloud SDK,
which includes the
- After installing Cloud SDK, install the
kubectlcommand-line tool by running the following command:
gcloud components install kubectl
- Install the Cloud SDK, which includes the
gcloudtool to configure two default settings: your default project and compute region. Configuring these settings makes it easier to run
gcloudrequires that you specify the project and compute zone in which you want to work.
To list the current settings:
gcloud config list
If a project and/or compute zone is not listed, then you need to add them with the commands shown below. If, from the list output, you determine that you need to switch the current settings to reflect your project and compute region (or zone), you can also use these commands:
gcloud config set project project-id
gcloud config set compute/region compute-region
gcloud config set compute/zone compute-zone
Where project-id is the name of your GCP project, compute-region is the name of a GCP compute region, and compute-zone is the name of a GCP compute zone. For example:
compute/region us-central1. For a list of compute regions and zones, see Available regions and zones.
Create a GKE cluster
In this step, you will create a Kubernetes cluster in your GCP project (the project you set
gcloud config command).
Execute the following command to create the cluster. The machine type, number of nodes, and other settings specified in the command create a minimally configured cluster suitable for a trial Apigee hybrid installation:
gcloud container clusters create cluster-name \ --machine-type "n1-standard-4" --num-nodes "3" --enable-autoscaling --min-nodes "3" --max-nodes "6"
Where cluster-name is the name you choose for the cluster.
Cluster creation can take a few minutes. Upon success, you will see output similar to
the following with a status of
NAME LOCATION MASTER_VERSION MASTER_IP MACHINE_TYPE NODE_VERSION NUM_NODES STATUS apigee-hybrid us-central1-a 1.13.11-gke.9 22.214.171.124 n1-standard-4 1.13.11-gke.9 3 RUNNING
Set the current context
A context is a group of access parameters. Each context contains a Kubernetes cluster,
a user and a namespace. The current context is the cluster that is currently the default for
kubectl commands run against that cluster.
Make sure the current
gcloud context is set to the cluster you just created.
- First, list the contexts to determine which is the current context. In the
following example, the current context is
gke_hybrid-project_us-central1-a_apigee-hybrid. The name includes the name of a GCP project (
hybrid-project), a region or zone (
us-central1-a), and a cluster name (
kubectl config get-contexts CURRENT NAME CLUSTER AUTHINFO NAMESPACE * gke_hybrid-project_us-central1-a_apigee-hybrid gke_hybrid-project_us-central1-a_apigee-hybrid gke_hybrid-project_us-central1-a_apigee-hybrid gke_apigee-project_us-west1-a_apigee-cluster gke_apigee-project_us-west1-a_apigee-cluster gke_apigee-project_us-west1-a_apigee-cluster
- If necessary, set the current context to the cluster you just created (the cluster
into which you intend to install Apigee hybrid). Assuming the previous
get-contextsoutput, if the cluster name you created were
apigee-clusterin the region
us-west1, you would switch to the
gke_apigee-project_us-west1-a_apigee-clustercontext, as follows:
kubectl config use-context gke_apigee-project_us-west1-a_apigee-cluster
gke_apigee-project_us-west1-a_apigee-clusteris the name of the context to switch to.
- Check the current context to be sure it is set to the intended cluster. For example:
kubectl config current-context gke_apigee-project_us-west1-a_apigee-cluster
Grant cluster credentials
Cluster credentials give you access to the containers running in the cluster. Fetch your credentials and grant yourself the cluster-admin role:
- Fetch the credentials:
gcloud container clusters get-credentials cluster-name
Where cluster-name is the name is the name of the cluster you created (the cluster into which you intend to install Apigee hybrid).
- Set the cluster role binding. Execute this command exactly as shown:
kubectl create clusterrolebinding cluster-admin-binding \ --clusterrole cluster-admin --user $(gcloud config get-value account)
You now have a Kubernetes cluster running in your GCP project. Your shell environment is set up, and you are ready to install the Apigee hybrid runtime plane software on your local machine.