Skip to main contentCloud-Native Toolkit

Cloud Native Toolkit CLI

The Cloud-Native Toolkit Command Line Interface (CLI)

TLDR; Install the CLI

npm i -g @ibmgaragecloud/cloud-native-toolkit-cli

The Cloud-Native Toolkit includes the IBM Garage for Cloud (IGC) Command Line Interface (CLI). The IGC CLI provides a set of helpful utilities that can be invoked from the command line. It was created to automate and simplify complicated and repetitive tasks, allowing developers to be more productive.

Use of the CLI is in no way required to work with the Cloud-Native Toolkit and everything done by the CLI can be done manually instead. For each of the commands, the equivalent manual steps are also given for the sake of full transparency and to take away any notion of “magic” that the CLI might be performing.

Some of the utilities provided by the CLI include:

  • Register your application’s git repo into a CI pipeline (Jenkins, Tekton, etc.)
  • List the ingress URLs and route URLs defined within the cluster
  • List the connection information (endpoints, user names, and passwords) for the tools configured in the environment
  • Help copy config maps and secrets into new projects/namespace
  • Enable existing Starter Kits with the necessary artifacts to be integrated easily into the environment

You can either install the CLI onto your computer or install the Cloud Shell Commands environment.


    • Install the CLI:

      npm i -g @ibmgaragecloud/cloud-native-toolkit-cli
    • Verify the version:

      igc --version

    Note: If you are adventurous, you can install the beta version of the cli that contains upcoming features with the following command (switch back at any time with the above command):

    npm i -g @ibmgaragecloud/cloud-native-toolkit-cli@beta
  • Follow the instructions in the development environment setup to install the shell commands.

Invoking the CLI

When the CLI is installed, it adds an executable named igc to the PATH. Running igc --help will list the available commands. The output text will be similar to the following:

