> ## Documentation Index
> Fetch the complete documentation index at: https://namespace.so/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# nsc expose kubernetes

Expose a Kubernetes Load Balancer.

`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 instance. 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.

**Note**: Only HTTP services can currently be exposed.

## Usage

```bash theme={null}
nsc expose kubernetes <instance-id> --namespace <name> --service <name> [--name <ingress-name>] [--port <port>] [--output <plain|json>] [--wait] [--wildcard] [--ingress <rules>]
```

### Example

In the example below, we first create an ephemeral instance, start nginx with `kubectl run`, create a Load Balancer with `kubectl expose` and then expose it
using `nsc expose kubernetes`.

<Steps titleSize="h4">
  <Step title="Create an ephemeral instance">
    Create an ephemeral instance and note its ID:

    ```bash theme={null}
    nsc create
    ```

    ```text nocopy Output theme={null}
    Created new ephemeral environment! ID: 072higp5dg0bg
    ```
  </Step>

  <Step title="Start nginx">
    Start nginx within the created instance:

    ```bash theme={null}
    nsc kubectl 072higp5dg0bg run nginx --image=nginx
    ```

    ```text nocopy Output theme={null}
    pod/nginx created
    ```
  </Step>

  <Step title="Create a load balancer">
    Expose the nginx pod through a Kubernetes load balancer:

    ```bash theme={null}
    nsc kubectl 072higp5dg0bg expose pod nginx --type=LoadBalancer --port=80
    ```

    ```text nocopy Output theme={null}
    service/nginx exposed
    ```
  </Step>

  <Step title="Expose port 80">
    Expose port 80 using `nsc expose kubernetes`:

    ```bash theme={null}
    nsc expose kubernetes 072higp5dg0bg --namespace=default --service=nginx --name=nginx-foobar
    ```

    ```text nocopy Output theme={null}
    Exported port 80 from default/nginx:
      https://nginx-foobar-072higp5dg0bg.fra1.namespaced.app
    ```
  </Step>

  <Step title="Visit the exposed endpoint">
    Visit **[https://nginx-foobar-072higp5dg0bg.fra1.namespaced.app](https://nginx-foobar-072higp5dg0bg.fra1.namespaced.app)**
    in your browser and use your Namespace credentials for authentication.
  </Step>
</Steps>

## Options

<h3 id="--namespace-namespace">
  \--namespace \<namespace>
</h3>

Specifies the namespace of the exposed Load Balancer. This option is required.

<h3 id="--service-service">
  \--service \<service>
</h3>

Specifies the name of the exposed Load Balancer. This option is required.

<h3 id="--name-name">
  \--name \<name>
</h3>

Set the name of the exposed ingress. By default, ingress names will be generated by Namespace.

<h3 id="--port-port">
  \--port \<port>
</h3>

In case there are multiple ports exported by the Load Balancer, use this flag to select the port to expose.

<h3 id="--output--o-type">
  \--output, -o \<type>
</h3>

Specifies the output format. Supported options are `json` and
`plain`. By default, plain output format is used.

<h3 id="--wait">
  \--wait
</h3>

Wait until the provided service has a valid ingress to expose.

<h3 id="--ingress-rules">
  \--ingress \<rules>
</h3>

Specify additional rules per ingress. The following effects can be set per
route:

* `noauth`: Disables authentication on the route.

Rules are defined by specifying method, path regex, using one of the following schemes:

* `<effect>`: Applies effect to any method or path.
* `<path_regex>:<effect>`: Applies effect to paths that match `path_regex` (the full path without the query is using for matching.).
* `<method>[,<method>,...]:<path_regex>:<effect>`: In addition to matching path, also matches against the HTTP method used.

<h3 id="--wildcard">
  \--wildcard
</h3>

Expose the service load balancer under a wildcard ingress.
The hosting instance needs to be configured to support wildcard ingresses.
