update shell pod config
parent
037d6d3f54
commit
4bd37a492f
|
|
@ -9,6 +9,7 @@ type Cluster struct {
|
||||||
Namespace *Namespace `yaml:"namespace"`
|
Namespace *Namespace `yaml:"namespace"`
|
||||||
View *View `yaml:"view"`
|
View *View `yaml:"view"`
|
||||||
FeatureGates *FeatureGates `yaml:"featureGates"`
|
FeatureGates *FeatureGates `yaml:"featureGates"`
|
||||||
|
ShellPod *ShellPod `yaml:"shellPod"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCluster creates a new cluster configuration.
|
// NewCluster creates a new cluster configuration.
|
||||||
|
|
@ -17,6 +18,7 @@ func NewCluster() *Cluster {
|
||||||
Namespace: NewNamespace(),
|
Namespace: NewNamespace(),
|
||||||
View: NewView(),
|
View: NewView(),
|
||||||
FeatureGates: NewFeatureGates(),
|
FeatureGates: NewFeatureGates(),
|
||||||
|
ShellPod: NewShellPod(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,4 +36,9 @@ func (c *Cluster) Validate(conn client.Connection, ks KubeSettings) {
|
||||||
c.View = NewView()
|
c.View = NewView()
|
||||||
}
|
}
|
||||||
c.View.Validate()
|
c.View.Validate()
|
||||||
|
|
||||||
|
if c.ShellPod == nil {
|
||||||
|
c.ShellPod = NewShellPod()
|
||||||
|
}
|
||||||
|
c.ShellPod.Validate(conn, ks)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -261,7 +261,6 @@ func TestSetup(t *testing.T) {
|
||||||
|
|
||||||
var expectedConfig = `k9s:
|
var expectedConfig = `k9s:
|
||||||
refreshRate: 100
|
refreshRate: 100
|
||||||
dockerShellImage: busybox:1.31
|
|
||||||
headless: false
|
headless: false
|
||||||
readOnly: true
|
readOnly: true
|
||||||
noIcons: false
|
noIcons: false
|
||||||
|
|
@ -284,6 +283,12 @@ var expectedConfig = `k9s:
|
||||||
active: po
|
active: po
|
||||||
featureGates:
|
featureGates:
|
||||||
nodeShell: false
|
nodeShell: false
|
||||||
|
shellPod:
|
||||||
|
image: busybox:1.31
|
||||||
|
namespace: default
|
||||||
|
limits:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 100Mi
|
||||||
fred:
|
fred:
|
||||||
namespace:
|
namespace:
|
||||||
active: default
|
active: default
|
||||||
|
|
@ -297,6 +302,12 @@ var expectedConfig = `k9s:
|
||||||
active: po
|
active: po
|
||||||
featureGates:
|
featureGates:
|
||||||
nodeShell: false
|
nodeShell: false
|
||||||
|
shellPod:
|
||||||
|
image: busybox:1.31
|
||||||
|
namespace: default
|
||||||
|
limits:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 100Mi
|
||||||
minikube:
|
minikube:
|
||||||
namespace:
|
namespace:
|
||||||
active: kube-system
|
active: kube-system
|
||||||
|
|
@ -310,6 +321,12 @@ var expectedConfig = `k9s:
|
||||||
active: ctx
|
active: ctx
|
||||||
featureGates:
|
featureGates:
|
||||||
nodeShell: false
|
nodeShell: false
|
||||||
|
shellPod:
|
||||||
|
image: busybox:1.31
|
||||||
|
namespace: default
|
||||||
|
limits:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 100Mi
|
||||||
thresholds:
|
thresholds:
|
||||||
cpu:
|
cpu:
|
||||||
critical: 90
|
critical: 90
|
||||||
|
|
@ -321,7 +338,6 @@ var expectedConfig = `k9s:
|
||||||
|
|
||||||
var resetConfig = `k9s:
|
var resetConfig = `k9s:
|
||||||
refreshRate: 2
|
refreshRate: 2
|
||||||
dockerShellImage: busybox:1.31
|
|
||||||
headless: false
|
headless: false
|
||||||
readOnly: false
|
readOnly: false
|
||||||
noIcons: false
|
noIcons: false
|
||||||
|
|
@ -344,6 +360,12 @@ var resetConfig = `k9s:
|
||||||
active: po
|
active: po
|
||||||
featureGates:
|
featureGates:
|
||||||
nodeShell: false
|
nodeShell: false
|
||||||
|
shellPod:
|
||||||
|
image: busybox:1.31
|
||||||
|
namespace: default
|
||||||
|
limits:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 100Mi
|
||||||
thresholds:
|
thresholds:
|
||||||
cpu:
|
cpu:
|
||||||
critical: 90
|
critical: 90
|
||||||
|
|
|
||||||
|
|
@ -2,16 +2,11 @@ package config
|
||||||
|
|
||||||
import "github.com/derailed/k9s/internal/client"
|
import "github.com/derailed/k9s/internal/client"
|
||||||
|
|
||||||
const (
|
const defaultRefreshRate = 2
|
||||||
defaultRefreshRate = 2
|
|
||||||
// DefaultDockerShellImage specifies the docker image and tag for shelling into nodes.
|
|
||||||
DefaultDockerShellImage = "busybox:1.31"
|
|
||||||
)
|
|
||||||
|
|
||||||
// K9s tracks K9s configuration options.
|
// K9s tracks K9s configuration options.
|
||||||
type K9s struct {
|
type K9s struct {
|
||||||
RefreshRate int `yaml:"refreshRate"`
|
RefreshRate int `yaml:"refreshRate"`
|
||||||
DockerShellImage string `yaml:"dockerShellImage"`
|
|
||||||
Headless bool `yaml:"headless"`
|
Headless bool `yaml:"headless"`
|
||||||
ReadOnly bool `yaml:"readOnly"`
|
ReadOnly bool `yaml:"readOnly"`
|
||||||
NoIcons bool `yaml:"noIcons"`
|
NoIcons bool `yaml:"noIcons"`
|
||||||
|
|
@ -29,11 +24,10 @@ type K9s struct {
|
||||||
// NewK9s create a new K9s configuration.
|
// NewK9s create a new K9s configuration.
|
||||||
func NewK9s() *K9s {
|
func NewK9s() *K9s {
|
||||||
return &K9s{
|
return &K9s{
|
||||||
RefreshRate: defaultRefreshRate,
|
RefreshRate: defaultRefreshRate,
|
||||||
DockerShellImage: DefaultDockerShellImage,
|
Logger: NewLogger(),
|
||||||
Logger: NewLogger(),
|
Clusters: make(map[string]*Cluster),
|
||||||
Clusters: make(map[string]*Cluster),
|
Thresholds: NewThreshold(),
|
||||||
Thresholds: NewThreshold(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,9 +98,6 @@ func (k *K9s) validateDefaults() {
|
||||||
if k.RefreshRate <= 0 {
|
if k.RefreshRate <= 0 {
|
||||||
k.RefreshRate = defaultRefreshRate
|
k.RefreshRate = defaultRefreshRate
|
||||||
}
|
}
|
||||||
if k.DockerShellImage == "" {
|
|
||||||
k.DockerShellImage = DefaultDockerShellImage
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k *K9s) validateClusters(c client.Connection, ks KubeSettings) {
|
func (k *K9s) validateClusters(c client.Connection, ks KubeSettings) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/derailed/k9s/internal/client"
|
||||||
|
v1 "k8s.io/api/core/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
const defaultDockerShellImage = "busybox:1.31"
|
||||||
|
|
||||||
|
// Limits represents resource limits.
|
||||||
|
type Limits map[v1.ResourceName]string
|
||||||
|
|
||||||
|
// ShellPod represents k9s shell configuration.
|
||||||
|
type ShellPod struct {
|
||||||
|
Image string `json:"Image"`
|
||||||
|
Namespace string `json:"namespace"`
|
||||||
|
Limits Limits `json:"resources,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewShellPod returns a new instance.
|
||||||
|
func NewShellPod() *ShellPod {
|
||||||
|
return &ShellPod{
|
||||||
|
Image: defaultDockerShellImage,
|
||||||
|
Namespace: "default",
|
||||||
|
Limits: defaultLimits(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate validates the configuration.
|
||||||
|
func (s *ShellPod) Validate(client.Connection, KubeSettings) {
|
||||||
|
if s.Image == "" {
|
||||||
|
s.Image = defaultDockerShellImage
|
||||||
|
}
|
||||||
|
if len(s.Limits) == 0 {
|
||||||
|
s.Limits = defaultLimits()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func defaultLimits() Limits {
|
||||||
|
return Limits{
|
||||||
|
v1.ResourceCPU: "100m",
|
||||||
|
v1.ResourceMemory: "100Mi",
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue