Connect an Existing GKE Cluster
This topic describes connecting an existing GKE cluster to Ocean using the Spot Console.
Prerequisites
- Connect your GCP project to Spot. If you don't have a GCP project, see Manage Resources.
- Ensure that billing is enabled for your project: Learn how to enable billing.
- Ensure that you have enabled the Google Kubernetes Engine API: Enable the GKE API.
- Ocean Controller Version 2.
Limitations
You cannot connect a GKE cluster with Autopilot mode turned on.
Access the Cluster Creation Wizard
- In the left menu of the Spot Console, click Ocean > Cloud Clusters.
- Click Create Cluster.
Step 1: General
-
Enter a Cluster Name and the Location Type and click the Region where the cluster runs.
- Cluster Name is the name of the Ocean entity to create. We recommend giving a cluster you import the same name as the original GKE cluster. This will make it easier to identify related entities in each system.
- Location Type can be either Zonal or Regional.
-
Select the GKE cluster from which to import the configuration.
Step 2: Compute
-
Ocean imports the compute configuration from your GKE cluster and displays it on the Compute page. Edit the configuration if needed:
- Machine Types. All types are selected by default to provide Ocean with maximum flexibility. Click Customize to adjust them.
- Resource Limit
- Max vCPUs
- Max Memory (GB)
- Additional Configurations
- Draining Timeout
-
Optionally, you can import all GKE node pools into Ocean as virtual node groups. (The default node pool will be automatically imported).
Click for image
Step 3: Connectivity
Install the Ocean Controller Version 2 and establish the connection between the Ocean SaaS and the cluster.
Click for image
To install the Ocean Controller and establish connectivity:
-
Create a Spot token (or use an existing one) and copy it to the text box.
-
Enter the Namespace. The default is spot-system.
-
To install the Ocean Kubernetes Controller, use either Helm (the preferred option) or via script.
- Helm: This is the preferred method because it lets you customize using command-line options or
values.yaml
. Install Helm 3.x and add thespotinst
repo. Then, use thehelm install
command with set command-line options to install the Ocean controller in a separate spot-ocean namespace.
# add repo
helm repo add spot https://charts.spot.io
helm repo update spot
# install controller
helm upgrade --install --wait ocean-controller spot/ocean-kubernetes-controller \
--namespace "${NAMESPACE}" --create-namespace \
--set spotinst.account="${SPOTINST_ACCOUNT}" \
--set spotinst.clusterIdentifier="${SPOTINST_CLUSTER_IDENTIFIER}" \
--set spotinst.token="${SPOTINST_TOKEN}"
--set metrics-server.deployChart=false
-
Connect via Script: Use Spot’s script to install the Ocean Controller:
curl -fsSL https://spotinst-public.s3.amazonaws.com/integrations/kubernetes/cluster-controller-v2/scripts/init.sh | \
SPOTINST_TOKEN=$SPOTINST_TOKEN \
SPOTINST_ACCOUNT=$SPOTINST_ACCOUNT \
SPOTINST_CLUSTER_IDENTIFIER=$SPOTINST_CLUSTER_IDENTIFIER \
ENABLE_OCEAN_METRIC_EXPORTER=false \
INCLUDE_METRIC_SERVER=false \
bashIf you need admin privileges for this script, run the following command:
kubectl create clusterrolebinding <cluster name> --clusterrole=cluster-admin --user=<userEmail>
noteOptionally install the Ocean Prometheus exporter ...
- Helm: This is the preferred method because it lets you customize using command-line options or
-
Click Test Connectivity to confirm that the Ocean Controller is functioning in the cluster. The test takes around two minutes. A green OK is displayed when the Ocean Controller pod runs in the AKS cluster and communicates with the Ocean SaaS engine.
Additional Tips:
- For unsuccessful connectivity, check the outbound connection and that the Ocean Controller pods are running.
- To change the Ocean Controller init.sh script, download, edit, and execute it from the command line (bash shell).
For a Private GKE Cluster
-
For a private GKE cluster, install the Spotinst Kubernetes Controller with the following command:
kubectl apply -f https://spotinst-public.s3.amazonaws.com/integrations/kubernetes/cluster-controller/spotinst-kubernetes-cluster-controller-gcr.yaml
-
Ensure your GKE cluster has NAT so the controller can report information to the Ocean SaaS.
-
Click Test Connectivity to ensure the controller functionality.
Preserve Original Node Pool
Preserve the original node pool and its name to sync upgrades of the node pool. The original node pool can be drained from all nodes as long as it is preserved.
For any changes to the original node pool, contact Spot Support.
Step 4: Review
Review all the Ocean settings you have configured. Click Create to finish or use the generated JSON template to create the Ocean cluster using other tooling.
Optional: You can manually scale down your existing GKE nodes in migrated node pools so that Ocean provisions pod-driven optimized infrastructure for your existing workload. To do this, run the following command:
gcloud container clusters resize <cluster_name> --num-nodes=0 --region=<region/zone> --node-pool <node_pool_name>
To avoid unnecessary downtime, the scale-down of existing nodes should be gradual. For example, run the above command several times, gradually reducing the value of num-nodes
. Only Use num-nodes=0
for the last time you run the command.