Skip to content

Commit

Permalink
feat: add imagePullSecrets and imagePullPolicy configuration for shel…
Browse files Browse the repository at this point in the history
…lpod (#2301)

* feat: add imagePullSecrets and imagePullPolicy in shell_pod for internal registry use cases

* docs: add imagePullPolicy and imagePullSecrets configuration example

* docs: remove comments

* docs: use same wording

* docs: remove useless phrase

* fix: truncated comment

* fix: use correct type, remove useless if

* add: ImagePullPolicy on container variable

---------

Co-authored-by: clementlachaussee <[email protected]>
  • Loading branch information
ClementLachaussee and ClementLachaussee authored Nov 21, 2023
1 parent a208059 commit 2d8fb99
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
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 @@ -15,12 +15,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 @@ -360,8 +360,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 @@ -393,6 +394,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

0 comments on commit 2d8fb99

Please sign in to comment.