|
44 | 44 | docker run --rm --net=host $curlimage -s 'https://127.0.0.1/v3/users?action=changepassword' -H 'content-type: application/json' -H "Authorization: Bearer $LOGINTOKEN" --data-binary '{"currentPassword":"admin","newPassword":"'$admin_password'"}' --insecure |
45 | 45 |
|
46 | 46 | # Create API key |
47 | | -APIRESPONSE=$(docker run --rm --net=host $curlimage -s 'https://127.0.0.1/v3/token' -H 'content-type: application/json' -H "Authorization: Bearer $LOGINTOKEN" --data-binary '{"type":"token","description":"automation"}' --insecure) |
| 47 | +while true; do |
| 48 | + |
| 49 | + APIRESPONSE=$(docker run --rm --net=host $curlimage -s 'https://127.0.0.1/v3/token' -H 'content-type: application/json' -H "Authorization: Bearer $LOGINTOKEN" --data-binary '{"type":"token","description":"automation"}' --insecure) |
| 50 | + # Extract and store token |
| 51 | + APITOKEN=`echo $APIRESPONSE | docker run --rm -i $jqimage -r .token` |
| 52 | + |
| 53 | + if [ "$APITOKEN" != "null" ]; then |
| 54 | + break |
| 55 | + else |
| 56 | + sleep 5 |
| 57 | + fi |
48 | 58 |
|
49 | | -# Extract and store token |
50 | | -APITOKEN=`echo $APIRESPONSE | docker run --rm -i $jqimage -r .token` |
| 59 | +done |
51 | 60 |
|
52 | 61 | # Configure server-url |
53 | 62 | RANCHER_SERVER="https://${rancher_ip}" |
54 | 63 | docker run --rm --net=host $curlimage -s 'https://127.0.0.1/v3/settings/server-url' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" -X PUT --data-binary '{"name":"server-url","value":"'$RANCHER_SERVER'"}' --insecure |
55 | 64 |
|
56 | 65 | # Create cluster |
57 | | -CLUSTERRESPONSE=$(docker run --rm --net=host $curlimage -s 'https://127.0.0.1/v3/cluster' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" --data-binary '{"dockerRootDir":"/var/lib/docker","enableNetworkPolicy":false,"type":"cluster","rancherKubernetesEngineConfig":{"kubernetesVersion":"'$k8s_version'","addonJobTimeout":30,"ignoreDockerVersion":true,"sshAgentAuth":false,"type":"rancherKubernetesEngineConfig","authentication":{"type":"authnConfig","strategy":"x509"},"network":{"options":{"flannelBackendType":"vxlan"},"plugin":"canal","canalNetworkProvider":{"iface":"eth1"}},"ingress":{"type":"ingressConfig","provider":"nginx"},"monitoring":{"type":"monitoringConfig","provider":"metrics-server"},"services":{"type":"rkeConfigServices","kubeApi":{"podSecurityPolicy":false,"type":"kubeAPIService"},"etcd":{"creation":"12h","extraArgs":{"heartbeat-interval":500,"election-timeout":5000},"retention":"72h","snapshot":false,"type":"etcdService","backupConfig":{"enabled":true,"intervalHours":12,"retention":6,"type":"backupConfig"}}}},"localClusterAuthEndpoint":{"enabled":true,"type":"localClusterAuthEndpoint"},"name":"quickstart"}' --insecure) |
| 66 | +while true; do |
| 67 | + CLUSTERRESPONSE=$(docker run --rm --net=host $curlimage 'https://127.0.0.1/v3/cluster' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" --data-binary '{"dockerRootDir":"/var/lib/docker","enableNetworkPolicy":false,"type":"cluster","rancherKubernetesEngineConfig":{"kubernetesVersion":"'$k8s_version'","addonJobTimeout":30,"ignoreDockerVersion":true,"sshAgentAuth":false,"type":"rancherKubernetesEngineConfig","authentication":{"type":"authnConfig","strategy":"x509"},"network":{"options":{"flannelBackendType":"vxlan"},"plugin":"canal","canalNetworkProvider":{"iface":"eth1"}},"ingress":{"type":"ingressConfig","provider":"nginx"},"monitoring":{"type":"monitoringConfig","provider":"metrics-server"},"services":{"type":"rkeConfigServices","kubeApi":{"podSecurityPolicy":false,"type":"kubeAPIService"},"etcd":{"creation":"12h","extraArgs":{"heartbeat-interval":500,"election-timeout":5000},"retention":"72h","snapshot":false,"type":"etcdService","backupConfig":{"enabled":true,"intervalHours":12,"retention":6,"type":"backupConfig"}}}},"localClusterAuthEndpoint":{"enabled":true,"type":"localClusterAuthEndpoint"},"name":"quickstart"}' --insecure) |
| 68 | + |
| 69 | + # Extract clusterid to use for generating the docker run command |
| 70 | + CLUSTERID=$(echo $CLUSTERRESPONSE | docker run --rm -i $jqimage -r .id) |
| 71 | + |
| 72 | + if [ "$CLUSTERID" != "null" ]; then |
| 73 | + break |
| 74 | + else |
| 75 | + sleep 5 |
| 76 | + fi |
| 77 | +done |
| 78 | + |
| 79 | + |
| 80 | + |
58 | 81 |
|
59 | | -# Extract clusterid to use for generating the docker run command |
60 | | -CLUSTERID=`echo $CLUSTERRESPONSE | docker run --rm -i $jqimage -r .id` |
61 | 82 |
|
62 | 83 | # Generate registrationtoken |
63 | 84 | docker run --rm --net=host $curlimage -s 'https://127.0.0.1/v3/clusterregistrationtoken' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" --data-binary '{"type":"clusterRegistrationToken","clusterId":"'$CLUSTERID'"}' --insecure |
0 commit comments