Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add imagePullSecrets and imagePullPolicy configuration for shellpod #2301

Merged
merged 8 commits into from
Nov 21, 2023
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,11 @@ K9s uses aliases to navigate most K8s resources.
image: killerAdmin
# The namespace to launch to shell pod into.
namespace: fred
# imagePullPolicy defaults to Always
imagePullPolicy: Always
# imagePullSecrets defaults to no secret
imagePullSecrets:
- name: my-regcred
# The resource limit to set on the shell pod.
limits:
cpu: 100m
Expand Down Expand Up @@ -429,6 +434,12 @@ k9s:
shellPod:
image: cool_kid_admin:42
namespace: blee
# imagePullPolicy defaults to Always
imagePullPolicy: Always
# imagePullSecrets defaults to no secret
imagePullSecrets:
- name: my-regcred
# The resource limit to set on the shell pod.
limits:
cpu: 100m
memory: 100Mi
Expand Down
14 changes: 8 additions & 6 deletions internal/config/shell_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ type Limits map[v1.ResourceName]string

// ShellPod represents k9s shell configuration.
type ShellPod struct {
Image string `json:"image"`
Command []string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Namespace string `json:"namespace"`
Limits Limits `json:"resources,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
Image string `json:"image"`
ImagePullSecrets []v1.LocalObjectReference `json:"imagePullSecrets,omitempty" yaml:"imagePullSecrets,omitempty"`
ImagePullPolicy v1.PullPolicy `json:"imagePullPolicy,omitempty" yaml:"imagePullPolicy,omitempty"`
Command []string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Namespace string `json:"namespace"`
Limits Limits `json:"resources,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
}

// NewShellPod returns a new instance.
Expand Down
6 changes: 4 additions & 2 deletions internal/view/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,9 @@ func k9sShellPod(node string, cfg *config.ShellPod) *v1.Pod {

log.Debug().Msgf("Shell Config %#v", cfg)
c := v1.Container{
Name: k9sShell,
Image: cfg.Image,
Name: k9sShell,
Image: cfg.Image,
ImagePullPolicy: cfg.ImagePullPolicy,
VolumeMounts: []v1.VolumeMount{
{
Name: "root-vol",
Expand Down Expand Up @@ -390,6 +391,7 @@ func k9sShellPod(node string, cfg *config.ShellPod) *v1.Pod {
RestartPolicy: v1.RestartPolicyNever,
HostPID: true,
HostNetwork: true,
ImagePullSecrets: cfg.ImagePullSecrets,
TerminationGracePeriodSeconds: &grace,
Volumes: []v1.Volume{
{
Expand Down