# cloider target command reference

> Reference for cloider target, to route a domain's paths to apps, Kubernetes services or bucket websites, list routes, change a route and delete it.

`cloider target` routes traffic on your [domains](/domains/targets) to where it should go. A **target** maps a path on a domain, such as `example.com/` or `example.com/api`, to one of your apps, to a Service in one of your Kubernetes clusters, or to a bucket's [static website](/object-storage/static-websites). Cloider serves the domain over HTTPS and forwards each request to the matching target.

```text
cloider target <command> [flags]
```

**Alias:** `cloider targets`. Targets are named by their id, which `cloider target list <domain> -o wide` shows.

## Subcommands

| Command | Description |
| --- | --- |
| [`cloider target list`](#cloider-target-list) | List a domain's targets |
| [`cloider target create`](#cloider-target-create) | Route a path of a domain to an app, a bucket website or a cluster service, or a domain to a LoadBalancer |
| [`cloider target update`](#cloider-target-update) | Change a target, keeping what isn't given |
| [`cloider target delete`](#cloider-target-delete) | Delete a target |

All subcommands also take the [global flags](/cli/configuration#global-flags).

## Target flags

`create` and `update` take the same flags:

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--app` | string | | Route to this app (name or id) |
| `--bucket` | string | | Serve this bucket's website (name or id), at the domain's root. The bucket's website must be on, and `--path` must be `/` |
| `--cluster` | string | | Route to a service in this cluster (name or id). `--app`, `--bucket` and `--cluster` can't be combined |
| `--service` | string | | The cluster service, as `<namespace>/<service>`, for example `default/web` |
| `--loadbalancer` | string | | With `--cluster`, point the whole custom domain at this LoadBalancer's IP with an A record, as `<namespace>/<service>`. Can't be combined with `--service`, `--port`, `--protocol`, `--app` or `--bucket`, and `--path` must be `/`. See [Point a domain at a LoadBalancer](/domains/targets#point-a-domain-at-a-loadbalancer) |
| `--port` | int | the service's only port | The service port. Required when the service has several |
| `--protocol` | string | the port's own | `TCP` or `UDP` |
| `--path` | string | `/` | Path on the domain to route |
| `--target-path` | string | `--path` | Path the request reaches the target with |

The services you can route to are listed by [`cloider cluster services`](/cli/commands/cluster#cloider-cluster-services).

## cloider target list

List a domain's targets.

```text
cloider target list <domain> [flags]
```

**Alias:** `cloider target ls`.

```bash
cloider target list example.com -o wide
```

```text title="Output"
ID      ROUTE             TARGET                     TARGET PATH   PROTOCOL
t4k9x   example.com/      app web                    /             -
m2p8q   example.com/api   production/shop/api:8080   /             TCP
```

**ROUTE** is the domain and path; **TARGET** is `app <name>`, `website of bucket <name>`, `<cluster>/<namespace>/<service>:<port>` or `lb <cluster>/<namespace>/<service> (<ip>)`; **TARGET PATH** is the path the request arrives at the target with. Without `-o wide`, the **ID** column is hidden; `-q` prints ids. `cloider domain get` shows the same table. The MCP server has no separate list tool; agents read targets from `get_domain`.

## cloider target create

Route a path of a domain to an app, a bucket website or a cluster service, or a domain to a LoadBalancer.

```text
cloider target create <domain> [flags]
```

Route a free subdomain to an app:

```bash
cloider target create blog.cloider.app --app blog
```

```text title="Output"
✓ Routed blog.cloider.app/ to the app
```

Serve a bucket's [static website](/object-storage/static-websites) on a domain:

```bash
cloider target create docs.example.com --bucket acme-site
```

```text title="Output"
✓ Routed docs.example.com/ to the bucket's website
```

Route `/api` on a custom domain to a Service in a cluster, stripping the prefix:

```bash
cloider target create example.com --cluster production --service shop/api --port 8080 --path /api --target-path /
```

```text title="Output"
✓ Routed example.com/api to production/shop/api:8080
```

Point a custom domain at a LoadBalancer Service, for any port and protocol. The domain can have no other targets, and Cloider issues no certificate for it: you manage the ingress controller or Gateway API, routes and TLS behind the LoadBalancer, see [Point a domain at a LoadBalancer](/domains/targets#point-a-domain-at-a-loadbalancer):

```bash
cloider target create play.example.com --cluster production --loadbalancer games/server
```

```text title="Output"
✓ Routed play.example.com/ to LoadBalancer games/server
```

The CLI checks the cluster's services first: an unknown service fails with exit code `4` (``no service shop/api in cluster production, see `cloider cluster services` ``), and a service with several ports needs `--port` (`shop/api has several ports (8080/TCP, 9090/TCP), pick one with --port`). Without `--app`, `--bucket` or `--cluster` it fails with `say where to route to with --app, --bucket or --cluster`. See [Targets](/domains/targets) and [Expose services](/kubernetes/expose-services). MCP tool: `create_domain_target`.

## cloider target update

Change a target's path, target path or destination. What you don't pass is kept. If the path and target path were the same, changing `--path` changes both.

```text
cloider target update <domain> <target-id> [flags]
```

```bash
cloider target update example.com m2p8q --path /v2
cloider target update example.com t4k9x --app blog
cloider target update example.com t4k9x --bucket acme-site
cloider target update example.com m2p8q --port 9090
```

```text title="Output"
✓ Updated example.com/v2 to production/shop/api:8080
```

To move an app target to a cluster service, give `--cluster` and `--service`; `--service`, `--port` or `--protocol` alone on an app target fail with `this target routes to an app, give --cluster to route it to a service instead`, on a bucket target with `this target serves a bucket website, give --cluster to route it to a service instead`, and on a LoadBalancer target with `this target points at a LoadBalancer, give --cluster to route it to a service instead`. `--loadbalancer` without `--cluster` uses the cluster a cluster or LoadBalancer target already routes to; a target at a path other than `/` needs `--path /` with it. `--bucket` moves a target to a bucket's website, which works only for a target whose path is `/`. MCP tool: `update_domain_target`.

## cloider target delete

Delete a target. Its route stops answering.

```text
cloider target delete <target-id> [flags]
```

**Alias:** `cloider target rm`. Unlike `update`, `delete` takes only the target's id. It asks `Delete target ...? Its route stops answering. [y/N]`; pass `--yes` to skip it.

```bash
cloider target delete m2p8q --yes
```

```text title="Output"
✓ Deleted target m2p8q
```

MCP tool: `delete_domain_target`.

## Related

- [Targets](/domains/targets) and [Expose services](/kubernetes/expose-services)
- [`cloider domain`](/cli/commands/domain) and [`cloider cluster services`](/cli/commands/cluster#cloider-cluster-services)
- [Terraform `cloider_target`](/terraform/resources/target)
