Skip to content

Instantly share code, notes, and snippets.

@tuxfight3r
Last active October 11, 2024 07:13
Show Gist options
  • Save tuxfight3r/b867caf997eaf6eddb972766dda79e87 to your computer and use it in GitHub Desktop.
Save tuxfight3r/b867caf997eaf6eddb972766dda79e87 to your computer and use it in GitHub Desktop.

Revisions

  1. tuxfight3r revised this gist Jan 21, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion jump.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    #!/usr/bin/env bash

    # Allows you to connect to remote endpoints via port forward
    set -e

    TEMP_POD_NAME=db-jump-server
  2. tuxfight3r created this gist Jan 21, 2022.
    18 changes: 18 additions & 0 deletions jump.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/usr/bin/env bash

    set -e

    TEMP_POD_NAME=db-jump-server
    LOCAL_PORT=3307
    REMOTE_HOST=prod.abc123.region-1.rds.amazonaws.com
    REMOTE_PORT=3306

    function cleanup {
    echo ""
    kubectl delete pod/$TEMP_POD_NAME --grace-period 1 --wait=false
    }
    trap cleanup EXIT

    kubectl run --restart=Never --image=alpine/socat $TEMP_POD_NAME -- -d -d tcp-listen:$REMOTE_PORT,fork,reuseaddr tcp-connect:$REMOTE_HOST:$REMOTE_PORT
    kubectl wait --for=condition=Ready pod/$TEMP_POD_NAME
    kubectl port-forward pod/$TEMP_POD_NAME $LOCAL_PORT:$REMOTE_PORT