Coder Social home page Coder Social logo

akarasateh / kubefwd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from txn2/kubefwd

0.0 0.0 0.0 15.74 MB

Bulk port forwarding Kubernetes services for local development.

Home Page: https://imti.co/kubernetes-port-forwarding/

License: Apache License 2.0

Go 99.78% Dockerfile 0.22%

kubefwd's Introduction

English|δΈ­ζ–‡

Kubernetes port forwarding for local development, Contributions welcome!

kubefwd - kubernetes bulk port forwarding

Build Status GitHub license Go Report Card GitHub release

kubefwd (Kube Forward)

Read Kubernetes Port Forwarding for Local Development for background and a detailed guide to kubefwd. Follow Craig Johnston on Twitter for project updates.

kubefwd is a command line utility built to port forward multiple services within one or more namespaces on one or more Kubernetes clusters. kubefwd uses the same port exposed by the service and forwards it from a loopback IP address on your local workstation. kubefwd temporally adds domain entries to your /etc/hosts file with the service names it forwards.

When working on our local workstation, my team and I often build applications that access services through their service names and ports within a Kubernetes namespace. kubefwd allows us to develop locally with services available as they would be in the cluster.

kubefwd - Kubernetes port forward

kubefwd - Kubernetes Port Forward Diagram

OS

Tested directly on macOS and Linux based docker containers.

MacOs Install / Update

kubefwd assumes you have kubectl installed and configured with access to a Kubernetes cluster. kubefwd uses the kubectl current context. The kubectl configuration is not used. However, its configuration is needed to access a Kubernetes cluster.

Ensure you have a context by running:

kubectl config current-context

If you are running MacOS and use homebrew you can install kubefwd directly from the txn2 tap:

brew install txn2/tap/kubefwd

To upgrade:

brew upgrade kubefwd

Windows Install / Update

scoop install kubefwd

To upgrade:

scoop update kubefwd

Docker

Forward all services from the namespace the-project to a Docker container named the-project:

docker run -it --rm --privileged --name the-project \
    -v "$(echo $HOME)/.kube/":/root/.kube/ \
    txn2/kubefwd services -n the-project

Execute a curl call to an Elasticsearch service in your Kubernetes cluster:

docker exec the-project curl -s elasticsearch:9200

Alternative Installs (tar.gz, RPM, deb, snap)

Check out the releases section on Github for alternative binaries.

Contribute

Fork kubefwd and build a custom version. We welcome any useful pull requests.

Usage

Forward all services for the namespace the-project. Kubefwd finds the first Pod associated with each Kubernetes service found in the Namespace and port forwards it based on the Service spec to a local IP address and port. A domain name is added to your /etc/hosts file pointing to the local IP.

Update

Forwarding of headlesss Service is currently supported, Kubefwd forward all Pods for headless service; At the same time, the namespace-level service monitoring is supported. When a new service is created or the old service is deleted under the namespace, kubefwd can automatically start/end forwarding; Supports Pod-level forwarding monitoring. When the forwarded Pod is deleted (such as updating the deployment, etc.), the forwarding of the service to which the pod belongs is automatically restarted;

sudo kubefwd svc -n the-project

Forward all svc for the namespace the-project where labeled system: wx:

sudo kubefwd svc -l system=wx -n the-project

Help

$ kubefwd svc --help

INFO[20:48:38]  _          _           __             _
INFO[20:48:38] | | ___   _| |__   ___ / _|_      ____| |
INFO[20:48:38] | |/ / | | | '_ \ / _ \ |_\ \ /\ / / _  |
INFO[20:48:38] |   <| |_| | |_) |  __/  _|\ V  V / (_| |
INFO[20:48:38] |_|\_\\__,_|_.__/ \___|_|   \_/\_/ \__,_|
INFO[20:48:38]
INFO[20:48:38] Version 1.11.0
INFO[20:48:38] https://github.com/txn2/kubefwd
INFO[20:48:38]
Forward multiple Kubernetes services from one or more namespaces. Filter services with selector.

Usage:
  kubefwd services [flags]

Aliases:
  services, svcs, svc

Examples:
  kubefwd svc -n the-project
  kubefwd svc -n the-project -l app=wx,component=api
  kubefwd svc -n default -n the-project
  kubefwd svc -n default -d internal.example.com
  kubefwd svc -n the-project -x prod-cluster


Flags:
  -x, --context strings     specify a context to override the current context
  -d, --domain string       Append a pseudo domain name to generated host names.
      --exitonfailure       Exit(1) on failure. Useful for forcing a container restart.
  -h, --help                help for services
  -c, --kubeconfig string   absolute path to a kubectl config file
  -n, --namespace strings   Specify a namespace. Specify multiple namespaces by duplicating this argument.
  -l, --selector string     Selector (label query) to filter on; supports '=', '==', and '!=' (e.g. -l key1=value1,key2=value2).
  -v, --verbose             Verbose output.

Development

Build and Run

Local

go run ./cmd/kubefwd/kubefwd.go

Build Release

Build test release:

goreleaser --skip-publish --rm-dist --skip-validate

Build and release:

GITHUB_TOKEN=$GITHUB_TOKEN goreleaser --rm-dist

License

Apache License 2.0

Sponsor

Open source utility by Craig Johnston, imti blog and sponsored by Deasil Works, Inc.

Similar projects, products, alternatives and complementary utilities

  • inlets - inlets provides an L7 HTTP tunnel for applications through the use of an exit node, it is used by the inlets operator
  • inlets-operator - L4 TCP tunnel, which can tunnel any TCP traffic and is on the roadmap for the inlets-operator
  • telepresence.io - Telepresence substitutes a two-way network proxy for your normal pod running in the Kubernetes cluster.

kubefwd's People

Contributors

cjimti avatar calmkart avatar cedrickring avatar chenrui333 avatar indrayam avatar aude avatar ben-st avatar bradsheppard avatar daveelsensohn avatar jmasud avatar jakereps avatar alrs avatar miles- avatar n-oden avatar bittner avatar rmja avatar alloran avatar cmaster11 avatar rimusz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.