Skip to content

Commit

Permalink
Add ImageListPullJob to simplify ImagePullJob
Browse files Browse the repository at this point in the history
Signed-off-by: liuzhenwei <dui_zhang@163.com>

calculate status for imagelistpulljob

Signed-off-by: liuzhenwei <dui_zhang@163.com>

make generate manifests

Signed-off-by: liuzhenwei <dui_zhang@163.com>

add imagelistpulljob.status.status

Signed-off-by: liuzhenwei <dui_zhang@163.com>

make generate manifests

Signed-off-by: liuzhenwei <dui_zhang@163.com>

regist webhook handler

delete image pull job which is not existed in ImageListPullJob.Spec.Images

Signed-off-by: liuzhenwei <dui_zhang@163.com>

support the same behavior as image pull job for TTLSecondsAfterFinished and CompletionTime fields

Signed-off-by: liuzhenwei <dui_zhang@163.com>

resourceVersionExpectations

Signed-off-by: liuzhenwei <dui_zhang@163.com>

add ut

Signed-off-by: liuzhenwei <dui_zhang@163.com>

verify the maximum number of images cannot > 255

Signed-off-by: liuzhenwei <dui_zhang@163.com>

make generate manifests

Signed-off-by: liuzhenwei <dui_zhang@163.com>

add failled image pull job status

Signed-off-by: liuzhenwei <dui_zhang@163.com>

simplify imageListPullJobStatus and spec

Signed-off-by: liuzhenwei <dui_zhang@163.com>

fix mdlint

Signed-off-by: liuzhenwei <dui_zhang@163.com>

define ImagePullJobTemplate & fix imageliststatus when completionPolicy.Type is Never

Signed-off-by: liuzhenwei <dui_zhang@163.com>

fix,some print info

Signed-off-by: liuzhenwei <dui_zhang@163.com>

trigger ci

Signed-off-by: liuzhenwei <dui_zhang@163.com>

fix some issues of code

Signed-off-by: liuzhenwei <dui_zhang@163.com>

fix some logic of Expectations

Signed-off-by: liuzhenwei <dui_zhang@163.com>

Check for duplicate values of spec.images

Signed-off-by: liuzhenwei <dui_zhang@163.com>

move proposal doc to other PR

Signed-off-by: liuzhenwei <dui_zhang@163.com>

trigger ci&& modify comment

Signed-off-by: liuzhenwei <dui_zhang@163.com>

add e2e

Signed-off-by: liuzhenwei <dui_zhang@163.com>
  • Loading branch information
diannaowa committed Apr 18, 2023
1 parent 7f5046d commit aa2db64
Show file tree
Hide file tree
Showing 19 changed files with 1,455 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/e2e-1.16.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ jobs:
export KUBECONFIG=/home/runner/.kube/config
make ginkgo
set +e
./bin/ginkgo -timeout 60m -v --focus='\[apps\] (PullImage|ContainerRecreateRequest)' test/e2e
./bin/ginkgo -timeout 60m -v --focus='\[apps\] (PullImage|ContainerRecreateRequest|PullImages)' test/e2e
retVal=$?
restartCount=$(kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $4}')
if [ "${restartCount}" -eq "0" ];then
Expand Down Expand Up @@ -456,7 +456,7 @@ jobs:
export KUBECONFIG=/home/runner/.kube/config
make ginkgo
set +e
./bin/ginkgo -timeout 90m -v --skip='\[apps\] (StatefulSet|PullImage|ContainerRecreateRequest|DaemonSet|SidecarSet|EphemeralJob)' --skip='\[policy\] PodUnavailableBudget' test/e2e
./bin/ginkgo -timeout 90m -v --skip='\[apps\] (StatefulSet|PullImage|PullImages|ContainerRecreateRequest|DaemonSet|SidecarSet|EphemeralJob)' --skip='\[policy\] PodUnavailableBudget' test/e2e
retVal=$?
restartCount=$(kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $4}')
if [ "${restartCount}" -eq "0" ];then
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-1.24.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:
export KUBECONFIG=/home/runner/.kube/config
make ginkgo
set +e
./bin/ginkgo -timeout 60m -v --focus='\[apps\] (PullImage|ContainerRecreateRequest)' test/e2e
./bin/ginkgo -timeout 60m -v --focus='\[apps\] (PullImage|ContainerRecreateRequest|PullImages)' test/e2e
retVal=$?
restartCount=$(kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $4}')
if [ "${restartCount}" -eq "0" ];then
Expand Down Expand Up @@ -502,7 +502,7 @@ jobs:
export KUBECONFIG=/home/runner/.kube/config
make ginkgo
set +e
./bin/ginkgo -timeout 90m -v --skip='\[apps\] (StatefulSet|PullImage|ContainerRecreateRequest|DaemonSet|SidecarSet|EphemeralJob)' --skip='\[policy\] PodUnavailableBudget' test/e2e
./bin/ginkgo -timeout 90m -v --skip='\[apps\] (StatefulSet|PullImage|PullImages|ContainerRecreateRequest|DaemonSet|SidecarSet|EphemeralJob)' --skip='\[policy\] PodUnavailableBudget' test/e2e
retVal=$?
restartCount=$(kubectl get pod -n kruise-system -l control-plane=controller-manager --no-headers | awk '{print $4}')
if [ "${restartCount}" -eq "0" ];then
Expand Down
16 changes: 16 additions & 0 deletions apis/apps/defaults/v1alpha1.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,3 +370,19 @@ func SetDefaultsImagePullJob(obj *v1alpha1.ImagePullJob) {
obj.Spec.PullPolicy.BackoffLimit = utilpointer.Int32Ptr(3)
}
}

