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.
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!
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.
use rancher2 provider to create imported i.e. “rancher2_cluster” “foo-imported”
look for the outputs and use the appropriate command (curl for self signed kubectl for signed ssl)
I found out that creating the cluster directly in rancher2 provider works best
I assume you are using the Terraform example, what Terraform version, what provider.rancher2 version and what Rancher version are you using? And what Terraform code if its not a copy paste of above.
It looks like you’ve included an API Key in your post. API keys are private and should not be shared on public forums such as this. If this is a key that is used in a production cluster please consider changing it immediately as it could lead to an exposure and a security risk. API keys should never be needed for support requests - so please make sure to remove them from your posts to reduce the potential for security issues.
Please let us know if you have any questions or concerns about this.
Thanks!