Scripts to set up the shell environment with several key clis to support Cloud-Native development with the "Cloud-Native Toolkit".
The components included in the installer:
- IBM Garage Cloud CLI (igc)
- ArgoCD cli (argocd)
- Tekton cli (tkn)
- IBM Cloud fast switching (icc)
- kube-ps1 prompt
- OpenShift cli (oc)
- Kubernetes cli (kubectl)
- JSON cli (jq)
- IBM Cloud cli (ibmcloud)
The installer verifies/sets up the node environment before installing the IGC cli and copies the other clis into ~/bin while setting up the PATH accordingly.
After sourcing .bashrc or .zshrc all of the clis will be available in the PATH.
The components can all be installed with the following command:
curl -sL shell.cloudnativetoolkit.dev | sh -The installer updates PATH in the .zshrc or .bashrc file. You will need to source the file to apply the update to the current shell environment:
if [[ "${SHELL}" =~ zsh ]]; then
source ~/.zshrc
else
source ~/.bashrc
fiThe installer updates the prompt to include Kubernetes cluster and namespace information using kube-ps1. This information can be toggled on and off with the following commands:
kubeon- turns kube-ps1 on for the current sessionkubeon -g- turns kube-ps1 on globallykubeoff- turns kube-ps1 off for the current sessionkubeoff -g- turns kube-ps1 off globally
Fork this repo into you personal github account and customize the parameters for you personal configuration. Then use the git repo to clone into the Cloud Shell.
The cloud-shell-commands contains a number of very useful commands for a developer or sys admin. They are also very useful for when you are running education, enablement or workshops where you want the developer to live 100% in the web browser.
git clone https://github.com/ibm-garage-cloud/cloud-shell-commands.git
export PATH=~/cloud-shell-commands:$PATH
Run the following to install igc and add it to the path.
source ./cloud-shell-commands/install-igc
A utility CLI named icc has been provided to make it easy to switch between cluster across IBM Cloud accounts. There are three files that make up the icc CLI:
-
icc- the executable shell script. This file can be copied into the path or run from its current location -
ibmcloud-account.yaml- the yaml configuration file containing the API keys for the various IBM Cloud accountsThis file contains sensitive information and should not be checked into source control. Example contents of this file are provided below:
accounts: myaccount: {APIKey}
where:
myaccountis any arbitrary nickname for the account{APIKey}is the API key value used to access that account
-
ibmcloud.yaml- the yaml configuration of the clusters in the accounts. This file has a reference to the account nickname used inibmcloud-account.yamlbut does not contain any sensitive information so it can be shared with others. Theicccommand will generate this configuration file for the existing clusters in the account by runningicc --generate
To configure the CLI for your environment, follow the instructions below:
- Run the
install-icccommand to copy theicccommand to ~/bin and update .bashrc - Source .bashrc to pick up the change:
source ~/.bashrc
By default the icc command looks for the configuration files in the ICC_HOME directory. If the environment variable has not been set the value defaults to
the HOME directory. If you would like to store the files in a location other than the HOME directory, set the ICC_HOME environment variable to your desired directory
and export the variable. E.g.
export ICC_HOME=$PWDRun icc --add-account to register the apikey for an account.
icc --add-accountYou will be prompted for the account nickname and the api key. The api key will not be echoed to the console.
Note: Never store API Keys in Git, its a small price to pay for the simplicity of the time this little CLI trick saves you.
-
Use the
icc --generatecommand to initialize theibmcloud.yamlfile with the existing clusters in the account:icc --generate
Note: If you have multiple accounts configured and would only like to generate the cluster configuration for a single account then provide the account name, e.g.
icc --generate myaccountNote: The
--generateprocess merges the new results with the existing configuration, so it can be run repeatedly without losing information.
The generated file uses the cluster name as the nickname. In most cases you will want to use a shorter nickname to speed up the process.
-
List the defined clusters with
iccicc
-
Update the generated nicknames using
icc --nicknameicc --nickname
You will be prompted to provide the cluster name or the existing cluster nickname then the new cluster nickname.
To see the list of clusters that have been configured and the nickname that can be used for login, run the icc command without any parameters:
iccIf you have a large number of clusters, you can filter the list to an account and/or a resource group by providing the --account and/or --resourceGroup flags to the command:
icc --account europe
icc --resourceGroup dev
icc --account europe --resourceGroup devicc gdev45This speeds up you ability to switch accounts:
Logging into ibmcloud: us-east/garage-dev-tools
Logging into OpenShift cluster garage-dev-ocp45-vpc with server url https://c104-e.us-east.containers.cloud.ibm.com:30922
The following commands will add the current cluster and project to the command prompt.
- Run
./install-kube-ps1-bashto set up the prompt - Source the .bashrc file to load the changes -
source ~/.bashrc
- Run
./install-kube-ps1-zshto set up the prompt - Source the .zshrc file to load the changes -
source ~/.zshrc