gke with terraform, dataproc with terraform
One may install gcloud sdk silently for all users as root with access to GCLOUD_HOME for only speficic user:
export USERNAME="<<you_user_name>>"
export SHARE_DATA=/data
su -c "export SHARE_DATA=/data && export CLOUDSDK_INSTALL_DIR=$SHARE_DATA export CLOUDSDK_CORE_DISABLE_PROMPTS=1 && curl https://sdk.cloud.google.com | bash" $USER_NAME
OR
export SHARE_DATA=/data && export CLOUDSDK_INSTALL_DIR=$SHARE_DATA export CLOUDSDK_CORE_DISABLE_PROMPTS=1 && curl https://sdk.cloud.google.com | bash
echo "source $SHARE_DATA/google-cloud-sdk/path.bash.inc" >> /etc/profile.d/gcloud.sh
echo "source $SHARE_DATA/google-cloud-sdk/completion.bash.inc" >> /etc/profile.d/gcloud.sh
terraform init && terraform plan -out "run.plan" && terraform apply "run.plan"
. Please note the tags name prompted during plan may be dev/tst or any other stage.Prompted variables | Expected value |
---|---|
cluster_name | Name of the GKE Cluster |
cluster_location | us-central1 or europe-west2 (UK) or europe-west4 (NL) any other region |
node_count | master count - 1 master is to three minimum workers e.g: 1 |
master_auth_username | admin |
master_auth_password | 16 letters and strong like e.g: !@#olie!@#olie!@#23D# |
cluster_tag | gke_devor gke_tst or gke_uat or gke_prod |
project | The GCP project name |
### Automatic Provisioning
https://github.com/cloudgear-io/gke-terraform
Pre-req:
gcloud should be installed. Silent install is -
export $USERNAME="<<you_user_name>>" && export SHARE_DATA=/data && su -c "export SHARE_DATA=/data && export CLOUDSDK_INSTALL_DIR=$SHARE_DATA export CLOUDSDK_CORE_DISABLE_PROMPTS=1 && curl https://sdk.cloud.google.com | bash" $USER_NAME && echo "source $SHARE_DATA/google-cloud-sdk/path.bash.inc" >> /etc/profile.d/gcloud.sh && echo "source $SHARE_DATA/google-cloud-sdk/completion.bash.inc" >> /etc/profile.d/gcloud.sh &&
Plan:
terraform init && terraform plan -var cluster_location=us-west1 -var cluster_name=devgkeclus -var cluster_tag=devgkeuswest -var master_auth_password=\!@#olie\!@#olie\!@#23D# -var master_auth_username=admin -var node_count=1 -var project=<<your-google-cloud-project-name>> -out "run.plan"
Apply:
terraform apply "run.plan"
Destroy:
terraform destroy -var cluster_location=us-west1 -var cluster_name=devgkeclus -var cluster_tag=devgkeuswest -var master_auth_password=\!@#olie\!@#olie\!@#23D# -var master_auth_username=admin -var node_count=1 -var project=<<your-google-cloud-project-name>>
Please report bugs by opening an issue in the GitHub Issue Tracker. Bugs have auto template defined. Please view it here
Patches can be submitted as GitHub pull requests. If using GitHub please make sure your branch applies to the current master as a ‘fast forward’ merge (i.e. without creating a merge commit). Use the git rebase
command to update your branch to the current master if necessary.