$ igc --help
IBM Garage Cloud Native Toolkit CLI (https://cloudnativetoolkit.dev)
Usage: igc <command> [args]
Commands:
igc console Launch the IKS or OpenShift admin console
igc create-webhook Create a git webhook for a given Jenkins pipeline
igc credentials Lists the urls and credentials for the tools

As of v0.5.1, the IGC CLI will now install the commands as plugins to the kubectl and oc CLIs. For example, all of the following are equivalent:

igc pipeline
kubectl pipeline
oc pipeline

Prerequisite tools

Log into your cluster

Most all of the commands provided by the IGC CLI interact with a cluster. It probably comes as no surprise then that you should be logged into the prior to running the commands.

  • oc login --server=<url> --token=<apikey>
  • ibmcloud ks cluster config --cluster <CLUSTER>

Log into your IBM Cloud account

The vlan command provided by the IGC CLI interacts with your IBM Cloud account to get the VLAN information needed to create a cluster. The command assumes you have already logged into your account prior to running the command.

  • Log into your IBM Cloud account with the correct region and resource group:

    ibmcloud login -a cloud.ibm.com -r <region> -g <resource group>

Available commands

dashboard

Opens the Developer Dashboard in the default browser. If a default browser has not been configured, then the URL to the Dashboard will be printed out.

The dashboard displays the Cloud-Native Toolkit tools configured within the cluster along with links to activation content and links to Starter Kits to start a project quickly.

This command requires that the login context for the cluster has already been established.

Command flags

  • -n: the namespace where the dashboard has been deployed; the default is tools

Usage

The command is used in the following way:

igc dashboard

Related commands

  • credentials: shows information about the same tools shown in the dashboard from the command-line
  • tool-config: allows configuration for additional tools to be added to the cluster, making them available to the dashboard and credentials command

console

Opens the IKS or OpenShift admin console in the default browser. If a default browser has not been configured, then the URL to the console will be printed out.

This command requires that the login context for the cluster has already been established.

Usage

The command is used in the following way:

igc console

Related commands

  • credentials: shows information about the same tools shown in the dashboard from the command-line
  • tool-config: allows configuration for additional tools to be added to the cluster, making them available to the dashboard and credentials command

git

Opens the Git repo in the default browser for the current working directory. If a default browser has not been configured, then the URL to the repo will be printed out.

Usage

The command is used in the following way:

igc git

If you have multiple remotes and would like to open one other than origin:

igc git origin-fork

Related commands

  • credentials: shows information about the same tools shown in the dashboard from the command-line
  • tool-config: allows configuration for additional tools to be added to the cluster, making them available to the dashboard and credentials command

credentials

Lists the endpoints, user names, and passwords for the tools configured in the environment. This is the easiest way to get the login credentials for each of the installed tools. Ideally all of the tools would be accessible via SSO at which point this command will be obsolete.

The command works by reading information available in the cluster. When each tool is installed by the toolkit, a config map and secret are created to store the url and credential for the tool. That information is used in a number of different ways within the environment:

  • Provide configuration information to the pipelines
  • Populate the tiles on the Developer Dashboard
  • Populate the results of the credentials command

This command requires that the login context for the cluster has already been established.

Command flags

  • -n: the namespace where the tools have been deployed; the default is tools

Usage

The command is used in the following way:

igc credentials

The credential output is JSON format like this

Credentials: {
argocd: {
user: 'admin',
password: '12345678',
url: 'https://argocd-tools.mycluster.us-east.containers.appdomain.cloud'
},
. . .
dashboard: {
url: 'https://dashboard-tools.mycluster.us-east.containers.appdomain.cloud'

Related commands

  • dashboard: displays the url of the Developer Dashboard and launches the default browser
  • tool-config: allows configuration for additional tools to be added to the cluster, making them available to the dashboard and credentials command

endpoints

Lists the ingress and/or route URLs for the applications in a given namespace. An attempt will be made to get the namespace from the current context if one is not provided as an argument. Results of the command are provided in an interactive menu. If one of the endpoints is selected, it will display the URL and launch it in the default browser. Selecting Exit will print the full list of endpoints and exit.

This command requires that the login context for the cluster has already been established.

Command flags

  • -n: the namespace from which the endpoints will be read; the value will be read from the current context if not provided

Usage

The command is used in the following way:

igc endpoints

sync

Creates a Kubernetes namespace or OpenShift project (if it doesn’t already exist) and sets it up so that the namespace can be used as a target for application deployments and/or to host the environment.

The command synchronize the ConfigMaps and Secrets from a template namespace (ie tools) to create a “development” namespace. After the command has run successfully it will set the provided namespace in the current context (e.g. equivalent to oc project X)

This command copies the relevant ConfigMaps and Secrets into the namespace that are needed for development activities. Managing resources across namespaces (particularly ConfigMaps and Secrets) is a common challenge in Kubernetes environments. We have provided the command at this time to simplify the steps required to get everything ready. Ultimately, this problem seems like an ideal one for an Operator to solve and when one is available (either from the Toolkit or elsewhere) this command will be retired or transitioned.

The command will setup the “development” namespace where DevOps pipelines can be run (e.g. myapp-dev)

The “development” namespace will have the ConfigMaps and Secrets copied over.

Positionals:
namespace The namespace that will be created and/or prepared
Options:
--version Show version number [boolean]
--help Show help [boolean]
-t, --templateNamespace the template namespace that will be the source of the
config [string] [default: "tools"]
-z, --serviceAccount the service account that will be used within the

Usage

Create a dev namespace for development

igc sync myapp-dev

pull-secret

Copy pull secrets into the provided project from the template namespace for the IBM Container Registry.

Set up a service account in the namespace with the pull secret(s) for the IBM Container Registry that are copied.

The pull secret(s) are required in order for pods to pull images that are stored in the IBM Container Registry. When the cluster is created in IBM Cloud, a pull secret is provided in the default namespace. In order for a pod in another namespace to use it, the secret must first be copied into the namespace. After that, the pod either needs to reference the pull secret directly or the service account used by the resource needs to have a reference to the secret. The CLI copies the pull secret over and adds it to the service account so the pod can take either approach.

This command should be use to set up “release” namespaces where applications can be deployed (e.g. test, staging)

Positionals:
namespace The namespace into which the pull-secret(s) will be created
Options:
--version Show version number [boolean]
--help Show help [boolean]
-t, --templateNamespace the template namespace that will be the source of the
config [string] [default: "tools"]
-z, --serviceAccount the service account that will be used within the

Usage

Copy the pull secret from default namespace into myapp-test namepsace and add to serviceAccount default

igc pull-secret myapp-test -t default -z default

pipeline

Connects a branch in a Git repo to a either a Jenkins or Tekton CI pipeline in the environment and triggers an initial build. A webhook is also created so that when a new commit is added to the branch, the pipeline is triggered to start the process to rebuild and redeploy the app using the new code. Currently, webhook creation is supported for repositories hosted on Gitlab, Github, Github Enterprise, Bitbucket, and Gogs.

This command can either be used to register a git repository that has previously been cloned to the local filesystem OR using the remote repo url.

Repository location

The pipeline command supports registering a CI pipeline for a repository that has been cloned locally or using the remote repository url.

Local repository

If you are registering a local repository then you must run the command from within the directory of your local clone of the Git repo. When registering a local repository, the pipeline will use the branch that is currently checked out.

Remote repository

To register a remote repository, pass the repo url as an argument to the pipeline command. For example:

oc pipeline "https://github.com/my-org/my-repo"

You can optionally provide the branch name with the url using a hash (#):

oc pipeline "https://github.com/my-org/my-repo#my-branch"

Note: When registering a remote git repo, if the branch is not provided then the default branch will be used.

Pipeline type

The pipeline command supports registering pipelines with either Tekton or Jenkins. The pipeline can be specified from the command-line with either the --tekton or --jenkins flags. If a flag is not provided then you will be prompted to select the pipeline.

Git credentials

The command will prompt for the username and password/personal access token to access the Git repository, unless those are already stored in a secret in the cluster namespace or provided as command-line parameters. The username and password can be provided with the -u and -p flags. If you want to change the credentials that have already been stored in the cluster namespace, the -g argument an be provided and you will be prompted for the credentials.

Tekton template pipeline

If a Tekton pipeline will be used, a template pipeline must be selected for the new repository pipeline. The command reads the template pipelines available in the template namespace. The template namespace can be provided with the -t argument and will default to tools if not provided. The command will also filter the list of pipelines based on the runtime determined from the given repository.

If there is more than one template pipeline available then you will be prompted to pick one. The template pipeline can also be provided on the command-line using the --pipeline argument. If the name doesn’t match an available pipeline then you will be prompted to select one.

Pipeline parameters

Once the pipeline template is selected, you will be prompted to provide values for the defined pipeline parameters. The values can also be provided from the command-line using the -p argument. The name of the parameter is listed at the beginning of the prompt message. Multiple parameters can be provided by repeating the -p argument. For example:

oc pipeline --tekton "https://github.com/my-org/my-repo" -p scan-image=false -p edge=false

Optional arguments

  • -u: the username for accessing the Git repo
  • -P: the password or personal access token for accessing the Git repo
  • -g: ignore existing git-credentials secret and prompt to update the values
  • -p: provide parameters for the pipeline
  • --jenkins: deploy using a Jenkins pipeline
  • --tekton: deploy using a Tekton pipeline
  • --pipeline: the name of the Tekton pipeline
  • -n: the deployment namespace; if not provided the namespace from the current context will be used
  • -t: the template namespace; if not provided the value will default to tools

Usage

Create a Jenkins pipeline in the current namespace and prompt for the Git credentials
oc pipeline --jenkins

Create a Tekton pipeline in the my-dev namespace, using the Git credentials gituser and gitpat

oc pipeline -n my-dev -u gituser -P gitpat --tekton

enable

Adds DevOps artifacts to a Git repo that the environment uses to deploy the app. The command displays a list of available pipelines and applies the one you select to your code repo. The DevOps files added to your repo include (but are not limited to):

  • Helm chart
  • Jenkinsfile

This command DOES NOT require that the terminal is already logged in to an IBM Cloud account nor the cluster. It DOES require that the terminal’s current directory is the repository directory for your local copy of the Git repo.

The command will add files to the local repo. You should commit these new files and push them to the server repo. Then run igc pipeline to connect your repo to a pipeline in the environment.

Command flags

  • --repo: the set of pipelines to choose from; the default is https://github.com/cloud-native-toolkit/garage-pipelines
  • -p: the name of the pipeline that should be installed; if not provided then you will be prompted
  • -b: the branch from which the pipeline should be installed; the default is stable
  • r: the version number of the pipeline that should be installed; the default is latest

Usage

  1. Before running the command, make sure you have a clean repository with no unstaged changes. Either commit any changes or stash them temporarily with git stash. It is particularly important that any changes to the pipeline be dealt with.

  2. Apply the pipeline updates using the CLI command

    igc enable
  3. Review the changes using git diff and revert any application-specific changes that should remain (e.g. customization to the Jenkins pipeline in the Jenkinsfile, specific values added to values.yaml, customizations to the templates in the helm chart)

  4. Commit the changes when you are happy with them

git-secret

Creates a kubernetes secret that contains the username and personal access token for a git repo and a config map that contains the url, host, org, repo, and branch for the git repository. The secret is always named git-credentials and the config map is named {git org}.{git repo}. The config map and secret will be created in the currently selected namespace/project, unless a value is passed with the -n flag. If the git-credentials secret already exists then it won’t be replaced/updated it won’t be updated unless the --replace argument is passed.

Command flags

  • [positional]: overwrites the name of the config map
  • -n: the namespace where the secret and config map should be created. Defaults to the currently selected project/namespace
  • -d: the directory where the cloned repository is located. Defaults to the current working directory
  • -u: the username for the git secret, If not provided the value will be collected from a prompt
  • -p: the personal access token, If not provided the value will be collected from a prompt
  • --values: an optional yaml file that contains additional attributes to add to the secret
  • --replace: flag indicating that the secret should be replaced/updated if it already exists

Usage

The following gives an example of using the git-secret command to set up the config map and secret in the dev namespace

igc git-secret -n dev

gitops

Creates a kubernetes secret that contains the username and personal access token for a git repo and a config map that contains the url, host, org, repo, and branch for the git repository. The secret is always named git-credentials and the config map is named gitops-repo. The config map and secret will be created in the currently selected namespace/project, unless a value is passed with the -n flag. If the git-credentials secret already exists then it won’t be replaced/updated unless the --replace argument is passed.

Command flags

  • -n: the namespace where the secret and config map should be created. Defaults to the currently selected project/namespace
  • -d: the directory where the cloned repository is located. Defaults to the current working directory
  • -u: the username for the git secret, If not provided the value will be collected from a prompt
  • -p: the personal access token, If not provided the value will be collected from a prompt
  • --values: an optional yaml file that contains additional attributes to add to the secret
  • --replace: flag indicating that the secret should be replaced/updated if it already exists

Usage

The following gives an example of using the gitops command to set up the config map and secret in the dev namespace

igc gitops -n dev

tool-config

Configures a new tool in the environment. After deploying the tool, use this command to add the tool to the list of credentials so that it will be displayed in the dashboard.

Command flags

  • The name for the tool
  • -n: the tools namespace; the default is tools
  • --url: the endpoint for accessing the tool, usually its dashboard
  • --username: (optional) the user name for logging into to tool
  • --password: (optional) the password for logging into to tool

Usage

The following gives an example of using the tool-config command to set up a tool named my-tool with its dashboard’s endpoint and credentials

igc tool-config my-tool \
--url https://mytool-dashboard.mycluster.us-east.containers.appdomain.cloud \
--username admin \
--password password

vlan

Lists the VLANs for a particular IBM Cloud region. This information is useful for preparing Terraform cluster creation steps. The command reads all the data centers in the region and allows you to select the appropriate data center for the vlan.

This command requires that the terminal is already logged in to the cloud region. It does NOT need to be logged in to a cluster.

Usage

List a pair of public/private VLANs for a new environment to use

igc vlan