---
# System prepended metadata

title: Environments

---

# Environments

```console
$ rudr env init -n test
$ rudr env test # switch to test environment

$ rudr env init -n prod

    Do you want to use *prod* as production environment? (y/n)
    > yes
    Environment *prod* is protected!
```

# Basic Usage

## Run Workload

```console
$ rudr deployment:run frontend -i nginx
```

> or docker style: $ rudr deployment run -n frontend -i nginx

## List and Show


```console
$ rudr ls

NAME      WORKLOAD
frontend  deployment.apps.k8s.io
```

```console
$ rudr show frontend
```

## Apply Trait

```console
$ rudr scale frontend -n 100
$ rudr scale frontend --detach
```

# Advanced Usage

## Initialize, apply and Run

```console
$ rudr deployment:init frontend -i nginx

$ rudr node-affinity frontend --labels az=west2

$ rudr deployment:run frontend
```

## Enable deployment manifest

Execute `rudr deploy init` in your project folder so that manifest will be auto generated.

```console
$ rudr deploy:init demo
### this is a CUE template of AppConfig
deploy.yaml

### with context, deploy.yaml updated
$ rudr deployment:run frontend -i nginx

### with context, deploy.yaml updated
$ rudr scale frontend -min 1 -max 100
```

### GitOps

Skip ...

### Multiple components in one deploy
```console
### In your project folder

$ rudr deploy:init demo

$ rudr deployment:init frontend -i nginx
$ rudr scale frontend -n 100 

$ rudr statefulset:init backend -i redis
$ rudr scale backend -n 3

$ rudr deploy:up demo

$ rudr deploy:ls
$ rudr deploy:show demo


$ rudr ls
$ rudr show frontend
```

#### Generate manifest for app

```console
$ rudr deploy:manifest frontend -o yaml
```

# Naming is hard!

```yaml
app = Instantiate(workload,{trait1,trait2...})
deploy = {app1,app2...} ### easy to understand, deploy confuse with k8s deployment

component = Instantiate(workload,{trait1,trait2...})
app = {comp1,comp2...} ### most accurate, bad story for `rudr ls`

workload = Instantiate(workloadType,{trait1,trait2...})
app = {workload1,workload2...} ### easy to understand, bad story for `rudr workloads`

svc = Instantiate(workload,{trait1,trait2...})
app = {svc1,svc2...} ### easy to undertand, bad story for `rudr ls`
```