Command Cheatsheet
All commands and subcommands have the option that will provide information about the options and arguments that the subcommand has. In case of any error in the command, Cilium CLI will return a non-zero status.
All the list commands will return a pretty printed list with the information retrieved from Cilium Daemon. If you need something more detailed you can use JSON output, to get the JSON output you can use the global option -o json
$ cilium endpoint list -o json
Moreover, Cilium also provides a JSONPath support, so detailed information can be extracted. JSONPath template reference can be found in
$ cilium endpoint list -o jsonpath='{[*].id}'
29898 38939 56326
$ cilium endpoint list -o jsonpath='{range [*]}{@.id}{"="}{@.status.policy.spec.policy-enabled}{"\n"}{end}'
29898=none
38939=none
56326=none
Shell Tab-completion
If you use bash or zsh, Cilium CLI can provide tab completion for subcommands. If you want to install tab completion, you should run the following command in your terminal.
$ source <(cilium completion)
If you want to have Cilium completion always loaded, you can install using the following:
$ echo "source <(cilium completion)" >> ~/.bashrc
Basics
Check the status of the agent
$ cilium status
KVStore: Ok Consul: 172.17.0.3:8300
ContainerRuntime: Ok
Kubernetes: Disabled
Cilium: Ok OK
Cilium health daemon: Ok
Controller Status: 6/6 healthy
Proxy Status: OK, ip 10.15.28.238, port-range 10000-20000
Cluster health: 1/1 reachable (2018-04-11T07:33:09Z)
$
Get a detailed status of the agent:
$ cilium status --all-controllers --all-health --all-redirects
KVStore: Ok Consul: 172.17.0.3:8300
ContainerRuntime: Ok
Kubernetes: Disabled
NodeMonitor: Listening for events on 2 CPUs with 64x4096 of shared memory
Cilium health daemon: Ok
Controller Status: 6/6 healthy
Name Last success Last error Count Message
kvstore-lease-keepalive 2m52s ago never 0 no error
ipcache-bpf-garbage-collection 2m50s ago never 0 no error
resolve-identity-29898 2m50s ago never 0 no error
sync-identity-to-k8s-pod (29898) 50s ago never 0 no error
sync-IPv4-identity-mapping (29898) 2m49s ago never 0 no error
sync-IPv6-identity-mapping (29898) 2m49s ago never 0 no error
Proxy Status: OK, ip 10.15.28.238, port-range 10000-20000
Cluster health: 1/1 reachable (2018-04-11T07:32:09Z)
Name IP Reachable Endpoints reachable
runtime (localhost) 10.0.2.15 true false
$
Get the current agent configuration
cilium config
Importing a Cilium Network Policy
cilium policy import my-policy.json
Get list of all imported policy rules
cilium policy get
Remove all policies
cilium policy delete --all
Tracing
Check policy enforcement between two labels on port 80:
Check policy enforcement between two pods:
cilium policy trace --src-k8s-pod <namespace>:<pod.from> --dst-k8s-pod <namespace>:<pod.to>
Monitoring
Monitor cilium datapath notifications
cilium monitor
Verbose output (including debug if enabled)
cilium monitor -v
Extra verbose output (including packet dissection)
cilium monitor -v -v
Filter for only the events related to endpoint
cilium monitor --related-to=<id>
Filter for only events on layer 7
Show notifications only for dropped packet events
cilium monitor --type drop
Don’t dissect packet payload, display payload in hex information
cilium monitor -v -v --hex
Connectivity
Check cluster Connectivity
cilium-health status
There is also a related to this tool.
Endpoints
Get list of all local endpoints
cilium endpoint list
Get detailed view of endpoint properties and state
cilium endpoint get <id>
Enable debugging output on the cilium monitor for this endpoint
cilium endpoint config <id> Debug=true
Get list of loadbalancer services
cilium service list
Or you can get the loadbalancer information using bpf list ::
cilium bpf lb list
Add a new loadbalancer
cilium service update --frontend 127.0.0.1:80 \
--backends 127.0.0.2:90,127.0.0.3:90 \
--id 20
BPF
List node tunneling mapping information
cilium bpf tunnel list
Checking logs for verifier issue
journalctl -u cilium | grep -B20 -F10 Verifier
List connection tracking entries:
sudo cilium bpf ct list global
Flush connection tracking entries:
sudo cilium bpf ct flush
List proxy configuration:
sudo cilium bpf proxy list
If you running Cilium on top of Kubernetes you may also want a way to list all cilium endpoints or policies from a single Kubectl commands. Cilium provides all this information to the user by using Kubernetes Resource Definitions:
Policies
In Kubernetes you can use two kinds of policies, Kubernetes Network Policies or Cilium Network Policies. Both can be retrieved from the kubectl
command:
Kubernetes Network Policies
kubectl get netpol
$ kubectl get cnp
NAME AGE
rule1 3m
$ kubectl get cnp rule1
NAME AGE
rule1 3m
To retrieve a list of all endpoints managed by cilium, resource can be used.