API: k8s.mk
This is the complete list of namespaces & static public targets that are available from k8s.mk, along with their documentation. Documentation here is pulled automatically from the latest source.
Dynamic target scaffolding is also generated for each of the containers defined in k8s-tools.yml, such as helpers for target-dispatch, debugging shells for that container, etc, but that documentation is out of scope here. For an overview of autogenerated targets, see instead the upstream compose.mk documentation. See also the overview of CLI help.
k8s.mk: (Static Targets)
Target names are reserved names after declaration, but collisions aren't likely because things are organized into a few namespaces:
- Most targets depend on compose.mk. When used in stand-alone mode, k8s.mk will attempt to import compose.mk from the same directory.
- Most targets have a soft-requirement k8s-tools.yml. This isn't always a hard-requirement if you have tools like
kubectlavailable already on the docker-host. - Targets are usable interactively from your shell as
make <target>or./k8s.mk <target>. If you use k8s.mk directly here, you need to set vars likeKUBECONFIGyourself instead of relying on your project Makefile to set them up. - Targets are usable as an API, either as prereq-targets or as part of the body in your targets.
-
Target names are reserved names after declaration. Things are organized into a few namespaces, which hopefully avoids collisions with your project targets.
-
k8s.* targets: Default namespace with general helpers. These targets only use things available in the k8s:base container.
- k3d.* targets:: Helpers for working with the
k3dtool / container - kubefwd.* targets: Helpers for working with
kubefwdtool / container - helm.* targets: Helpers for working with
helmtool / container
API: k8s
This is the default target-namespace for k8s.mk. It covers general helpers, and should be safe to use from the docker host even if tools like kubectl are not available.
DOCS:
-
[1] https://robot-wranglers.github.io/k8s-tools/api#api-k8s
-
[2] https://kubernetes.io/docs/reference/using-api/server-side-apply/
For more details, read on into the API, or see the k8s:base container spec in k8s-tools.yml
This documentation is pulled automatically from source.
k8s.ansible
Interface for the ansible `kubernetes.core.k8s` module[1].
This accepts only module args, but there are a few ways to pass them.
See the docs in 'ansible.adhoc/<module>' for discussion of examples.
* `[1]`: https://docs.ansible.com/ansible/latest/collections/kubernetes/core/k8s_module.html
k8s.cluster.ready
Checks whether the cluster is available.
This just returns the exit status of cluster-info, and not
whether pods are all in a ready state. For that, see 'k8s.wait'
EXAMPLE:
./k8s.mk k8s.cluster.ready
EXAMPLE: ( in a loop )
./k8s.mk flux.loop.until/k8s.cluster.ready
REFS:
* `[1]`: https://github.com/alecjacobs5401/kubectl-sick-pods
k8s.cluster.wait
Waits until all pods in all namespaces are ready. (Alias for 'k8s.namespace.wait/all')
k8s.deployments/arg
Shows deployments for the given namespace
Not for parsing; this info is human friendly, and output to logging channel.
k8s.dispatch.quiet/kubectl.kubectx
k8s.get.svc/arg
USAGE:
k8s.get.svc/<ns>/<name>/<filter>
k8s.get.svc/ab-testing/coin-service/.spec.clusterIP
k8s.graph
Alias for k8s.graph/all/pods. This returns dot-format data.
k8s.graph.tui
Alias for 'k8s.graph.tui/all/pods'. This prints a visual graph on the terminal.
k8s.graph.tui/arg
Previews topology for a given kubernetes <namespace>/<kind> in a way that is terminal-friendly.
This is a human-friendly way to visualize progress or changes, because it supports
very large input data from complex deployments with lots of services/pods, either in
one namespace or across the whole cluster. To do that, it has to throw away some
information compared with raw kubectl output, and node labels on the graph aren't
visible.
This is basically a pipeline from graphs in dot format, generated by kubectl-graph,
then passed through some image-magick transformations, and then pushed into
the 'chafa' tool for generating ASCII-art from images.
USAGE: (same as k8s.graph)
./k8s.mk k8s.graph.tui/<namespace>/<kind>
./k8s.mk k8s.graph.tui/<namespace>/<kind>,<outfile>
k8s.graph.tui/all/pods
Previews topology for a given kubernetes <namespace>/<kind> in a way that is terminal-friendly.
This is a human-friendly way to visualize progress or changes, because it supports
very large input data from complex deployments with lots of services/pods, either in
one namespace or across the whole cluster. To do that, it has to throw away some
information compared with raw kubectl output, and node labels on the graph aren't
visible.
This is basically a pipeline from graphs in dot format, generated by kubectl-graph,
then passed through some image-magick transformations, and then pushed into
the 'chafa' tool for generating ASCII-art from images.
USAGE: (same as k8s.graph)
./k8s.mk k8s.graph.tui/<namespace>/<kind>
./k8s.mk k8s.graph.tui/<namespace>/<kind>,<outfile>
k8s.graph/arg
Graphs resources under the given namespace, for the given kind, in dot-format.
Pipe Friendly: results are always dot files. Caller should handle any errors.
This requires the krew plugin "graph" (installed by default with k8s-tools.yml).
USAGE:
./k8s.mk k8s.graph/<namespace>/<kind>
./k8s.mk k8s.graph/<namespace>/<kind>,<outfile>
Argument for 'kind' must be provided, but may be "all".
k8s.graph/all/pods
Graphs resources under the given namespace, for the given kind, in dot-format.
Pipe Friendly: results are always dot files. Caller should handle any errors.
This requires the krew plugin "graph" (installed by default with k8s-tools.yml).
USAGE:
./k8s.mk k8s.graph/<namespace>/<kind>
./k8s.mk k8s.graph/<namespace>/<kind>,<outfile>
Argument for 'kind' must be provided, but may be "all".
k8s.help
Shows targets for just the 'k8s' namespace.
k8s.jobs.wait
Wait for all jobs in all namespaces
k8s.jobs.wait/arg
Wait for all jobs in the given namespace
k8s.jobs.wait/all
Wait for all jobs in the given namespace
k8s.kubectx
Returns `kubectx` result
k8s.kubens.create/arg
Context-manager. Activates the given namespace, creating it first if necessary.
NB: This modifies state in the kubeconfig, so that it can effect contexts
outside of the current process, therefore this is not thread-safe.
USAGE:
./k8s.mk k8s.kubens.create/<namespace>
k8s.kubens/arg
Context-manager. Activates the given namespace.
NB: This modifies state in the kubeconfig, so that it can effect contexts
outside of the current process, and therefore this is not thread-safe.
USAGE:
./k8s.mk k8s.kubens/<namespace>
k8s.namespace.fwd/arg
kubefwd.enter/k8s.namespace.label/arg
Appends the given label to the given namespace.
USAGE:
key=<key> val=<val> ./k8s.mk k8s.namespace.label/<namespace>
./k8s.mk k8s.namespace.label/<namespace>/<key>/<val>
k8s.namespace.purge.by.prefix/arg
Runs a separate purge for every matching namespace.
NB: This isn't likely to clean everything, see the docs for your dependencies.
USAGE:
./k8s.mk k8s.namespace.purge.by.prefix/<prefix>
k8s.namespace.purge/arg
Wipes everything inside the given namespace.
USAGE:
k8s.namespace.purge/<namespace>
k8s.namespace.wait
Wait for all pods in all namespaces
k8s.namespace.wait/arg
Waits for every pod/job in the given namespace to be ready.
This uses only kubectl/jq to loop on pod-status, but assumes that
the krew-plugin 'sick-pods'[1] is available for formatting the
user-message. See `k8s.wait` for an alias that waits on all pods.
NB: If the parameter is "all" then this uses --all-namespaces
USAGE:
./k8s.mk k8s.namespace.wait/<namespace>
REFS:
* `[1]`: https://github.com/alecjacobs5401/kubectl-sick-pods
k8s.namespace.wait/all
Waits for every pod/job in the given namespace to be ready.
This uses only kubectl/jq to loop on pod-status, but assumes that
the krew-plugin 'sick-pods'[1] is available for formatting the
user-message. See `k8s.wait` for an alias that waits on all pods.
NB: If the parameter is "all" then this uses --all-namespaces
USAGE:
./k8s.mk k8s.namespace.wait/<namespace>
REFS:
* `[1]`: https://github.com/alecjacobs5401/kubectl-sick-pods
k8s.namespace/arg
Context-manager. Activates the given namespace.
NB: This modifies state in the kubeconfig, so that it can effect contexts
outside of the current process, therefore this is not thread-safe.
USAGE:
./k8s.mk k8s.namespace/<namespace>
k8s.pod.shell/arg
This drops into a debugging shell for the named pod using `kubectl exec`,
plus a streaming version of the same which allows for working with pipes.
NB: This target assumes that the named pod actually exists. If you want
an idempotent create-operation for such a pod.. see `k8s.test_harness`.
NB: This target attempts to be "universal", so that it may run from the
docker host or inside the `k8s:base` container. This works by detecting
aspects of the caller context. In general, it tries to use k8s-tools.yml
when that makes sense and if it's present, falling back to kubectl.
If `user` is set as an environment variable, this tries to use `su` to overcome
the fact that `kubectl exec --user` does no work like `docker exec --user`.
See also: https://github.com/kubernetes/kubernetes/issues/30656
USAGE: Interactive shell in pod:
./k8s.mk k8s.shell/<namespace>/<pod_name>
k8s.pods
Returns information about pods in all namespaces.
Not for parsing; this info is human friendly, and output to logging channel.
k8s.pods.all
Returns information about pods in all namespaces.
Not for parsing; this info is human friendly, and output to logging channel.
k8s.pods.wait
Wait for all pods in all namespaces
k8s.pods.wait/arg
Wait for all pods in the given namespace
k8s.pods.wait/all
Wait for all pods in the given namespace
k8s.pods/arg
Shows pods for the given namespace, excluding ones with "completed" status.
Not for parsing; this info is human friendly, and output to logging channel.
k8s.pods/all
Shows pods for the given namespace, excluding ones with "completed" status.
Not for parsing; this info is human friendly, and output to logging channel.
k8s.ready
Checks whether the cluster is available.
This just returns the exit status of cluster-info, and not
whether pods are all in a ready state. For that, see 'k8s.wait'
EXAMPLE:
./k8s.mk k8s.cluster.ready
EXAMPLE: ( in a loop )
./k8s.mk flux.loop.until/k8s.cluster.ready
REFS:
* `[1]`: https://github.com/alecjacobs5401/kubectl-sick-pods
k8s.stat
k8s.stat.env
Shows cluster, kube, and docker environment variables
k8s.stat.ns
Shows all namespaces for the current cluster.
(This is just the output of `kubens` with no arguments)
k8s.svc/arg
Shows services for the given namespace
Not for parsing; this info is human friendly, and output to logging channel.
k8s.test_harness.random
Starts a test-pod with a random name in the given namespace, optionally blocking until it's ready.
USAGE:
`k8s.test_harness.random`
k8s.test_harness/arg
Starts a test-pod in the given namespace, optionally blocking
until it's ready. If `img` is provided in environment it will
be used, otherwise defaults to 'IMG_ALPINE_K8S'.
USAGE:
`k8s.test_harness/<namespace>/<pod_name>`
k8s.wait
Waits until all pods in all namespaces are ready. (Alias for 'k8s.namespace.wait/all')
API: ansible
DOCS: [1] https://robot-wranglers.github.io/k8s-tools/api#api-ansible
These targets use the ansible container, but are generally safe to run from the docker-host.
This documentation is pulled automatically from source.
ansible.adhoc/arg
An interface into the named ansible module. Just pass the module-arguments.
Like adhoc ansible, this allows you to call a task without a playbook.
This actually generates a playbook JIT though, which makes things
more flexible.
USAGE:
echo '<arg_json>' | ./compose.mk ansible.adhoc/<ansible_module_name>
ansible.adhoc/blockinfile
An interface into the named ansible module. Just pass the module-arguments.
Like adhoc ansible, this allows you to call a task without a playbook.
This actually generates a playbook JIT though, which makes things
more flexible.
USAGE:
echo '<arg_json>' | ./compose.mk ansible.adhoc/<ansible_module_name>
ansible.adhoc/kubernetes.core.helm
An interface into the named ansible module. Just pass the module-arguments.
Like adhoc ansible, this allows you to call a task without a playbook.
This actually generates a playbook JIT though, which makes things
more flexible.
USAGE:
echo '<arg_json>' | ./compose.mk ansible.adhoc/<ansible_module_name>
ansible.adhoc/kubernetes.core.k8s
An interface into the named ansible module. Just pass the module-arguments.
Like adhoc ansible, this allows you to call a task without a playbook.
This actually generates a playbook JIT though, which makes things
more flexible.
USAGE:
echo '<arg_json>' | ./compose.mk ansible.adhoc/<ansible_module_name>
ansible.blockinfile
Interface for the ansible block-in-file module[1].
This accepts only module args, but there are several ways to pass them.
See the docs in ansible.adhoc/<module> for discussion of examples.
USAGE:
echo <json_data> | ./k8s.mk ansible.blockinfile
./k8s.mk jb <key1>=<val1> <keyn>=<valn> | ./k8s.mk ansible.blockinfile
data="<key1>=<val1> <keyn>=<valn>" ./k8s.mk ansible.blockinfile
EXAMPLE:
path=.gitignore block=".flux.stage.*" | ./k8s.mk ansible.blockinfile
* `[1]`: https://docs.ansible.com/ansible/latest/collections/ansible/builtin/blockinfile_module.html
ansible.helm
Interface for the ansible helm module[1].
This accepts only module args, but there are a few ways to pass them.
See the docs in 'ansible.adhoc/<module>' for discussion of examples.
* `[1]`: https://docs.ansible.com/ansible/latest/collections/kubernetes/core/helm_module.html
ansible.kubernetes.core.k8s
Interface for the ansible `kubernetes.core.k8s` module[1].
This accepts only module args, but there are a few ways to pass them.
See the docs in 'ansible.adhoc/<module>' for discussion of examples.
* `[1]`: https://docs.ansible.com/ansible/latest/collections/kubernetes/core/k8s_module.html
ansible.run
Runs the input-stream as an ansible playbook.
This calls ansible in a way that ensures all output is JSON.
USAGE:
cat <playbook> | ./compose.mk ansible.run
ansible.run.def/arg
Like `ansible.run.tasks`, but reads content from given define-block
ansible.run.tasks
Runs ansible tasks defined by stdin.
ansible.run/arg
Runs the given playbook file.
This calls ansible in a way that ensures all output is JSON.
USAGE:
./k8s.mk ansible.run/<path>
API: argo
The argo.* targets describe a small interface for both argo-workflows and argo-events.
DOCS: [1] https://robot-wranglers.github.io/k8s-tools/api#api-argo
These targets use the argo container, but are generally safe to run from the docker-host.
This documentation is pulled automatically from source.
argo.list
List for the default namespace (i.e. "argo")
argo.list/arg
Returns the results of 'argo list' for the current argo context.
argo.list/argo
Returns the results of 'argo list' for the current argo context.
argo.submit.stdin
USAGE:
cat manifest.yml | k8s.mk argo.submit.stdin
argo.submit.url
USAGE:
url="http://../manifest.yml" ./k8s.mk argo.submit.url
argo.submit/arg
Pass the given path to `argo submit`.
This fills in CLI args for `--wait` and `--log` based
on whether corresponding environment variables are set.
USAGE:
./k8s.mk argo.submit/manifest.yml
API: fission
DOCS: [1] https://robot-wranglers.github.io/k8s-tools/api#api-fission
These targets use the fission container, but are generally safe to run from the docker-host.
This documentation is pulled automatically from source.
fission.assert.env/arg
Succeeds only when the given environment exists
for the currently active namespace. No output.
fission.env.create/arg
Creates the named fission environment if it doesn't already exist.
Desired namespace should already be activated and `img` must be
set in the environment.
fission.env.list
Newline-separated list of all the fission environments available.
fission.function.create/arg
USAGE:
fission_env=<env_name>
fission_code=<path> ./k8s.mk
fission.function.create/<fxn_name>
fission.stat
Describe fission status for the current namespace.
This only writes to stderr, combining the following
commands and failing if any one of them fails:
fission check
fission env list
fission function list
API: kind
The k3d.* targets describe a small interface for working with k3d[2].
Mostly just small utilities that can help to keep common tasks idempotent, but there's also a TUI that provides a useful overview of what's going on with K3d
DOCS: [1]: https://robot-wranglers.github.io/k8s-tools/api#api-k3d [2]: https://k3d.io/
For more details, read on into the API, or see the k8s:kind container spec in k8s-tools.yml
This documentation is pulled automatically from source.
k3d.cluster.agents/arg
Lists only the agents for the given cluster.
k3d.cluster.create/arg
Creates a k3d cluster with the given name, using the given configuration.
This supports most of the usual command-line options,
but they must be passed as variables.
USAGE:
k3d_servers=.. k3d_agents=..
k3d_port=.. k3d_api_port=..
./k8s.mk k3d.cluster.create/<cluster_name>
k3d.cluster.delete/arg
Idempotent version of k3d cluster delete
USAGE:
./k8s.mk k3d.cluster.delete/<cluster_name>
k3d.cluster.exists/arg
Succeeds iff cluster exists.
k3d.cluster.get_or_create/arg
Create a k3d cluster if it does not already exist.
k3d.cluster.list
Returns cluster-names, newline delimited. Available as a macro.
For more details in a human friendly summary, see `k3d.stat`.
USAGE:
./k8s.mk k3d.cluster.list
k3d.commander
Starts a 4-pane TUI dashboard, using the commander layout.
This opens 'lazydocker', 'ktop', and other widgets that are convenient for working with k3d.
USAGE:
KUBECONFIG=.. ./k8s.mk k3d.commander/<namespace>
k3d.context/arg
Sets the given k3d cluster as the active kubectx.
NB: This appends the usual "k3d-" prefix
k3d.has_cluster/arg
k3d.cluster.exists/k3d.help
Shows targets for just the 'k3d' namespace.
k3d.list
Returns cluster-names, newline delimited. Available as a macro.
For more details in a human friendly summary, see `k3d.stat`.
USAGE:
./k8s.mk k3d.cluster.list
k3d.panic
Non-graceful stop for everything that is k3d related.
USAGE:
./k8s.mk k3d.panic
k3d.purge
Deletes all known k3d clusters.
k3d.stat
Show status for k3d.
API: k3d
The k3d.* targets describe a small interface for working with k3d[2].
Mostly just small utilities that can help to keep common tasks idempotent, but there's also a TUI that provides a useful overview of what's going on with K3d
DOCS: [1]: https://robot-wranglers.github.io/k8s-tools/api#api-k3d [2]: https://k3d.io/
For more details, read on into the API, or see the k8s:k3d container spec in k8s-tools.yml
This documentation is pulled automatically from source.
k3d.cluster.agents/arg
Lists only the agents for the given cluster.
k3d.cluster.create/arg
Creates a k3d cluster with the given name, using the given configuration.
This supports most of the usual command-line options,
but they must be passed as variables.
USAGE:
k3d_servers=.. k3d_agents=..
k3d_port=.. k3d_api_port=..
./k8s.mk k3d.cluster.create/<cluster_name>
k3d.cluster.delete/arg
Idempotent version of k3d cluster delete
USAGE:
./k8s.mk k3d.cluster.delete/<cluster_name>
k3d.cluster.exists/arg
Succeeds iff cluster exists.
k3d.cluster.get_or_create/arg
Create a k3d cluster if it does not already exist.
k3d.cluster.list
Returns cluster-names, newline delimited. Available as a macro.
For more details in a human friendly summary, see `k3d.stat`.
USAGE:
./k8s.mk k3d.cluster.list
k3d.commander
Starts a 4-pane TUI dashboard, using the commander layout.
This opens 'lazydocker', 'ktop', and other widgets that are convenient for working with k3d.
USAGE:
KUBECONFIG=.. ./k8s.mk k3d.commander/<namespace>
k3d.context/arg
Sets the given k3d cluster as the active kubectx.
NB: This appends the usual "k3d-" prefix
k3d.has_cluster/arg
k3d.cluster.exists/k3d.help
Shows targets for just the 'k3d' namespace.
k3d.list
Returns cluster-names, newline delimited. Available as a macro.
For more details in a human friendly summary, see `k3d.stat`.
USAGE:
./k8s.mk k3d.cluster.list
k3d.panic
Non-graceful stop for everything that is k3d related.
USAGE:
./k8s.mk k3d.panic
k3d.purge
Deletes all known k3d clusters.
k3d.stat
Show status for k3d.
API: kubefwd
These targets use the kubefwd container, but are generally safe to run from the docker-host.
The kubefwd.* targets describe a small interface for working with kubefwd. It aims to cleanly background / foreground kubefwd in an unobtrusive way, with clean setup/teardown and reasonable defaults for usage per-project.
Forwarding is not just for ports but for DNS as well. Note that this takes effect everywhere, including the containers inside k8s-tools.yml via /etc/hosts bind-mount, as it does on the docker-host.
DOCS: [1] https://robot-wranglers.github.io/k8s-tools/api#api-k8smk
This documentation is pulled automatically from source.
kubefwd.ctx/arg
This wraps the given target, using the given given kubefwd arguments.
See `flux.context_manager` docs for more details.
Roughly equivalent:
kubefwd.ctx/1st,2nd => kubefwd.start/2nd 1st kubefwd.stop/2nd
kubefwd.enter/arg
Runs kubefwd for the given namespace, finding and forwarding ports/DNS for the given
service, or for all services. This is idempotent, and implicitly stops port-forwarding
if it is running, then restarts it.
NB: This target should only run from the docker host (not from the kubefwd container),
and it assumes k8s-tools.yml is present with that filename. Simple port-mapping and
filtering by name is supported; other usage with selectors/labels/reservations/etc
should just invoke kubefwd directly.
USAGE:
./k8s.mk kubefwd/<namespace>
./k8s.mk kubefwd/<namespace>/<svc_name>
kubefwd_mapping="8080:80" ./k8s.mk kubefwd/<namespace>
kubefwd_mapping="8080:80" ./k8s.mk kubefwd/<namespace>/<svc_name>
kubefwd.exit/arg
Stops the named kubefwd instance. Mostly for internal usage,
usually you want 'kubefwd.start' or 'kubefwd.panic' instead.
USAGE:
./k8s.mk kubefwd.stop/<namespace>/<svc_name>
kubefwd.help
Shows targets for just the 'kubefwd' namespace.
kubefwd.panic
Non-graceful stop for everything that is kubefwd related.
Emergency use only; this can clutter up your /etc/hosts
file as kubefwd may not get a chance to clean things up.
USAGE:
./k8s.mk kubefwd.panic
kubefwd.ps
kubefwd.start/arg
kubefwd.enter/kubefwd.stat
Display status info for all kubefwd instances that are running
kubefwd.stop/arg
kubefwd.exit/API: helm
DOCS: [1] https://robot-wranglers.github.io/k8s-tools/api#api-helm
For more details, read on into the API, or see the k8s:helm container spec in k8s-tools.yml.
This documentation is pulled automatically from source.
helm.dispatch/.helm.repo.list
helm.list
helm.repo.list
Returns JSON for the currently available helm repositories.
helm.stat
Shows the status of things that were installed with helm
This is human friendly output on stderr, use `helm.list` for a JSON dump.