AI prompts
base on A kubectl plugin to render watch output in a more readable fashion <!--
SPDX-FileCopyrightText: 2023 Kalle Fagerberg
SPDX-License-Identifier: CC-BY-4.0
-->
# kubectl-klock

[](https://github.com/applejag/kubectl-klock/releases)
[](https://api.reuse.software/info/github.com/applejag/kubectl-klock)
A `kubectl` plugin to render the `kubectl get pods --watch` output in a
much more readable fashion.
Think of it as running `watch kubectl get pods`, but instead of polling,
it uses the regular watch feature to stream updates as soon as they occur.
## Installation
### Krew
[](https://krew.sigs.k8s.io/plugins/)
```sh
kubectl krew install klock
```
### Snap
[](https://snapcraft.io/klock)
```sh
sudo snap install klock
```
### Scoop

```pwsh
scoop bucket add applejag https://github.com/applejag/applejag-bucket
scoop install applejag/kubectl-klock
```
### Nix
[](https://repology.org/project/kubectl-klock/versions)
```sh
nix-shell -p kubectl-klock
```
### Pre-built binaries
You can download pre-built binaries from the latest GitHub release: <https://github.com/applejag/kubectl-klock/releases/latest>
Download the one that fits your OS and architecture, extract the
tarball/zip file, and move the `kubectl-klock` binary to somewhere in your PATH.
For example:
```sh
tar -xzf kubectl-klock_linux_amd64.tar.gz
sudo mv ./kubectl-klock /usr/local/bin
```
### From source
Requires Go 1.21 (or later).
```sh
go install github.com/applejag/kubectl-klock@latest
```
## Usage
Supports a wide range of flags
```sh
kubectl klock <resource> [name(s)] [flags]
```
### Examples
```sh
# Watch all pods
kubectl klock pods
# Watch all pods with more information (such as node name)
kubectl klock pods -o wide
# Watch a specific pod
kubectl klock pods my-pod-7d68885db5-6dfst
# Watch a subset of pods, filtering on labels
kubectl klock pods --selector app=my-app
kubectl klock pods -l app=my-app
# Watch all pods in all namespaces
kubectl klock pods --all-namespaces
kubectl klock pods -A
# Watch other resource types
kubectl klock cronjobs
kubectl klock deployments
kubectl klock statefulsets
kubectl klock nodes
# Watch all pods, but restart the watch when your ~/.kube/config file changes,
# such as when using "kubectl config use-context NAME"
kubectl klock pods --watch-kubeconfig
kubectl klock pods -W
```
There's also some hotkeys available:
```text
→/l/pgdn next page / filter by text ctrl+c quit
←/h/pgup prev page enter close the filter input field ?/esc close help
g/home go to start esc clear the applied filter d show all deleted
G/end go to end ↓/ctrl+n show next suggestion f toggle fullscreen
↑/ctrl+p show previous suggestion
tab accept a suggestion
```
## Features
- Pagination, for when the terminal window gets too small (height-wise)
- Same output format as `kubectl get`
- Watch arbitrary resources, just like `kubectl get <resource> [name]`
- Filter results
- Auto updating age column.
- Colors on statuses (e.g `Running`) and fractions (e.g `1/1`) to make
them stand out more.
- Restart watch when kubeconfig file changes (flag: `--watch-kubeconfig`, `-W`),
such as when changed by [kubectx](https://github.com/ahmetb/kubectx).
- Color themes powered by [kubecolor](https://kubecolor.github.io/)
- Shows deleted table rows for a short duration,
controllable via the `--hide-deleted=10s` flag
and `KLOCK_HIDE_DELETED=10s` environment variable.
Can be disabled to always show deleted rows by setting `--hide-deleted=false`
### Environment variables
Command-line flags can be controlled via environment variables:
```bash
export KLOCK_ALL_NAMESPACES="true" # --all-namespaces
export KLOCK_FIELD_SELECTOR="status.phase!=Succeeded" # --field-separator
export KLOCK_HIDE_DELETED="false" # --hide-deleted
export KLOCK_LABEL_COLUMNS="app.kubernetes.io/name" # --label-columns
export KLOCK_OUTPUT="wide" # --output
export KLOCK_SELECTOR="team!=frontend" # --selector
export KLOCK_WATCH_KUBECONFIG="true" # --watch-kubeconfig
```
The command-line flags have precedense over the environment variables.
So if you set `KLOCK_ALL_NAMESPACES=true` then you can revert the value
by passing the flag `--all-namespaces=false`
### Color themes
Klock uses kubecolor's coloring logic and behavior when coloring its output.
See: <https://kubecolor.github.io/customizing/themes/>
Color settings that klock uses:
- `KUBECOLOR_THEME_BASE_DANGER` for rows with errors
- `KUBECOLOR_THEME_BASE_MUTED` for "No resources found"
- `KUBECOLOR_THEME_BASE_MUTED` for deleted rows
- `KUBECOLOR_THEME_BASE_MUTED` for status line
- `KUBECOLOR_THEME_BASE_SECONDARY` for "FILTER:" prompt
- `KUBECOLOR_THEME_BASE_WARNING` for "No resources visible" when filtering
- `KUBECOLOR_THEME_DATA_DURATIONFRESH` for `AGE: 12h` when below threshold
- `KUBECOLOR_THEME_DATA_RATIO_EQUAL` for `READY: 1/1`
- `KUBECOLOR_THEME_DATA_RATIO_UNEQUAL` for `READY: 0/1`
- `KUBECOLOR_THEME_STATUS_ERROR` for `STATUS: CrashLoopBackOff`
- `KUBECOLOR_THEME_STATUS_SUCCESS` for `STATUS: Running`
- `KUBECOLOR_THEME_STATUS_WARNING` for `STATUS: Terminating`
- `KUBECOLOR_THEME_TABLE_COLUMNS` for table columns
- `KUBECOLOR_THEME_TABLE_HEADER` for table header
You can configure these colors either via
[environment variables](https://kubecolor.github.io/reference/environment-variables/)
or via the [`~/.kube/color.yaml` config file](https://kubecolor.github.io/reference/config/)
### Completion
To get completion when writing `kubectl klock`, you need to add
[`./bin/kubectl_complete-klock`](./bin/kubectl_complete-klock)
to your `PATH`.
For example:
```sh
sudo curl https://github.com/applejag/kubectl-klock/raw/main/bin/kubectl_complete-klock -o /usr/local/bin/kubectl_complete-klock
sudo chmod +x /usr/local/bin/kubectl_complete-klock
```
", Assign "at most 3 tags" to the expected json: {"id":"13875","tags":[]} "only from the tags list I provide: [{"id":77,"name":"3d"},{"id":89,"name":"agent"},{"id":17,"name":"ai"},{"id":54,"name":"algorithm"},{"id":24,"name":"api"},{"id":44,"name":"authentication"},{"id":3,"name":"aws"},{"id":27,"name":"backend"},{"id":60,"name":"benchmark"},{"id":72,"name":"best-practices"},{"id":39,"name":"bitcoin"},{"id":37,"name":"blockchain"},{"id":1,"name":"blog"},{"id":45,"name":"bundler"},{"id":58,"name":"cache"},{"id":21,"name":"chat"},{"id":49,"name":"cicd"},{"id":4,"name":"cli"},{"id":64,"name":"cloud-native"},{"id":48,"name":"cms"},{"id":61,"name":"compiler"},{"id":68,"name":"containerization"},{"id":92,"name":"crm"},{"id":34,"name":"data"},{"id":47,"name":"database"},{"id":8,"name":"declarative-gui "},{"id":9,"name":"deploy-tool"},{"id":53,"name":"desktop-app"},{"id":6,"name":"dev-exp-lib"},{"id":59,"name":"dev-tool"},{"id":13,"name":"ecommerce"},{"id":26,"name":"editor"},{"id":66,"name":"emulator"},{"id":62,"name":"filesystem"},{"id":80,"name":"finance"},{"id":15,"name":"firmware"},{"id":73,"name":"for-fun"},{"id":2,"name":"framework"},{"id":11,"name":"frontend"},{"id":22,"name":"game"},{"id":81,"name":"game-engine "},{"id":23,"name":"graphql"},{"id":84,"name":"gui"},{"id":91,"name":"http"},{"id":5,"name":"http-client"},{"id":51,"name":"iac"},{"id":30,"name":"ide"},{"id":78,"name":"iot"},{"id":40,"name":"json"},{"id":83,"name":"julian"},{"id":38,"name":"k8s"},{"id":31,"name":"language"},{"id":10,"name":"learning-resource"},{"id":33,"name":"lib"},{"id":41,"name":"linter"},{"id":28,"name":"lms"},{"id":16,"name":"logging"},{"id":76,"name":"low-code"},{"id":90,"name":"message-queue"},{"id":42,"name":"mobile-app"},{"id":18,"name":"monitoring"},{"id":36,"name":"networking"},{"id":7,"name":"node-version"},{"id":55,"name":"nosql"},{"id":57,"name":"observability"},{"id":46,"name":"orm"},{"id":52,"name":"os"},{"id":14,"name":"parser"},{"id":74,"name":"react"},{"id":82,"name":"real-time"},{"id":56,"name":"robot"},{"id":65,"name":"runtime"},{"id":32,"name":"sdk"},{"id":71,"name":"search"},{"id":63,"name":"secrets"},{"id":25,"name":"security"},{"id":85,"name":"server"},{"id":86,"name":"serverless"},{"id":70,"name":"storage"},{"id":75,"name":"system-design"},{"id":79,"name":"terminal"},{"id":29,"name":"testing"},{"id":12,"name":"ui"},{"id":50,"name":"ux"},{"id":88,"name":"video"},{"id":20,"name":"web-app"},{"id":35,"name":"web-server"},{"id":43,"name":"webassembly"},{"id":69,"name":"workflow"},{"id":87,"name":"yaml"}]" returns me the "expected json"