> ## 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.

# Access and networking

> Expose ingresses and read SSH, VNC, Kubernetes, and network configuration for Namespace compute instances with the TypeScript SDK.

Once an instance is running, `client.compute` also hands out the configuration needed to reach it: public ingresses, SSH and VNC endpoints, a kubeconfig, and the workspace network configuration.

The examples on this page use a Compute client:

```typescript theme={null}
import { createComputeClient } from "@namespacelabs/sdk/api/compute";

const client = createComputeClient();
```

## `compute.createIngress()`

Expose a backend inside the instance to the public internet, usually to serve HTTPS-terminated traffic from a container running in the instance. See [Ingress](/docs/architecture/networking/ingress) for how Namespace routes and secures this traffic.

<h3 id="compute-createingress-example">
  Example
</h3>

```typescript {1-9} theme={null}
const { allocatedIngresses } = await client.compute.createIngress({
  instanceId,
  ingresses: [
    {
      name: "api",
      exportedPortBackend: { port: 8080 },
    },
  ],
});

console.log(allocatedIngresses[0]?.fqdn);
```

<h3 id="compute-createingress-api-reference">
  API reference
</h3>

```typescript theme={null}
createIngress(
  request: MessageInitShape<typeof CreateIngressRequestSchema>,
  options?: CallOptions,
): Promise<CreateIngressResponse>
```

<h4 id="compute-createingress-arguments-and-options">
  Arguments and options
</h4>

<ResponseField name="instanceId" type="string" required>
  The instance that serves the backend.
</ResponseField>

<ResponseField name="ingresses" type="IngressRequest[]" required>
  The ingresses to create.

  <Expandable title="properties" defaultOpen>
    <ResponseField name="name" type="string" required>
      The ingress name, matching `[a-z0-9]([a-z0-9-_]*[a-z0-9])?`.
    </ResponseField>

    <ResponseField name="exportedPortBackend" type="ExportedPortBackend">
      The backend to route to, as a `port` and an optional `ipAddress` inside the instance.
    </ResponseField>

    <ResponseField name="httpMatchRule" type="HttpMatchRule[]">
      HTTP match rules for the ingress. Each rule carries a `match` and can set `doesNotRequireAuth`.
    </ResponseField>

    <ResponseField name="wildcard" type="boolean">
      Routes all first-level subdomains of the instance wildcard domain to this ingress. Requires the instance to have a wildcard domain.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="compute-createingress-return-value">
  Return value
</h4>

Returns a `CreateIngressResponse` with `allocatedIngresses`. Each `AllocatedIngress` carries the `name` you requested, the allocated `fqdn`, and a `description`.

If the instance does not exist, the call fails with `NotFound`.

***

## `compute.listIngresses()`

List the backends exposed from an instance to the public internet. The response includes ingresses created with `createIngress()` and those exposed declaratively through the Kubernetes ingress manager feature.

<h3 id="compute-listingresses-example">
  Example
</h3>

```typescript {1} theme={null}
const { allocatedIngresses } = await client.compute.listIngresses({ instanceId });

for (const ingress of allocatedIngresses) {
  console.log(ingress.name, ingress.fqdn);
}
```

<h3 id="compute-listingresses-api-reference">
  API reference
</h3>

```typescript theme={null}
listIngresses(
  request: MessageInitShape<typeof ListIngressesRequestSchema>,
  options?: CallOptions,
): Promise<ListIngressesResponse>
```

<h4 id="compute-listingresses-arguments-and-options">
  Arguments and options
</h4>

<ResponseField name="instanceId" type="string" required>
  The instance to list ingresses for.
</ResponseField>

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="compute-listingresses-return-value">
  Return value
</h4>

Returns a `ListIngressesResponse` with `allocatedIngresses`.

If the instance does not exist, the call fails with `NotFound`. If it is already terminated, the call fails with `FailedPrecondition`.

***

## `compute.getSSHConfig()`

Return the configuration needed to open an SSH session to the instance. See [SSH and remote display](/docs/architecture/compute/ssh-remote-display) for what the session supports.

<h3 id="compute-getsshconfig-example">
  Example
</h3>

```typescript {1} theme={null}
const config = await client.compute.getSSHConfig({ instanceId });

console.log(`ssh ${config.username}@${config.endpoint}`);
```

<h3 id="compute-getsshconfig-api-reference">
  API reference
</h3>

```typescript theme={null}
getSSHConfig(
  request: MessageInitShape<typeof GetSSHConfigRequestSchema>,
  options?: CallOptions,
): Promise<GetSSHConfigResponse>
```

<h4 id="compute-getsshconfig-arguments-and-options">
  Arguments and options
</h4>

<ResponseField name="instanceId" type="string" required>
  The instance to provide an SSH configuration for.
</ResponseField>

<ResponseField name="targetContainer" type="string">
  A container name to connect to. The connection endpoint then targets that container.
</ResponseField>

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="compute-getsshconfig-return-value">
  Return value
</h4>

Returns a `GetSSHConfigResponse`.

