Skip to content

Commit 90a810f

Browse files
authored
K9s/release v0.31.8 (#2528)
* [Maint] Fix race condition issue * [Bug] Fix #2501 * [Maint] Allow reference to resource aliases for plugins * [Feat] Intro cp namespace command + misc cleanup * [Maint] Rev k8s v0.29.1 * [Bug] Fix #1033, #1558 * [Bug] Fix #2527 * [Bug] Fix #2520 * rel v0.31.8
1 parent 763a6b0 commit 90a810f

33 files changed

+979
-118
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ DATE ?= $(shell TZ=UTC date -j -f "%s" ${SOURCE_DATE_EPOCH} +"%Y-%m-%dT%H:
1111
else
1212
DATE ?= $(shell date -u -d @${SOURCE_DATE_EPOCH} +"%Y-%m-%dT%H:%M:%SZ")
1313
endif
14-
VERSION ?= v0.31.7
14+
VERSION ?= v0.31.8
1515
IMG_NAME := derailed/k9s
1616
IMAGE := ${IMG_NAME}:${VERSION}
1717

change_logs/release_v0.31.8.md

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/k9s.png" align="center" width="800" height="auto"/>
2+
3+
# Release v0.31.8
4+
5+
## Notes
6+
7+
Thank you to all that contributed with flushing out issues and enhancements for K9s!
8+
I'll try to mark some of these issues as fixed. But if you don't mind grab the latest rev
9+
and see if we're happier with some of the fixes!
10+
If you've filed an issue please help me verify and close.
11+
12+
Your support, kindness and awesome suggestions to make K9s better are, as ever, very much noted and appreciated!
13+
Also big thanks to all that have allocated their own time to help others on both slack and on this repo!!
14+
15+
As you may know, K9s is not pimped out by corps with deep pockets, thus if you feel K9s is helping your Kubernetes journey,
16+
please consider joining our [sponsorship program](https://github.com/sponsors/derailed) and/or make some noise on social! [@kitesurfer](https://twitter.com/kitesurfer)
17+
18+
On Slack? Please join us [K9slackers](https://join.slack.com/t/k9sers/shared_invite/enQtOTA5MDEyNzI5MTU0LWQ1ZGI3MzliYzZhZWEyNzYxYzA3NjE0YTk1YmFmNzViZjIyNzhkZGI0MmJjYzhlNjdlMGJhYzE2ZGU1NjkyNTM)
19+
20+
## Maintenance Release!
21+
22+
Thank you all for pitching in and helping flesh out issues!!
23+
24+
Please make sure to add gory details to issues ie relevant configs, debug logs, etc...
25+
26+
Comments like: `same here!` or `me to!` doesn't really cut it for us to zero in ;(
27+
Everyone has slightly different settings/platforms so every little bits of info helps with the resolves even if seemingly irrelevant.
28+
29+
---
30+
31+
## Videos Are In The Can!
32+
33+
Please dial [K9s Channel](https://www.youtube.com/channel/UC897uwPygni4QIjkPCpgjmw) for up coming content...
34+
35+
* [K9s v0.31.0 Configs+Sneak peek](https://youtu.be/X3444KfjguE)
36+
* [K9s v0.30.0 Sneak peek](https://youtu.be/mVBc1XneRJ4)
37+
* [Vulnerability Scans](https://youtu.be/ULkl0MsaidU)
38+
39+
---
40+
41+
## ♫ Sounds Behind The Release ♭
42+
43+
Going back to the classics...
44+
45+
* [Ambulance Blues - Neil Young](https://www.youtube.com/watch?v=bCQisTEdBwY)
46+
* [Christopher Columbus - Burning Spear](https://www.youtube.com/watch?v=5qbMKTY_Cr0)
47+
* [Feelin' the Same - Clinton Fearon](https://www.youtube.com/watch?v=aRPF2Yta_cs)
48+
49+
---
50+
51+
## A Word From Our Sponsors...
52+
53+
To all the good folks below that opted to `pay it forward` and join our sponsorship program, I salute you!!
54+
55+
* [Andreas Frangopoulos](https://github.com/qubeio)
56+
* [Tu Hoang](https://github.com/rebyn)
57+
* [Shoshin Nikita](https://github.com/ShoshinNikita)
58+
* [Dima Altukhov](https://github.com/alt-dima)
59+
* [wpbeckwith](https://github.com/wpbeckwith)
60+
* [a-thomas-22](https://github.com/a-thomas-22)
61+
* [kmath313](https://github.com/kmath313)
62+
* [Jörgen](https://github.com/wthrbtn)
63+
* [Eckl, Máté](https://github.com/ecklm)
64+
* [Jacky Nguyen](https://github.com/nktpro)
65+
* [Chris Bradley](https://github.com/chrisbradleydev)
66+
* [Vytautas Kubilius](https://github.com/vytautaskubilius)
67+
* [Patrick Christensen](https://github.com/BuriedStPatrick)
68+
* [Ollie Lowson](https://github.com/ollielowson-wcbs)
69+
* [Mike Macaulay](https://github.com/mmacaula)
70+
* [David Birks](https://github.com/dbirks)
71+
* [James Hounshell](https://github.com/jameshounshell)
72+
* [elapse2039](https://github.com/elapse2039)
73+
* [Vinicius Xavier](https://github.com/vinixaavier)
74+
* [Phuc Phung](https://github.com/Foxhound401)
75+
* [ollielowson](https://github.com/ollielowson)
76+
77+
> Sponsorship cancellations since the last release: **4!** 🥹
78+
79+
---
80+
81+
## Resolved Issues
82+
83+
* [#2527](https://github.com/derailed/k9s/issues/2527) Multiple k9s panels open in parallel for the same cluster breaks config.yaml
84+
* [#2520](https://github.com/derailed/k9s/issues/2520) pods with init container with restartPolicy: Always stay in Init status
85+
* [#2501](https://github.com/derailed/k9s/issues/2501) Cannot add plugins to helm scope bug
86+
* [#2492](https://github.com/derailed/k9s/issues/2492) API Resources "carry over" between contexts, causing errors if they share shortnames
87+
* [#1158](https://github.com/derailed/k9s/issues/1158) Removing a helm release incorrectly determines the namespace of resources
88+
* [#1033](https://github.com/derailed/k9s/issues/1033) Helm delete deletes only the helm entry but not the deployment
89+
90+
---
91+
92+
## Contributed PRs
93+
94+
Please be sure to give `Big Thanks!` and `ATTA Girls/Boys!` to all the fine contributors for making K9s better for all of us!!
95+
96+
* [#2509](https://github.com/derailed/k9s/pull/2509) Fix Toggle Faults filtering
97+
* [#2511](https://github.com/derailed/k9s/pull/2511) adding the f command to pf extender view
98+
* [#2518](https://github.com/derailed/k9s/pull/2518) Added defaultsToFullScreen flag for Live/Details view,logs
99+
100+
---
101+
102+
<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/imhotep_logo.png" width="32" height="auto"/> © 2024 Imhotep Software LLC. All materials licensed under [Apache v2.0](http://www.apache.org/licenses/LICENSE-2.0)

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/anchore/syft v0.100.0
1212
github.com/atotto/clipboard v0.1.4
1313
github.com/cenkalti/backoff/v4 v4.2.1
14-
github.com/derailed/popeye v0.11.2
14+
github.com/derailed/popeye v0.11.3
1515
github.com/derailed/tcell/v2 v2.3.1-rc.3
1616
github.com/derailed/tview v0.8.3
1717
github.com/fatih/color v1.16.0
@@ -22,7 +22,7 @@ require (
2222
github.com/olekukonko/tablewriter v0.0.5
2323
github.com/petergtz/pegomock v2.9.0+incompatible
2424
github.com/rakyll/hey v0.1.4
25-
github.com/rs/zerolog v1.31.0
25+
github.com/rs/zerolog v1.32.0
2626
github.com/sahilm/fuzzy v0.1.0
2727
github.com/spf13/cobra v1.8.0
2828
github.com/stretchr/testify v1.8.4

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
381381
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
382382
github.com/deitch/magic v0.0.0-20230404182410-1ff89d7342da h1:ZOjWpVsFZ06eIhnh4mkaceTiVoktdU67+M7KDHJ268M=
383383
github.com/deitch/magic v0.0.0-20230404182410-1ff89d7342da/go.mod h1:B3tI9iGHi4imdLi4Asdha1Sc6feLMTfPLXh9IUYmysk=
384-
github.com/derailed/popeye v0.11.2 h1:8MKMjYBJdYNktTKeh98TeT127jZY6CFAsurrENoTZCY=
385-
github.com/derailed/popeye v0.11.2/go.mod h1:HygqX7A8BwidorJjJUnWDZ5AvbxHIU7uRwXgOtn9GwY=
384+
github.com/derailed/popeye v0.11.3 h1:gQUp6zuSIRDBdyLS1Ln0nFs8FbQ+KGE+iQxe0w4Ug8M=
385+
github.com/derailed/popeye v0.11.3/go.mod h1:HygqX7A8BwidorJjJUnWDZ5AvbxHIU7uRwXgOtn9GwY=
386386
github.com/derailed/tcell/v2 v2.3.1-rc.3 h1:9s1fmyRcSPRlwr/C9tcpJKCujbrtmPpST6dcMUD2piY=
387387
github.com/derailed/tcell/v2 v2.3.1-rc.3/go.mod h1:nf68BEL8fjmXQHJT3xZjoZFs2uXOzyJcNAQqGUEMrFY=
388388
github.com/derailed/tview v0.8.3 h1:jhN7LW7pfCWf7Z6VC5Dpi/1usavOBZxz2mY90//TMsU=
@@ -1013,8 +1013,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
10131013
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
10141014
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
10151015
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
1016-
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
1017-
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
1016+
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
1017+
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
10181018
github.com/rubenv/sql-migrate v1.5.2 h1:bMDqOnrJVV/6JQgQ/MxOpU+AdO8uzYYA/TxFUBzFtS0=
10191019
github.com/rubenv/sql-migrate v1.5.2/go.mod h1:H38GW8Vqf8F0Su5XignRyaRcbXbJunSWxs+kmzlg0Is=
10201020
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=

internal/client/config.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const (
2020
defaultCallTimeoutDuration time.Duration = 15 * time.Second
2121

2222
// UsePersistentConfig caches client config to avoid reloads.
23-
UsePersistentConfig = true
23+
UsePersistentConfig = false
2424
)
2525

2626
// Config tracks a kubernetes configuration.
@@ -85,6 +85,24 @@ func (c *Config) SwitchContext(name string) error {
8585
return nil
8686
}
8787

88+
func (c *Config) Clone(ns string) (*genericclioptions.ConfigFlags, error) {
89+
flags := genericclioptions.NewConfigFlags(false)
90+
ct, err := c.CurrentContextName()
91+
if err != nil {
92+
return nil, err
93+
}
94+
cl, err := c.CurrentClusterName()
95+
if err != nil {
96+
return nil, err
97+
}
98+
flags.Context, flags.ClusterName = &ct, &cl
99+
flags.Namespace = &ns
100+
flags.Timeout = c.Flags().Timeout
101+
flags.KubeConfig = c.Flags().KubeConfig
102+
103+
return flags, nil
104+
}
105+
88106
// CurrentClusterName returns the currently active cluster name.
89107
func (c *Config) CurrentClusterName() (string, error) {
90108
if isSet(c.flags.ClusterName) {

internal/config/data/config.go

+2-17
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package data
66
import (
77
"fmt"
88
"io"
9-
"os"
109
"sync"
1110

1211
"github.com/derailed/k9s/internal/client"
@@ -29,6 +28,8 @@ func NewConfig(ct *api.Context) *Config {
2928

3029
// Validate ensures config is in norms.
3130
func (c *Config) Validate(conn client.Connection, ks KubeSettings) {
31+
c.mx.Lock()
32+
defer c.mx.Unlock()
3233

3334
if c.Context == nil {
3435
c.Context = NewContext()
@@ -42,19 +43,3 @@ func (c *Config) Dump(w io.Writer) {
4243

4344
fmt.Fprintf(w, "%s\n", string(bb))
4445
}
45-
46-
// Save saves the config to disk.
47-
func (c *Config) Save(path string) error {
48-
c.mx.RLock()
49-
defer c.mx.RUnlock()
50-
51-
if err := EnsureDirPath(path, DefaultDirMod); err != nil {
52-
return err
53-
}
54-
cfg, err := yaml.Marshal(c)
55-
if err != nil {
56-
return err
57-
}
58-
59-
return os.WriteFile(path, cfg, DefaultFileMod)
60-
}

internal/config/data/dir.go

+21-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"os"
1010
"path/filepath"
11+
"sync"
1112

1213
"github.com/derailed/k9s/internal/config/json"
1314
"github.com/rs/zerolog/log"
@@ -18,6 +19,7 @@ import (
1819
// Dir tracks context configurations.
1920
type Dir struct {
2021
root string
22+
mx sync.Mutex
2123
}
2224

2325
// NewDir returns a new instance.
@@ -50,14 +52,32 @@ func (d *Dir) Load(n string, ct *api.Context) (*Config, error) {
5052

5153
func (d *Dir) genConfig(path string, ct *api.Context) (*Config, error) {
5254
cfg := NewConfig(ct)
53-
if err := cfg.Save(path); err != nil {
55+
if err := d.Save(path, cfg); err != nil {
5456
return nil, err
5557
}
5658

5759
return cfg, nil
5860
}
5961

62+
func (d *Dir) Save(path string, c *Config) error {
63+
d.mx.Lock()
64+
defer d.mx.Unlock()
65+
66+
if err := EnsureDirPath(path, DefaultDirMod); err != nil {
67+
return err
68+
}
69+
cfg, err := yaml.Marshal(c)
70+
if err != nil {
71+
return err
72+
}
73+
74+
return os.WriteFile(path, cfg, DefaultFileMod)
75+
}
76+
6077
func (d *Dir) loadConfig(path string) (*Config, error) {
78+
d.mx.Lock()
79+
defer d.mx.Unlock()
80+
6181
bb, err := os.ReadFile(path)
6282
if err != nil {
6383
return nil, err

internal/config/k9s.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func (k *K9s) Save() error {
7878
data.MainConfigFile,
7979
)
8080

81-
return k.getActiveConfig().Save(path)
81+
return k.dir.Save(path, k.getActiveConfig())
8282
}
8383

8484
// Merge merges k9s configs.
@@ -157,7 +157,6 @@ func (k *K9s) ActiveContextName() string {
157157

158158
// ActiveContext returns the currently active context.
159159
func (k *K9s) ActiveContext() (*data.Context, error) {
160-
161160
if cfg := k.getActiveConfig(); cfg != nil && cfg.Context != nil {
162161
return cfg.Context, nil
163162
}

internal/dao/helm_chart.go

+14-10
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"helm.sh/helm/v3/pkg/action"
1616
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1717
"k8s.io/apimachinery/pkg/runtime"
18+
"k8s.io/cli-runtime/pkg/genericclioptions"
1819
)
1920

2021
var (
@@ -31,7 +32,7 @@ type HelmChart struct {
3132

3233
// List returns a collection of resources.
3334
func (h *HelmChart) List(ctx context.Context, ns string) ([]runtime.Object, error) {
34-
cfg, err := ensureHelmConfig(h.Client(), ns)
35+
cfg, err := ensureHelmConfig(h.Client().Config().Flags(), ns)
3536
if err != nil {
3637
return nil, err
3738
}
@@ -55,7 +56,7 @@ func (h *HelmChart) List(ctx context.Context, ns string) ([]runtime.Object, erro
5556
// Get returns a resource.
5657
func (h *HelmChart) Get(_ context.Context, path string) (runtime.Object, error) {
5758
ns, n := client.Namespaced(path)
58-
cfg, err := ensureHelmConfig(h.Client(), ns)
59+
cfg, err := ensureHelmConfig(h.Client().Config().Flags(), ns)
5960
if err != nil {
6061
return nil, err
6162
}
@@ -70,7 +71,7 @@ func (h *HelmChart) Get(_ context.Context, path string) (runtime.Object, error)
7071
// GetValues returns values for a release
7172
func (h *HelmChart) GetValues(path string, allValues bool) ([]byte, error) {
7273
ns, n := client.Namespaced(path)
73-
cfg, err := ensureHelmConfig(h.Client(), ns)
74+
cfg, err := ensureHelmConfig(h.Client().Config().Flags(), ns)
7475
if err != nil {
7576
return nil, err
7677
}
@@ -87,7 +88,7 @@ func (h *HelmChart) GetValues(path string, allValues bool) ([]byte, error) {
8788
// Describe returns the chart notes.
8889
func (h *HelmChart) Describe(path string) (string, error) {
8990
ns, n := client.Namespaced(path)
90-
cfg, err := ensureHelmConfig(h.Client(), ns)
91+
cfg, err := ensureHelmConfig(h.Client().Config().Flags(), ns)
9192
if err != nil {
9293
return "", err
9394
}
@@ -102,7 +103,7 @@ func (h *HelmChart) Describe(path string) (string, error) {
102103
// ToYAML returns the chart manifest.
103104
func (h *HelmChart) ToYAML(path string, showManaged bool) (string, error) {
104105
ns, n := client.Namespaced(path)
105-
cfg, err := ensureHelmConfig(h.Client(), ns)
106+
cfg, err := ensureHelmConfig(h.Client().Config().Flags(), ns)
106107
if err != nil {
107108
return "", err
108109
}
@@ -122,10 +123,13 @@ func (h *HelmChart) Delete(_ context.Context, path string, _ *metav1.DeletionPro
122123
// Uninstall uninstalls a HelmChart.
123124
func (h *HelmChart) Uninstall(path string, keepHist bool) error {
124125
ns, n := client.Namespaced(path)
125-
cfg, err := ensureHelmConfig(h.Client(), ns)
126+
flags := h.Client().Config().Flags()
127+
flags.Namespace = &ns
128+
cfg, err := ensureHelmConfig(flags, ns)
126129
if err != nil {
127130
return err
128131
}
132+
129133
u := action.NewUninstall(cfg)
130134
u.KeepHistory = keepHist
131135
res, err := u.Run(n)
@@ -140,13 +144,13 @@ func (h *HelmChart) Uninstall(path string, keepHist bool) error {
140144
}
141145

142146
// ensureHelmConfig return a new configuration.
143-
func ensureHelmConfig(c client.Connection, ns string) (*action.Configuration, error) {
147+
func ensureHelmConfig(flags *genericclioptions.ConfigFlags, ns string) (*action.Configuration, error) {
144148
cfg := new(action.Configuration)
145-
err := cfg.Init(c.Config().Flags(), ns, os.Getenv("HELM_DRIVER"), helmLogger)
149+
err := cfg.Init(flags, ns, os.Getenv("HELM_DRIVER"), helmLogger)
146150

147151
return cfg, err
148152
}
149153

150-
func helmLogger(s string, args ...interface{}) {
151-
log.Debug().Msgf("%s %v", s, args)
154+
func helmLogger(fmt string, args ...interface{}) {
155+
log.Debug().Msgf("[Helm] "+fmt, args...)
152156
}

0 commit comments

Comments
 (0)