// SetDefaultsImageListPullJob set default values for ImageListPullJob.
func SetDefaultsImageListPullJob(obj *v1alpha1.ImageListPullJob) {
if obj.Spec.CompletionPolicy.Type == "" {
obj.Spec.CompletionPolicy.Type = v1alpha1.Always
}
if obj.Spec.PullPolicy == nil {
obj.Spec.PullPolicy = &v1alpha1.PullPolicy{}
}
if obj.Spec.PullPolicy.TimeoutSeconds == nil {
obj.Spec.PullPolicy.TimeoutSeconds = utilpointer.Int32Ptr(600)
}
if obj.Spec.PullPolicy.BackoffLimit == nil {
obj.Spec.PullPolicy.BackoffLimit = utilpointer.Int32Ptr(3)
}
}
1 change: 1 addition & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ resources:
- bases/apps.kruise.io_persistentpodstates.yaml
- bases/apps.kruise.io_podprobemarkers.yaml
- bases/apps.kruise.io_nodepodprobes.yaml
- bases/apps.kruise.io_imagelistpulljobs.yaml
# +kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
Expand Down
26 changes: 26 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,32 @@ rules:
- get
- patch
- update
- apiGroups:
- apps.kruise.io
resources:
- imagelistpulljobs
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- apps.kruise.io
resources:
- imagelistpulljobs/finalizers
verbs:
- update
- apiGroups:
- apps.kruise.io
resources:
- imagelistpulljobs/status
verbs:
- get
- patch
- update
- apiGroups:
- apps.kruise.io
resources:
Expand Down
42 changes: 42 additions & 0 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,27 @@ webhooks:
resources:
- daemonsets
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /mutate-apps-kruise-io-v1alpha1-imagelistpulljob
failurePolicy: Fail
name: mimagelistpulljob.kb.io
rules:
- apiGroups:
- apps.kruise.io
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- imagelistpulljobs
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
Expand Down Expand Up @@ -453,6 +474,27 @@ webhooks:
resources:
- daemonsets
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-apps-kruise-io-v1alpha1-imagelistpulljob
failurePolicy: Fail
name: vimagelistpulljob.kb.io
rules:
- apiGroups:
- apps.kruise.io
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- imagelistpulljobs
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/openkruise/kruise/pkg/controller/containerrecreaterequest"
"github.com/openkruise/kruise/pkg/controller/daemonset"
"github.com/openkruise/kruise/pkg/controller/ephemeraljob"
"github.com/openkruise/kruise/pkg/controller/imagelistpulljob"
"github.com/openkruise/kruise/pkg/controller/imagepulljob"
"github.com/openkruise/kruise/pkg/controller/nodeimage"
"github.com/openkruise/kruise/pkg/controller/nodepodprobe"
Expand Down Expand Up @@ -65,6 +66,7 @@ func init() {
controllerAddFuncs = append(controllerAddFuncs, sidecarterminator.Add)
controllerAddFuncs = append(controllerAddFuncs, podprobemarker.Add)
controllerAddFuncs = append(controllerAddFuncs, nodepodprobe.Add)
controllerAddFuncs = append(controllerAddFuncs, imagelistpulljob.Add)
}

func SetupWithManager(m manager.Manager) error {
Expand Down
Loading

0 comments on commit aa2db64

Please sign in to comment.