mw gitlab cluster graph
Releasev0.35.0 · cfeceb67
mw gitlab cluster graph [flags]This command starts a web server that shows a live view of the Kubernetes object graph in a browser. It uses the GitLab Agent for Kubernetes running in the cluster. It requires:
- Version 18.1 or later of GitLab and the GitLab Agent.
- At least the Developer role in the agent project.
- This command requires a personal access token or project access token
for authentication. The token must have the
read_apiandk8s_proxyscopes.
Leave feedback in issue 7900.
Resource filtering
Section titled “Resource filtering”To filter resources, namespaces, and select root objects, use Common Expression Language (CEL).
object_selector_expression: Filters objects. The expression must return a boolean. These variables are available:
obj: The Kubernetes object being evaluated.group: The group of the object.version: The version of the object.resource: The resource name of the object, likepodsfor thePodkind.namespace: The namespace of the object.name: The name of the object.labels: The labels of the object.annotations: The annotations of the object.
resource_selector_expression: Filters Kubernetes discovery information to include or exclude resources
from the watch request. The expression must return a boolean. These variables are available:
group: The group of the object.version: The version of the object.resource: The resource name of the object, likepodsfor thePodkind.namespaced: The scope of group, version, and resource. Can bebool,true, orfalse.
To select root objects, use the --root-expression flag. When set, only objects that are directly
or transitively reachable from root objects are shown. This flag uses the same variables
as object_selector_expression, and must return a boolean. Multiple values are joined with OR
statements. If any match, the object is used as root.
For more information about using label selectors and field selectors to select namespaces, see the Kubernetes documentation.
Advanced usage
Section titled “Advanced usage”Apart from high-level ways to construct the query, this command enables you to construct and send the query using all underlying API features. To understand what is possible, and how to do it, see the technical design doc
The user should have permission to access the agent project. For more information, see Grant users Kubernetes access.
This feature is an experiment and is not ready for production use. It might be unstable or removed at any time. For more information, see https://docs.gitlab.com/policy/development_stages_support/.
Options
Section titled “Options”Global options
Section titled “Global options”Examples
Section titled “Examples”# Run the default query for agent 123$ glab cluster graph -R user/project -a 123
# Show common resources from the core and RBAC groups$ glab cluster graph -R user/project -a 123 --core --rbac
# Show certain resources$ glab cluster graph -R user/project -a 123 --resource=pods --resource=configmaps
# Same as above, but more compact$ glab cluster graph -R user/project -a 123 -r={pods,configmaps}
# Select a certain namespace$ glab cluster graph -R user/project -a 123 -n={my-ns,my-stuff}
# Select all namespaces that have a certain annotation$ glab cluster graph -R user/project -a 123 --ns-expression='"my-annotation" in annotations'
# Advanced usage - pass the full query directly via stdin.# The query below watches service accounts in all namespaces except for the kube-system.$ Q='{"queries":[{"include":{"resource_selector_expression":"resource == \"serviceaccounts\""}}],"namespaces":{"object_selector_expression":"name != \"kube-system\""}}'
$ echo -n "$Q" | glab cluster graph -R user/project -a 123 --stdin
# Roots filtering$ glab cluster graph -R user/project -a 123 --root-expression 'group == "" && resource == "pods"'See also
Section titled “See also”Page views: —Sessions: —