Skip to content

Commit 869b23b

Browse files
ls-2018刘硕
andauthored
[Feature] Add force image pull (openkruise#1385)
Co-authored-by: 刘硕 <liushuo@zetyun.com>
1 parent fbcd88a commit 869b23b

File tree

582 files changed

+57238
-7167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

582 files changed

+57238
-7167
lines changed

apis/apps/defaults/v1alpha1.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,9 @@ func SetDefaultsImagePullJob(obj *v1alpha1.ImagePullJob) {
385385
if obj.Spec.PullPolicy.BackoffLimit == nil {
386386
obj.Spec.PullPolicy.BackoffLimit = utilpointer.Int32Ptr(3)
387387
}
388+
if obj.Spec.ImagePullPolicy == "" {
389+
obj.Spec.ImagePullPolicy = v1alpha1.PullIfNotPresent
390+
}
388391
}
389392

390393
// SetDefaultsImageListPullJob set default values for ImageListPullJob.

apis/apps/v1alpha1/imagepulljob_types.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ const (
2727
ImagePreDownloadMinUpdatedReadyPods = "apps.kruise.io/image-predownload-min-updated-ready-pods"
2828
)
2929

30+
// ImagePullPolicy describes a policy for if/when to pull a container image
31+
// +enum
32+
type ImagePullPolicy string
33+
34+
const (
35+
// PullAlways means that kruise-daemon always attempts to pull the latest image.
36+
PullAlways ImagePullPolicy = "Always"
37+
// PullIfNotPresent means that kruise-daemon pulls if the image isn't present on disk.
38+
PullIfNotPresent ImagePullPolicy = "IfNotPresent"
39+
)
40+
3041
// ImagePullJobSpec defines the desired state of ImagePullJob
3142
type ImagePullJobSpec struct {
3243
// Image is the image to be pulled by the job
@@ -69,6 +80,11 @@ type ImagePullJobTemplate struct {
6980
// SandboxConfig support attach metadata in PullImage CRI interface during ImagePulljobs
7081
// +optional
7182
SandboxConfig *SandboxConfig `json:"sandboxConfig,omitempty"`
83+
84+
// Image pull policy.
85+
// One of Always, IfNotPresent. Defaults to IfNotPresent.
86+
// +optional
87+
ImagePullPolicy ImagePullPolicy `json:"imagePullPolicy,omitempty"`
7288
}
7389

7490
// ImagePullJobPodSelector is a selector over pods

apis/apps/v1alpha1/nodeimage_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ type ImageTagSpec struct {
8080
// Value must be treated as opaque by clients and .
8181
// +optional
8282
Version int64 `json:"version,omitempty"`
83+
84+
// Image pull policy.
85+
// One of Always, IfNotPresent. Defaults to IfNotPresent.
86+
// +optional
87+
ImagePullPolicy ImagePullPolicy `json:"imagePullPolicy,omitempty"`
8388
}
8489

8590
// ImageTagPullPolicy defines the policy of the pulling task

config/crd/bases/apps.kruise.io_imagelistpulljobs.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ spec:
8484
Default is Always.
8585
type: string
8686
type: object
87+
imagePullPolicy:
88+
description: Image pull policy. One of Always, IfNotPresent. Defaults
89+
to IfNotPresent.
90+
type: string
8791
images:
8892
description: Images is the image list to be pulled by the job
8993
items:

config/crd/bases/apps.kruise.io_imagepulljobs.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ spec:
9595
image:
9696
description: Image is the image to be pulled by the job
9797
type: string
98+
imagePullPolicy:
99+
description: Image pull policy. One of Always, IfNotPresent. Defaults
100+
to IfNotPresent.
101+
type: string
98102
parallelism:
99103
anyOf:
100104
- type: integer

config/crd/bases/apps.kruise.io_nodeimages.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ spec:
102102
description: Specifies the create time of this tag
103103
format: date-time
104104
type: string
105+
imagePullPolicy:
106+
description: Image pull policy. One of Always, IfNotPresent.
107+
Defaults to IfNotPresent.
108+
type: string
105109
ownerReferences:
106110
description: List of objects depended by this object.
107111
If this image is managed by a controller, then an entry

go.mod

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,24 @@ require (
77
github.com/appscode/jsonpatch v1.0.1
88
github.com/codegangsta/negroni v1.0.0
99
github.com/containerd/containerd v1.5.16
10-
github.com/docker/distribution v2.8.1+incompatible
11-
github.com/docker/docker v20.10.12+incompatible
10+
github.com/docker/distribution v2.8.2+incompatible
11+
github.com/docker/docker v24.0.0+incompatible
1212
github.com/evanphx/json-patch v4.12.0+incompatible
1313
github.com/fsnotify/fsnotify v1.5.1
1414
github.com/go-bindata/go-bindata v3.1.2+incompatible
15+
github.com/google/go-containerregistry v0.16.1
1516
github.com/gorilla/mux v1.8.0
1617
github.com/onsi/ginkgo v1.16.5
1718
github.com/onsi/gomega v1.19.0
1819
github.com/opencontainers/go-digest v1.0.0
19-
github.com/opencontainers/image-spec v1.0.2
20+
github.com/opencontainers/image-spec v1.1.0-rc3
2021
github.com/pkg/errors v0.9.1
2122
github.com/prometheus/client_golang v1.12.1
2223
github.com/robfig/cron/v3 v3.0.1
2324
github.com/spf13/pflag v1.0.5
2425
github.com/stretchr/testify v1.8.1
2526
github.com/xyproto/simpleredis v0.0.0-20200201215242-1ff0da2967b4
26-
golang.org/x/net v0.8.0
27+
golang.org/x/net v0.10.0
2728
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8
2829
gomodules.xyz/jsonpatch/v2 v2.2.0
2930
google.golang.org/grpc v1.40.0
@@ -47,7 +48,7 @@ require (
4748
require (
4849
cloud.google.com/go v0.81.0 // indirect
4950
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
50-
github.com/Microsoft/go-winio v0.5.2 // indirect
51+
github.com/Microsoft/go-winio v0.6.1 // indirect
5152
github.com/Microsoft/hcsshim v0.8.24 // indirect
5253
github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect
5354
github.com/beorn7/perks v1.0.1 // indirect
@@ -57,16 +58,19 @@ require (
5758
github.com/containerd/console v1.0.3 // indirect
5859
github.com/containerd/continuity v0.3.0 // indirect
5960
github.com/containerd/fifo v1.0.0 // indirect
61+
github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect
6062
github.com/containerd/ttrpc v1.1.0 // indirect
6163
github.com/containerd/typeurl v1.0.2 // indirect
6264
github.com/contiv/executor v0.0.0-20180626233236-d263f4daa3ad // indirect
6365
github.com/coreos/go-semver v0.3.0 // indirect
6466
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
6567
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
6668
github.com/davecgh/go-spew v1.1.1 // indirect
69+
github.com/docker/cli v24.0.0+incompatible // indirect
70+
github.com/docker/docker-credential-helpers v0.7.0 // indirect
6771
github.com/docker/go-connections v0.4.0 // indirect
6872
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
69-
github.com/docker/go-units v0.4.0 // indirect
73+
github.com/docker/go-units v0.5.0 // indirect
7074
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
7175
github.com/go-logr/logr v1.2.3 // indirect
7276
github.com/go-openapi/analysis v0.21.2 // indirect
@@ -91,14 +95,15 @@ require (
9195
github.com/imdario/mergo v0.3.12 // indirect
9296
github.com/josharian/intern v1.0.0 // indirect
9397
github.com/json-iterator/go v1.1.12 // indirect
94-
github.com/klauspost/compress v1.13.6 // indirect
98+
github.com/klauspost/compress v1.16.5 // indirect
9599
github.com/mailru/easyjson v0.7.7 // indirect
96100
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
101+
github.com/mitchellh/go-homedir v1.1.0 // indirect
97102
github.com/mitchellh/mapstructure v1.4.1 // indirect
98103
github.com/moby/locker v1.0.1 // indirect
99104
github.com/moby/spdystream v0.2.0 // indirect
100105
github.com/moby/sys/mountinfo v0.6.0 // indirect
101-
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
106+
github.com/moby/term v0.0.0-20221205130635-1aeaba878587 // indirect
102107
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
103108
github.com/modern-go/reflect2 v1.0.2 // indirect
104109
github.com/morikuni/aec v1.0.0 // indirect
@@ -112,7 +117,8 @@ require (
112117
github.com/prometheus/client_model v0.2.0 // indirect
113118
github.com/prometheus/common v0.32.1 // indirect
114119
github.com/prometheus/procfs v0.7.3 // indirect
115-
github.com/sirupsen/logrus v1.8.1 // indirect
120+
github.com/sirupsen/logrus v1.9.1 // indirect
121+
github.com/vbatts/tar-split v0.11.3 // indirect
116122
github.com/xyproto/pinterface v0.0.0-20200201214933-70763765f31f // indirect
117123
go.etcd.io/etcd/api/v3 v3.5.1 // indirect
118124
go.etcd.io/etcd/client/pkg/v3 v3.5.1 // indirect
@@ -122,16 +128,16 @@ require (
122128
go.uber.org/atomic v1.7.0 // indirect
123129
go.uber.org/multierr v1.6.0 // indirect
124130
go.uber.org/zap v1.19.1 // indirect
125-
golang.org/x/mod v0.9.0 // indirect
126-
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
127-
golang.org/x/sync v0.1.0 // indirect
128-
golang.org/x/sys v0.6.0 // indirect
129-
golang.org/x/term v0.6.0 // indirect
130-
golang.org/x/text v0.8.0 // indirect
131-
golang.org/x/tools v0.6.0 // indirect
131+
golang.org/x/mod v0.10.0 // indirect
132+
golang.org/x/oauth2 v0.8.0 // indirect
133+
golang.org/x/sync v0.2.0 // indirect
134+
golang.org/x/sys v0.8.0 // indirect
135+
golang.org/x/term v0.8.0 // indirect
136+
golang.org/x/text v0.9.0 // indirect
137+
golang.org/x/tools v0.9.1 // indirect
132138
google.golang.org/appengine v1.6.7 // indirect
133139
google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368 // indirect
134-
google.golang.org/protobuf v1.28.1 // indirect
140+
google.golang.org/protobuf v1.30.0 // indirect
135141
gopkg.in/inf.v0 v0.9.1 // indirect
136142
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
137143
gopkg.in/yaml.v2 v2.4.0 // indirect

0 commit comments

Comments
 (0)