@@ -68,7 +68,8 @@ func (d *DaemonSetPrepuller) CreateFunc(component string) error {
68
68
} else {
69
69
image = images .GetKubernetesImage (component , d .cfg )
70
70
}
71
- ds := buildPrePullDaemonSet (component , image )
71
+ pauseImage := images .GetPauseImage (d .cfg )
72
+ ds := buildPrePullDaemonSet (component , image , pauseImage )
72
73
73
74
// Create the DaemonSet in the API Server
74
75
if err := apiclient .CreateOrUpdateDaemonSet (d .client , ds ); err != nil {
@@ -155,8 +156,7 @@ func addPrepullPrefix(component string) string {
155
156
}
156
157
157
158
// buildPrePullDaemonSet builds the DaemonSet that ensures the control plane image is available
158
- func buildPrePullDaemonSet (component , image string ) * apps.DaemonSet {
159
- var gracePeriodSecs int64
159
+ func buildPrePullDaemonSet (component , image , pauseImage string ) * apps.DaemonSet {
160
160
return & apps.DaemonSet {
161
161
ObjectMeta : metav1.ObjectMeta {
162
162
Name : addPrepullPrefix (component ),
@@ -175,18 +175,32 @@ func buildPrePullDaemonSet(component, image string) *apps.DaemonSet {
175
175
},
176
176
},
177
177
Spec : v1.PodSpec {
178
- Containers : []v1.Container {
178
+ // Use an init container to prepull the target component image.
179
+ // Once the prepull completes, the "component --version" command is executed
180
+ // to get an exit code of 0.
181
+ // After the init container completes a regular container with "pause"
182
+ // will start to get this Pod in Running state with a blocking container process.
183
+ // Note that DaemonSet Pods can only use RestartPolicy of Always, so there has
184
+ // to be a blocking process to achieve the Running state.
185
+ InitContainers : []v1.Container {
179
186
{
180
187
Name : component ,
181
188
Image : image ,
182
- Command : []string {"/bin/sleep" , "3600" },
189
+ Command : []string {component , "--version" },
190
+ },
191
+ },
192
+ Containers : []v1.Container {
193
+ {
194
+ Name : "pause" ,
195
+ Image : pauseImage ,
196
+ Command : []string {"/pause" },
183
197
},
184
198
},
185
199
NodeSelector : map [string ]string {
186
200
constants .LabelNodeRoleMaster : "" ,
187
201
},
188
202
Tolerations : []v1.Toleration {constants .ControlPlaneToleration },
189
- TerminationGracePeriodSeconds : & gracePeriodSecs ,
203
+ TerminationGracePeriodSeconds : utilpointer . Int64Ptr ( 0 ) ,
190
204
// Explicitly add a PodSecurityContext to allow these Pods to run as non-root.
191
205
// This prevents restrictive PSPs from blocking the Pod creation.
192
206
SecurityContext : & v1.PodSecurityContext {
0 commit comments