Skip to main content

CGC CLI installation

How to install the CGC CLI (pip package cgcsdk), enable tab completion and log in with cgc login.

Prerequisites​

  • Python 3.11+

Windows​

Install Python and add it to PATH.

Linux​

Install Python and add it to PATH.

Installing CGC via pip​

CGC CLI is available as a pip package.

pip install cgcsdk

PS D:\cgc-docs> pip install cgcsdk
Collecting cgcsdk
Downloading cgcsdk-0.1.1-py3-none-any.whl (31 kB)
...
Installing collected packages: cgcsdk
WARNING: The script cgc.exe is installed in 'C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed cgcsdk-0.1.1

Please be aware of the message at the end of the installation process.

WARNING: The script cgc.exe is installed in 'C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts' which is not on PATH.

In that case, please follow instruction how to add location to your PATH

powershell example:

$env:Path += ';C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts'

The package creates a directory named cgcsdk in your %APPDATA% (Windows) or $XDG_CONFIG_HOME / $HOME/.config dir. This directory will contain the config file after you complete the next step.

Tab Completion​

This part is optional, but it will make your life way easier, therefore we advise to do it.

mkdir -p ~/.local/share/bash-completion/completions
_CGC_COMPLETE=bash_source cgc > ~/.local/share/bash-completion/completions/cgc

Done! Restart your terminal and now you can use tab completion. To test it, just type cgc and press tab.

Log in​

Your account is created by your administrator. You receive an e-mail from Keycloak with a link valid for 48 hours. Open it, set a password and confirm your e-mail address. If your organization uses its own identity provider (for example Microsoft Entra ID), you only confirm the e-mail and then log in with the company button. If the link has expired, ask your administrator to send a new one.

Then log in with your e-mail address (not the user_id):

cgc login

cgc login opens the browser. Other options:

  • cgc login --device - no local browser (for example over SSH): open the printed URL on another device and enter the code.
  • cgc login --no-browser - print the URL instead of opening the browser.

After a successful login the CLI also writes a kubectl context, so kubectl --context <name> get pods works with your identity. cgc logout removes the cached tokens.

Accounts created earlier keep logging in as before.

Next, choose the namespace to work in:

cgc namespace list # namespaces assigned to you; the active one is marked with *
cgc namespace use <name> # set the active namespace

Your first namespace is set at account creation. Further namespaces are assigned by your organization admin. See Namespaces.

note

If your organization runs its own CGC server (on-premise), the CLI must point at it before the first login. Run cgc context get-env-path and set API_HOST, API_PORT and CGC_SECRET in that file to the values from your administrator.