Giter Club home page Giter Club logo

k8s-net-expose's Introduction

Kubernetes net-expose

Expose your Kubernetes resources to the world!

You have created a Kubernetes cluster at home with k3sup, or you are using a Minikube instance. You have created your Pod, your Deployment or Service and your are ready to publicly test it.

Exposing your deployment to the Internet is not so trivial though!

How to install

To install net-expose through Helm you need to add this git repository as a helm repo:

helm repo add net-expose https://raw.githubusercontent.com/operatorequals/k8s-net-expose/master/charts/stable
helm repo update

helm install nginx-ingress net-expose/net-expose \
	--set ssh.host=ssh-connect.example.com \
	--set ssh.user=admin \
	--set-file ssh.key=~/.ssh/id_rsa \
	--set remotePort=8080 \
	--set k8sExportService.name=nginx-ingress-controller \
	--set k8sExportService.port=80

What it does

Exposes internal Kubernetes resources (anything with an IP and port) to public VPS hosts. You only need a working SSH key for the VPS. The rest is on net-expose.

generic-schematic

How it works

The net-expose deployment consists of a Kubernetes Pod with just enough privileges to remotely SSH to a VPS and establish a reverse SSH proxy, redirecting VPS port traffic to the internal Kubernetes resource (Pod or Service) to be exposed, making it accessible through the initial VPS port.

generic-schematic-deep

The SSH server catch of GatewayPorts option

OpenSSH server does not allow reverse tunnels to expose ports to all interfaces by default (only to localhost). To enable this the GatewayPorts has to be set to yes in the /etc/ssh/sshd_config as below:

[...]
GatewayPorts yes
[...]

To automate this process the gatewayports_test.sh can be used as below:

 ssh -i id_rsa REMOTE_HOST -l root ' sudo sh -s '  < gatewayports_test.sh

To apply the change the SSH server needs a restart.

The gatewayports initContainer

A K8s initContainer can be created from the Helm release to automatically run the gatewayports_test.sh towards the remote host and restart the SSH server before creating the connection tunnel. To enable this feature the gatewayports.enable needs to be set to true in the Helm values.yaml as below:

helm install nginx-ingress net-expose/net-expose \
[...]
	--set gatewayports.enable=true

k8s-net-expose's People

Contributors

operatorequals avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

domingosol

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.