Last active
August 15, 2018 11:59
Revisions
-
superseb revised this gist
Aug 15, 2018 . 2 changed files with 2 additions and 40 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ # MOVED https://gist.github.com/superseb/c363247c879e96c982495daea1125276 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,40 +0,0 @@ -
superseb revised this gist
Jul 12, 2018 . 1 changed file with 13 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,25 +15,26 @@ APIRESPONSE=`curl -s 'https://127.0.0.1/v3/token' -H 'content-type: application/ # Extract and store token APITOKEN=`echo $APIRESPONSE | jq -r .token` # Set server-url RANCHER_SERVER=https://your_rancher_server.com curl -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 > /dev/null # Create cluster CLUSTERRESPONSE=`curl -s 'https://127.0.0.1/v3/cluster' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" --data-binary '{"type":"cluster","nodes":[],"rancherKubernetesEngineConfig":{"ignoreDockerVersion":true},"name":"yournewcluster"}' --insecure` # Extract clusterid to use for generating the docker run command CLUSTERID=`echo $CLUSTERRESPONSE | jq -r .id` # Create token curl -s 'https://127.0.0.1/v3/clusterregistrationtoken' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" --data-binary '{"type":"clusterRegistrationToken","clusterId":"'$CLUSTERID'"}' --insecure > /dev/null # Set role flags ROLEFLAGS="--etcd --controlplane --worker" # Generate nodecommand AGENTCMD=`curl -s 'https://127.0.0.1/v3/clusterregistrationtoken?id="'$CLUSTERID'"' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" --insecure | jq -r '.data[].nodeCommand' | head -1` # Concat commands DOCKERRUNCMD="$AGENTCMD $ROLEFLAGS" # Echo command echo $DOCKERRUNCMD -
superseb revised this gist
Jul 12, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ #!/bin/bash docker run -d -p 80:80 -p 443:443 --name rancher-server rancher/rancher:latest while ! curl -k https://localhost/ping; do sleep 3; done -
superseb revised this gist
Feb 8, 2018 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,9 +28,7 @@ ROLEFLAGS="--etcd --controlplane --worker" RANCHERSERVER="https://rancher_server_address" # Generate token (clusterRegistrationToken) AGENTTOKEN=`curl -s 'https://127.0.0.1/v3/clusterregistrationtoken' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" --data-binary '{"type":"clusterRegistrationToken","clusterId":"'$CLUSTERID'"}' --insecure | jq -r .token` # Retrieve CA certificate and generate checksum CACHECKSUM=`curl -s -H "Authorization: Bearer $APITOKEN" https://127.0.0.1/v3/settings/cacerts --insecure | jq -r .value | sha256sum | awk '{ print $1 }'` -
superseb revised this gist
Feb 8, 2018 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,19 +4,19 @@ docker run -d -p 80:80 -p 443:443 --name rancher-server rancher/server:preview while ! curl -k https://localhost/ping; do sleep 3; done # Login LOGINRESPONSE=`curl -s 'https://127.0.0.1/v3-public/localProviders/local?action=login' -H 'content-type: application/json' --data-binary '{"username":"admin","password":"admin"}' --insecure` LOGINTOKEN=`echo $LOGINRESPONSE | jq -r .token` # Change password curl -s 'https://127.0.0.1/v3/users?action=changepassword' -H 'content-type: application/json' -H "Authorization: Bearer $LOGINTOKEN" --data-binary '{"currentPassword":"admin","newPassword":"thisisyournewpassword"}' --insecure # Create API key APIRESPONSE=`curl -s 'https://127.0.0.1/v3/token' -H 'content-type: application/json' -H "Authorization: Bearer $LOGINTOKEN" --data-binary '{"type":"token","description":"automation"}' --insecure` # Extract and store token APITOKEN=`echo $APIRESPONSE | jq -r .token` # Create cluster CLUSTERRESPONSE=`curl -s 'https://127.0.0.1/v3/cluster' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" --data-binary '{"type":"cluster","nodes":[],"rancherKubernetesEngineConfig":{"ignoreDockerVersion":true},"name":"yournewcluster"}' --insecure` # Extract clusterid to use for generating the docker run command CLUSTERID=`echo $CLUSTERRESPONSE | jq -r .id` -
superseb revised this gist
Feb 8, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ docker run -d -p 80:80 -p 443:443 --name rancher-server rancher/server:preview while ! curl -k https://localhost/ping; do sleep 3; done # Login LOGINRESPONSE=`curl 'https://127.0.0.1/v3-public/authProviders/local?action=login' -H 'content-type: application/json' --data-binary '{"username":"admin","password":"admin"}' --insecure` LOGINTOKEN=`echo $LOGINRESPONSE | jq -r .token` # Change password -
superseb revised this gist
Feb 8, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ docker run -d -p 80:80 -p 443:443 --name rancher-server rancher/server:preview while ! curl -k https://localhost/ping; do sleep 3; done # Login LOGINRESPONSE=`curl 'https://127.0.0.1/v3-public/localProviders/local?action=login' -H 'content-type: application/json' --data-binary '{"username":"admin","password":"admin"}' --insecure` LOGINTOKEN=`echo $LOGINRESPONSE | jq -r .token` # Change password -
superseb revised this gist
Feb 8, 2018 . 1 changed file with 21 additions and 15 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,32 +4,38 @@ docker run -d -p 80:80 -p 443:443 --name rancher-server rancher/server:preview while ! curl -k https://localhost/ping; do sleep 3; done # Login LOGINRESPONSE=`curl 'https://127.0.0.1/v3-public/localProviders/local?action=login' -H 'content-type: application/json' -H 'accept: application/json' --data-binary '{"username":"admin","password":"admin"}' --insecure` LOGINTOKEN=`echo $LOGINRESPONSE | jq -r .token` # Change password curl -s 'https://127.0.0.1/v3/users?action=changepassword' -H 'content-type: application/json' -H "Authorization: Bearer $LOGINTOKEN" --data-binary '{"currentPassword":"admin","newPassword":"thisisyournewpassword"}' --insecure # Create API key APIRESPONSE=`curl -s 'https://127.0.0.1/v3/token' -H 'content-type: application/json' -H "Authorization: Bearer $LOGINTOKEN" --data-binary '{"type":"token","description":"automation","name":""}' --insecure` # Extract and store token APITOKEN=`echo $APIRESPONSE | jq -r .token` # Create cluster CLUSTERRESPONSE=`curl -s 'https://127.0.0.1/v3/cluster' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" --data-binary '{"type":"cluster","nodes":[],"rancherKubernetesEngineConfig":{"type":"rancherKubernetesEngineConfig","hosts":[],"network":{"options":[],"plugin":"flannel"},"ignoreDockerVersion":true,"services":{"kubeApi":{"serviceClusterIpRange":"10.233.0.0/18","podSecurityPolicy":false,"extraArgs":{"v":"4"}},"kubeController":{"clusterCidr":"10.233.64.0/18","serviceClusterIpRange":"10.233.0.0/18"},"kubelet":{"clusterDnsServer":"10.233.0.3","clusterDomain":"cluster.local","infraContainerImage":"gcr.io/google_containers/pause-amd64:3.0"}},"authentication":{"options":[],"strategy":"x509"}},"googleKubernetesEngineConfig":null,"name":"yournewcluster","id":""}' --insecure` # Extract clusterid to use for generating the docker run command CLUSTERID=`echo $CLUSTERRESPONSE | jq -r .id` # Generate docker run AGENTIMAGE=`curl -s -H "Authorization: Bearer $APITOKEN" https://127.0.0.1/v3/settings/agent-image --insecure | jq -r .value` ROLEFLAGS="--etcd --controlplane --worker" RANCHERSERVER="https://rancher_server_address" # Generate token (clusterRegistrationToken) curl -s 'https://127.0.0.1/v3/clusterregistrationtoken' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" --data-binary '{"type":"clusterRegistrationToken","clusterId":"'$CLUSTERID'"}' --insecure # Extract the token and save it in $AGENTTOKEN AGENTTOKEN=`curl -s 'https://127.0.0.1/v3/clusterregistrationtokens?limit=-1' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" --insecure | jq -r .data[].token` # Retrieve CA certificate and generate checksum CACHECKSUM=`curl -s -H "Authorization: Bearer $APITOKEN" https://127.0.0.1/v3/settings/cacerts --insecure | jq -r .value | sha256sum | awk '{ print $1 }'` # Assemble the docker run command AGENTCOMMAND="docker run -d --restart=unless-stopped -v /var/run/docker.sock:/var/run/docker.sock --net=host $AGENTIMAGE $ROLEFLAGS --server $RANCHERSERVER --token $AGENTTOKEN --ca-checksum $CACHECKSUM" # Show the command echo $AGENTCOMMAND -
superseb revised this gist
Feb 8, 2018 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,8 +28,8 @@ AGENTTOKEN=`curl 'https://127.0.0.1/v3/clusterregistrationtokens?limit=-1' -H 'c AGENTIMAGE=`curl -s -k -H "Authorization: Bearer $TOKEN" https://127.0.0.1/v3/settings/agent-image | jq -r .value` CACHECKSUM=`curl -s -k -H "Authorization: Bearer $TOKEN" https://127.0.0.1/v3/settings/cacerts | jq -r .value | sha256sum | awk '{ print $1 }'` ROLEFLAGS="--etcd --controlplane --worker" RANCHERSERVER="https://rancher_server_address" AGENTCOMMAND="docker run -d --restart=unless-stopped -v /var/run/docker.sock:/var/run/docker.sock --net=host $AGENTIMAGE $ROLEFLAGS --server $RANCHERSERVER --token $AGENTTOKEN --ca-checksum $CACHECKSUM" echo $AGENTCOMMAND -
superseb revised this gist
Feb 8, 2018 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ #!/bin/bash docker run -d -p 80:80 -p 443:443 --name rancher-server rancher/server:preview while ! curl -k https://localhost/ping; do sleep 3; done -
superseb revised this gist
Feb 8, 2018 . 1 changed file with 9 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,29 @@ #!/bin/bash docker rm -f rancher-server docker run -d -p 80:80 -p 443:443 --name rancher-server rancher/server:preview while ! curl -k https://localhost/ping; do sleep 3; done # Login curl --cookie-jar ranchercookie 'https://127.0.0.1/v3-public/localProviders/local?action=login' -H 'content-type: application/json' -H 'accept: application/json' -H 'x-api-csrf: 000050de82' -H 'Cookie: CSRF=000050de82' --data-binary '{"username":"admin","password":"admin","description":"UI Session","responseType":"cookie","ttl":57600000,"labels":{"ui-session":"true"}}' --compressed --insecure # Change password curl -b ranchercookie 'https://127.0.0.1/v3/users?action=changepassword' -H 'content-type: application/json' -H 'accept: application/json' -H 'x-api-csrf: 000050de82' --data-binary '{"currentPassword":"admin","newPassword":"a"}' --compressed --insecure # Create API key RESPONSE=`curl -b ranchercookie 'https://127.0.0.1/v3/token' -H 'content-type: application/json' -H 'x-api-no-challenge: true' -H 'accept: application/json' -H 'x-api-csrf: 000050de82' --data-binary '{"type":"token","ttl":31536000000,"description":"automation","name":""}' --compressed --insecure` # Extract token from API key response TOKEN=`echo $RESPONSE | jq -r .token` # Create cluster CLUSTERRESPONSE=`curl 'https://127.0.0.1/v3/cluster' -H 'content-type: application/json' -H 'accept: application/json' -H "Authorization: Bearer $TOKEN" -H 'x-api-csrf: 000050de82' --data-binary '{"type":"cluster","nodes":[],"rancherKubernetesEngineConfig":{"type":"rancherKubernetesEngineConfig","hosts":[],"network":{"options":[],"plugin":"flannel"},"ignoreDockerVersion":true,"services":{"kubeApi":{"serviceClusterIpRange":"10.233.0.0/18","podSecurityPolicy":false,"extraArgs":{"v":"4"}},"kubeController":{"clusterCidr":"10.233.64.0/18","serviceClusterIpRange":"10.233.0.0/18"},"kubelet":{"clusterDnsServer":"10.233.0.3","clusterDomain":"cluster.local","infraContainerImage":"gcr.io/google_containers/pause-amd64:3.0"}},"authentication":{"options":[],"strategy":"x509"}},"googleKubernetesEngineConfig":null,"name":"testcluster2","id":""}' --compressed --insecure` CLUSTERID=`echo $CLUSTERRESPONSE | jq -r .id` # Create and Get agent token for joining cluster curl 'https://127.0.0.1/v3/clusterregistrationtoken' -H 'content-type: application/json' -H 'accept: application/json' -H "Authorization: Bearer $TOKEN" -H 'x-api-csrf: 000050de82' --data-binary '{"type":"clusterRegistrationToken","clusterId":"'$CLUSTERID'"}' --compressed --insecure AGENTTOKEN=`curl 'https://127.0.0.1/v3/clusterregistrationtokens?limit=-1' -H 'content-type: application/json' -H 'accept: application/json' -H "Authorization: Bearer $TOKEN" -H 'x-api-csrf: 000050de82' --compressed --insecure | jq -r .data[].token` # Generate docker run AGENTIMAGE=`curl -s -k -H "Authorization: Bearer $TOKEN" https://127.0.0.1/v3/settings/agent-image | jq -r .value` -
superseb created this gist
Feb 8, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ #!/bin/bash docker run -d -p 80:80 -p 443:443 --name rancher-server rancher/server:preview while ! curl -k https://localhost/ping; do sleep 0.1; done # Login curl --cookie-jar ranchercookie 'https://127.0.0.1/v3-public/localProviders/local?action=login' -H 'Origin: https://127.0.0.1' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.9,nl;q=0.8' -H 'x-api-action-links: actionLinks' -H 'content-type: application/json' -H 'x-api-no-challenge: true' -H 'accept: application/json' -H 'Referer: https://127.0.0.1/login' -H 'Connection: keep-alive' -H 'x-api-csrf: 000050de82' -H 'Cookie: CSRF=000050de82' --data-binary '{"username":"admin","password":"admin","description":"UI Session","responseType":"cookie","ttl":57600000,"labels":{"ui-session":"true"}}' --compressed --insecure # Change password curl -b ranchercookie 'https://127.0.0.1/v3/users?action=changepassword' -H 'content-type: application/json' -H 'x-api-no-challenge: true' -H 'accept: application/json' -H 'x-api-csrf: 000050de82' --data-binary '{"currentPassword":"admin","newPassword":"a"}' --compressed --insecure # Create API key RESPONSE=`curl -b ranchercookie 'https://127.0.0.1/v3/token' -H 'Origin: https://127.0.0.1' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.9,nl;q=0.8' -H 'x-api-action-links: actionLinks' -H 'content-type: application/json' -H 'x-api-no-challenge: true' -H 'accept: application/json' -H 'Referer: https://127.0.0.1/apikeys' -H 'Connection: keep-alive' -H 'x-api-csrf: 000050de82' --data-binary '{"type":"token","ttl":31536000000,"description":"automation","name":""}' --compressed --insecure` # Extract token from API key response TOKEN=`echo $RESPONSE | jq -r .token` # Create cluster CLUSTERRESPONSE=`curl 'https://127.0.0.1/v3/cluster' -H 'Origin: https://127.0.0.1' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.9,nl;q=0.8' -H 'x-api-action-links: actionLinks' -H 'content-type: application/json' -H 'x-api-no-challenge: true' -H 'accept: application/json' -H "Authorization: Bearer $TOKEN" -H 'Connection: keep-alive' -H 'x-api-csrf: 000050de82' --data-binary '{"type":"cluster","nodes":[],"rancherKubernetesEngineConfig":{"type":"rancherKubernetesEngineConfig","hosts":[],"network":{"options":[],"plugin":"flannel"},"ignoreDockerVersion":true,"services":{"kubeApi":{"serviceClusterIpRange":"10.233.0.0/18","podSecurityPolicy":false,"extraArgs":{"v":"4"}},"kubeController":{"clusterCidr":"10.233.64.0/18","serviceClusterIpRange":"10.233.0.0/18"},"kubelet":{"clusterDnsServer":"10.233.0.3","clusterDomain":"cluster.local","infraContainerImage":"gcr.io/google_containers/pause-amd64:3.0"}},"authentication":{"options":[],"strategy":"x509"}},"googleKubernetesEngineConfig":null,"name":"testcluster2","id":""}' --compressed --insecure` CLUSTERID=`echo $CLUSTERRESPONSE | jq -r .id` # Create and Get agent token for joining cluster curl 'https://127.0.0.1/v3/clusterregistrationtoken' -H 'Origin: https://127.0.0.1' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.9,nl;q=0.8' -H 'x-api-action-links: actionLinks' -H 'content-type: application/json' -H 'x-api-no-challenge: true' -H 'accept: application/json' -H 'Referer: https://127.0.0.1/c/cluster-zr4bz/nodes/configure' -H "Authorization: Bearer $TOKEN" -H 'Connection: keep-alive' -H 'x-api-csrf: 000050de82' --data-binary '{"type":"clusterRegistrationToken","clusterId":"'$CLUSTERID'"}' --compressed --insecure AGENTTOKEN=`curl 'https://127.0.0.1/v3/clusterregistrationtokens?limit=-1' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.9,nl;q=0.8' -H 'x-api-action-links: actionLinks' -H 'content-type: application/json' -H 'x-api-no-challenge: true' -H 'accept: application/json' -H "Authorization: Bearer $TOKEN" -H 'Connection: keep-alive' -H 'x-api-csrf: 000050de82' --compressed --insecure | jq -r .data[].token` # Generate docker run AGENTIMAGE=`curl -s -k -H "Authorization: Bearer $TOKEN" https://127.0.0.1/v3/settings/agent-image | jq -r .value` CACHECKSUM=`curl -s -k -H "Authorization: Bearer $TOKEN" https://127.0.0.1/v3/settings/cacerts | jq -r .value | sha256sum | awk '{ print $1 }'` ROLEFLAGS="--etcd --controlplane --worker" RANCHERSERVER="https://207.154.250.150" COMMAND="docker run -d --restart=unless-stopped -v /var/run/docker.sock:/var/run/docker.sock --net=host $AGENTIMAGE $ROLEFLAGS --server $RANCHERSERVER --token $AGENTTOKEN --ca-checksum $CACHECKSUM" echo $COMMAND