Skip to content

Commit

Permalink
Merge branch 'master' into 1875-make-menu-foreground-brighter
Browse files Browse the repository at this point in the history
  • Loading branch information
derailed authored Feb 16, 2025
2 parents 267d870 + cc1c86c commit ee0ff68
Show file tree
Hide file tree
Showing 225 changed files with 4,207 additions and 1,731 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: K9s Lint

on:
pull_request:
branches: [ main ]
branches: [ master ]

jobs:
golangci:
Expand All @@ -12,13 +12,13 @@ jobs:
uses: actions/[email protected]

- name: Install Go
uses: actions/setup-go@v5.1.0
uses: actions/setup-go@v5.3.0
with:
go-version-file: go.mod
cache-dependency-path: go.sum

- name: Lint
uses: golangci/golangci-lint-action@v6.1.1
uses: golangci/golangci-lint-action@v6.3.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: actions/[email protected]

- name: Install Go
uses: actions/setup-go@v5.1.0
uses: actions/setup-go@v5.3.0
with:
go-version-file: go.mod
cache-dependency-path: go.sum
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ demos
kind
*.snap
/stresser
__debug_bin*
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# options for analysis running
run:
# default concurrency is a available CPU number
# default concurrency is an available CPU number
concurrency: 8

# timeout for analysis, e.g. 30s, 5m, default is 1m
Expand Down
18 changes: 9 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
# -----------------------------------------------------------------------------
# The base image for building the k9s binary

FROM golang:1.23-alpine3.20 AS build
FROM golang:1.23.6-alpine3.20 AS build

WORKDIR /k9s
COPY go.mod go.sum main.go Makefile ./
COPY internal internal
COPY cmd cmd
RUN apk --no-cache add --update make libx11-dev git gcc libc-dev curl && make build
RUN apk --no-cache add --update make libx11-dev git gcc libc-dev curl \
&& make build

# -----------------------------------------------------------------------------
# Build the final Docker image

FROM alpine:3.20.3
ARG KUBECTL_VERSION="v1.29.0"
FROM alpine:3.21.2
ARG KUBECTL_VERSION="v1.31.2"

