Create a Kubernetes cluster
This guide explains how to create a Kubernetes (K8s) cluster. It assumes you are new to Kubernetes.
There are several supported Kubernetes platforms and versions. This guide uses Google Kubernetes Engine (GKE) version 1.16.
After establishing a Kubernetes cluster, continue with Quickstart for the Kubernetes Operator for Apache Cassandra to apply pre-configured Cassandra Operator manifests and related definitions to the Kubernetes environment. Then, you can use the Cassandra Operator to manage the established open-source Apache Cassandra® or DataStax Enterprise (DSE) resources in your Kubernetes cluster.
Prepare your Google Cloud Platform account
-
Create or log into the Google account where you want to create the cluster.
-
Go to the Kubernetes Engine page in the Google Cloud Console.
-
In the Google Cloud Console, create or select a project.
-
If not already enabled, click Enable billing for the Kubernetes Engine service in your project.
It takes a few minutes to enable the Kubernetes Engine API and related services.
-
When the payment verification completes, click Create cluster to begin creating your cluster.
Create the Kubernetes cluster
On the Cluster basics page, before accepting all the defaults and clicking Create, DataStax recommends following the numbered steps using the MY FIRST CLUSTER option. These steps familiarize you with all the options and help you set your preferred values.
-
Name your cluster, and then click Next.
-
Select a location, and then click Next.
This example uses
Zonaland sets the zone tous-central-1-c. -
Set the release channel, and then click Next.
This example uses the
Static versionoption and selects GKE version1.16.8-gke.15. This value is chosen in anticipation of applying the pre-configured 1.16 manifest YAML file, as covered in the quickstart. However, you can select any supported GKE version for your cass-operator version. The cass-operator repository has version-specific manifest YAML files to help you define common settings and get started quickly. -
Choose low-cost resources.
This example uses the default General Purpose machine configuration, using
Series N1and machine typen1-standard-4 (4 vCPU, 15 GB memory). To keep costs low during the free trial, theautoscalingandtelemetryoptions remaindisabled(default). -
Review your cluster settings.
-
To apply your custom settings, click Make Changes.
-
Click Create.
The Google Cloud Console shows the record for your created Kubernetes cluster.
Install kubectl from the Google Cloud SDK
The kubectl command-line (CLI) tool lets you control Kubernetes clusters.
When working with the Kubernetes cluster and the Cassandra Operator, 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
kubectlinstalled, install the Google Cloud SDK and installkubectlfrom it:You can download the SDK from the versioned list of Google Cloud SDK packages, or download from the command line. The following examples assume a 64-bit machine.
-
Download a Google Cloud SDK tarball, specifying the appropriate tarball for your environment and preferred version:
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:
./google-cloud-sdk/install.sh
-
-
Source your updated profile settings:
source ~/.bashrc -
Install
kubectlfrom the SDK:gcloud components install kubectlYou might receive a warning about older versions of Google Cloud Platform tools 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/kubectlTo resolve this issue, run the following commands to remove the old version and then verify the new installation location:
sudo rm /usr/local/bin/kubectl which kubectl /home/automaton/google-cloud-sdk/bin/kubectl
Configure the Google Cloud environment from your local machine
On your local machine where you just installed the Google Cloud SDK and the kubectl tool, create a connection from your local machine to the cloud environment.
-
Initialize the Google Cloud SDK:
./google-cloud-sdk/bin/gcloud init -
In the command output, when you are prompted to log in, enter
Y. -
Navigate to the outputted authentication URL.
If you are already logged into the Google email account that you used while creating the Kubernetes cluster, the page presents an OAuth code automatically.
-
In your terminal, enter the OAuth code at the prompt
Enter verification code:.If authentication succeeds, output continues.
-
When prompted, confirm or set the settings for the Kubernetes cloud environment.
For example:
You are logged in as: (account email address) ... Pick cloud project to use: [1] <userid>-project-datastax-fte [2] 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. [1] us-east1-b ... [7] 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! ...
Complete the connection between the GKE cloud and your machine
After configuring the Google Cloud SDK, connect the Google Kubernetes Engine (GKE) cloud instance and your local machine:
-
In the Google Cloud Console, go to the Clusters tab, and then select the box next to your cluster’s name.
-
Click the Connect button next to your cluster name.
-
Copy the example command from the Google Cloud Console, and then run it in your terminal.
Replace placeholders and modify the arguments as needed for your environment and configuration.
gcloud container clusters get-credentials <userid>-datastax-cluster1 --zone us-central1-c --project <userid>-project-datastax-fteResultFetching cluster endpoint and auth data. kubeconfig entry generated for <userid>-datastax-cluster1.
Next steps
You’ve created a Kubernetes cluster and connected a GKE cloud instance and your local machine.
You can now submit kubectl commands that directly control your Kubernetes cluster, including the commands to apply the Cassandra Operator configuration YAML files to the Kubernetes cluster, as explained in Quickstart for the Kubernetes Operator for Apache Cassandra.