Importing a GKE cluster into IBM Multicloud Manager

Chris Doan
IBM Cloud
Published in
2 min readJul 8, 2019
Photo by Pixabay from Pexels

IBM Multicloud Manager supports managing Kubernetes clusters from many different cloud providers, with Google Container Engine being one of them.

If you have an IBM Multicloud Manager hub-cluster running, and you want to import a GKE cluster so that you can manage that cluster, complete the following procedure:

First, ensure that you have the gcloud cli downloaded and installed. Then, use glcoud to login to Google Cloud Platform by using a command like the following example:

gcloud init
gcloud login john.smith@gmail.com

The example above shows a fictitious user John Smith. Once you have logged in, ensure that you have the appropriate IAM roles for container administration in your project. You can issue a command like the one in the following example:

PROJECT=$(gcloud info --format=json --flatten=config.project | jq -r '.[0]')
ZONE=$(gcloud info --format=json --flatten=config.properties.compute.zone | jq -r '.[0]')

This sets some environment variables needed by the following commands:

gcloud projects get-iam-policy $PROJECT \
--flatten=bindings \
--filter=bindings.role:roles/container.admin | grep john.smith

If the command returns some string, then your user account has the appropriate IAM roles required to add your cluster to IBM Multicloud Manager.

If nothing is returned from the command, you will need to speak to your GCP administrator to add the container.admin role to your account before continuing.

Now, export the kube config information for your cluster into a file. Use this sequence of commands:

export KUBECONFIG=kubeconfig
gcloud container clusters get-credentials $MANAGED_CLUSTER_NAME \
--zone $ZONE \
--project $PROJECT
unset KUBECONFIG

The get-credentials command exports the kube config values into a file specified by the KUBECONFIG environment variable.

You now have a kubeconfig file that specifies the information needed to connect to your cluster. You can now login to the IBM Multicloud Manager hub-clustermand run the following command:

cloudctl mc cluster template $MANAGED_CLUSTER_NAME -n $MANAGED_CLUSTER_NAME > cluster-import.yaml
cloudctl mc cluster import -f cluster-import.yaml -K kubeconfig | tee cluster-import.log

The MANAGED_CLUSTER_NAME variable is the cluster name of the cluster that you want to manage with the hub-cluster. Also, it is best practice to create a namespace in the hub, with this string to reference the managed-cluster.

Now, sit back and wait for the job run to deploy the Klusterlet on your cluster and connect and join to your IBM Multicloud Manager hub.

The Klusterlet is defined as the agent that is installed on a Kubernetes cluster, making it a managed-cluster.

--

--