Importing an Azure Kubernetes Service cluster

Follow the procedure to import an Azure Kubernetes Service cluster. See Azure Kubernetes Service Opens in a new tab for more information about the public Kubernetes service.

Required user type or access level: Cluster administrator

Prerequisites

Prepare for import

You need to create an <import_config_directory> directory to store your import configuration files.

To learn more about the import command and see [options] that are available, see IBM Cloud Private CLI multicluster commands (mc).

Generating your kubeconfig file for the targeted managed cluster

  1. From a terminal, go to your <import_config_directory> directory.

  2. Log in to Azure Cloud Platform with the following command, which opens a browser for authentication:

    az login
    
  3. Set the KUBECONFIG environment variable with the following command:

    export KUBECONFIG=kubeconfig
    
  4. Obtain your cluster access information by running the following command:

    az aks get-credentials \
    --resource-group <resource_group> \
    --name <cluster_name> \
    --file ./kubeconfig
    
  5. Verify the content of the kubeconfig file. Be sure that you have one value for clusters, one value for contexts, and one value for users. See the following example output:

    apiVersion: v1
    clusters:
    - cluster:
       certificate-authority-data: <ca-data>
       server: <targeted-managed cluster-kubernete-api-server>
     name: <cluster_name>
    contexts:
    - context:
       cluster: <cluster_name>
       user: <username>
     name: <cluster_name>-context
    current-context: <cluster_name>-context
    kind: Config
    preferences: {}
    users:
    - name: <username>
     user:
       client-certificate-data: <client-certificate-data>
       client-key-data: <client-key-data>
       token: <token>
    
  6. Verify that you can connect to your targeted managed cluster with kubectl by using the kubeconfig. Run any kubectl command. If you receive an unable to connect error, delete the file and retry.

  7. Unset the KUBECONFIG environment variable to avoid modifying the kubeconfig file as you proceed. Run the following command:

    unset KUBECONFIG
    

Create your IBM Multicloud Manager cluster-import.yaml configuration file

  1. From a terminal, go to your <import_config_directory> directory.

  2. Log in to your hub-cluster with cloudctl login the following command:

    cloudctl login -a https://<Hub Cluster Master Host>:<Cluster Master API Port> --skip-ssl-validation
    
  3. Run the following command to create the configuration template, cluster-import.yaml, where <cluster_name> is the name of the cluster resource on the hub, and <cluster_namespace> is the namespace of the cluster resources on the hub:

    cloudctl mc cluster template <cluster_name> -n <cluster_namespace> > cluster-import.yaml
    
  4. Open the cluster-import.yaml file and configure the following parameters:

    • default_admin_user: The cluster administrator username for the target managed cluster
    • container_runtime:The container runtime used in the cluster, currently supported options are docker and containerd

    See the Multicluster-endpoint settings section of Customizing the cluster with the config.yaml file for more parameters.

You are now ready to import a cluster.

Importing the cluster

  1. From a terminal, go to your <import_config_directory> directory.

  2. Log in to your hub-cluster with cloudctl login. Run the following command:

    cloudctl login -a https://<Cluster Master Host>:<Cluster Master API Port> --skip-ssl-validation
    
  3. Run the following command to import to the targeted managed cluster:

    cloudctl mc cluster import -f <cluster-import.yaml> -K kubeconfig | tee cluster-import.log
    
  4. Verify that the cluster is successfully imported.

    • Log in to your IBM Multicloud Manager hub cluster.
    • From the navigation bar, click Clusters.
    • Find your new imported managed cluster in the list.
    • Ensure the the status is Ready. Depending on environment, it may take a few minutes to see the status.