feat: add imagePullSecrets and imagePullPolicy configuration for shellpod (#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 <clement_lachaussee@ext.carrefour.com>
mine
ClementLachaussee 2023-11-21 21:03:27 +01:00 committed by GitHub
parent a208059e29
commit 2d8fb99993
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 8 deletions

View File

@ -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
@ -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

View File

@ -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.

View File

@ -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",
@ -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{
{