COPY --from=build /k9s/execs/k9s /bin/k9s
RUN apk add --update ca-certificates \
&& apk add --update -t deps curl vim \
RUN apk --no-cache add --update ca-certificates \
&& apk --no-cache add --update -t deps curl vim \
&& TARGET_ARCH=$(arch | sed s/aarch64/arm64/ | sed s/x86_64/amd64/) \
&& curl -L https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/${TARGET_ARCH}/kubectl -o /usr/local/bin/kubectl \
&& curl -f -L https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/${TARGET_ARCH}/kubectl -o /usr/local/bin/kubectl \
&& chmod +x /usr/local/bin/kubectl \
&& apk del --purge deps \
&& rm /var/cache/apk/*
&& apk del --purge deps

ENTRYPOINT [ "/bin/k9s" ]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ DATE ?= $(shell TZ=UTC date -j -f "%s" ${SOURCE_DATE_EPOCH} +"%Y-%m-%dT%H:
else
DATE ?= $(shell date -u -d @${SOURCE_DATE_EPOCH} +"%Y-%m-%dT%H:%M:%SZ")
endif
VERSION ?= v0.32.6
VERSION ?= v0.40.0
IMG_NAME := derailed/k9s
IMAGE := ${IMG_NAME}:${VERSION}

Expand Down
64 changes: 49 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Please refer to our [K9s documentation](https://k9scli.io) site for installation

Wanna discuss K9s features with your fellow `K9sers` or simply show your support for this tool?

* Channel: [K9ersSlack](https://k9sers.slack.com/)
* Channel: [K9sersSlack](https://k9sers.slack.com/)
* Invite: [K9slackers Invite](https://join.slack.com/t/k9sers/shared_invite/enQtOTA5MDEyNzI5MTU0LWQ1ZGI3MzliYzZhZWEyNzYxYzA3NjE0YTk1YmFmNzViZjIyNzhkZGI0MmJjYzhlNjdlMGJhYzE2ZGU1NjkyNTM)

## Installation
Expand Down Expand Up @@ -115,7 +115,7 @@ Binaries for Linux, Windows and Mac are available as tarballs in the [release pa
* On Ubuntu

```shell
wget https://github.com/derailed/k9s/releases/download/v0.32.5/k9s_linux_amd64.deb && apt install ./k9s_linux_amd64.deb && rm k9s_linux_amd64.deb
wget https://github.com/derailed/k9s/releases/download/v0.32.7/k9s_linux_amd64.deb && apt install ./k9s_linux_amd64.deb && rm k9s_linux_amd64.deb
```

* Via [Winget](https://github.com/microsoft/winget-cli) for Windows
Expand Down Expand Up @@ -171,7 +171,7 @@ Binaries for Linux, Windows and Mac are available as tarballs in the [release pa

## Building From Source

K9s is currently using GO v1.22.X or above.
K9s is currently using GO v1.23.X or above.
In order to build K9s from source you must:

1. Clone the repo
Expand Down Expand Up @@ -362,6 +362,8 @@ K9s uses aliases to navigate most K8s resources.
| To view and switch to another Kubernetes context (Pod view) | `:`ctx⏎ | |
| To view and switch directly to another Kubernetes context (Last used view) | `:`ctx context-name⏎ | |
| To view and switch to another Kubernetes namespace | `:`ns⏎ | |
| To switch back to the last active command (like how "cd -" works) | `-` | Navigation that adds breadcrumbs to the bottom are not commands |
| To go back and forward through the command history | back: `[`, forward: `]` | Same as above |
| To view all saved resources | `:`screendump or sd⏎ | |
| To delete a resource (TAB and ENTER to confirm) | `ctrl-d` | |
| To kill a resource (no confirmation dialog, equivalent to kubectl delete --now) | `ctrl-k` | |
Expand Down Expand Up @@ -396,7 +398,7 @@ You can now override the context portForward default address configuration by se
maxConnRetry: 5
# Indicates whether modification commands like delete/kill/edit are disabled. Default is false
readOnly: false
# Toggles whether k9s should exit when CTRL-C is pressed. When set to true, you will need to exist k9s via the :quit command. Default is false.
# Toggles whether k9s should exit when CTRL-C is pressed. When set to true, you will need to exit k9s via the :quit command. Default is false.
noExitOnCtrlC: false
#UI settings
ui:
Expand All @@ -411,13 +413,13 @@ You can now override the context portForward default address configuration by se
noIcons: false
# Toggles reactive UI. This option provide for watching on disk artifacts changes and update the UI live Defaults to false.
reactive: false
# By default all contexts wil use the dracula skin unless explicitly overridden in the context config file.
# By default all contexts will use the dracula skin unless explicitly overridden in the context config file.
skin: dracula # => assumes the file skins/dracula.yaml is present in the $XDG_DATA_HOME/k9s/skins directory
# Allows to set certain views default fullscreen mode. (yaml, helm history, describe, value_extender, details, logs) Default false
defaultsToFullScreen: false
# Toggles icons display as not all terminal support these chars.
noIcons: false
# Toggles whether k9s should check for the latest revision from the Github repository releases. Default is false.
# Toggles whether k9s should check for the latest revision from the GitHub repository releases. Default is false.
skipLatestRevCheck: false
# When altering kubeconfig or using multiple kube configs, k9s will clean up clusters configurations that are no longer in use. Setting this flag to true will keep k9s from cleaning up inactive cluster configs. Defaults to false.
keepMissingClusters: false
Expand All @@ -431,6 +433,8 @@ You can now override the context portForward default address configuration by se
sinceSeconds: 300 # => tail the last 5 mins.
# Toggles log line wrap. Default false
textWrap: false
# Autoscroll in logs will be disabled. Default is false.
disableAutoscroll: false
# Toggles log line timestamp info. Default false
showTime: false
# Provide shell pod customization when nodeShell feature gate is enabled!
Expand Down Expand Up @@ -563,6 +567,13 @@ In order to surface hotkeys globally please follow these steps:

---

## Port Forwarding over websockets

K9s follows `kubectl` feature flag environment variables to enable/disable port-forwarding over websockets. (default enabled in >1.30)
To disable Websocket support, set `KUBECTL_PORT_FORWARD_WEBSOCKETS=false`

---

## FastForwards

As of v0.25.0, you can leverage the `FastForwards` feature to tell K9s how to default port-forwards. In situations where you are dealing with multiple containers or containers exposing multiple ports, it can be cumbersome to specify the desired port-forward from the dialog as in most cases, you already know which container/port tuple you desire. For these use cases, you can now annotate your manifests with the following annotations:
Expand Down Expand Up @@ -620,7 +631,25 @@ The annotation value must specify a container to forward to as well as a local p

You can change which columns shows up for a given resource via custom views. To surface this feature, you will need to create a new configuration file, namely `$XDG_CONFIG_HOME/k9s/views.yaml`. This file leverages GVR (Group/Version/Resource) to configure the associated table view columns. If no GVR is found for a view the default rendering will take over (ie what we have now). Going wide will add all the remaining columns that are available on the given resource after your custom columns. To boot, you can edit your views config file and tune your resources views live!

> NOTE: This is experimental and will most likely change as we iron this out!
📢 🎉 As of `release v0.40.0` you can specify json parse expressions to further customize your resources rendering.

The new column syntax is as follows:

> COLUMN_NAME<:json_parse_expression><|column_attributes>

Where `:json_parse_expression` represents an expression to pull a specific snippet out of the resource manifest.
Similar to `kubectl -o custom-columns` command. This expression is optional.

Additionally, you can specify column attributes to further tailor the column rendering.
To use this you will need to add a `|` indicator followed by your rendering bits.
You can have one or more of the following attributes:

* `T` -> time column indicator
* `N` -> number column indicator
* `W` -> turns on wide column aka only shows while in wide mode. Defaults to the standard resource definition when present.
* `H` -> Hides the column
* `L` -> Left align (default)
* `R` -> Right align

Here is a sample views configuration that customize a pods and services views.

Expand All @@ -630,7 +659,9 @@ views:
v1/pods:
columns:
- AGE
- NAMESPACE
- NAMESPACE|WR # => 🌚 Specifies the NAMESPACE column to be right aligned and only visible while in wide mode
- ZORG:.metadata.labels.fred\.io\.kubernetes\.blee # => 🌚 extract fred.io.kubernetes.blee label into it's own column
- BLEE:.metadata.annotations.blee|R # => 🌚 extract annotation blee into it's own column and right align it
- NAME
- IP
- NODE
Expand All @@ -645,6 +676,8 @@ views:
- CLUSTER-IP
```

> 🩻 NOTE: This is experimental and will most likely change as we iron this out!

---

## Plugins
Expand All @@ -654,15 +687,15 @@ K9s allows you to extend your command line and tooling by defining your very own
A plugin is defined as follows:

* Shortcut option represents the key combination a user would type to activate the plugin. Valid values are [a-z], Shift-[A-Z], Ctrl-[A-Z].
* Override option make that the default action related to the shortcut will be overrided by the plugin
* Override option make that the default action related to the shortcut will be overridden by the plugin
* Confirm option (when enabled) lets you see the command that is going to be executed and gives you an option to confirm or prevent execution
* Description will be printed next to the shortcut in the k9s menu
* Scopes defines a collection of resources names/short-names for the views associated with the plugin. You can specify `all` to provide this shortcut for all views.
* Command represents ad-hoc commands the plugin runs upon activation
* Background specifies whether or not the command runs in the background
* Args specifies the various arguments that should apply to the command above
* OverwriteOutput boolean option allows plugin developers to provide custom messages on plugin stdout execution. See example in [#2644](https://github.com/derailed/k9s/pull/2644)
* Dangerous boolean option enables disabling the plugin when read-only mode is set. See [#2604](https://github.com/derailed/k9s/issues/2604)
* Dangerous boolean option enables disabling the plugin when read-only mode is set. See [#2604](https://github.com/derailed/k9s/issues/2604)

K9s does provide additional environment variables for you to customize your plugins arguments. Currently, the available environment variables are as follows:

Expand Down Expand Up @@ -694,9 +727,9 @@ plugins:
fred:
shortCut: Ctrl-L
override: false
overwriteOutput: false
overwriteOutput: false
confirm: false
dangerous: false
dangerous: false
description: Pod logs
scopes:
- pods
Expand Down Expand Up @@ -937,7 +970,7 @@ k9s:
noIcons: false
# Toggles reactive UI. This option provide for watching on disk artifacts changes and update the UI live Defaults to false.
reactive: false
# By default all contexts wil use the dracula skin unless explicitly overridden in the context config file.
# By default all contexts will use the dracula skin unless explicitly overridden in the context config file.
skin: dracula # => assumes the file skins/dracula.yaml is present in the $XDG_DATA_HOME/k9s/skins directory
defaultsToFullScreen: false
skipLatestRevCheck: false
Expand All @@ -958,6 +991,7 @@ k9s:
buffer: 5000
sinceSeconds: -1
textWrap: false
disableAutoscroll: false
showTime: false
thresholds:
cpu:
Expand Down Expand Up @@ -1083,12 +1117,12 @@ to make this project a reality!
## Meet The Core Team!
If you have chops in GO and K8s and would like to offer your time to help maintain and enhance this project, please reach out to me.
* [Fernand Galiana](https://github.com/derailed)
* <img src="assets/mail.png" width="16" height="auto" alt="email"/> [email protected]
* <img src="assets/twitter.png" width="16" height="auto" alt="twitter"/> [@kitesurfer](https://twitter.com/kitesurfer?lang=en)
* [Aleksei Romanenko](https://github.com/slimus)
We always enjoy hearing from folks who benefit from our work!
## Contributions Guideline
Expand Down
2 changes: 1 addition & 1 deletion change_logs/release_0.1.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rev and see if we're happier with some of the fixes!
```text
>po<ENTER>
```
+ Similarly to filter on a given resource you can use `/' and type your filter.
+ Similarly to filter on a given resource you can use `/` and type your filter.
+ In both instances `<ESC>` will back you out of command mode and into navigation mode.
<br/>
Expand Down
2 changes: 1 addition & 1 deletion change_logs/release_0.10.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Most of the refactors are around K8s resource fetching and viewing as well as na

## Custom Skins Per Cluster

In this release, we've added support for skins at the cluster level. Do you want K9s to look differently based on which cluster you're connecting to? All you'll need is to name the skin file in the K9s home directory as follows `mycluster_skin.yml`. If no cluster specific skin file is found, the standard `skin.yml` file will be loaded if present. Please checkout the `skins` directory in this repo or PR me if you have cool skins you'd like to share with your fellow K9ers as they will be featured in these release notes and in the project README.
In this release, we've added support for skins at the cluster level. Do you want K9s to look differently based on which cluster you're connecting to? All you'll need is to name the skin file in the K9s home directory as follows `mycluster_skin.yml`. If no cluster specific skin file is found, the standard `skin.yml` file will be loaded if present. Please checkout the `skins` directory in this repo or PR me if you have cool skins you'd like to share with your fellow K9sers as they will be featured in these release notes and in the project README.

## Hot(Ness)?

Expand Down
4 changes: 2 additions & 2 deletions change_logs/release_0.12.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Also if you dig this tool, please make some noise on social! [@kitesurfer](https

### Searchable Logs

There has been quiet a few demands for this feature. It should now be generally available in this drop. It works the same as the resource view ie `/fred`, you can also specify a fuzzy filter using `/-f blee-duh`. The paint is still fresh on that deal and not super confident that it will work nominally as I had to rework the logs to enable. So totally possible I've hosed something in the process.
There has been quite a few demands for this feature. It should now be generally available in this drop. It works the same as the resource view ie `/fred`, you can also specify a fuzzy filter using `/-f blee-duh`. The paint is still fresh on that deal and not super confident that it will work nominally as I had to rework the logs to enable. So totally possible I've hosed something in the process.

### APIServer Dud

Expand All @@ -38,7 +38,7 @@ k9s:

### K9s Slackers

I've enabled a [K9s slack channel](https://join.slack.com/t/k9sers/shared_invite/enQtOTAzNTczMDYwNjc5LWJlZjRkNzE2MzgzYWM0MzRiYjZhYTE3NDc1YjNhYmM2NTk2MjUxMWNkZGMzNjJiYzEyZmJiODBmZDYzOGQ5NWM) dedicated to all K9ers. This would be a place for us to meet and discuss ideas and use cases. I'll be honest here I am not a big slack afficionado as I don't do very well with interrupt drive workflows. But I think it would be a great resource for us all.
I've enabled a [K9s slack channel](https://join.slack.com/t/k9sers/shared_invite/enQtOTAzNTczMDYwNjc5LWJlZjRkNzE2MzgzYWM0MzRiYjZhYTE3NDc1YjNhYmM2NTk2MjUxMWNkZGMzNjJiYzEyZmJiODBmZDYzOGQ5NWM) dedicated to all K9sers. This would be a place for us to meet and discuss ideas and use cases. I'll be honest here I am not a big slack aficionado as I don't do very well with interrupt drive workflows. But I think it would be a great resource for us all.

NOTE: Please be kind to each others and threat everyone with respect as I would like this to be a safe and fun place for folks to hangout. Thank you for you support and understanding!!

Expand Down
2 changes: 1 addition & 1 deletion change_logs/release_0.2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Thank you so much for your support!!

+ [Feature #97](https://github.com/derailed/k9s/issues/97)
Changed log view to now use kubectl logs shell command.
There was some issues with the previous implementation with missing info and panics.
There were some issues with the previous implementation with missing info and panics.
NOTE! User must type Ctrl-C to exit the logs and navigate back to K9s
+ Reordered containers to show spec.containers first vs spec.initcontainers.
+ [Feature #29](https://github.com/derailed/k9s/issues/29)
Expand Down
2 changes: 1 addition & 1 deletion change_logs/release_0.3.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Thank you so much for your support!!

1. [Feature #124](https://github.com/derailed/k9s/issues/124)
1. *NodeView* Add current cpu/memory percentages to track current load on nodes.
2. *NodeView* Add requested cpu/memory percentages to track how much containers
2. *NodeView* Add requested cpu/memory percentages to track how many container
resources are requested on the cluster.
3. *NodeView* Add requested cpu/memory raw metrics
4. *NodeView* Add corresponding column sorters
Expand Down
Loading

0 comments on commit ee0ff68

Please sign in to comment.