Skip to content

Commit 34df433

Browse files
pacoxumikebrow
andcommitted
update ensure image pull secret design details per review comments
Co-authored-by: Mike Brown <[email protected]>
1 parent b14b2ee commit 34df433

File tree

2 files changed

+42
-31
lines changed

2 files changed

+42
-31
lines changed

keps/sig-node/2535-ensure-secret-pulled-images/README.md

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,10 @@ Items marked with (R) are required *prior to targeting to a milestone / release*
5757
- [ ] User-facing documentation has been created in [kubernetes/website], for publication to [kubernetes.io]
5858
- [ ] Supporting documentation—e.g., additional design documents, links to mailing list discussions/SIG meetings, relevant PRs/issues, release notes
5959

60-
6160
[kubernetes.io]: https://kubernetes.io/
6261
[kubernetes/enhancements]: https://git.k8s.io/enhancements
63-
[kubernetes/kubernetes]: https://git.k8s.io/kubernetes
6462
[kubernetes/website]: https://git.k8s.io/website
6563

66-
6764
## Summary
6865

6966
We will add support in kubelet for the `pullIfNotPresent` image pull policy, for
@@ -136,6 +133,9 @@ runtimes through the CRI wrt. how they should treat the caching of images on a
136133
node. Such as store for public use but only if encrypted. Or Store for private
137134
use un-encrypted...
138135

136+
This feature will not change the behavior of pod with image pull policy `Always`
137+
and `Never`.
138+
139139
## Proposal
140140

141141
For alpha `kubelet` will keep a list, across reboots of host and restart of
@@ -149,14 +149,15 @@ used is not present, thus enforcing authentication / re-authentication.
149149
### User Stories
150150

151151
#### Story 1
152+
152153
User with multiple tenants will be able to support all image pull policies without
153154
concern that one tenant will gain access to an image that they don't have rights to.
154155

155156
#### Story 2
157+
156158
User will will no longer have to inject the Pull Always Image Pull Policy to
157159
ensure all tenants have rights to the images that are already present on a host.
158160

159-
160161
### Notes/Constraints/Caveats (Optional)
161162

162163
With the default of the feature gate being off, users / cloud providers will have
@@ -183,8 +184,8 @@ or expect preloaded images since boot.
183184

184185
## Design Details
185186

186-
Kubelet will track, in memory, a hash map for the credentials that were successfully used to pull an image. The hash map
187-
will not be persisted to disk, in alpha. For alpha explicitly, we will not reuse or add other state manager concepts to kubelet.
187+
Kubelet will track, in memory, a hash map for the credentials that were successfully
188+
used to pull an image.
188189

189190
See PR linked above for detailed design / behavior documentation.
190191

@@ -193,15 +194,18 @@ the expired duration configurable. The default value could be 1d. For a pod with
193194
IfNotPresent image pull policy and an image pull secret, kubelet will recheck
194195
the secret after `PullImageSecretRecheckDuration`.
195196

196-
To make the cluster in most secure situation, set `PullImageSecretRecheckDuration` to 0,
197-
which means always recheck.
197+
Use image pull policy `Always` if user want to recheck the secret everytime.
198198

199-
If user doesn't want to do recheck, set `PullImageSecretRecheckDuration` to -1 to disable recheck.
199+
For image pull policy "if not present", when admin/user doesn't want to automatically
200+
recheck the secret, set `PullImageSecretRecheckDuration` to 0 to disable it(which means
201+
never recheck).
200202

201-
For kubelet restart, recheck is acceptable, because kubelet only restart when upgrade or in maintennance modes in most cases.
203+
Note: using the tag `:latest` is equivalent to using the image pull policy `Always.`
202204

