In this blog post, we will show you how to register an existing Kubernetes cluster in Rancher.
Kubernetes is a powerful container orchestration platform, and Rancher is a robust Kubernetes management tool that simplifies the management of Kubernetes clusters. If you already have an existing Kubernetes cluster and want to manage it with Rancher’s user-friendly interface, you’re in the right place.
- A Running Kubernetes Cluster: You should already have a functional Kubernetes cluster up and running.
- Access to the Cluster: Ensure you have the necessary permissions and credentials to access and make changes to your Kubernetes cluster.
- Rancher Installed: You need to have Rancher installed and accessible. If you haven’t installed Rancher yet, you can find installation instructions in the official Rancher documentation.
- Connectivity between Rancher and Kubernetes Cluster
Steps to Register an Existing Kubernetes Cluster into Rancher
Follow these steps to import your existing Kubernetes cluster into Rancher:
Step 1: Login to Rancher
Open a web browser and type your Rancher’s instance IP address.
Log in with your Rancher credentials.
Step 2: Choose Import Existing Cluster
Once logged in, click on “Import Existing” option as show below,
In the next screen, choose “Generic” under ‘Cluster Management’
Fill in the necessary details for your existing Kubernetes cluster:
- Cluster Name
- Member Roles
Connect to your Kubernetes cluster via command line and run following commands to get cluster name of your Kubernetes cluster.
$ kubectl config current-context Or $ kubectl config view
As we can see our cluster name is “Kubernetes”, now head back to Rancher GUI and specify the cluster name there.
Click on Create.
We will get the following instructions to register Kubernetes cluster to Rancher. Run these commands into your Kubernetes cluster. In most of the cases, we are using self-signed certificates in Kubernetes, so we can run the highlighted command.
Step 3: Registering Kubernetes Cluster to Rancher
Connect to your Kubernetes cluster via command line and run following command to register,
$ curl --insecure -sfL https://192.168.1.4/v3/import/fhpr4677wjbnzggdw9fjrtlq9stqnl5vbhpq8wpskmvtxz948v7cxx_c-m-kqs8twh5.yaml | kubectl apply -f -
Above command will create the necessary ClusterRole, namespace, secret and deployments etc.
Wait for 2 to 3 minutes to start all the Kubernetes objects and then head back to Rancher UI.
Perfect, above screen confirms that our Kubernetes cluster is registered successfully on Rancher UI.
Now, when you go to home page of Rancher, you will see one more cluster is available there,
When you click on newly registered cluster, you will get all details as shown below.
That’s all from this post, I hope you have found it useful and informative. kindly do post your queries and feedback in below comments section.
Registering an existing Kubernetes cluster into Rancher is a straightforward process that empowers you to take advantage of Rancher’s management capabilities without the need for a fresh Kubernetes installation. Whether you’re looking to simplify cluster management or enhance your Kubernetes workflows, Rancher provides a user-friendly solution for achieving these goals.