Skip to content

Instantly share code, notes, and snippets.

@clemenko
Created February 12, 2024 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clemenko/385d6ce697e1f7a4601dbfc24d9a87e2 to your computer and use it in GitHub Desktop.
Save clemenko/385d6ce697e1f7a4601dbfc24d9a87e2 to your computer and use it in GitHub Desktop.
# this is for joining federated clusters within NeuVector
# check the passwords
export masterPassword=Pa22word
export masterUrl=neuvector.rfed.io
export masterApi=nv-api.rfed.io
export manangedPassword=admin
export managedUrl=nv2.rfed.io
export managedApi=nv2-api.rfed.io
# Master - create federation and get join token
TOKEN=$(curl -sk -H "Content-Type: application/json" https://$masterUrl/auth -d '{"isRancherSSOUrl":false, "username": "admin", "password": "'$masterPassword'"}' | jq -r .token.token)
curl -sk -H "Content-Type: application/json" -H 'Token: '$TOKEN https://$masterUrl/fed/promote -d '{"name":"'$masterUrl'","master_rest_info":{"server":"'$masterApi'","port":443},"use_proxy":"","deploy_repo_scan_data":false}'
TOKEN=$(curl -sk -H "Content-Type: application/json" https://$master_url/auth -d '{"isRancherSSOUrl":false, "username": "admin", "password": "'$password'"}' | jq -r .token.token)
JOIN_TOKEN=$(curl -sk -H "Content-Type: application/json" -H 'Token: '$TOKEN https:/$master_urlfed/join_token | jq -r .join_token)
# Managed - join
TOKEN=$(curl -sk -H "Content-Type: application/json" https://$managedUrl/auth -d '{"isRancherSSOUrl":false, "username": "admin", "password": "'$manangedPassword'"}' | jq -r .token.token)
curl -sk -H "Content-Type: application/json" -H 'Token: '$TOKEN https://$managedUrl/fed/join -d '{"name":"nv2","server":"'$masterApi'","port":443,"join_token":"'$JOIN_TOKEN'","joint_rest_info":{"server":"'$managedApi'","port":443},"use_proxy":""}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment