Skip to content

Instantly share code, notes, and snippets.

@gitlawr
Last active June 18, 2019 15:46
Show Gist options
  • Save gitlawr/8fe61c24e72b9cb405bb18fb1ee03506 to your computer and use it in GitHub Desktop.
Save gitlawr/8fe61c24e72b9cb405bb18fb1ee03506 to your computer and use it in GitHub Desktop.

Example multiclusterapp command flow:

$ rancher multiclusterapps -h
Operations with multi-cluster apps

Usage:
   rancher multiclusterapps command [command options] [arguments...]

Commands:
     ls                  List multi-cluster apps
     delete              Delete a multi-cluster app
     install             Install a multi-cluster app
     rollback            Rollback a multi-cluster app to a previous version
     upgrade             Upgrade an app to a newer version
     add-project         Add target projects to a multi-cluster app
     delete-project      Delete target projects from a multi-cluster app
     add-member          Add members to a multi-cluster app
     delete-member       Delete members from a multi-cluster app
     list-members, lm    List current members of a multi-cluster app
     list-templates, lt  List templates available for installation
     show-template, st   Show versions available to install for an app template
     show-app, sa        Show an app's available versions and revisions

Options:
   --format value, -o value  'json', 'yaml' or custom format
   --quiet, -q               Only display IDs
   --help, -h                show help

install command

$ rancher multiclusterapps install -h
Usage:
  rancher multiclusterapps install [OPTIONS] [TEMPLATE_NAME, APP_NAME]...

Options:
   --answers value, -a value   Path to an answers file, the format of the file is a map with key:value. This supports JSON and YAML.
   --values value              Path to a helm values file.
   --set value                 Set answers for the template, can be used multiple times. Example: --set foo=bar
   --version value             Version of the template to use
   --no-prompt                 Suppress asking questions and use the default values when required answers are not provided
   --target value, -t value    Target project names/ids to install the app into
   --role value                Set roles required to launch/manage the apps in target projects. For example, set "project-member" role when the app needs to manage resources in the projects in which it is deployed. Or set "cluster-owner" role when the app needs to manage resources in the clusters in which it is deployed.
   --member value              Set members of the app, with the same access type defined by --member-access-type
   --member-access-type value  Access type of the members. Specify only one value, and it applies to all members defined by --member. Valid options are 'owner', 'member' and 'read-only' (default: "owner")
   --timeout value             Time in seconds to wait until the app is in a ready state (default: 60)

Note: Scoped answers are supported by using the following formats: ClusterID:key=value, ClusterName:key=value, ClusterID:ProjectID:key=value or ClusterName:ProjectName:key=value

e.g.:

# install redis with different scoped answers set
$ rancher multiclusterapps install --set foo=bar --set c-lhr4b:foo=clsbar --set c-lhr4b:p-5n7wz:foo=projbar --target c-lhr4b:p-5n7wz --target c-lhr4b:p-kc89d --role project-member redis my-example-redis
# install redis with non-default version
$ rancher multiclusterapps install --version 2.3.1 --role project-member redis my-redis

or use answers file,

# answers.yaml
foo: bar
"c-lhr4b:foo": clsbar
"c-lhr4b:p-5n7wz:foo": projbar
$ rancher multiclusterapps install --answers ./answers.yaml --target c-lhr4b:p-5n7wz --role project-member redis my-example-redis

upgrade command

Upgrade an app to a newer version

Usage:
  rancher multiclusterapps upgrade [OPTIONS] [APP_NAME/APP_ID VERSION]

Options:
   --answers value, -a value  Path to an answers file, the format of the file is a map with key:value. Supports JSON and YAML
   --values value             Path to a helm values file.
   --set value                Set answers for the template, can be used multiple times. Example: --set foo=bar
   --role value, -r value     Set roles required to launch/manage the apps in target projects. Specified roles on upgrade will override all the original roles. For example, provide all existing roles if you want to add additional roles. Leave it empty to keep current roles
   --show-versions, -v        Display versions available to upgrade to

e.g.:

$ rancher multiclusterapps upgrade --show-versions my-example-redis
$ rancher multiclusterapps upgrade --set foo=newbar my-example-redis 0.3.7
$ rancher multiclusterapps upgrade -a ./answers.yaml my-example-redis 0.3.8
$ rancher multiclusterapps upgrade --set foo=newbar --role cluster-owner my-example-redis 0.3.7

