Rancher-cli login 2 clusters automatic

Hi,

I want to use the rancher cli in our CI/CD-pipeline. We are using bamboo.

When only one cluster is managed by the Rancher everything works fine.

But when a second cluster is managed, the Cli is asking for a default cluster.

I tried

" echo -e ‘yes\n1’ | rancher login --token … "
" printf-e ‘yes\n1’ | rancher login --token … "
" printf-e ‘yes\n1\n’ | rancher login --token … "

The result is always:

Select your default Project:time=“2018-06-18T10:30:54+02:00” level=fatal msg=EOF

Ho can i set automatically on cluster? Is there a trick?

It would be great, when someone has an idea.

Greatings
Delck

1 Like

Also having the same problem preventing us automating rancher deployments, making things really hard.

Anyone ?

In recent versions of rancher-cli you can specify --context. You can see available context-id when doing a manual login, it is called normally like “local:p-8ss68” or “c-5tq98:p-9lmbq”. Using local: works since rancher-cli-v2.2.0-rc5.
Example:
rancher login -t abcdef:ghijklmnopqrstuvwxzy --context c-5tq98:p-9lmbq https://rancher.example.com