Create a Kubernetes cluster
Create a Kubernetes cluster
In this topic, we'll walk through the steps to create a Kubernetes cluster. If you're new to Kubernetes, 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.
Once a Kubernetes cluster is established, you can proceed to the Get started with Cassandra Operator topic to apply pre-configured Cass Operator manifests and related definitions to the Kubernetes environment.
With those resources in place, you can then use Cass Operator to manage open-source Apache Cassandra® or DataStax Enterprise (DSE) resources in your Kubernetes cluster.
Here's the overall process as described in this topic:
- 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. In this example, we'll specify a few non-default options.
- Install the
kubectl
command-line tool, which you can use to control your Kubernetes cluster. We'll getkubectl
from the Google Cloud SDK. - Complete the steps to authenticate connections between your newly created Kubernetes
cluster and your local machine, from which you'll enter
kubectl
commands and perform related tasks.
Start in the Google Cloud Console
Start by navigating to the Kubernetes Engine page in the Google Cloud Console. If you haven't 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.
Create or select a GCP project, and set up billing
In the Google Cloud Console, create or select a project. If it's new, name the project.
Click Enable billing. It may take a few minutes while the Kubernetes Engine API and related services are enabled. When the payment verification completes, GCP console displays its options:
Click Create cluster to initiate the next set of dialogs.
Select options while creating the Kubernetes cluster
On the resulting Cluster basics page, instead of accepting all the defaults and before clicking Create, DataStax recommends following the numbered steps via the MY FIRST CLUSTER option near the upper right side of the page:
- Name your cluster and click Next.
- Pick a location. This example chose Zonal and set the zone to
us-central-1-c
. Adjust according to your preference, and click Next. - Set the release channel. This example chose the Static version option and
selected
1.16.8-gke.15
.Note: This value was 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 version from 1.13 to 1.17. DataStax provides per-version manifest YAML for your convenience to define common settings and help you get started quickly. Hold that thought while we continue to define options for the Kubernetes cluster creation.So far in this example of the console's Cluster basics options, we chose:
When you're ready, click Next.
- Chose low-cost resources. This example chose the default General Purpose machine
configuration, using Series
N1
and machine typen1-standard-4 (4 vCPU, 15 GB memory)
. To keep costs low during the free trial, we also chose to keep the autoscaling and telemetry options disabled. - 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:
Install kubectl from the Google Cloud SDK
The kubectl
command-line tool lets you control Kubernetes clusters. When
you're working with the Kubernetes cluster and Cass Operator, it's likely that you'll use
the Google Cloud Console user interface, as well as a Terminal window from which to submit
kubectl
commands. If you don't already have kubectl
installed, there are many options, but one is to first install the Google Cloud SDK. On the
kubernetes.io site, refer to the article about downloading the SDK and installing
kubectl
from it.
To go directly to the versioned list of Google Cloud SDK packages, see these installation instructions.
curl
:
curl -LO https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-295.0.0-linux-x86_64.tar.gzTo extract the tarball, for example:
tar -xzvf google-cloud-sdk-295.0.0-linux-x86_64.tar.gzTo install the Google Cloud SDK:
./google-cloud-sdk/install.sh
source ~/.bashrc
kubectl
from the
SDK:gcloud components install kubectl
WARNING: There are older versions of Google Cloud Platform tools on your system PATH. Please remove the following to avoid accidentally invoking these old tools: /usr/local/bin/kubectlFor example, to remove it and then verify the just-installed 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
kubectl
, there are a few additional steps to create the connection from
your local machine to the cloud environment.
./google-cloud-sdk/bin/gcloud init
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.reauthGo to the URL in a browser. If you're already logged into the Google email account that you used while creating the Kubernetes cluster, the page presents an OAuth code. For example:
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) ...
Pick cloud project to use: [1] johnsmart-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: [johnsmart-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
Now that the Google Cloud SDK is configured, there's 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. For example:
Click the Connect button near the right side of the display. The console displays a command example.
gcloud container clusters get-credentials johnsmart-datastax-cluster1 --zone us-central1-c --project johnsmart-project-datastax-fte
Fetching cluster endpoint and auth data. kubeconfig entry generated for johnsmart-datastax-cluster1.
What's next?
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 Cass
Operator configuration YAML files – provided by DataStax – to the Kubernetes cluster. For
those steps, see the next topic, Get started with Cassandra Operator.