Skip to content

Instantly share code, notes, and snippets.

@rujmah
Created November 18, 2022 10:50
Show Gist options
  • Save rujmah/0e0256bf0277119402da68311bab783d to your computer and use it in GitHub Desktop.
Save rujmah/0e0256bf0277119402da68311bab783d to your computer and use it in GitHub Desktop.

Revisions

  1. rujmah created this gist Nov 18, 2022.
    27 changes: 27 additions & 0 deletions setup-kong.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    #!/bin/env bash

    set -e

    RED="\e[31m"
    GREEN="\e[32m"
    YELLOW="\e[33m"
    ENDCOLOR="\e[0m"

    CLUSTER_NAME=$1
    [[ -z "$CLUSTER_NAME" ]] && { echo "${RED}Please specify a CLUSTER NAME: ${YELLOW} . ./setup-kong.sh CLUSTER_NAME ${ENDCOLOR}"; exit 1; }

    echo -e "${GREEN}>>> Setting up Kong dev Env on Cluster ${YELLOW}$CLUSTER_NAME \r\n${ENDCOLOR}"

    aws eks update-kubeconfig --name $CLUSTER_NAME

    export KONG_PROXY=$(kubectl get -o jsonpath="{.status.loadBalancer.ingress[0].hostname}" service -n kong kong-data-plane-kong-proxy)
    export KONG_ADMIN=$(kubectl get -o jsonpath="{.status.loadBalancer.ingress[0].hostname}" service -n kong kong-control-plane-kong-admin)
    export KONG_ADMIN_URL=http://$KONG_ADMIN:8001
    export KONG_PROXY_URL=http://$KONG_PROXY
    export DECK_KONG_ADDR=$KONG_ADMIN_URL

    echo -e "${GREEN}\nthe following env variables were set:\n ${YELLOW}"

    env | ack KONG

    echo -e "${GREEN}\nend\n${ENDCOLOR}"