Importing an OpenShift cluster

Follow the procedure to import an OpenShift cluster. For more information about IBM Cloud Private with OpenShift and setting up your environment, see IBM Cloud Private with OpenShift overview.

Prerequisites

Required user type or access level: Cluster administrator

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. Set the KUBECONFIG environment variable with the following command:

    export KUBECONFIG=kubeconfig
    
  3. Log into your Red Hat OpenShift with oc login and generate your kubeconfig file. Run the following command:

    oc login <openshift console> -u <username> -p <password>
    
  4. List the files in your directory and confirm that your kubeconfig file was created.

  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:
       insecure-skip-tls-verify: true
       server: <target managed cluster OpenShift server URL>
     name: <cluster name>
    contexts:
    - context:
       cluster: <cluster name>
       namespace: default
       user: <user profile name>
     name: <context name>
    current-context: <context name>
    kind: Config
    preferences: {}
    users:
    - name: <user profile name>
     user:
       token: <user token>
    
  6. Verify that you can connect to your targeted managed cluster with kubectl 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.

    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

    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.

    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.

Post-import

If you completed the optional step 4 in the Create your IBM Multicloud Manager cluster-import.yaml configuration file section to configure your private Docker in your cluster-import.yaml, you need to remove the credentials from the ConfigMap on the hub cluster.

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

    cloudctl login -a https://<Hub Cluster Master Host>:<Cluster Master API Port> --skip-ssl-validation-->
    
  2. Edit the bootstrap-config ConfigMap for the targeted managed cluster. Run the following command:

    kubectl edit configmap -n <cluster_namespace> <cluster_name>-bootstrap-config
    
  3. Remove the private Docker Registry authentication information, as it is displayed in the following example:

    docker_username: <docker_username>
    docker_password: <docker_password>
    
  4. Save and exit.