Skip to content

Interacting with Kubernetes

The KX Insights Platform can be deployed in all three cloud providers AWS, GCP & Azure. The clusters are typically managed through Terraform GitOps scripts. New cluster setup and reconfigurations can be achieved by updating the terraform configuration and applying via DevOps processes.

Prerequisites

A number of tools are required to allow the user to deploy the KX Insights Platform:

Connection to cluster

To connect to a cluster, you must create a context.

A context is essentially the configuration that you use to access a particular cluster & namespace with a user account.

The user needs to be authorized and permissioned to the appropriate cloud provider project. This is done via the cloud provider cli and may need assistance from the project administrator. See the relevant cloud provider documentation for further details on how to do this. Some info is provided below.

Assuming the user has been given appropriate permissions to the cloud provider and cluster, and has authenticated via the CLI, the next step will be to connect to a specific cluster & namespace.

This command will create the necessary configuration to set up kubectl to point to the cluster kxi-a1 in the region us-east-1.

aws eks --region us-east-1 update-kubeconfig --name kxi-a1

To authorize gcloud and utilize GKE, set the appropriate account and project to be active.

gcloud auth login
gcloud auth configure-docker

Note

The gcloud command offers significant helpers. Running incomplete commands will prompt the user with options for what is available. For example gcloud container clusters will indicate cluster commands available. See gcloud documentation for full details.

gcloud container clusters get-credentials \ 
  kxi-g1 --region us-central1 --project <gcp-project-name>

To authorize az and utilize AKS within the kubectl setup the below steps are required.

  • Set the account subscription id to link az to the Azure subscription.
az account show | grep id                   # Get subscription ID 
az account set --subscription <id>          # Set subscription ID
  • Link kubectl to your credentials by providing the resource group name containing the AKS cluster along with the cluster name.
az aks get-credentials --resource-group <resource group name> --name <cluster name>

Kubernetes contexts and namespaces

Once connected to the cluster, Kubernetes/kubectl requires the user to setup an 'active context'. The default context will point the user at the default namespace within the active cluster. This should be changed to a siloed namespace to allow multiple deployments of applications within a cluster.

Depending on the maturity of the cluster being used and the kubectl setup, this may require a number of steps. Full documentation on contexts and namespaces available here. Below are common commands to help interrogate the active context, clusters, and namespaces.

View active context

Displays the name of the active context.

kubectl config current-context

View defined contexts

Displays all contexts within your configuration and includes cluster information, users access configuration and namespace association. Note this is dynamically built from various calls highlighted here.

kubectl config view

Create from command line

kubectl create namespace kxi-sys

Create a context

Link the cluster, user and namespace to a single context entity.

kubectl config set-context kxi --namespace=kxi-sys \
  --cluster=<cluster-name> \
  --user=<user-name>

Note

The namespace, cluster and user should already exist in your config kubectl config view

Set active context

Once created, the context should be set as active.

kubectl config use-context kxi