Programmatically Import Cluster (No Web UI)

I am able to programmatically install, configure, and create a default cluster. The issue is the final step still requires someone to login into the UI to obtain the import manifest, e.g.

“curl --insecure -sfL | kubectl apply -f -”

I cant locate this in the API or docs. Is it possible to get this information from any CLI?

Using the CLI:

rancher cluster create test --import
rancher cluster import test

Thanks. Rancher CLI isn’t quite non-interactive (my fault, poorly worded question), but I imagine I can ‘expect’ some of the required prompts. In any case, appreciate the help!

The registration command is in /v3/clusters/<id>/clusterRegistrationTokens. The UI is just an API client; anything it does you can.

After the cluster creation using rke I do rancher clusters create --import
I then do rancher clusters import but it prints a curl command to run how do I avoid this as this is not scriptable

Importing clusters requires creating a cluster (with an empty config so its treated as a imported cluster), then deploying the needed resources into the cluster so Rancher can access it. This is done by providing a YAML file with the needed resources that can be deployed using kubectl (or with curl + kubectl if you are using self signed certificates). All of these steps can be done in an automated way, the command provided for the cluster can be retrieved and be automatically executed after you configured the correct kubeconfig for your cluster for kubectl.

Can you give us some samples please, i’m creating a K8S cluster with terraform inside a gitlab-ci pipeline, but later i wanna administer the cluster via Rancher.

Thanks a lot