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
-
You need access to an environment with Red Hat OpenShift installed.
-
You must install Docker. To install Docker, see Install Docker
.
-
You need to install the Kubernetes command line tool,
kubectl. To installkubectl, see Install and Set Up kubectl.
-
You must install the OpenShift CLI,
oc. For more information see Get Started with the CLI.
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
-
From a terminal, go to your
<import_config_directory>directory. -
Set the
KUBECONFIGenvironment variable with the following command:export KUBECONFIG=kubeconfig -
Log into your Red Hat OpenShift with
oc loginand generate yourkubeconfigfile. Run the following command:oc login <openshift console> -u <username> -p <password> -
List the files in your directory and confirm that your
kubeconfigfile was created. -
Verify the content of the
kubeconfigfile. Be sure that you have one value forclusters, one value forcontexts, and one value forusers. 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> -
Verify that you can connect to your targeted managed cluster with
kubectlusing thekubeconfig. Run anykubectlcommand. If you receive anunable to connecterror, delete the file and retry. -
Unset the
KUBECONFIGenvironment variable to avoid modifying thekubeconfigfile as you proceed. Run the following command:unset KUBECONFIG
Create your IBM Multicloud Manager cluster-import.yaml configuration file
-
From a terminal, go to your
<import_config_directory>directory. -
Log in to your hub-cluster with
cloudctl login.cloudctl login -a https://<Hub Cluster Master Host>:<Cluster Master API Port> --skip-ssl-validation--> -
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 -
Open the
cluster-import.yamlfile and configure the following parameters:default_admin_user: The cluster administrator username for the target managed clustercontainer_runtime:The container runtime used in the cluster, currently supported options aredockerandcontainerd
You are now ready to import a cluster.
Importing the cluster
-
From a terminal, go to your
<import_config_directory>directory. -
Log in to your hub-cluster with
cloudctl login.cloudctl login -a https://<Cluster Master Host>:<Cluster Master API Port> --skip-ssl-validation -
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 -
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.
-
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--> -
Edit the
bootstrap-configConfigMap for the targeted managed cluster. Run the following command:kubectl edit configmap -n <cluster_namespace> <cluster_name>-bootstrap-config -
Remove the private Docker Registry authentication information, as it is displayed in the following example:
docker_username: <docker_username> docker_password: <docker_password> -
Save and exit.