Skip to content

Commit

Permalink
Create scripts that manage creation and connection to CAPI Developmen…
Browse files Browse the repository at this point in the history
…t kubernetes

cluster

#38
fixes #38

Co-authored-by: Seth Boyles <[email protected]>
Co-authored-by: Marc Paquette <[email protected]>
  • Loading branch information
sethboyles and MarcPaquette committed May 19, 2021
1 parent 94224ff commit da817b1
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
22 changes: 22 additions & 0 deletions bin/capi-workspaces
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e
pods=$(kubectl get pods -l workstation=true -o name | cut -d / -f 2)
PS3="Please select your workstation pod or press 'q' to quit: "
OLD_IFS=$IFS
IFS=$'\n'
select pod in $pods; do
POD=$pod
break
done

IFS=$OLD_IFS

if [ -z "${POD}" ]; then
echo "No pod selected. Goodbye"
exit
fi
echo "Running 'kubectl exec --stdin --tty $pod -- /bin/bash'"
echo ""
echo ""
kubectl exec --stdin --tty "$pod" -- /bin/bash
28 changes: 28 additions & 0 deletions bin/create-capi-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -x

CURRENT_CONTEXT=$(kubectl config current-context)
HAS_CONTEXT=$?
if [ $HAS_CONTEXT -ne 0 ] || [ $CURRENT_CONTEXT != "gke_cf-capi-arya_us-central1-c_capi-workstation" ]
then
echo "The current Kubernetes context is not set to CAPI's cluster."
echo "Please run: gcloud container clusters get-credentials capi-workstation --zone us-central1-c"
exit "1"
fi

set -ex

echo "What would you like to call your workstation?"

read -r STORY_ID

kubectl create deployment $STORY_ID --image=cloudfoundry/capi:capi-workstation-test

#if the above is successful
kubectl label pods -l app="$STORY_ID" workstation=true

POD_NAME=$(kubectl get pod -l app=$STORY_ID -o name | cut -f 2 -d /)

echo "Please connect to your workstation via the following command:"
echo "kubectl exec --stdin --tty $POD_NAME -- /bin/bash"

0 comments on commit da817b1

Please sign in to comment.