Kong Mesh CLI

Uses: Kong Mesh
Related Documentation
Minimum Version
Kong Mesh - 3.0
Tags
Previous Versions of this page

kongctl is the CLI for Kong Mesh. It connects to a control plane over its HTTP API and works the same way against Konnect and a self-managed control plane.

kongctl learns the resource types from the control plane itself, by reading what the control plane serves rather than carrying a compiled-in list. A policy added in a newer Kong Mesh release is usable without upgrading the CLI, and kongctl get mesh resource-types is the authoritative list for your control plane.

Authenticating

Against Konnect, log in once:

kongctl login

kongctl login runs a browser-based device authorization flow and stores a token. You can also pass a Personal Access Token with the --pat flag.

A self-managed control plane needs no login. Point --control-plane-url at its API instead, and pass a user token with --control-plane-token, and --ca-cert-file for HTTPS. The Kong Mesh API enforces RBAC and treats only requests from the control plane host itself as admin, so without a token, a remote kongctl can’t issue tokens or write resources.

Choosing a control plane and a mesh

Every mesh command needs to know which control plane to connect to, and most need to know which mesh. You can pass both as flags or hold them in configuration.

Select

Flag

Configuration entry

A Konnect control plane by ID. --control-plane-id konnect.mesh.control-plane.id
A Konnect control plane by name. --control-plane-name konnect.mesh.control-plane.name
A self-managed control plane by API URL. --control-plane-url konnect.mesh.control-plane.url
The mesh that mesh-scoped resources belong to. Defaults to default. -m, --mesh konnect.mesh.mesh
Mesh-scoped resources across every mesh. Ignored for global types. --all-meshes None

Pass only one of --control-plane-id, --control-plane-name or --control-plane-url. When you pass none, kongctl uses the configured values in the order URL, ID, name.

To see what control planes are available, run:

kongctl get mesh control-planes

Commands

The following kongctl commands are available for Kong Mesh. For more information, see the kongctl docs.

Listing and reading resources

List every resource type this control plane serves:

kongctl get mesh resource-types

List all resources of one type, in the default mesh:

kongctl get mesh meshtimeouts

Read one resource, as YAML:

kongctl get mesh meshtimeouts "$POLICY_NAME" -o yaml

List resources across every mesh:

kongctl get mesh meshtrafficpermissions --all-meshes

You can give a type as its plural name, its singular, or its short alias: meshtrafficpermissions, meshtrafficpermission and mtp all work, and matching is case-insensitive. resource-types lists the aliases.

Applying resources

Apply one file:

kongctl apply mesh -f policy.yaml

Apply every resource in a directory:

kongctl apply mesh -f ./policies

Apply from stdin:

cat policy.yaml | kongctl apply mesh -f -

apply mesh creates or replaces each resource, so re-applying a file is how you edit a resource. Each resource carries its own type, name and mesh, so one file or directory can span types and meshes.

Deleting resources

Delete a resource in the default mesh:

kongctl delete mesh meshtrafficpermission "$POLICY_NAME"

Delete a resource in another mesh with -m:

kongctl delete mesh meshtimeout "$POLICY_NAME" -m "$MESH_NAME"

Use the --auto-approve flag to skip the confirmation prompt.

Inspecting what the control plane computed

get mesh reads resources back as they were written. inspect provides the state of resources once matching and merging have run.

Show which policies apply to a proxy, and on which of its ports:

kongctl inspect mesh dataplane "$DATAPLANE_NAME"

Show which proxies a policy matches:

kongctl inspect mesh meshtimeout "$POLICY_NAME"

Get an overview of all data plane proxies:

kongctl inspect mesh dataplanes

Get an overview of all meshes:

kongctl inspect mesh meshes

Get an overview of all zones:

kongctl inspect mesh zones

inspect dataplane reports per port rather than per proxy, because that is where a policy actually lands:

PORT       KIND         ORIGINS
admin-ssl  MeshTimeout  kri_mt_default___mesh-wide-timeout_
proxy      MeshTimeout  kri_mt_default___mesh-wide-timeout_
postgres   MeshTimeout  kri_mt_default___outbound-timeout_

--type reaches the proxy’s own Envoy configuration instead of the control plane’s view:

--type

Reports

policies The policies the control plane matched to each port. The default, and the only one that doesn’t need the proxy reachable.
stats Envoy statistics.
clusters The proxy’s clusters.
xds The xDS configuration dump.
config The proxy’s configuration.

Everything but policies is relayed from the proxy’s Envoy admin interface verbatim, so it needs the zone connected to the control plane and the proxy reachable from the zone.

