Skip to content

Commit

Permalink
K9s/release v0.31.8 (derailed#2528)
Browse files Browse the repository at this point in the history
* [Maint] Fix race condition issue

* [Bug] Fix derailed#2501

* [Maint] Allow reference to resource aliases for plugins

* [Feat] Intro cp namespace command + misc cleanup

* [Maint] Rev k8s v0.29.1

* [Bug] Fix derailed#1033, derailed#1558

* [Bug] Fix derailed#2527

* [Bug] Fix derailed#2520

* rel v0.31.8
  • Loading branch information
derailed authored Feb 7, 2024
1 parent 53a7c53 commit 01a2f7c
Show file tree
Hide file tree
Showing 33 changed files with 979 additions and 118 deletions.
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.31.7
VERSION ?= v0.31.8
IMG_NAME := derailed/k9s
IMAGE := ${IMG_NAME}:${VERSION}

Expand Down
102 changes: 102 additions & 0 deletions change_logs/release_v0.31.8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<img src="https://raw.githubusercontent.com/derailed/k9s/master/assets/k9s.png" align="center" width="800" height="auto"/>

# Release v0.31.8

## Notes

Thank you to all that contributed with flushing out issues and enhancements for K9s!
I'll try to mark some of these issues as fixed. But if you don't mind grab the latest rev
and see if we're happier with some of the fixes!
If you've filed an issue please help me verify and close.

Your support, kindness and awesome suggestions to make K9s better are, as ever, very much noted and appreciated!
Also big thanks to all that have allocated their own time to help others on both slack and on this repo!!

As you may know, K9s is not pimped out by corps with deep pockets, thus if you feel K9s is helping your Kubernetes journey,
please consider joining our [sponsorship program](https://github.com/sponsors/derailed) and/or make some noise on social! [@kitesurfer](https://twitter.com/kitesurfer)

On Slack? Please join us [K9slackers](https://join.slack.com/t/k9sers/shared_invite/enQtOTA5MDEyNzI5MTU0LWQ1ZGI3MzliYzZhZWEyNzYxYzA3NjE0YTk1YmFmNzViZjIyNzhkZGI0MmJjYzhlNjdlMGJhYzE2ZGU1NjkyNTM)

## Maintenance Release!

Thank you all for pitching in and helping flesh out issues!!

Please make sure to add gory details to issues ie relevant configs, debug logs, etc...

Comments like: `same here!` or `me to!` doesn't really cut it for us to zero in ;(
Everyone has slightly different settings/platforms so every little bits of info helps with the resolves even if seemingly irrelevant.

---

## Videos Are In The Can!

Please dial [K9s Channel](https://www.youtube.com/channel/UC897uwPygni4QIjkPCpgjmw) for up coming content...

* [K9s v0.31.0 Configs+Sneak peek](https://youtu.be/X3444KfjguE)
* [K9s v0.30.0 Sneak peek](https://youtu.be/mVBc1XneRJ4)
* [Vulnerability Scans](https://youtu.be/ULkl0MsaidU)

---

## ♫ Sounds Behind The Release ♭

Going back to the classics...

* [Ambulance Blues - Neil Young](https://www.youtube.com/watch?v=bCQisTEdBwY)
* [Christopher Columbus - Burning Spear](https://www.youtube.com/watch?v=5qbMKTY_Cr0)
* [Feelin' the Same - Clinton Fearon](https://www.youtube.com/watch?v=aRPF2Yta_cs)

---

## A Word From Our Sponsors...

To all the good folks below that opted to `pay it forward` and join our sponsorship program, I salute you!!

* [Andreas Frangopoulos](https://github.com/qubeio)
* [Tu Hoang](https://github.com/rebyn)
* [Shoshin Nikita](https://github.com/ShoshinNikita)
* [Dima Altukhov](https://github.com/alt-dima)
* [wpbeckwith](https://github.com/wpbeckwith)
* [a-thomas-22](https://github.com/a-thomas-22)
* [kmath313](https://github.com/kmath313)
* [Jörgen](https://github.com/wthrbtn)
* [Eckl, Máté](https://github.com/ecklm)
* [Jacky Nguyen](https://github.com/nktpro)
* [Chris Bradley](https://github.com/chrisbradleydev)
* [Vytautas Kubilius](https://github.com/vytautaskubilius)
* [Patrick Christensen](https://github.com/BuriedStPatrick)
* [Ollie Lowson](https://github.com/ollielowson-wcbs)
* [Mike Macaulay](https://github.com/mmacaula)
* [David Birks](https://github.com/dbirks)
* [James Hounshell](https://github.com/jameshounshell)
* [elapse2039](https://github.com/elapse2039)
* [Vinicius Xavier](https://github.com/vinixaavier)
* [Phuc Phung](https://github.com/Foxhound401)
* [ollielowson](https://github.com/ollielowson)

> Sponsorship cancellations since the last release: **4!** 🥹
---

## Resolved Issues

* [#2527](https://github.com/derailed/k9s/issues/2527) Multiple k9s panels open in parallel for the same cluster breaks config.yaml
* [#2520](https://github.com/derailed/k9s/issues/2520) pods with init container with restartPolicy: Always stay in Init status
* [#2501](https://github.com/derailed/k9s/issues/2501) Cannot add plugins to helm scope bug
* [#2492](https://github.com/derailed/k9s/issues/2492) API Resources "carry over" between contexts, causing errors if they share shortnames
* [#1158](https://github.com/derailed/k9s/issues/1158) Removing a helm release incorrectly determines the namespace of resources
* [#1033](https://github.com/derailed/k9s/issues/1033) Helm delete deletes only the helm entry but not the deployment

---

## Contributed PRs

Please be sure to give `Big Thanks!` and `ATTA Girls/Boys!` to all the fine contributors for making K9s better for all of us!!

* [#2509](https://github.com/derailed/k9s/pull/2509) Fix Toggle Faults filtering
* [#2511](https://github.com/derailed/k9s/pull/2511) adding the f command to pf extender view
* [#2518](https://github.com/derailed/k9s/pull/2518) Added defaultsToFullScreen flag for Live/Details view,logs

---

<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)
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/anchore/syft v0.100.0
github.com/atotto/clipboard v0.1.4
github.com/cenkalti/backoff/v4 v4.2.1
github.com/derailed/popeye v0.11.2
github.com/derailed/popeye v0.11.3
github.com/derailed/tcell/v2 v2.3.1-rc.3
github.com/derailed/tview v0.8.3
github.com/fatih/color v1.16.0
Expand All @@ -22,7 +22,7 @@ require (
github.com/olekukonko/tablewriter v0.0.5
github.com/petergtz/pegomock v2.9.0+incompatible
github.com/rakyll/hey v0.1.4
github.com/rs/zerolog v1.31.0
github.com/rs/zerolog v1.32.0
github.com/sahilm/fuzzy v0.1.0
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.8.4
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/deitch/magic v0.0.0-20230404182410-1ff89d7342da h1:ZOjWpVsFZ06eIhnh4mkaceTiVoktdU67+M7KDHJ268M=
github.com/deitch/magic v0.0.0-20230404182410-1ff89d7342da/go.mod h1:B3tI9iGHi4imdLi4Asdha1Sc6feLMTfPLXh9IUYmysk=
github.com/derailed/popeye v0.11.2 h1:8MKMjYBJdYNktTKeh98TeT127jZY6CFAsurrENoTZCY=
github.com/derailed/popeye v0.11.2/go.mod h1:HygqX7A8BwidorJjJUnWDZ5AvbxHIU7uRwXgOtn9GwY=
github.com/derailed/popeye v0.11.3 h1:gQUp6zuSIRDBdyLS1Ln0nFs8FbQ+KGE+iQxe0w4Ug8M=
github.com/derailed/popeye v0.11.3/go.mod h1:HygqX7A8BwidorJjJUnWDZ5AvbxHIU7uRwXgOtn9GwY=
github.com/derailed/tcell/v2 v2.3.1-rc.3 h1:9s1fmyRcSPRlwr/C9tcpJKCujbrtmPpST6dcMUD2piY=
github.com/derailed/tcell/v2 v2.3.1-rc.3/go.mod h1:nf68BEL8fjmXQHJT3xZjoZFs2uXOzyJcNAQqGUEMrFY=
github.com/derailed/tview v0.8.3 h1:jhN7LW7pfCWf7Z6VC5Dpi/1usavOBZxz2mY90//TMsU=
Expand Down Expand Up @@ -1013,8 +1013,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A=
github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
github.com/rubenv/sql-migrate v1.5.2 h1:bMDqOnrJVV/6JQgQ/MxOpU+AdO8uzYYA/TxFUBzFtS0=
github.com/rubenv/sql-migrate v1.5.2/go.mod h1:H38GW8Vqf8F0Su5XignRyaRcbXbJunSWxs+kmzlg0Is=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand Down
20 changes: 19 additions & 1 deletion internal/client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const (
defaultCallTimeoutDuration time.Duration = 15 * time.Second

// UsePersistentConfig caches client config to avoid reloads.
UsePersistentConfig = true
UsePersistentConfig = false
)

// Config tracks a kubernetes configuration.
Expand Down Expand Up @@ -85,6 +85,24 @@ func (c *Config) SwitchContext(name string) error {
return nil
}

func (c *Config) Clone(ns string) (*genericclioptions.ConfigFlags, error) {
flags := genericclioptions.NewConfigFlags(false)
ct, err := c.CurrentContextName()
if err != nil {
return nil, err
}
cl, err := c.CurrentClusterName()
if err != nil {
return nil, err
}
flags.Context, flags.ClusterName = &ct, &cl
flags.Namespace = &ns
flags.Timeout = c.Flags().Timeout
flags.KubeConfig = c.Flags().KubeConfig

return flags, nil
}

// CurrentClusterName returns the currently active cluster name.
func (c *Config) CurrentClusterName() (string, error) {
if isSet(c.flags.ClusterName) {
Expand Down
19 changes: 2 additions & 17 deletions internal/config/data/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package data
import (
"fmt"
"io"
"os"
"sync"

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

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

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

fmt.Fprintf(w, "%s\n", string(bb))
}

// Save saves the config to disk.
func (c *Config) Save(path string) error {
c.mx.RLock()
defer c.mx.RUnlock()

if err := EnsureDirPath(path, DefaultDirMod); err != nil {
return err
}
cfg, err := yaml.Marshal(c)
if err != nil {
return err
}

return os.WriteFile(path, cfg, DefaultFileMod)
}
22 changes: 21 additions & 1 deletion internal/config/data/dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"os"
"path/filepath"
"sync"

"github.com/derailed/k9s/internal/config/json"
"github.com/rs/zerolog/log"
Expand All @@ -18,6 +19,7 @@ import (
// Dir tracks context configurations.
type Dir struct {
root string
mx sync.Mutex
}

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

func (d *Dir) genConfig(path string, ct *api.Context) (*Config, error) {
cfg := NewConfig(ct)
if err := cfg.Save(path); err != nil {
if err := d.Save(path, cfg); err != nil {
return nil, err
}

return cfg, nil
}

func (d *Dir) Save(path string, c *Config) error {
d.mx.Lock()
defer d.mx.Unlock()

if err := EnsureDirPath(path, DefaultDirMod); err != nil {
return err
}
cfg, err := yaml.Marshal(c)
if err != nil {
return err
}

return os.WriteFile(path, cfg, DefaultFileMod)
}

func (d *Dir) loadConfig(path string) (*Config, error) {
d.mx.Lock()
defer d.mx.Unlock()

bb, err := os.ReadFile(path)
if err != nil {
return nil, err
Expand Down
3 changes: 1 addition & 2 deletions internal/config/k9s.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (k *K9s) Save() error {
data.MainConfigFile,
)

return k.getActiveConfig().Save(path)
return k.dir.Save(path, k.getActiveConfig())
}

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

// ActiveContext returns the currently active context.
func (k *K9s) ActiveContext() (*data.Context, error) {

if cfg := k.getActiveConfig(); cfg != nil && cfg.Context != nil {
return cfg.Context, nil
}
Expand Down
24 changes: 14 additions & 10 deletions internal/dao/helm_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"helm.sh/helm/v3/pkg/action"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/cli-runtime/pkg/genericclioptions"
)

var (
Expand All @@ -31,7 +32,7 @@ type HelmChart struct {

// List returns a collection of resources.
func (h *HelmChart) List(ctx context.Context, ns string) ([]runtime.Object, error) {
cfg, err := ensureHelmConfig(h.Client(), ns)
cfg, err := ensureHelmConfig(h.Client().Config().Flags(), ns)
if err != nil {
return nil, err
}
Expand All @@ -55,7 +56,7 @@ func (h *HelmChart) List(ctx context.Context, ns string) ([]runtime.Object, erro
// Get returns a resource.
func (h *HelmChart) Get(_ context.Context, path string) (runtime.Object, error) {
ns, n := client.Namespaced(path)
cfg, err := ensureHelmConfig(h.Client(), ns)
cfg, err := ensureHelmConfig(h.Client().Config().Flags(), ns)
if err != nil {
return nil, err
}
Expand All @@ -70,7 +71,7 @@ func (h *HelmChart) Get(_ context.Context, path string) (runtime.Object, error)
// GetValues returns values for a release
func (h *HelmChart) GetValues(path string, allValues bool) ([]byte, error) {
ns, n := client.Namespaced(path)
cfg, err := ensureHelmConfig(h.Client(), ns)
cfg, err := ensureHelmConfig(h.Client().Config().Flags(), ns)
if err != nil {
return nil, err
}
Expand All @@ -87,7 +88,7 @@ func (h *HelmChart) GetValues(path string, allValues bool) ([]byte, error) {
// Describe returns the chart notes.
func (h *HelmChart) Describe(path string) (string, error) {
ns, n := client.Namespaced(path)
cfg, err := ensureHelmConfig(h.Client(), ns)
cfg, err := ensureHelmConfig(h.Client().Config().Flags(), ns)
if err != nil {
return "", err
}
Expand All @@ -102,7 +103,7 @@ func (h *HelmChart) Describe(path string) (string, error) {
// ToYAML returns the chart manifest.
func (h *HelmChart) ToYAML(path string, showManaged bool) (string, error) {
ns, n := client.Namespaced(path)
cfg, err := ensureHelmConfig(h.Client(), ns)
cfg, err := ensureHelmConfig(h.Client().Config().Flags(), ns)
if err != nil {
return "", err
}
Expand All @@ -122,10 +123,13 @@ func (h *HelmChart) Delete(_ context.Context, path string, _ *metav1.DeletionPro
// Uninstall uninstalls a HelmChart.
func (h *HelmChart) Uninstall(path string, keepHist bool) error {
ns, n := client.Namespaced(path)
cfg, err := ensureHelmConfig(h.Client(), ns)
flags := h.Client().Config().Flags()
flags.Namespace = &ns
cfg, err := ensureHelmConfig(flags, ns)
if err != nil {
return err
}

u := action.NewUninstall(cfg)
u.KeepHistory = keepHist
res, err := u.Run(n)
Expand All @@ -140,13 +144,13 @@ func (h *HelmChart) Uninstall(path string, keepHist bool) error {
}

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

return cfg, err
}

func helmLogger(s string, args ...interface{}) {
log.Debug().Msgf("%s %v", s, args)
func helmLogger(fmt string, args ...interface{}) {
log.Debug().Msgf("[Helm] "+fmt, args...)
}
Loading

0 comments on commit 01a2f7c

Please sign in to comment.