CodeZero CLI
The czctl
command-line interface makes it easy to develop against a Kubernetes cluster.
Documentation can be found here: https://docs.codezero.io/
CodeZero provides a simple CLI tool to help manage the development and testing of CodeZero applications. Install it globally from NPM using npm install -g @c6o/cli
.
Install the CLI
sudo npm install -g @c6o/cli
[!WIP] Yarn fails to install the @c6o/cli, so please use npm for now.
Requirements:
- NPM (Version 6.14+)
- Node (Version 14+)
Configure the CLI
After installing the CLI, run:
> sudo czctl start
[!NOTE] The CLI requires
sudo
access to modify your systemshosts
file. Thehosts
file is used to define in-cluster DNS information on your local machine during a teleport session.
[!NOTE] Node.js version 13.0.0 (or newer) is required.
Access Your Cluster
Many CLI commands need to interact with a Kubernetes cluster. Therefore, the CLI requires access to a kubeconfig
for your cluster. By default, we use the default cluster in ~/.kube/config
. Alternatively, you can set the KUBECONFIG
environment variable to your kubeconfig
file.
export KUBECONFIG=<path to kubeconfig>
[!NOTE] Some commands let you explicitly specify a kubeconfig file. This is the same as configuring the
kubectl
CLI. See here for more information.
Using the CLI
The CLI is invoked via the czctl
command. To get more information about individual commands, check out the CLI reference, or run:
> czctl help
Teleport
see: https://docs.codezero.io/#/references/teleport
> czctl deployment teleport --help
Teleport your local machine so you can reference the name of a deployment in a network request.
USAGE
$ czctl deployment teleport [RESOURCENAME]
ARGUMENTS
RESOURCENAME The name of the Kubernetes resource.
OPTIONS
-a, --additional=additional Additional namespaces to include. Repeat this flag for each additional namespace.
-c, --clean Close and clean up
-f, --file=file Write environment variables to a file.
-k, --kubeconfig=kubeconfig Path to a specific the kubeconfig file to use for cluster credentials
-m, --format=sh|env|json|yaml The format of the environment file. One of the following: sh (source-able shell file), env (env format p=v), json (JSON format), or yaml (YAML format).
-n, --namespace=namespace Namespace for the operation
-q, --quiet Only display error messages
-w, --wait Wait for terminate signal and then clean up
--all Include all other namespaces as secondary namespaces
EXAMPLE
czctl deployment teleport halyard-backend -n halyard -f env.sh
Intercept
See: https://docs.codezero.io/#/references/intercept
> czctl service intercept --help
Intercept Service traffic to a locally running service through a tunnel
USAGE
$ czctl service intercept [SERVICE]
ARGUMENTS
SERVICE The name of the remote service to be intercepted.
OPTIONS
-a, --all Intercept all traffic irrespective of headers
-c, --clean Close and clean up
-k, --kubeconfig=kubeconfig Path to a specific the kubeconfig file to use for cluster credentials
-l, --localPort=localPort The local port number of the local service
-n, --namespace=namespace Namespace for the operation
-q, --quiet Only display error messages
-r, --remotePort=remotePort The remote port number of the remote service to be intercepted.
-w, --wait Wait for terminate signal and then clean up
-x, --header=header Custom intercept header and value header:value. Default is X-C6O-INTERCEPT:yes
EXAMPLES
czctl service intercept <service name> -r <remote port> -l <local port> -n <namespace>
czctl service intercept foo --remotePort 3000 --localPort 3010 --namespace bar
czctl service intercept foo -r 8080 -l 3010 -n bar