Skip to content

Commit

Permalink
[Feature] Add force image pull (openkruise#1385)
Browse files Browse the repository at this point in the history
Signed-off-by: 刘硕 <[email protected]>
Co-authored-by: 刘硕 <[email protected]>
  • Loading branch information
ls-2018 and 刘硕 authored Nov 16, 2023
1 parent 01717ff commit c272055
Show file tree
Hide file tree
Showing 582 changed files with 57,238 additions and 7,167 deletions.
3 changes: 3 additions & 0 deletions apis/apps/defaults/v1alpha1.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,9 @@ func SetDefaultsImagePullJob(obj *v1alpha1.ImagePullJob) {
if obj.Spec.PullPolicy.BackoffLimit == nil {
obj.Spec.PullPolicy.BackoffLimit = utilpointer.Int32Ptr(3)
}
if obj.Spec.ImagePullPolicy == "" {
obj.Spec.ImagePullPolicy = v1alpha1.PullIfNotPresent
}
}

// SetDefaultsImageListPullJob set default values for ImageListPullJob.
Expand Down
16 changes: 16 additions & 0 deletions apis/apps/v1alpha1/imagepulljob_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ const (
ImagePreDownloadMinUpdatedReadyPods = "apps.kruise.io/image-predownload-min-updated-ready-pods"
)

// ImagePullPolicy describes a policy for if/when to pull a container image
// +enum
type ImagePullPolicy string

const (
// PullAlways means that kruise-daemon always attempts to pull the latest image.
PullAlways ImagePullPolicy = "Always"
// PullIfNotPresent means that kruise-daemon pulls if the image isn't present on disk.
PullIfNotPresent ImagePullPolicy = "IfNotPresent"
)

// ImagePullJobSpec defines the desired state of ImagePullJob
type ImagePullJobSpec struct {
// Image is the image to be pulled by the job
Expand Down Expand Up @@ -69,6 +80,11 @@ type ImagePullJobTemplate struct {
// SandboxConfig support attach metadata in PullImage CRI interface during ImagePulljobs
// +optional
SandboxConfig *SandboxConfig `json:"sandboxConfig,omitempty"`

// Image pull policy.
// One of Always, IfNotPresent. Defaults to IfNotPresent.
// +optional
ImagePullPolicy ImagePullPolicy `json:"imagePullPolicy,omitempty"`
}

// ImagePullJobPodSelector is a selector over pods
Expand Down
5 changes: 5 additions & 0 deletions apis/apps/v1alpha1/nodeimage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ type ImageTagSpec struct {
// Value must be treated as opaque by clients and .
// +optional
Version int64 `json:"version,omitempty"`

// Image pull policy.
// One of Always, IfNotPresent. Defaults to IfNotPresent.
// +optional
ImagePullPolicy ImagePullPolicy `json:"imagePullPolicy,omitempty"`
}

// ImageTagPullPolicy defines the policy of the pulling task
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/apps.kruise.io_imagelistpulljobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ spec:
Default is Always.
type: string
type: object
imagePullPolicy:
description: Image pull policy. One of Always, IfNotPresent. Defaults
to IfNotPresent.
type: string
images:
description: Images is the image list to be pulled by the job
items:
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/apps.kruise.io_imagepulljobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ spec:
image:
description: Image is the image to be pulled by the job
type: string
imagePullPolicy:
description: Image pull policy. One of Always, IfNotPresent. Defaults
to IfNotPresent.
type: string
parallelism:
anyOf:
- type: integer
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/apps.kruise.io_nodeimages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ spec:
description: Specifies the create time of this tag
format: date-time
type: string
imagePullPolicy:
description: Image pull policy. One of Always, IfNotPresent.
Defaults to IfNotPresent.
type: string
ownerReferences:
description: List of objects depended by this object.
If this image is managed by a controller, then an entry
Expand Down
40 changes: 23 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@ require (
github.com/appscode/jsonpatch v1.0.1
github.com/codegangsta/negroni v1.0.0
github.com/containerd/containerd v1.5.16
github.com/docker/distribution v2.8.1+incompatible
github.com/docker/docker v20.10.12+incompatible
github.com/docker/distribution v2.8.2+incompatible
github.com/docker/docker v24.0.0+incompatible
github.com/evanphx/json-patch v4.12.0+incompatible
github.com/fsnotify/fsnotify v1.5.1
github.com/go-bindata/go-bindata v3.1.2+incompatible
github.com/google/go-containerregistry v0.16.1
github.com/gorilla/mux v1.8.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.19.0
github.com/opencontainers/go-digest v1.0.0
github.com/opencontainers/image-spec v1.0.2
github.com/opencontainers/image-spec v1.1.0-rc3
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.12.1
github.com/robfig/cron/v3 v3.0.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.8.1
github.com/xyproto/simpleredis v0.0.0-20200201215242-1ff0da2967b4
golang.org/x/net v0.8.0
golang.org/x/net v0.10.0
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8
gomodules.xyz/jsonpatch/v2 v2.2.0
google.golang.org/grpc v1.40.0
Expand All @@ -47,7 +48,7 @@ require (
require (
cloud.google.com/go v0.81.0 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/hcsshim v0.8.24 // indirect
github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand All @@ -57,16 +58,19 @@ require (
github.com/containerd/console v1.0.3 // indirect
github.com/containerd/continuity v0.3.0 // indirect
github.com/containerd/fifo v1.0.0 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect
github.com/containerd/ttrpc v1.1.0 // indirect
github.com/containerd/typeurl v1.0.2 // indirect
github.com/contiv/executor v0.0.0-20180626233236-d263f4daa3ad // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/cli v24.0.0+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/analysis v0.21.2 // indirect
Expand All @@ -91,14 +95,15 @@ require (
github.com/imdario/mergo v0.3.12 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/sys/mountinfo v0.6.0 // indirect
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
Expand All @@ -112,7 +117,8 @@ require (
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/sirupsen/logrus v1.9.1 // indirect
github.com/vbatts/tar-split v0.11.3 // indirect
github.com/xyproto/pinterface v0.0.0-20200201214933-70763765f31f // indirect
go.etcd.io/etcd/api/v3 v3.5.1 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.1 // indirect
Expand All @@ -122,16 +128,16 @@ require (
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sync v0.2.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/tools v0.9.1 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
Expand Down
Loading

0 comments on commit c272055

Please sign in to comment.