mgmttools
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
Download the
calicoctlbinary: 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.Make it executable and move to PATH:
sudo chmod +x calicoctl sudo mv ./calicoctl /usr/local/bin/calicoctlVerify 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:
sudomight be needed if your KUBECONFIG points to a root-owned file or if Calico resources require elevated privileges, but oftencalicoctlcan 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.
Create the directory and file:
Paste the following content into
/etc/calico/calicoctl.cfg. Ensure thekubeconfigpath is correct for your system.(Generalized the kubeconfig path to
~/.kube/configand added a comment.)Note: If this config file exists and is readable,
calicoctlshould pick up these settings automatically. You might needsudoto runcalicoctlif 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
Download the latest stable
kubectlbinary: This command fetches the version string for the latest stable release and downloads the corresponding binary.Make it executable and move to PATH:
Verify installation:
Last updated