mgmttools

Home

Management Tools: calicoctl and kubectl

This guide provides installation and basic usage instructions for calicoctl (the Calico command-line tool) and kubectl (the Kubernetes command-line tool).

1. calicoctl

calicoctl is used to manage Calico network policies, IP address management, and other Calico configurations.

1.1 Installation

  1. Download the calicoctl binary: The following command downloads a specific version (v3.21.2). For the latest version, please check the Project Calico releases page.

    curl -o calicoctl -L "https://github.com/projectcalico/calicoctl/releases/download/v3.21.2/calicoctl"
    # Note: The original command had an extra -O flag which is not needed with -o.
  2. Make it executable and move to PATH:

    sudo chmod +x calicoctl
    sudo mv ./calicoctl /usr/local/bin/calicoctl
  3. Verify installation (optional):

    calicoctl version

1.2 Configuration

calicoctl needs to know how to access your datastore (etcd or Kubernetes API). This can be configured via environment variables or a configuration file.

Method 1: Environment Variables

You can set these per command or export them for your session.

  • Per command:

    (Note: sudo might be needed if your KUBECONFIG points to a root-owned file or if Calico resources require elevated privileges, but often calicoctl can be run by a user with appropriate kubeconfig access.)

  • For the session:

Method 2: Configuration File

You can create a configuration file at /etc/calico/calicoctl.cfg.

  1. Create the directory and file:

    Paste the following content into /etc/calico/calicoctl.cfg. Ensure the kubeconfig path is correct for your system.

    (Generalized the kubeconfig path to ~/.kube/config and added a comment.)

    Note: If this config file exists and is readable, calicoctl should pick up these settings automatically. You might need sudo to run calicoctl if it needs to read this root-owned config file, or adjust permissions on the file/directory.

1.3 Usage Examples

(Assuming configuration is done via environment variables or the config file)

List Calico nodes:

List Calico workload endpoints:

2. kubectl

kubectl is the primary command-line tool for interacting with a Kubernetes cluster.

2.1 Installation

  1. Download the latest stable kubectl binary: This command fetches the version string for the latest stable release and downloads the corresponding binary.

  2. Make it executable and move to PATH:

  3. Verify installation:

Home

Last updated