Skip to content

Instantly share code, notes, and snippets.

@Ziaunys
Last active July 14, 2020 19:14
Show Gist options
  • Save Ziaunys/c6e28b37d0c683410744135f1351157d to your computer and use it in GitHub Desktop.
Save Ziaunys/c6e28b37d0c683410744135f1351157d to your computer and use it in GitHub Desktop.
A small script to generate the request object needed to trigger a migration
TOKEN_NAME=$(kubectl -n cd4pe get secrets | grep ^cd4pe-migration | cut -f1 -d ' ')
SERVICE_ACCOUNT_TOKEN=$(kubectl -n cd4pe get secret $TOKEN_NAME -o jsonpath="{['data']['token']}")
K8S_API_URL=$(kubectl config view --minify -o jsonpath='{.clusters[*].cluster.server}')
K8S_CA_CERT=$(kubectl config view --raw --minify -o jsonpath='{.clusters[*].cluster.certificate-authority-data}')
cat <<EOF > migrate-to-replicated-request-local-generated.json
{
"op": "MigrateToReplicated",
"content": {
"k8sApiserverUrl": "$K8S_API_URL",
"k8sServiceAccountTokenBase64": "$SERVICE_ACCOUNT_TOKEN",
"customCACertBase64": "$K8S_CA_CERT",
"updateRepoWebhooks": false
}
}
EOF
echo "Generated request file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment