Last active
January 11, 2025 23:24
-
-
Save jdbohrman/714bb13d8b8404f647174d9132f5f320 to your computer and use it in GitHub Desktop.
Revisions
-
jdbohrman renamed this gist
Jan 16, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jdbohrman revised this gist
Jan 14, 2020 . 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,7 +1,7 @@ #!/bin/bash -x export curl export jq export RANCHER_IP=34.70.139.14 export CLUSTER_NAME=test-cluster-new export OUTPUT_DIR=/var/lib/rancher/k3s/server/manifests -
jdbohrman revised this gist
Jan 14, 2020 . 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,7 +1,7 @@ #!/bin/bash -x export curl export jq export RANCHER_IP=# CHANGE ME export CLUSTER_NAME=test-cluster-new export OUTPUT_DIR=/var/lib/rancher/k3s/server/manifests -
jdbohrman revised this gist
Jan 14, 2020 . 1 changed file with 17 additions and 26 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,45 +1,36 @@ #!/bin/bash -x export curl export jq export RANCHER_IP=34.70.139.14 export CLUSTER_NAME=test-cluster-new export OUTPUT_DIR=/var/lib/rancher/k3s/server/manifests while true; do curl -sLk https://${RANCHER_IP}/ping && break sleep 5 done while true; do LOGIN_RESPONSE=$(curl -s "https://$RANCHER_IP/v3-public/localProviders/local?action=login" -H 'content-type: application/json' --data-binary '{"username":"admin","password":"rancher"}' --insecure) LOGIN_TOKEN=$(echo $LOGIN_RESPONSE | jq -r .token) echo "$LOGIN_TOKEN" if [ "$LOGIN_TOKEN" != "null" ]; then break else sleep 5 fi done # Create API key API_RESPONSE=$(curl -s "https://$RANCHER_IP/v3/token" -H 'content-type: application/json' -H "Authorization: Bearer $LOGIN_TOKEN" --data-binary '{"type":"token","description":"automation"}' --insecure) # Extract and store token API_TOKEN=`echo $API_RESPONSE | jq -r .token` # Configure server-url RANCHER_SERVER_URL="https://$RANCHER_IP/latest/meta-data/public-ipv4" curl -s 'https://$RANCHER_IP/v3/settings/server-url' -H 'content-type: application/json' -H "Authorization: Bearer $API_TOKEN" -X PUT --data-binary '{"name":"server-url","value":"'$RANCHER_SERVER_URL'"}' --insecure # Create cluster CLUSTER_RESPONSE=$(curl -s "https://$RANCHER_IP/v3/cluster" -H 'content-type: application/json' -H "Authorization: Bearer $API_TOKEN" --data-binary '{"dockerRootDir":"/var/lib/docker","enableNetworkPolicy":false,"type":"cluster","rancherKubernetesEngineConfig":{"addonJobTimeout":30,"ignoreDockerVersion":true,"sshAgentAuth":false,"type":"rancherKubernetesEngineConfig","authentication":{"type":"authnConfig","strategy":"x509"},"network":{"type":"networkConfig","plugin":"canal"},"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":"'$CLUSTER_NAME'"}' --insecure) # Extract clusterid to use for generating the docker run command CLUSTER_ID=`echo $CLUSTER_RESPONSE | jq -r .id` # Generate registrationtoken CLUSTER_JSON=$(curl -s "https://$RANCHER_IP/v3/clusterregistrationtoken" -H 'content-type: application/json' -H "Authorization: Bearer $API_TOKEN" --data-binary '{"type":"clusterRegistrationToken","clusterId":"'$CLUSTER_ID'"}' --insecure) CLUSTER_TOKEN=`echo $CLUSTER_JSON | jq -r .token` curl -o $OUTPUT_DIR/cattle-agent.yaml "https://$RANCHER_IP/v3/import/$CLUSTER_TOKEN.yaml" --insecure -
jdbohrman revised this gist
Jan 14, 2020 . 1 changed file with 4 additions and 4 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 @@ -12,7 +12,7 @@ done while true; do LOGINRESPONSE=$(curl -s 'https://34.70.139.14/v3-public/localProviders/local?action=login' -H 'content-type: application/json' --data-binary '{"username":"admin","password":"rancher"}' --insecure) LOGINTOKEN=$(echo $LOGINRESPONSE | jq -r .token) echo "$LOGINTOKEN" if [ "$LOGINTOKEN" != "null" ]; then @@ -23,16 +23,16 @@ while true; do done # Change password curl -s 'https://34.70.139.14/v3/users?action=changepassword' -H 'content-type: application/json' -H "Authorization: Bearer $LOGINTOKEN" --data-binary '{"currentPassword":"rancher","newPassword":"${admin_password}"}' --insecure # Create API key APIRESPONSE='$(curl -s 'https://34.70.139.14/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` # Configure server-url RANCHER_SERVER="https://$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)" curl -s 'https://34.70.139.14/v3/settings/server-url' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" -X PUT --data-binary '{"name":"server-url","value":"'$RANCHER_SERVER'"}' --insecure # Create cluster -
jdbohrman created this gist
Jan 14, 2020 .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,45 @@ #!/bin/bash -x export curl export jq export DEBIAN_FRONTEND=noninteractive while true; do curl -sLk https://34.70.139.14/ping && break sleep 5 done while true; do LOGINRESPONSE=$(curl -s 'https://34.70.139.14/v3-public/localProviders/local?action=login' -H 'content-type: application/json' --data-binary '{"username":"jdbohrman","password":"Flatbush2016"}' --insecure) LOGINTOKEN=$(echo $LOGINRESPONSE | jq -r .token) echo "$LOGINTOKEN" if [ "$LOGINTOKEN" != "null" ]; then break else sleep 5 fi done # Change password curl -s 'https://34.70.139.14/v3/users?action=changepassword' -H 'content-type: application/json' -H "Authorization: Bearer $LOGINTOKEN" --data-binary '{"currentPassword":"Flatbush2016","newPassword":"${admin_password}"}' --insecure # Create API key APIRESPONSE=$(curl -s 'https://34.70.139.14/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` # Configure server-url RANCHER_SERVER="$(curl -s http://169.254.169.254/latest/meta-data/public-ipv4)" curl -s 'https://34.70.139.14/v3/settings/server-url' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" -X PUT --data-binary '{"name":"server-url","value":"'$RANCHER_SERVER'"}' --insecure # Create cluster CLUSTERRESPONSE=$(curl -s 'https://34.70.139.14/v3/cluster' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" --data-binary '{"dockerRootDir":"/var/lib/docker","enableNetworkPolicy":false,"type":"cluster","rancherKubernetesEngineConfig":{"addonJobTimeout":30,"ignoreDockerVersion":true,"sshAgentAuth":false,"type":"rancherKubernetesEngineConfig","authentication":{"type":"authnConfig","strategy":"x509"},"network":{"type":"networkConfig","plugin":"canal"},"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":"${cluster_name}"}' --insecure) # Extract clusterid to use for generating the docker run command CLUSTERID=`echo $CLUSTERRESPONSE | jq -r .id` # Generate registrationtoken curl -s 'https://34.70.139.14/v3/clusterregistrationtoken' -H 'content-type: application/json' -H "Authorization: Bearer $APITOKEN" --data-binary '{"type":"clusterRegistrationToken","clusterId":"'$CLUSTERID'"}' --insecure