Skip to content

Commit

Permalink
The cluster name in generate-yaml.sh is now a random string. (#370)
Browse files Browse the repository at this point in the history
This change removes the static name from generate-yaml.sh and instead
generates a random string for the name. The reason for doing this is to
allow the script to be run over and over without failing due to accounts
already existing with the same name and to allow developers to verify
their changes with a more clean environment
  • Loading branch information
spew authored and k8s-ci-robot committed Jun 22, 2018
1 parent 91dabb6 commit a9881d5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion clusterctl/examples/google/generate-yaml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ set -o pipefail
GCLOUD_PROJECT=$(gcloud config get-value project)
ZONE=$(gcloud config get-value compute/zone)
ZONE="${ZONE:-us-central1-f}"
CLUSTER_NAME=test1
# Generate a somewhat unique cluster name, UUID is not an option as service-accounts are limited to 30 characters in length
# and one has a 19 character prefix (i.e. 'machine-controller-'). Of the 11 remaining characters 6 are reserved for the human
# friendly cluster name, one for a dash, and 5 are left for this random string.
RANDOM_STRING=$(head -c5 < <(LC_ALL=C tr -dc 'a-zA-Z0-9' < /dev/urandom) | tr '[:upper:]' '[:lower:]')
# Human friendly cluster name, limited to 6 characters
HUMAN_FRIENDLY_CLUSTER_NAME=test1
CLUSTER_NAME=${HUMAN_FRIENDLY_CLUSTER_NAME}-${RANDOM_STRING}

OUTPUT_DIR=out

Expand Down Expand Up @@ -179,3 +185,5 @@ cat $ADDON_TEMPLATE_FILE \
| sed -e "s/\$CLUSTER_NAME/$CLUSTER_NAME/" \
| sed "s/\$LOADBALANCER_SA_KEY/$LOADBALANCER_SA_KEY/" \
> $ADDON_GENERATED_FILE

echo -e "\nYour cluster name is '${CLUSTER_NAME}'"

0 comments on commit a9881d5

Please sign in to comment.