Exporting a control plane

Export control plane configuration:

kongctl dump mesh > mesh.yaml

dump mesh covers every mesh on the control plane and writes resources in the same shape apply mesh reads. --export-profile selects which resource types to export:

--export-profile

Exports

Leaves out

federation (default) Mesh, Secret, GlobalSecret, HostnameGenerator, MeshIdentity, MeshTrust, MeshExternalService, MeshMultiZoneService and MeshOpenTelemetryBackend. Policies, and the resources each zone creates for itself: Dataplane, Workload, MeshService, MeshZoneAddress, Zone, and every insight type.
federation-with-policies Everything in federation, and every policy. The same zone-created resources as federation.
no-dataplanes Every resource type the control plane serves, including read-only insight types. Dataplane and DataplaneInsight.
all Every resource type the control plane serves, including Dataplane and read-only insight types. Nothing.

The two federation profiles prepare the export to be applied to a new global control plane: they remove control-plane-owned labels, such as kuma.io/origin, kuma.io/zone and kuma.io/display-name, so the new control plane sets its own. They keep kuma.io/mesh.

all and no-dataplanes keep every label and include read-only resources. They describe a control plane rather than seed one, so they can’t necessarily be applied back unchanged.

Every profile leaves out the envoy-admin-ca and inter-cp-ca global secrets, which secure traffic between control planes and break TLS if applied to another one. Any user-token-signing-key global secret goes last in the stream, because applying it invalidates the token used to apply everything else.

An export can contain secrets. Store it somewhere appropriate for credentials.

Issuing tokens

Issue a token a data plane uses to prove its identity:

kongctl create mesh dataplane-token --name "$DATAPLANE_NAME" --workload "$WORKLOAD_NAME" --valid-for 24h > token

Issue a token for a zone control plane:

kongctl create mesh zone-token --zone "$ZONE_NAME" --valid-for 720h > token

Both write the token to stdout with no trailing newline, so the output can be redirected straight into the file that kuma-dp or the zone control plane reads.

Bind a data plane token as narrowly as the deployment allows rather than to the mesh alone. Once a MeshIdentity derives identities from the kuma.io/workload label, the control plane rejects a proxy carrying that label unless its token is bound with --workload. A token bound only by --name, or only to the mesh, no longer authenticates it.

Flag

Binds the token to

--name One named data plane.
--workload A workload label value the data plane must carry.
--tag Label values the data plane must carry. Repeatable; comma-separate multiple values for one label.
--proxy-type The proxy type, for example dataplane.
--valid-for How long the token remains valid, for example 24h.

zone-token takes --zone and --scope, which defaults to cp.

Output

-o selects the format: text (default), json, or yaml.

text is a summary table, useful for scanning.

For scripting, --jq filters JSON responses with a full jq expression, and -r strips the quotes from string results:

kongctl get mesh meshservices --all-meshes -o json \
  --jq '.items[] | select(.spec.state == "Unavailable") | .name' -r

--columns picks the fields a text table shows, as HEADER=.field, which covers the cases where you want a table with columns different from the default ones.

Getting help

Every command explains itself. For example:

kongctl get mesh --help
kongctl create mesh dataplane-token --help

FAQs

kumactl

kongctl

kumactl apply -f policy.yaml kongctl apply mesh -f policy.yaml
kumactl get meshtimeouts kongctl get mesh meshtimeouts
kumactl delete meshtimeout NAME kongctl delete mesh meshtimeout NAME
kumactl export kongctl dump mesh
kumactl generate dataplane-token kongctl create mesh dataplane-token
kumactl inspect dataplane NAME kongctl inspect mesh dataplane NAME
kumactl inspect POLICY_TYPE NAME kongctl inspect mesh POLICY_TYPE NAME
kumactl config control-planes add kongctl login, or --control-plane-url for a self-managed control plane
  • Resource types come from the control plane. kumactl carried a compiled-in list, so a newer policy needed a newer CLI. kongctl reads what the control plane serves.
  • Installation isn’t supported. kumactl install control-plane has no kongctl counterpart.
  • kumactl still installs the transparent proxy. It ships in the Kong Mesh archive. Use kumactl install transparent-proxy on Universal to install the iptables rules. For more information, see Universal data plane.
  • kumactl apply -v variables are not supported.

Read-only behavior is unchanged: the global control plane doesn’t write to resources that zones generate, such as MeshService, and kongctl rejects the write before sending the request. A zone control plane accepts the write but doesn’t reconcile it back from its source.

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!