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.
kubefwd helps to enable a seamless and efficient way to develop applications and services on a local workstation. Locally develop applications that intend to interact with other services in a Kubernetes cluster. kubefwd allows applications with connection strings like http://elasticsearch:9200/ or tcp://db:3306 to communicate into the remote cluster. kubefwd can be used to reduce or eliminate the need for local environment specific connection configurations.
Prerequisites
Kubernetes (K8S)
Kubernetes (K8s) is an open-source system for automating deployment, scaling, and management of containerized applications.
Homebrew
Homebrew is the Missing Package Manager for macOS (or Linux).
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.
1
$ sudo kubefwd services -n the-project
Execute a curl call to the service sin your Kubernetes 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 '=', '==', '!=' (e.g. -l key1=value1,key2=value2) and 'in' (e.g. -l "app in (value1, value2)"). -m, --mapping strings Specify a port mapping. Specify multiple mapping by duplicating this argument. -v, --verbose Verbose output.