203-
- upgrade: user needs to drain the node according to the best practice, and re-check is acceptable. (Honestly, many users don't)
204-
- other scanerios(like changing a configuration or some restart scripts for memory leak): still some maintenance modes.
205+
Note: since the cache is not persisted to disk, a recheck will happen every kubelet restart.
206+
This is acceptable because kubelet only restarts during upgrades or in maintenance modes.
207+
In other words, it should be relatively infrequent(and much less frequent than the default
208+
value of `PullImageSecretRecheckDuration`).
205209

206210
### Test Plan
207211

@@ -211,39 +215,43 @@ necessary to implement this enhancement.
211215

212216
##### Prerequisite testing updates
213217

214-
215218
##### Unit tests
216219

217220
For alpha, exhaustive Kubelet unit tests will be provided. Functions affected by the feature gate will be run with the feature gate on and with the feature gate off. Unit buckets will be provided for:
221+
218222
- HashAuth - (new, small) returns a hash code for a CRI pull image auth [link](https://github.com/kubernetes/kubernetes/pull/94899/files#diff-ca08601dfd2fdf846f066d0338dc332beddd5602ab3a71b8fac95b419842da63R704-R751) ** per review comment will use SHA256 **
219223
- shouldPullImage - (modified, large sized change) determines if image should be pulled based on presence, and image pull policy, and now with the feature gate on if the image has been pulled/ensured by a secret. A unit test bucket did not exist for this function. The unit bucket will cover a matrix for:
220-
```
221-
pullIfNotPresent := &v1.Container{
224+
225+
```golang
226+
pullIfNotPresent := &v1.Container{
222227
..
223-
ImagePullPolicy: v1.PullIfNotPresent,
224-
}
225-
pullNever := &v1.Container{
228+
ImagePullPolicy: v1.PullIfNotPresent,
229+
}
230+
pullNever := &v1.Container{
226231
..
227232
ImagePullPolicy: v1.PullNever,
228-
}
229-
pullAlways := &v1.Container{
230-
..
233+
}
234+
pullAlways := &v1.Container{
235+
..
231236
ImagePullPolicy: v1.PullAlways,
232-
}
233-
tests := []struct {
234-
description string
235-
container *v1.Container
236-
imagePresent bool
237-
pulledBySecret bool
238-
ensuredBySecret bool
239-
expectedWithFGOff bool
240-
expectedWithFGOn bool
241-
}
237+
}
238+
tests := []struct {
239+
description string
240+
container *v1.Container
241+
imagePresent bool
242+
pulledBySecret bool
243+
ensuredBySecret bool
244+
expectedWithFGOff bool
245+
expectedWithFGOn bool
246+
}
242247
```
248+
243249
[TestShouldPullImage link](https://github.com/kubernetes/kubernetes/pull/94899/files#diff-7297f08c72da9bf6479e80c03b45e24ea92ccb11c0031549e51b51f88a91f813R311-R438)
244250

245251
Additionally, for Alpha we will update this readme with an enumeration of the core packages being touched by the PR to implement this enhancement and provide the current unit coverage for those in the form of:
252+
246253
- <package>: <date> - <current test coverage>
254+
247255
The data will be read from:
248256
https://testgrid.k8s.io/sig-testing-canaries#ci-kubernetes-coverage-unit
249257

@@ -305,6 +313,7 @@ TBD subsequent to alpha
305313
## Production Readiness Review Questionnaire
306314

307315
### Feature Enablement and Rollback
316+
308317
- At Alpha this feature will be disabled by default with a feature gate.
309318
- At Beta this feature will be enabled by default with the feature gate.
310319
- At GA the ability to gate the feature will be removed leaving the feature enabled.
@@ -333,6 +342,7 @@ Will go back to working as designed.
333342
Yes, tests run both enabled and disabled.
334343

335344
### Rollout, Upgrade and Rollback Planning
345+
336346
TBD
337347

338348
###### How can a rollout or rollback fail? Can it impact already running workloads?

keps/sig-node/2535-ensure-secret-pulled-images/kep.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ reviewers:
1111
- "@yujuhong"
1212
- "@mrunalp"
1313
- "@adisky"
14+
- "@haircommander"
1415
approvers:
1516
- "@dchen1107"
1617
- "@derekwaynecarr"

0 commit comments

Comments
 (0)