Created
March 18, 2020 22:24
-
-
Save anax32/0a93ab3bd032024a5d3ab97306eb9318 to your computer and use it in GitHub Desktop.
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 characters
#!/bin/bash -u | |
# | |
# create a GKE cluster with | |
# + a windows node pool, | |
# + a linux node pool, and | |
# + a gpu node pool | |
# | |
CLUSTER_NAME="mixed-os-cluster" | |
NODE_POOL_WIN_VM="node-pool-win-vm" | |
NODE_POOL_LNX_VM="node-pool-lnx-vm" | |
NODE_POOL_GPU_VM="node-pool-gpu-vm" | |
ZONE="europe-west2-a" | |
gcloud beta container clusters \ | |
create \ | |
${CLUSTER_NAME} \ | |
--enable-ip-alias \ | |
--release-channel=rapid \ | |
--zone ${ZONE} \ | |
--node-taints my-taint/node=default:NoSchedule | |
# | |
# standard linux node pool | |
# | |
gcloud container node-pools \ | |
create \ | |
${NODE_POOL_LNX_VM} \ | |
--cluster=${CLUSTER_NAME} \ | |
--machine-type=n1-standard-8 \ | |
--zone=${ZONE} \ | |
--node-taints my-taint/node=linux:NoSchedule | |
# | |
# windows node pool | |
# | |
# https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster-windows | |
# NB: [IMAGE_TYPE] is either WINDOWS_SAC or WINDOWS_LTSC. | |
# To run on GKE, Windows Server container images need to be built on Windows Server version 2019 (LTSC) or Windows Server version 1909 (SAC). | |
gcloud container node-pools \ | |
create \ | |
${NODE_POOL_WIN_VM} \ | |
--cluster=${CLUSTER_NAME} \ | |
--image-type="WINDOWS_LTSC" \ | |
--enable-autoupgrade \ | |
--machine-type=n1-standard-16 \ | |
--zone ${ZONE} \ | |
--node-taints my-taint/node=windows:NoSchedule | |
# | |
# gpu node pool | |
# | |
GPU_TYPE=$(gcloud compute accelerator-types list | grep ${ZONE} | head -n 1 | cut -f1 -d" ") | |
gcloud container node-pools \ | |
create \ | |
${NODE_POOL_GPU_VM} \ | |
--accelerator type=${GPU_TYPE},count=1 \ | |
--cluster ${CLUSTER_NAME} \ | |
--zone ${ZONE} \ | |
--node-taints my-taint/node=gpu:NoSchedule | |
# | |
# get creds | |
# | |
gcloud container clusters \ | |
get-credentials \ | |
${CLUSTER_NAME} \ | |
--zone ${ZONE} | |
# list the nodes | |
kubectl get nodes | |
# list the taints | |
kubectl get nodes -o json | jq '.items[].spec.taints' | |
# delete the cluster | |
gcloud container node-pools delete ${NODE_POOL_GPU_VM} --cluster ${CLUSTER_NAME} --zone ${ZONE} --quiet | |
gcloud container node-pools delete ${NODE_POOL_WIN_VM} --cluster ${CLUSTER_NAME} --zone ${ZONE} --quiet | |
gcloud container node-pools delete ${NODE_POOL_LNX_VM} --cluster ${CLUSTER_NAME} --zone ${ZONE} --quiet | |
gcloud container clusters delete ${CLUSTER_NAME} --zone ${ZONE} --quiet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment