Skip to content

Instantly share code, notes, and snippets.

@gaurish
Last active June 3, 2022 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaurish/1102915dc28ba30c0848362d72c864cd to your computer and use it in GitHub Desktop.
Save gaurish/1102915dc28ba30c0848362d72c864cd to your computer and use it in GitHub Desktop.
#!/bin/bash
shopt -s extdebug
function mothership2() {
CLUSTER=punchh-prod-2
PROFILE=mothership
REGION=us-west-2
NAMESPACE=mothership2
}
function service() {
CLUSTER=punchh-service
PROFILE=service
REGION=us-east-1
NAMESPACE=service
}
function dev(){
CLUSTER=punchh-development
PROFILE=dev
REGION=us-east-1
}
STACK=${1:-mothership2}
FAMILY=${2:-dashboard}
COMMAND=bash
$STACK
if [ -z "$NAMESPACE" ]
then
NAMESPACE=$3
fi
echo connecting to $CLUSTER:$NAMESPACE:$FAMILY on $STACK using credentials from $PROFILE
aws eks update-kubeconfig --name $CLUSTER --region $REGION --profile $PROFILE
container_id=$(kubectl get pods -l app.kubernetes.io/name=$FAMILY --field-selector=status.phase=Running --no-headers -n $NAMESPACE | head -n1 | awk '{print $1}')
kubectl exec -it $container_id -n $NAMESPACE --container $FAMILY -- $COMMAND
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment