CLI Reference

November 4, 2020 ยท View on GitHub

Table of Contents

attach

Attach to a process running in a container

Usage
rio attach [OPTIONS] CONTAINER
Options
flagaliasesdescriptiondefault
--timeout valueTimeout waiting for the container to be created to attach to1m
--pod valueSpecify pod, default is first pod found
Examples
rio attach demo

rio attach --timeout 30s --pod mydemopod demo

build

Build a docker image using buildkitd

Usage
rio build command [command options] [arguments...]
Options
flagaliasesdescriptiondefault
--file value-fName of the file to look for build, support both Riofile and Dockerfile
--tag value-tName and optionally a tag in the 'name:tag' format
--build-argSet build-time variables
--no-cacheDo not use cache when building the image
--help-hshow help
Examples

# Navigate to directory with Dockerfile and build it into local registry
rio build -t test:v1

# See image that was build
rio image

# Build from riofile insted
rio build -t test:v1 --no-cache -f Riofile.yaml

# Now run the image
rio run -n test -p 8080 localhost:5442/default/test:v1

# Build the image again with new tag
rio build -t test:v2

# Now stage the 2nd image
rio stage --image localhost:5442/default/test:v2 test v2

build-history

Show previous builds

Usage
rio build-history [command options] [arguments...]
Options
flagaliasesdescriptiondefault
--quiet-qOnly display Names
--format value'json' or 'yaml' or Custom format: {{ "'{{.Obj.Name}}'" }} [$FORMAT]
Examples
# see previous builds from stacks or workloads
rio build-history

# custom output format
rio build-history --format {{ "{{.Obj.Name}}" }}

cat

Print the contents of a config

Usage
rio cat [OPTIONS] [NAME...]
Options
flagaliasesdescriptiondefault
--key-kThe values which to cat
Examples
# cat a configmap
rio cat configmap/config-foo

# cat a key from a configmap
rio cat --key=a configmap/config-foo

dashboard

Open the dashboard in a browser

Usage
rio dashboard [OPTIONS]
Options
flagaliasesdescriptiondefault
--reset-adminReset admin password
Examples
# reset admin pw
rio dashboard --reset-admin 

edit

Edit resources

Usage
rio edit [TYPE/]RESOURCE_NAME
Options
flagaliasesdescriptiondefault
--rawEdit the raw API object, not the pretty formatted one
Examples
rio edit demo@v4

rio edit router/myrouter

exec

Run a command in a running container

Usage
rio exec [OPTIONS] CONTAINER COMMAND [ARG...]
Options
flagaliasesdescriptiondefault
--stdin-iPass stdin to the container
--tty-tStdin is a TTY
--container value-c valueSpecify container in pod, default is first container
--pod valueSpecify pod, default is first pod found
Examples
# ssh into running container
rio exec -it demo sh

# this is equivalent of doing
rio exec --tty --stdin demo sh

# choose pod and container
rio exec -it --pod mypod --container server demo sh

export

Export a namespace or service

Usage
rio export [TYPE/]NAMESPACE_OR_SERVICE
Options
flagaliasesdescriptiondefault
--format valueSpecify output format, yaml/json. Defaults to yamlyaml
--riofileExport riofile format
Examples
# export a service
rio export demo

# export a namespace in riofile format
rio export --riofile namespace/default

image

List images built from the local registry

Usage
rio image

info

Show system info

Usage
rio info

inspect

Inspect resources

Usage
rio inspect [TYPE/][NAMESPACE/]SERVICE_NAME
Options
flagaliasesdescriptiondefault
--formatEdit the raw API object, not the pretty formatted one
Examples
rio inspect svc@v2

# inspect a build
rio inspect taskrun/affectionate-mirzakhani-mfp5q-ee709-4e40c

install

Install the Rio management plane

See the install docs for more info.

Usage
rio install [OPTIONS]
Options
flagaliasesdescriptiondefault
--checkOnly check status, don't deploy controller
--disable-features valueManually specify features to disable, supports comma separated values
--enable-debugEnable debug logging in controller
--ip-address valueManually specify IP addresses to generate rdns domain, supports comma separated values
--yamlOnly print out k8s yaml manifest
--rdns-urlSpecify Rdns server url to usehttps://api.on-rio.io/v1

--check

Check if Rio is installed in the current cluster without deploying the Rio controller. If Rio has not been installed, this command might hang on Waiting for rio controller to initialize.

--disable-features

Choose features to be disabled when starting the Rio control plane. Below are a list of available features

FeatureDescription
autoscalingAuto-scaling services based on in-flight requests
buildRio Build, from source code to deployment
glooAPI gateway backed by gloo
linkerdLinkerd service mesh
letsencryptLet's Encrypt
rdnsAcquire DNS from public Rancher DNS service
dashboardRio UI

--ip-address

Manually specify IPAddress for API gateway services. The IP will be used to generate a record for the cluster domain. By default, if this flag is not specified, Rio will use the IP of Service Loadbalancer that points to API gateway.

Note: If service loadbalancer cannot be provisioned, Nodeport is used to expose API gateway.

Examples
# basic install
rio install

# install with debug and disable some features
rio install --enable-debug --disable-features linkerd,gloo

# print yaml to run manually, with custom ip-address
rio install --yaml --ip-address 127.0.0.1

kill

Kill pods individually or all pods belonging to a service

Usage
rio kill [SERVICE_NAME/POD_NAME]
Examples
# kill a service
rio kill demo

# kill individual pods
rio pods # first get pod name
rio kill pod/demo-v042dxp-5fb7d8f677-f9xgn

logs

Print logs from services or containers

Usage
rio logs [OPTIONS] SERVICE/BUILD
Options
flagaliasesdescriptiondefault
--since value-s valueLogs since a certain time, either duration (5s, 2m, 3h) or RFC3339"24h"
--timestamps-tPrint the logs with timestamp
--tail value-n valueNumber of recent lines to print, -1 for all200
--container value-c valuePrint the logs of a specific container, use -a for system containers
--previous-pPrint the logs for the previous instance of the container in a pod if it exists, excludes running
--init-containersInclude or exclude init containers
--all-aInclude hidden or systems logs when logging
--no-color--ncDont show color when logging
--output value-o valueOutput format: [default, raw, json]default
Examples
# get logs from a service
rio logs demo

# Get logs from a build
rio build-history
rio logs taskrun/affectionate-mirzakhani-mfp5q-ee709-4e40c

# get 1 previous log line for the linkerd-proxy in demo service
rio logs --tail 1 --container linkerd-proxy -a demo

# ignore init-containers and filter to waiting or terminated pods, include timestamps
rio logs --container-state "terminated,waiting" --init-containers=false --timestamps demo

# target terminated pods of all kinds, format as json
rio logs -p -a  --output json demo

Promote

Send 100% of traffic to an app version and scale down other versions. See also weight.

Usage
rio promote [OPTIONS] SERVICE_NAME
Options
flagaliasesdescriptiondefault
--durationnoneHow long the rollout should take. An approximation, actual time may fluctuate0s
--pausenoneWhether to pause all rollouts on current appfalse
Examples
# promote n@v2 
rio promote n@v2

# promote n@v2 over 1 hour 
rio promote --duration=1h n@v2

# pause last command
rio promote --pause=true n@v2

ps

List services

Usage
rio ps [OPTIONS]
Options
flagaliasesdescriptiondefault
--quiet-qOnly display Names
--format'json' or 'yaml' or Custom format: {{ "'{{.Name}} {{.Obj.Name}}'" }} [$FORMAT]
--all-aprint all resources, including router and externalservice
--workloads-winclude apps/v1 Deployments and DaemonSets in output
Examples
# show services and workloads
rio ps -w

# output json
rio ps --format json

# display name and weight in custom format
rio ps --format {{ "{{.Obj.Name}} -> {{.Data.Weight}}" }}

router

Route traffic across the mesh

Usage
rio routers command [command options] [arguments...]
Options
flagaliasesdescriptiondefault
--quiet-qOnly display Names
--format'json' or 'yaml' or Custom format: {{ "'{{.Name}} {{.Obj.Name}}'" }} [$FORMAT]
Examples
# show existing routers
rio route

add/create

Create a router. By default appends at the end.

Services specified without a version are assumed to be apps. For example rio route add x to svc would target the svc app endpoint, not the svc@v0 version.

Usage
rio router create/add MATCH ACTION [TARGET...]
Options
flagaliasesdescriptiondefault
--insertInsert the rule at the beginning instead of the end
--header valueMatch HTTP header (format key=value, value optional)
--fault-percentage valuePercentage of matching requests to fault0
--fault-delay-milli-seconds valueInject a delay for fault in milliseconds0
--fault-httpcode valueHTTP code to send for fault injection0
--add-header valueAdd HTTP header to request (format key=value)
--set-header valueOverride HTTP header to request (format key=value)
--remove-header valueRemove HTTP header to request (format key=value)
--retry-attempts valueHow many times to retry0
--retry-timeout-seconds valueTimeout per retry in seconds0
--timeout-seconds valueTimeout in seconds for all requests0
--method valueMatch HTTP method, support comma-separated values
Examples

