Create a Kubernetes cluster
This topic walks through the steps to create a Kubernetes (K8s) cluster. If you are new to K8s, these instructions are for you.
There are several supported Kubernetes platforms and versions. This walkthrough presents an example using Google Kubernetes Engine (GKE) version 1.16.
After establishing a Kubernetes cluster, you can proceed to the Get started with Kubernetes Operator for Apache Cassandra topic to apply pre-configured Kubernetes Operator for Apache Cassandra manifests and related definitions to the Kubernetes environment.
Now use the Kubernetes Operator for Apache Cassandra to manage the established open-source Apache Cassandra® or DataStax Enterprise (DSE) resources in your Kubernetes cluster.
Here is the workflow as described in this example:
Start in the Google Cloud Console.
Create or select a project, and set up billing information for potential use after the free trial.
Create the Kubernetes cluster. This example specifies a few non-default options.
kubectlcommand-line (CLI) tool, which you can use to control your Kubernetes cluster. This example installs
kubectlfrom the Google Cloud SDK.
Complete the steps to authenticate connections between your newly created Kubernetes cluster and your local machine, from which you enter
kubectlcommands and perform related tasks.
Navigate to the Kubernetes Engine page in the Google Cloud Console. If you have not already done so, create or log into a Google account.
Read the free trial Terms of Service. If you agree, check the box and click Continue.
In the Google Cloud Console, create or select a project. If it is new, name the project.
Enter your information and sign up for the free trial.
The terms may vary for each country. This example shows a $300 USD credit to spend during 12 months.
For example, after creating the project and providing the billing information, the console presents a verification message:
Click Enable billing. It takes a few minutes to enable the Kubernetes Engine API and related services. When the payment verification completes, GCP console displays its options:
Click Create cluster to initiate the next set of dialogs.
Here is the resulting Cluster basics page. Before accepting all the defaults and clicking Create, DataStax recommends following the numbered steps using the MY FIRST CLUSTER option near the upper right side of the page:
Walking through these steps familiarizes you with all the options and allows you to enter your preferred values.
Name your cluster and click Next.
Select a location. This example uses
Zonaland sets the zone to
us-central-1-c. Adjust according to your preference, and click Next.
Set the release channel. This example uses the
Static versionoption and selects GKE version
This value is chosen in anticipation of applying the pre-configured 1.16 manifest YAML file, as covered in the next topic of this guide. However, you can select any GKE version from 1.13 to 1.17. DataStax provides a per-version manifest YAML to conveniently define common settings and to help you get started quickly. Working with YAML files happens after we continue to define options for the Kubernetes cluster creation.
Here are the selections in this example of the console’s Cluster basics options:
When you are ready, click Next.
Choose low-cost resources. This example uses the default General Purpose machine configuration, using
Series N1and machine type
n1-standard-4 (4 vCPU, 15 GB memory). To keep costs low during the free trial, the
Review your cluster settings. To apply your custom settings, click Make Changes. Then click Create on the resulting page.
The Google Cloud Console presents an entry for your created Kubernetes cluster. For example:
kubectl command-line (CLI) tool lets you control Kubernetes clusters. When working with the Kubernetes cluster and Kubernetes Operator for Apache Cassandra, it is common to use the Google Cloud Console user interface and a Terminal window from which to submit
kubectl commands. If you do not already have
kubectl installed, then first install the Google Cloud SDK and install
kubectl from it. On the kubernetes.io site, refer to the article about downloading the SDK.
To go directly to the versioned list of Google Cloud SDK packages, see these installation instructions.
(Alternatively): use a
curlcommand to download and install the Google Cloud SDK on a 64-bit machine:
curl -LO https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-347.0.0-linux-x86_64.tar.gz
Extract the tarball:
tar -xzvf google-cloud-sdk-347.0.0-linux-x86_64.tar.gz
Install the Google Cloud SDK:
After completing the installation, source your updated profile settings, as in the following example:
The Google Cloud SDK provides many tools. To install
kubectlfrom the SDK, run:
gcloud components install kubectl
It is possible to receive a warning message similar to the following about an older version of a tool on your machine:
There are older versions of Google Cloud Platform tools on your system PATH. Remove the following to avoid accidentally invoking these old tools: /usr/local/bin/kubectl
Run the following commands to remove the old version and then verify the just-installed location:
sudo rm /usr/local/bin/kubectl which kubectl /home/automaton/google-cloud-sdk/bin/kubectl
On your local machine where you just installed the Google Cloud SDK and the
kubectl tool, follow these additional steps to create the connection from your local machine to the cloud environment.
Enter this command:
In the command output, watch for the paused message to log in. For example:
Welcome! This command will take you through the configuration of gcloud. Your current configuration has been set to: [default] You can skip diagnostics next time by using the following flag: gcloud init --skip-diagnostics Network diagnostic detects and fixes local network connection issues. Checking network connection...done. Reachability Check passed. Network diagnostic passed (1/1 checks passed). You must log in to continue. Would you like to log in (Y/n)? Go to the following link in your browser: https://accounts.google.com/o/oauth2/auth?code_challenge=VZjkwrJjlQoFMWDEsAahmxl3 ... www.googleapis.com%2Fauth%2Faccounts.reauth
Copy and paste the returned URL in a browser. If you are already logged into the Google email account that you used while creating the Kubernetes cluster, the page presents an
OAuthcode simlar to:
Now return to your Terminal session and paste the code at this prompt:
Enter verification code: 4/0gEBbO8hFWV2pA8lL8nK4xqPMwbXbOTrM9VodAi2l0rhYePNbFKr2KI You are logged in as: (account email address) ...
The command output continues, displaying your authorized email address and prompting you to confirm or specify settings for the Kubernetes cloud environment. Here is a sample extract of the messages and prompts:
Pick cloud project to use:  <userid>-project-datastax-fte  Create a new project Please enter numeric choice or text value (must exactly match list item): 1 Your current project has been set to: [<userid>-project-datastax-fte]. Do you want to configure a default Compute Region and Zone? (Y/n)? Which Google Compute Engine zone would you like to use as project default? If you do not specify a zone via a command line flag while working with Compute Engine resources, the default is assumed.  us-east1-b ...  us-central1-c ... Please enter numeric choice or text value (must exactly match list item): 7 Your project default Compute Engine zone has been set to [us-central1-c]. You can change it by running [gcloud config set compute/zone NAME]. Your project default Compute Engine region has been set to [us-central1]. You can change it by running [gcloud config set compute/region NAME]. ... Your Google Cloud SDK is configured and ready to use! ...
Now that the Google Cloud SDK is configured, there is one more step to complete the connection between the Google Kubernetes Engine (GKE) cloud instance and your local machine.
In the Google Cloud Console, go to the Clusters tab. Click the box next to your cluster’s name:
Click the Connect button next to your cluster name. The console displays a command example.
Copy the command from the Google Cloud Console, and enter it in your Terminal session.
gcloud container clusters get-credentials <userid>-datastax-cluster1 --zone us-central1-c --project <userid>-project-datastax-fte
Fetching cluster endpoint and auth data. kubeconfig entry generated for <userid>-datastax-cluster1.
Congratulations on creating your Kubernetes cluster and completing the steps to connect your GKE cloud instance and your local machine. You can now submit
kubectl commands that directly control your Kubernetes cluster, including the commands to apply Kubernetes Operator for Apache Cassandra configuration YAML files that are provided by DataStax to the Kubernetes cluster. For those steps, proceed to Get started with Kubernetes Operator for Apache Cassandra.