<ResponseField name="endpoint" type="string">
  The SSH endpoint to connect to. Use it together with `username`.
</ResponseField>

<ResponseField name="username" type="string">
  The username for the session, as in `ssh <username>@<endpoint>`.
</ResponseField>

<ResponseField name="sshPrivateKey" type="Uint8Array">
  When set, a private key that establishes the session. Any key returned here has limited access rights, restricted to a single instance.
</ResponseField>

If the instance does not exist, the call fails with `NotFound`.

***

## `compute.getVNCConfig()`

Return the configuration needed to reach the instance's remote display over VNC.

<h3 id="compute-getvncconfig-example">
  Example
</h3>

```typescript {1} theme={null}
const config = await client.compute.getVNCConfig({ instanceId });

console.log(config.endpoint, config.username);
```

<h3 id="compute-getvncconfig-api-reference">
  API reference
</h3>

```typescript theme={null}
getVNCConfig(
  request: MessageInitShape<typeof GetVNCConfigRequestSchema>,
  options?: CallOptions,
): Promise<GetVNCConfigResponse>
```

<h4 id="compute-getvncconfig-arguments-and-options">
  Arguments and options
</h4>

<ResponseField name="instanceId" type="string" required>
  The instance to provide a VNC configuration for.
</ResponseField>

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="compute-getvncconfig-return-value">
  Return value
</h4>

Returns a `GetVNCConfigResponse` with the `endpoint` exposed by the instance ingress, and the `username` and `password` to use when the VNC server requires authentication.

If the instance does not exist, the call fails with `NotFound`. If it exposes no VNC service, the call fails with `FailedPrecondition`.

<Info>
  The token used to connect to the returned endpoint must also grant access to the instance ingress.
</Info>

***

## `compute.getKubernetesConfig()`

Return a kubeconfig for the Kubernetes cluster running inside the instance.

<h3 id="compute-getkubernetesconfig-example">
  Example
</h3>

```typescript {3} theme={null}
import { writeFile } from "node:fs/promises";

const { kubeconfig } = await client.compute.getKubernetesConfig({ instanceId });

await writeFile("kubeconfig.yaml", kubeconfig);
```

<h3 id="compute-getkubernetesconfig-api-reference">
  API reference
</h3>

```typescript theme={null}
getKubernetesConfig(
  request: MessageInitShape<typeof GetKubernetesConfigRequestSchema>,
  options?: CallOptions,
): Promise<GetKubernetesConfigResponse>
```

<h4 id="compute-getkubernetesconfig-arguments-and-options">
  Arguments and options
</h4>

<ResponseField name="instanceId" type="string" required>
  The instance to read the Kubernetes configuration from.
</ResponseField>

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="compute-getkubernetesconfig-return-value">
  Return value
</h4>

Returns a `GetKubernetesConfigResponse` with `kubeconfig`, the configuration `kubectl` uses to reach Kubernetes inside the instance.

If the instance does not exist, the call fails with `NotFound`. If it is not running Kubernetes, the call fails with `FailedPrecondition`.

***

## `compute.getNetworkConfiguration()`

Return the network configuration of the workspace. Unlike the other methods on this page, it describes the workspace rather than one instance. See [Networking](/docs/architecture/networking) for the wider picture.

<h3 id="compute-getnetworkconfiguration-example">
  Example
</h3>

```typescript {1} theme={null}
const { egress } = await client.compute.getNetworkConfiguration({});

for (const cidr of egress?.egressCidrs ?? []) {
  console.log(cidr.kind, cidr.cidr, cidr.segment);
}
```

<h3 id="compute-getnetworkconfiguration-api-reference">
  API reference
</h3>

```typescript theme={null}
getNetworkConfiguration(
  request: MessageInitShape<typeof GetNetworkConfigurationRequestSchema>,
  options?: CallOptions,
): Promise<GetNetworkConfigurationResponse>
```

<h4 id="compute-getnetworkconfiguration-arguments-and-options">
  Arguments and options
</h4>

The request has no fields. Pass an empty object.

<ResponseField name="options" type="CallOptions">
  Cancellation, timeout, and header options. See [Shared call options](/docs/reference/typescript-sdk/compute/manage#shared-call-options).
</ResponseField>

<h4 id="compute-getnetworkconfiguration-return-value">
  Return value
</h4>

Returns a `GetNetworkConfigurationResponse` whose `egress` carries `egressCidrs`. Each entry has a `kind`, the `cidr` itself, and the `segment` it belongs to. Use these ranges when you need to allow Namespace traffic through a firewall.

## Related documentation

<Columns cols={3}>
  <Card title="Create and manage instances" icon="server" href="/docs/reference/typescript-sdk/compute/manage">
    Create instances and start containers to expose.
  </Card>

  <Card title="Ingress" icon="radio-tower" href="/docs/architecture/networking/ingress">
    How Namespace routes and secures public traffic.
  </Card>

  <Card title="SSH and remote display" icon="terminal" href="/docs/architecture/compute/ssh-remote-display">
    Interactive access to an instance.
  </Card>
</Columns>