# route to the demo app endpoint
rio route add myroute to demo

# route a specific path to the demo app's version 0, and insert into first slot
rio route add --insert myroute/name.html to demo@v0

See the routers readme for advanced example usage.


run

Create and run a new service

Usage
rio run [OPTIONS] IMAGE [COMMAND] [ARG...]
Options
flagaliasesdescriptiondefault
--add-host valueAdd a custom host-to-IP mapping (host=ip)
--annotations valueAnnotations to attach to this service
--build-branch valueBuild repository branchmaster
--build-dockerfile valueSet Dockerfile namedefaults to Dockerfile
--build-context valueSet build context.
--build-webhook-secret valueSet GitHub webhook secret name
--build-docker-push-secret valueSet docker push secret name
--build-clone-secret valueSet git clone secret name
--build-image-name valueSpecify custom image name to push
--build-registry valueSpecify to push image to
--build-revision valueBuild git commit or tag
--build-prEnable builds on new pull requests
--build-tagEnable builds on any new tags instead of new commits on a branch, requires webhook, does not support polling
--build-tag-includePattern that tags must match
--build-tag-excludePattern that excludes tags
--build-timeout valueTimeout for build, ( (ms/s/m/h))10m
--command valueOverwrite the default ENTRYPOINT of the image
--config valueConfigs to expose to the service (format: name[/key]:target)
--concurrency valueThe maximum concurrent request a container can handle (autoscaling)10
--cpus valueNumber of CPUs
--dns valueSet custom DNS servers
--dnsoption valueSet DNS options (format: key:value or key)
--dnssearch valueSet custom DNS search domains
--env value-e valueSet environment variables
--env-file valueRead in a file of environment variables
--global-permission valuePermissions to grant to container's service account for all namespaces
--group valueThe GID to run the entrypoint of the container process
--health-cmd valueCommand to run to check health
--health-failure-threshold valueConsecutive failures needed to report unhealthy0
--health-header valueHTTP Headers to send in GET request for healthcheck
--health-initial-delay valueStart period for the container to initialize before starting healthchecks ( (ms/s/m/h))"0s"
--health-interval valueTime between running the check ( (ms/s/m/h))"0s"
--health-success-threshold valueConsecutive successes needed to report healthy0
--health-timeout valueMaximum time to allow one check to run ( (ms/s/m/h))"0s"
--health-url valueURL to hit to check health (example: http://:8080/ping)
--host-dnsUse the host level DNS and not the cluster level DNS
--hostname valueContainer host name
--image-pull-policy valueBehavior determining when to pull the image (never/always/not-present)"not-present"
--image-pull-secrets valueSpecify image pull secrets
--interactive-iKeep STDIN open even if not attached
--label-file valueRead in a line delimited file of labels
--label value-l valueSet meta data on a container
--memory value-m valueMemory reservation (format: [], where unit = b, k, m or g)
--name value-n valueAssign a name to the container. Use format [namespace:]name[@version]
--net valueSet network mode (host)
--no-meshDisable service mesh
--permission valuePermissions to grant to container's service account in current namespace
--ports value-p valuePublish a container's port(s) (format: svcport:containerport/protocol)
--privilegedRun container with privilege
--read-onlyMount the container's root filesystem as read only
--rollout-duration valueHow long the rollout should take. An approximation, actual time may fluctuate. Affects template services, but not weight or promote commands."0s"
--request-timeout-seconds valueSet request timeout in seconds0
--scale valueThe number of replicas to run or a range for autoscaling (example 1-10)
--secret valueSecrets to inject to the service (format: name[/key]:target)
--stage-onlyOnly stage service when generating new services. Can only be used when template is true
--templateIf true new version is created per git commit. If false update in-place
--tty-tAllocate a pseudo-TTY
--user value-u valueUID[:GID] Sets the UID used and optionally GID for entrypoint process (format: [:])
--volume value-v valueSpecify volumes for for services
--weight valueSpecify the weight for the services0
--workdir value-w valueWorking directory inside the container
Examples
# basic run
rio run -p 80 nginx

# run a named service with set scale, concurrency and ports. Build an image from a github repo
rio run -n mysvc --scale 5-10 --concurrency 5 -p 80:8080/http https://github.com/rancher/rio-demo

# add a version to service
rio run --weight 50 -n mysvc@v2 -p 80 nginx

# set custom readiness probe
rio run --health-url http://:8080/status --health-initial-delay 10s --health-interval 5s --health-failure-threshold 5 --health-timeout 5s -p 8080 cbron/mybusybox:dev

# set permission for containers. By setting permissions, rio will assign a serviceaccount to the pod which will have the corresponding permissions. Global permission means permissions across all namespaces.
rio run --global-permission "create,update,delete services" --permission "* apps/deployments" nginx

# set host:ip entry in container
rio run --add-host db=1.2.3.4 nginx

# set build parameters
rio run --build-branch dev --build-dockerfile Dockerfile.production --build-context . --build-webhook-secret webhook https://github.com/example/exmaple 

# run a service that deploy on any new tag matching '^v' and not match 'alpha'
rio run -p 8080 -n tag-demo --build-webhook-secret=githubtoken --build-tag=true --build-tag-include="^v" --build-tag-exclude="alpha" https://github.com/rancher/rio-demo


rm

Delete resources

Usage
rio rm [TYPE/]RESOURCE_NAME
Examples
# delete service foo
rio rm foo

# delete multiple resources of different types
rio rm svc1 svc2 router/route1 externalservice/foo

scale

Scale a service to a desired number, or set autoscaling params

Usage
rio scale [SERVICE=NUMBER_OR_MIN-MAX...]
Examples
rio scale foo=5

# autoscaling
rio scale foo=1-5

stage

Stage a new revision of a service

Note that when using --edit certain values (like spec.weight) will be overwritten, and other flags (like --env) won't take effect.

Usage
rio stage [OPTIONS] SERVICE NEW_REVISION
Options
flagaliasesdescriptiondefault
--image valueRuntime image (Docker image/OCI image)
--editEdit the config to change the spec in new revision
--env value-e valueSet environment variables
--env-file valueRead in a file of environment variables
Examples
# stage an image (tag v3) to the 2nd version of the demo service
rio stage --image ibuildthecloud/demo:v3 demo v2

# stage the same image with different env variables
rio stage -e abc=xyz demo v2

# stage but edit first
rio stage --edit demo v2

system logs

Print the logs from the Rio management plane

Usage
rio system logs

system feature

View/Edit system feature/configuration

Uasge
# view system feature
rio system feature

# edit system feature/configuration
rio system feature --edit

uninstall

Uninstall rio

Usage
rio uninstall [OPTIONS]
Options
flagaliasesdescriptiondefault
--namespace valuenamespace to install system resources"rio-system"
Examples
rio uninstall

rio uninstall --namespace alt-namespace

up

Apply a Riofile

Usage
rio up [OPTIONS]
Options
flagaliasesdescriptiondefault
--name value-nSet stack name, defaults to current directory name
--answers valueSet answer file
--file value-f valueSet rio file
--parallel-pRun builds in parallel
--branch valueSet branch when pointing stack to git repomaster
--revision valueUse a specific commit hash
--build-webhook-secret valueSet GitHub webhook secret name
--build-tagEnable builds on any new tags instead of new commits on a branch, requires webhook, does not support polling
--build-tag-includePattern that tags must match
--build-tag-excludePattern that excludes tags
--build-clone-secret valueSet name of secret to use with git clone
--push-registry-secret valueSet secret for pushing to custom registry
--permission valuePermissions to grant to container's service account in current namespace
Examples
# apply a file named 'Riofile' in current directory
rio up

# apply stack.yaml as a stack named mystack as 2nd revision
rio up --name mystack -f stack.yaml -p

# apply a riofile from git repo, from a specific branch and commit, using a secret, and setup webhook.
rio up --branch branchname --build-webhook-secret=githubtoken --build-clone-secret=mysecret --revision {commit_sha}  https://github.com/exmaple/example

# Set custom permissions to give the stack, and supply answers to riofile questions
rio up  --permissions '* configmaps' --answers answerfile.yaml

weight

Set the percentage of traffic to allocate to a given service version. See also promote.

Defaults to an immediate rollout, set duration to perform a gradual rollout

Note that once a service version is set to 100% of weight, you must assign weight to other services in order to route traffic to them. For instance if you have svc-a and svc-b, and you set svc-a=100% and then svc-a=50%, svc-b will still have 0% weight and svc-a will still have 100%. You must set svc-b=50% to give it weight.

Usage
rio weight [OPTIONS] SERVICE_NAME=PERCENTAGE
Options
flagaliasesdescriptiondefault
--durationHow long the rollout should take. An approximation, actual time may fluctuate0s
--pauseWhether to pause all rollouts on current appfalse
Examples
# immediately shift 100% of traffic to app n@v0
rio weight n=100 

# shift n@v2 to 50% of traffic gradually over 5m
rio weight --duration=5m n@v2=50 

# Pause last command at current state, will pause all rollouts on versions in app
rio weight --pause=true n@v2=50