rollback command

$ rancher multiclusterapps rollback -h
Rollback a multiclusterapps to a previous version

Usage:
  rancher multiclusterapps rollback [OPTIONS] [APP_NAME/APP_ID, REVISION_ID/REVISION_NAME]

Options:
   --show-revisions, -r  Show revisions available to rollback to

e.g.:

$ rancher multiclusterapps rollback --show-revisions
$ rancher multiclusterapps rollback my-example-redis apprevision-rz5vw

add-project command

$ rancher multiclusterapps add-project -h
Add target projects to a multi-cluster app
Examples:
 #Add 'p1' project in cluster 'mycluster' to target projects of a multi-cluster app named 'myapp'
 rancher multiclusterapp add-project myapp mycluster:p1

Usage:
  rancher multiclusterapps add-project [OPTIONS] [APP_NAME/APP_ID, CLUSTER_NAME:PROJECT_NAME/PROJECT_ID...]

Options:
   --answers value, -a value  Path to an answers file that provides overrided answers for the new target projects, the format of the file is a map with key:value. Supports JSON and YAML
   --values value             Path to a helm values file that provides overrided answers for the new target projects
   --set value                Set overrided answers for the new target projects

e.g.:

$ rancher multiclusterapps add-project myapp mycluster:Default mycluster:myProject
# set overrided answers for newly added projects
$ rancher multiclusterapps add-project --set mycluster:Default:foo=bar myapp mycluster:Default mycluster:myProject

delete-project command

$ rancher multiclusterapps delete-project -h
Delete target projects from a multi-cluster app
Examples:
 #Delete 'p1' project in cluster 'mycluster' from target projects of a multi-cluster app named 'myapp'
 rancher multiclusterapp delete-project myapp mycluster:p1

Usage:
  rancher multiclusterapps delete-project [APP_NAME/APP_ID, CLUSTER_NAME:PROJECT_NAME/PROJECT_ID...]

e.g.:

$ rancher multiclusterapp delete-project myapp mycluster:p1

add-member command

$ rancher multiclusterapps add-member -h
Add members to a multi-cluster app
Examples:
 #Add 'user1' and 'user2' as the owners of a multi-cluster app named 'myapp'
 rancher multiclusterapp add-member myapp owner user1 user2

Usage:
  rancher multiclusterapps add-member [APP_NAME/APP_ID, ACCESS_TYPE, USER_NAME/USER_ID...]

delete-member command

$ rancher multiclusterapps delete-member -h
Delete members from a multi-cluster app
Examples:
 #Delete the membership of a user named 'user1' from a multi-cluster app named 'myapp'
 rancher multiclusterapp delete-member myapp user1

Usage:
  rancher multiclusterapps delete-member [APP_NAME/APP_ID, USER_NAME/USER_ID...]

list-members command

$ rancher multiclusterapps list-members -h
List current members of a multi-cluster app

Usage:
  rancher multiclusterapps list-members [OPTIONS] [APP_NAME/APP_ID]

Options:
   --format value, -o value  'json', 'yaml' or custom format

e.g.:

$ rancher multiclusterapp list-members myapp

delete command

$ rancher multiclusterapps delete -h
Delete a multiclusterapps

Usage:
  rancher multiclusterapps delete [APP_NAME/APP_ID]

e.g.:

$ rancher multiclusterapps delete myapp1 myapp2

list command

$ rancher multiclusterapps ls -h
List multi-cluster apps

List all multi-cluster apps in the current Rancher server
Usage:
  rancher multiclusterapps ls [OPTIONS]

Options:
   --format value, -o value  'json', 'yaml' or custom format
   --quiet, -q               Only display IDs

e.g.

$ rancher multiclusterapps # the default subcommand is ls
$ rancher multiclusterapps ls
NAME          STATE     VERSION   PROJECT_TARGETS
example-app   active    0.3.8     nn:Default,nn:System
$ rancher multiclusterapps ls -q
cattle-global-data:myapp
$ rancher multiclusterapps ls --format json
{some jsonn app data...}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment