nsc expose kubernetes
expose kubernetes
opens a public ingress to a Load Balancer. The
provided service needs to be up and running. For example, it can be created
with nsc kubectl expose
within an ephemeral cluster. The exposed endpoint is
encrypted with TLS and secured with Namespace authentication, so whoever has
access to the workspace where the ephemeral environment was created in, will
also have access to the endpoint.
Usage
nsc expose kubernetes <cluster-id> --namespace <name> --service <name> [--name <ingress-name>] [--port <port>]
Example
In the example below, we first create an ephemeral cluster, start nginx with kubectl run
, create a Load Balancer with kubectl expose
and then expose it
using nsc expose kubernetes
.
Create an ephemeral cluster:
$ nsc create
Created new ephemeral environment! ID: 072higp5dg0bg
Start nginx within the created cluster:
nsc kubectl 072higp5dg0bg run nginx --image=nginx
pod/nginx created
And create a Load Balancer:
nsc kubectl 072higp5dg0bg expose pod nginx --type=LoadBalancer --port=80
service/nginx exposed
Afterwards, expose port 80 using the nsc expose kubernetes
command:
$ nsc expose kubernetes 072higp5dg0bg --namespace=default --service=nginx --name=nginx-foobar
Exported port 80 from default/nginx:
https://nginx-foobar-072higp5dg0bg.fra1.namespaced.app
Now you can visit the provided URL https://nginx-foobar-072higp5dg0bg.fra1.namespaced.app in your browser and use your Namespace credentials for authentication.
Options
--namespace <namespace>
Specifies the namespace of the exposed Load Balancer. This option is required.
--service <service>
Specifies the name of the exposed Load Balancer. This option is required.
--name <name>
Set the name of the exposed ingress. By default, ingress names will be generated by Namespace.
--port <port>
In case there are multiple ports exported by the Load Balancer, use this flag to select the port to expose.