kube-relay

command module
v0.0.0-...-7e2d15d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2022 License: MIT Imports: 16 Imported by: 0

README

kube-relay

Small CLI tool to proxy tcp connections from local to resources in k8s network (e.g. databases or resource in other namespaces that you cannot access directly or via kubectl port-forward). It will spawn a pod with socat to use as relay and connect to that pod via kubernetes' port-forwarding facility.

                   ┌───────────────────────────────┐
                   │                               │
                   │  kubernetes cluster network   │
                   │                               │
   ┌───────────┐   │  ┌─────────┐     ┌─────────┐  │
   │           │   │  │         │     │         │  │
   │           │   │  │ relay   │     │ cluster │  │
   │ localhost ├───┼─►│         ├────►│         │  │
   │           │   │  │ pod     │     │ service │  │
   │           │   │  │         │     │         │  │
   └─────┬─────┘   │  └─────────┘     └─────────┘  │
                   │                        ▲      │
         │         └────────────────────────┼──────┘
                                             
         └ ── ── ── ── ── ── ── ── ── ── ── ┘

Build

Tested with Go v1.17 on Linux and MacOS.

go mod tidy
go build

Run

./kube-relay -ch some-service.my-namespace
Created pod "kube-relay"
Pod "kube-relay" is running
Forwarding from 127.0.0.1:1999 -> 9000
Forwarding from [::1]:1999 -> 9000

Test in another shell

curl localhost:1999/health
{"status":"OK"}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL