test pass
parent
a7e4d890f3
commit
921a39f897
|
|
@ -5,7 +5,7 @@
|
|||
K9s provides a curses based terminal UI to interact with your Kubernetes clusters.
|
||||
The aim of this project is to make it easier to navigate, observe and manage
|
||||
your applications in the wild. K9s continually watches Kubernetes
|
||||
for changes and offers subsequent commands to interact with observed resources.
|
||||
for changes and offers subsequent commands to interact with observed Kubernetes resources.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -14,6 +14,7 @@ for changes and offers subsequent commands to interact with observed resources.
|
|||
[](https://github.com/derailed/k9s/releases)
|
||||
[](https://github.com/mum4k/termdash/blob/master/LICENSE)
|
||||
[](https://snapcraft.io/k9s)
|
||||
[]()
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -418,7 +419,7 @@ Available color names are defined below:
|
|||
This initial drop is brittle. K9s will most likely blow up...
|
||||
|
||||
1. You're running older versions of Kubernetes. K9s works best Kubernetes 1.12+.
|
||||
1. You don't have enough RBAC fu to manage your cluster (see RBAC section below).
|
||||
2. You don't have enough RBAC fu to manage your cluster.
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
26
cmd/root.go
26
cmd/root.go
|
|
@ -76,7 +76,7 @@ func run(cmd *cobra.Command, args []string) {
|
|||
app := views.NewApp(cfg)
|
||||
{
|
||||
defer app.BailOut()
|
||||
app.Init(version, refreshRate, k8sFlags)
|
||||
app.Init(version, refreshRate)
|
||||
app.Run()
|
||||
}
|
||||
}
|
||||
|
|
@ -138,6 +138,7 @@ func initK9sFlags() {
|
|||
|
||||
func initK8sFlags() {
|
||||
k8sFlags = genericclioptions.NewConfigFlags()
|
||||
|
||||
rootCmd.Flags().StringVar(
|
||||
k8sFlags.KubeConfig,
|
||||
"kubeconfig",
|
||||
|
|
@ -173,6 +174,19 @@ func initK8sFlags() {
|
|||
"The name of the kubeconfig user to use",
|
||||
)
|
||||
|
||||
rootCmd.Flags().StringVarP(
|
||||
k8sFlags.Namespace,
|
||||
"namespace",
|
||||
"n",
|
||||
"",
|
||||
"If present, the namespace scope for this CLI request",
|
||||
)
|
||||
|
||||
initAsFlags()
|
||||
initCertFlags()
|
||||
}
|
||||
|
||||
func initAsFlags() {
|
||||
rootCmd.Flags().StringVar(
|
||||
k8sFlags.Impersonate,
|
||||
"as",
|
||||
|
|
@ -186,7 +200,9 @@ func initK8sFlags() {
|
|||
[]string{},
|
||||
"Group to impersonate for the operation",
|
||||
)
|
||||
}
|
||||
|
||||
func initCertFlags() {
|
||||
rootCmd.Flags().BoolVar(
|
||||
k8sFlags.Insecure,
|
||||
"insecure-skip-tls-verify",
|
||||
|
|
@ -221,14 +237,6 @@ func initK8sFlags() {
|
|||
"",
|
||||
"Bearer token for authentication to the API server",
|
||||
)
|
||||
|
||||
rootCmd.Flags().StringVarP(
|
||||
k8sFlags.Namespace,
|
||||
"namespace",
|
||||
"n",
|
||||
"",
|
||||
"If present, the namespace scope for this CLI request",
|
||||
)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ func newTable() *Table {
|
|||
func newTableHeader() *TableHeader {
|
||||
return &TableHeader{
|
||||
FgColor: "white",
|
||||
BgColor: "red",
|
||||
BgColor: "black",
|
||||
SorterColor: "aqua",
|
||||
}
|
||||
}
|
||||
|
|
@ -223,9 +223,9 @@ func newMenu() *Menu {
|
|||
}
|
||||
|
||||
// NewStyles creates a new default config.
|
||||
func NewStyles(p string) (*Styles, error) {
|
||||
func NewStyles(path string) (*Styles, error) {
|
||||
s := &Styles{Style: newStyle()}
|
||||
return s, s.load(p)
|
||||
return s, s.load(path)
|
||||
}
|
||||
|
||||
// FgColor returns the foreground color.
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import (
|
|||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions/printers"
|
||||
"k8s.io/kubernetes/pkg/kubectl/describe"
|
||||
versioned "k8s.io/kubernetes/pkg/kubectl/describe/versioned"
|
||||
|
|
@ -127,7 +126,7 @@ func (b *Base) List(ns string) (Columnars, error) {
|
|||
}
|
||||
|
||||
// Describe a given resource.
|
||||
func (b *Base) Describe(kind, pa string, flags *genericclioptions.ConfigFlags) (string, error) {
|
||||
func (b *Base) Describe(kind, pa string) (string, error) {
|
||||
ns, n := namespaced(pa)
|
||||
|
||||
mapping, err := k8s.RestMapping.Find(kind)
|
||||
|
|
@ -136,7 +135,7 @@ func (b *Base) Describe(kind, pa string, flags *genericclioptions.ConfigFlags) (
|
|||
return "", err
|
||||
}
|
||||
|
||||
d, err := versioned.Describer(flags, mapping)
|
||||
d, err := versioned.Describer(b.Connection.Config().Flags(), mapping)
|
||||
if err != nil {
|
||||
log.Error().Err(err).Msgf("Unable to find describer for %#v", mapping)
|
||||
return "", err
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import (
|
|||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||
mv1beta1 "k8s.io/metrics/pkg/apis/metrics/v1beta1"
|
||||
)
|
||||
|
||||
|
|
@ -104,7 +103,7 @@ type (
|
|||
Get(path string) (Columnar, error)
|
||||
List(ns string) (Columnars, error)
|
||||
Delete(path string, cascade, force bool) error
|
||||
Describe(kind, pa string, flags *genericclioptions.ConfigFlags) (string, error)
|
||||
Describe(kind, pa string) (string, error)
|
||||
Marshal(pa string) (string, error)
|
||||
Header(ns string) Row
|
||||
NumCols(ns string) map[string]bool
|
||||
|
|
@ -189,7 +188,7 @@ func (l *list) GetNamespace() string {
|
|||
// SetNamespace updates the namespace on the list. Default ns is "" for all
|
||||
// namespaces.
|
||||
func (l *list) SetNamespace(n string) {
|
||||
if l.namespace == NotNamespaced {
|
||||
if !l.Namespaced() {
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,12 @@ import (
|
|||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// AllNamespaces designates all namespaces.
|
||||
const AllNamespaces = ""
|
||||
const (
|
||||
// AllNamespaces designates all namespaces.
|
||||
allNamespaces = ""
|
||||
// AllNamespaces designate the special `all` namespace.
|
||||
allNamespace = "all"
|
||||
)
|
||||
|
||||
type (
|
||||
// Row represents a collection of string fields.
|
||||
|
|
@ -59,11 +63,14 @@ type Informer struct {
|
|||
|
||||
// NewInformer creates a new cluster resource informer
|
||||
func NewInformer(client k8s.Connection, ns string) *Informer {
|
||||
log.Debug().Msgf(">> Starting Informer")
|
||||
if ns == allNamespace {
|
||||
ns = allNamespaces
|
||||
}
|
||||
log.Debug().Msgf(">> Starting Informer in namespace %q", ns)
|
||||
i := Informer{client: client, informers: map[string]StoreInformer{}}
|
||||
|
||||
nsAccess, err := client.CanIAccess("", "", "namespaces", []string{"list", "watch"})
|
||||
if ns == AllNamespaces && (err != nil || !nsAccess) {
|
||||
if ns == allNamespaces && (err != nil || !nsAccess) {
|
||||
user, _ := client.Config().CurrentUserName()
|
||||
if err != nil {
|
||||
log.Panic().Err(err).Msgf("Unauthorized: All namespaces. No access for user `%s", user)
|
||||
|
|
@ -72,7 +79,7 @@ func NewInformer(client k8s.Connection, ns string) *Informer {
|
|||
}
|
||||
|
||||
// Namespace is locked in. check if user has auth for this ns access.
|
||||
if ns != AllNamespaces {
|
||||
if ns != allNamespaces {
|
||||
acc, err := client.CanIAccess("", ns, "namespaces", []string{"get", "watch"})
|
||||
if err != nil {
|
||||
log.Panic().Err(err).Msgf("Failed access %s", ns)
|
||||
|
|
@ -83,7 +90,7 @@ func NewInformer(client k8s.Connection, ns string) *Informer {
|
|||
}
|
||||
i.init(ns)
|
||||
} else {
|
||||
i.init(AllNamespaces)
|
||||
i.init(allNamespaces)
|
||||
}
|
||||
|
||||
return &i
|
||||
|
|
|
|||
Loading…
Reference in New Issue