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

Using the Module's spec.moduleLoader.container.imagePullPolicy. #1203

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/v1beta1/nodemodulesconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
type ModuleConfig struct {
KernelVersion string `json:"kernelVersion"`
ContainerImage string `json:"containerImage"`
// +kubebuilder:default=IfNotPresent
ImagePullPolicy v1.PullPolicy `json:"imagePullPolicy"`
// When InsecurePull is true, the container image can be pulled without TLS.
InsecurePull bool `json:"insecurePull"`
//+optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ metadata:
}
]
capabilities: Basic Install
createdAt: "2024-09-03T16:21:51Z"
createdAt: "2024-09-08T06:59:15Z"
operatorframework.io/suggested-namespace: openshift-kmm-hub
operators.operatorframework.io/builder: operator-sdk-v1.32.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ metadata:
}
]
capabilities: Basic Install
createdAt: "2024-09-03T16:21:50Z"
createdAt: "2024-09-08T06:59:14Z"
operatorframework.io/suggested-namespace: openshift-kmm
operators.operatorframework.io/builder: operator-sdk-v1.32.0
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
Expand Down
12 changes: 12 additions & 0 deletions bundle/manifests/kmm.sigs.x-k8s.io_nodemodulesconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ spec:
properties:
containerImage:
type: string
imagePullPolicy:
default: IfNotPresent
description: PullPolicy describes a policy for if/when to
pull a container image
type: string
inTreeModuleToRemove:
type: string
inTreeModulesToRemove:
Expand Down Expand Up @@ -155,6 +160,7 @@ spec:
type: object
required:
- containerImage
- imagePullPolicy
- insecurePull
- kernelVersion
- modprobe
Expand Down Expand Up @@ -201,6 +207,11 @@ spec:
properties:
containerImage:
type: string
imagePullPolicy:
default: IfNotPresent
description: PullPolicy describes a policy for if/when to
pull a container image
type: string
inTreeModuleToRemove:
type: string
inTreeModulesToRemove:
Expand Down Expand Up @@ -298,6 +309,7 @@ spec:
type: object
required:
- containerImage
- imagePullPolicy
- insecurePull
- kernelVersion
- modprobe
Expand Down
12 changes: 12 additions & 0 deletions config/crd/bases/kmm.sigs.x-k8s.io_nodemodulesconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ spec:
properties:
containerImage:
type: string
imagePullPolicy:
default: IfNotPresent
description: PullPolicy describes a policy for if/when to
pull a container image
type: string
inTreeModuleToRemove:
type: string
inTreeModulesToRemove:
Expand Down Expand Up @@ -151,6 +156,7 @@ spec:
type: object
required:
- containerImage
- imagePullPolicy
- insecurePull
- kernelVersion
- modprobe
Expand Down Expand Up @@ -197,6 +203,11 @@ spec:
properties:
containerImage:
type: string
imagePullPolicy:
default: IfNotPresent
description: PullPolicy describes a policy for if/when to
pull a container image
type: string
inTreeModuleToRemove:
type: string
inTreeModulesToRemove:
Expand Down Expand Up @@ -294,6 +305,7 @@ spec:
type: object
required:
- containerImage
- imagePullPolicy
- insecurePull
- kernelVersion
- modprobe
Expand Down
1 change: 1 addition & 0 deletions internal/controllers/module_nmc_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ func (mnrh *moduleNMCReconcilerHelper) enableModuleOnNode(ctx context.Context, m
moduleConfig := kmmv1beta1.ModuleConfig{
KernelVersion: mld.KernelVersion,
ContainerImage: mld.ContainerImage,
ImagePullPolicy: mld.ImagePullPolicy,
InTreeModulesToRemove: mld.InTreeModulesToRemove,
Modprobe: mld.Modprobe,
}
Expand Down
9 changes: 5 additions & 4 deletions internal/controllers/nmc_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1141,10 +1141,11 @@ func (p *podManagerImpl) baseWorkerPod(ctx context.Context, nmc client.Object, i
Spec: v1.PodSpec{
InitContainers: []v1.Container{
{
Name: initContainerName,
Image: moduleConfig.ContainerImage,
Command: []string{"/bin/sh", "-c"},
Args: []string{""},
Name: initContainerName,
Image: moduleConfig.ContainerImage,
ImagePullPolicy: moduleConfig.ImagePullPolicy,
Command: []string{"/bin/sh", "-c"},
Args: []string{""},
VolumeMounts: []v1.VolumeMount{
{
Name: volNameTmp,
Expand Down
11 changes: 7 additions & 4 deletions internal/controllers/nmc_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ var _ = Describe("NodeModulesConfigReconciler_Reconcile", func() {
var moduleConfig = kmmv1beta1.ModuleConfig{
KernelVersion: "kernel-version",
ContainerImage: "container image",
ImagePullPolicy: v1.PullIfNotPresent,
InsecurePull: true,
InTreeModulesToRemove: []string{"intree1", "intree2"},
Modprobe: kmmv1beta1.ModprobeSpec{
Expand Down Expand Up @@ -1943,6 +1944,7 @@ func getBaseWorkerPod(subcommand string, owner ctrlclient.Object, firmwareHostPa
hostPathDirectoryOrCreate := v1.HostPathDirectoryOrCreate

configAnnotationValue := `containerImage: container image
imagePullPolicy: IfNotPresent
inTreeModulesToRemove:
- intree1
- intree2
Expand Down Expand Up @@ -2000,10 +2002,11 @@ cp -R /firmware-path/* /tmp/firmware-path;
Spec: v1.PodSpec{
InitContainers: []v1.Container{
{
Name: "image-extractor",
Image: "container image",
Command: []string{"/bin/sh", "-c"},
Args: []string{initContainerArg},
Name: "image-extractor",
Image: "container image",
ImagePullPolicy: v1.PullIfNotPresent,
Command: []string{"/bin/sh", "-c"},
Args: []string{initContainerArg},
Resources: v1.ResourceRequirements{
Limits: limits,
Requests: requests,
Expand Down
Loading