#!/bin/sh

source ./common.sh

set -ex

# Create a Kubernetes cluster
gcloud beta container clusters create \
  --num-nodes 4 \
  --machine-type n1-standard-8 \
  --min-cpu-platform "Intel Broadwell" \
  --disk-size 30 \
  --zone $ZONE \
  --project $PROJECT \
  $CLUSTER_NAME

# Fetch its credentials so we can use kubectl locally
gcloud container clusters get-credentials --zone $ZONE $CLUSTER_NAME --project $PROJECT

# Import the credentials into the cluster as a secret
kubectl create secret generic ${SERVICE_ACCOUNT}-creds --from-file=service-account.json=${SERVICE_ACCOUNT}-key.json
