@@ -248,36 +248,53 @@ a name for an image (for example: `pause`, `example/mycontainer`, `kube-apiserve
248
248
and allow different systems to fetch the right binary image for the machine
249
249
architecture they are using.
250
250
251
- Kubernetes itself typically names container images with a suffix ` -$(ARCH) ` . For
252
- backward compatibility, generate older images with suffixes . For instance,
253
- an image named as ` pause ` would be a multi-architecture image containing manifests
254
- for all supported architectures, while ` pause-amd64 ` would be a backward-compatible
255
- version for older configurations, or for YAML files with hardcoded image names
256
- containing suffixes.
251
+ The Kubernetes project typically creates container images for its releases with
252
+ names that include the suffix ` -$(ARCH) ` . For backward compatibility, generate
253
+ older images with suffixes. For instance, an image named as ` pause ` would be a
254
+ multi-architecture image containing manifests for all supported architectures,
255
+ while ` pause-amd64 ` would be a backward-compatible version for older configurations,
256
+ or for YAML files with hardcoded image names containing suffixes.
257
257
258
258
## Using a private registry
259
259
260
- Private registries may require keys to read images from them.
260
+ Private registries may require authentication to be able to discover and/or pull
261
+ images from them.
261
262
Credentials can be provided in several ways:
262
263
264
+ - [ Specifying ` imagePullSecrets ` when you define a Pod] ( #specifying-imagepullsecrets-on-a-pod )
265
+
266
+ Only Pods which provide their own keys can access the private registry.
267
+
263
268
- [ Configuring Nodes to Authenticate to a Private Registry] ( #configuring-nodes-to-authenticate-to-a-private-registry )
264
- - all pods can read any configured private registries
265
- - requires node configuration by cluster administrator
266
- - [ Kubelet Credential Provider to dynamically fetch credentials for private registries] ( #kubelet-credential-provider )
267
- - kubelet can be configured to use credential provider exec plugin
268
- for the respective private registry.
269
+ - All Pods can read any configured private registries.
270
+ - Requires node configuration by cluster administrator.
271
+ - Using a _ kubelet credential provider_ plugin to [ dynamically fetch credentials for private registries] ( #kubelet-credential-provider )
272
+
273
+ The kubelet can be configured to use credential provider exec plugin for the
274
+ respective private registry.
275
+
269
276
- [ Pre-pulled Images] ( #pre-pulled-images )
270
- - all pods can use any images cached on a node
271
- - requires root access to all nodes to set up
272
- - [ Specifying ImagePullSecrets on a Pod] ( #specifying-imagepullsecrets-on-a-pod )
273
- - only pods which provide their own keys can access the private registry
277
+ - All Pods can use any images cached on a node.
278
+ - Requires root access to all nodes to set up.
274
279
- Vendor-specific or local extensions
275
- - if you're using a custom node configuration, you (or your cloud
276
- provider) can implement your mechanism for authenticating the node
277
- to the container registry.
280
+
281
+ If you're using a custom node configuration, you (or your cloud provider) can
282
+ implement your mechanism for authenticating the node to the container registry.
278
283
279
284
These options are explained in more detail below.
280
285
286
+ ### Specifying ` imagePullSecrets ` on a Pod
287
+
288
+ {{< note >}}
289
+ This is the recommended approach to run containers based on images
290
+ in private registries.
291
+ {{< /note >}}
292
+
293
+ Kubernetes supports specifying container image registry keys on a Pod.
294
+ All ` imagePullSecrets ` must be Secrets that exist in the same
295
+ {{< glossary_tooltip term_id="namespace" >}} as the
296
+ Pod. These Secrets must be of type ` kubernetes.io/dockercfg ` or ` kubernetes.io/dockerconfigjson ` .
297
+
281
298
### Configuring nodes to authenticate to a private registry
282
299
283
300
Specific instructions for setting credentials depends on the container runtime and registry you
@@ -289,14 +306,17 @@ task. That example uses a private registry in Docker Hub.
289
306
290
307
### Kubelet credential provider for authenticated image pulls {#kubelet-credential-provider}
291
308
292
- {{< note >}}
293
- This approach is especially suitable when the kubelet needs to fetch registry credentials
294
- dynamically. Most commonly used for registries provided by cloud providers where
295
- authentication tokens are short-lived.
296
- {{< /note >}}
309
+ You can configure the kubelet to invoke a plugin binary to dynamically fetch
310
+ registry credentials for a container image. This is the most robust and versatile
311
+ way to fetch credentials for private registries, but also requires kubelet-level
312
+ configuration to enable.
297
313
298
- You can configure the kubelet to invoke a plugin binary to dynamically fetch registry credentials for a container image.
299
- This is the most robust and versatile way to fetch credentials for private registries, but also requires kubelet-level configuration to enable.
314
+ This technique can be especially useful for running {{< glossary_tooltip term_id="static-pod" text="static Pods" >}}
315
+ that require container images hosted in a private registry.
316
+ Using a {{< glossary_tooltip term_id="service-account" >}} or a
317
+ {{< glossary_tooltip term_id="secret" >}} to provide private registry credentials
318
+ is not possible in the specification of a static Pod, because it _ cannot_
319
+ have references to other API resources in its specification.
300
320
301
321
See [ Configure a kubelet image credential provider] ( /docs/tasks/administer-cluster/kubelet-credential-provider/ ) for more details.
302
322
@@ -321,8 +341,8 @@ This means that a `config.json` like this is valid:
321
341
``` json
322
342
{
323
343
"auths" : {
324
- "my-registry.io /images" : { "auth" : " …" },
325
- "*.my-registry.io /images" : { "auth" : " …" }
344
+ "my-registry.example /images" : { "auth" : " …" },
345
+ "*.my-registry.example /images" : { "auth" : " …" }
326
346
}
327
347
}
328
348
```
@@ -331,33 +351,33 @@ Image pull operations pass the credentials to the CRI container runtime for ever
331
351
valid pattern. For example, the following container image names would match
332
352
successfully:
333
353
334
- - ` my-registry.io /images `
335
- - ` my-registry.io /images/my-image `
336
- - ` my-registry.io /images/another-image `
337
- - ` sub.my-registry.io /images/my-image `
354
+ - ` my-registry.example /images `
355
+ - ` my-registry.example /images/my-image `
356
+ - ` my-registry.example /images/another-image `
357
+ - ` sub.my-registry.example /images/my-image `
338
358
339
359
However, these container image names would * not* match:
340
360
341
- - ` a.sub.my-registry.io /images/my-image `
342
- - ` a.b.sub.my-registry.io /images/my-image `
361
+ - ` a.sub.my-registry.example /images/my-image `
362
+ - ` a.b.sub.my-registry.example /images/my-image `
343
363
344
364
The kubelet performs image pulls sequentially for every found credential. This
345
365
means that multiple entries in ` config.json ` for different paths are possible, too:
346
366
347
367
``` json
348
368
{
349
369
"auths" : {
350
- "my-registry.io /images" : {
370
+ "my-registry.example /images" : {
351
371
"auth" : " …"
352
372
},
353
- "my-registry.io /images/subpath" : {
373
+ "my-registry.example /images/subpath" : {
354
374
"auth" : " …"
355
375
}
356
376
}
357
377
}
358
378
```
359
379
360
- If now a container specifies an image ` my-registry.io /images/subpath/my-image `
380
+ If now a container specifies an image ` my-registry.example /images/subpath/my-image `
361
381
to be pulled, then the kubelet will try to download it using both authentication
362
382
sources if one of them fails.
363
383
@@ -376,33 +396,27 @@ then a local image is used (preferentially or exclusively, respectively).
376
396
If you want to rely on pre-pulled images as a substitute for registry authentication,
377
397
you must ensure all nodes in the cluster have the same pre-pulled images.
378
398
379
- This can be used to preload certain images for speed or as an alternative to authenticating to a
380
- private registry.
399
+ This can be used to preload certain images for speed or as an alternative to
400
+ authenticating to a private registry.
401
+
402
+ Similar to the usage of the [ kubelet credential provider] ( #kubelet-credential-provider ) ,
403
+ pre-pulled images are also suitable for launching
404
+ {{< glossary_tooltip text="static Pods" term_id="static-pod" >}} that depend
405
+ on images hosted in a private registry.
381
406
382
407
{{< note >}}
383
408
{{< feature-state feature_gate_name="KubeletEnsureSecretPulledImages" >}}
384
409
Access to pre-pulled images may be authorized according to [ image pull credential verification] ( #ensureimagepullcredentialverification ) .
385
410
{{< /note >}}
386
411
387
- ### Specifying ` imagePullSecrets ` on a Pod
388
-
389
- {{< note >}}
390
- This is the recommended approach to run containers based on images
391
- in private registries.
392
- {{< /note >}}
393
-
394
- Kubernetes supports specifying container image registry keys on a Pod.
395
- All ` imagePullSecrets ` must be Secrets that exist in the same namespace as the
396
- Pod. These Secrets must be of type ` kubernetes.io/dockercfg ` or ` kubernetes.io/dockerconfigjson ` .
397
-
398
- #### Ensure Image Pull Credential Verification {#ensureimagepullcredentialverification}
412
+ #### Ensure image pull credential verification {#ensureimagepullcredentialverification}
399
413
400
414
{{< feature-state feature_gate_name="KubeletEnsureSecretPulledImages" >}}
401
415
402
- If the ` KubeletEnsureSecretPulledImages ` feature gate is enabled, Kubernetes will
403
- validate image credentials for every image that requires credentials to be pulled,
404
- even if that image is already present on the node. This validation ensures that
405
- images in a Pod request which have not been successfully pulled
416
+ If the ` KubeletEnsureSecretPulledImages ` feature gate is enabled for your cluster,
417
+ Kubernetes will validate image credentials for every image that requires credentials
418
+ to be pulled, even if that image is already present on the node. This validation
419
+ ensures that images in a Pod request which have not been successfully pulled
406
420
with the provided credentials must re-pull the images from the registry.
407
421
Additionally, image pulls that re-use the same credentials
408
422
which previously resulted in a successful image pull will not need to re-pull from
@@ -535,17 +549,18 @@ If you need access to multiple registries, you can create one Secret per registr
535
549
536
550
## Legacy built-in kubelet credential provider
537
551
538
- In older versions of Kubernetes, the kubelet had a direct integration with cloud provider credentials.
539
- This gave it the ability to dynamically fetch credentials for image registries.
552
+ In older versions of Kubernetes, the kubelet had a direct integration with cloud
553
+ provider credentials. This provided the ability to dynamically fetch credentials
554
+ for image registries.
540
555
541
- There were three built-in implementations of the kubelet credential provider integration:
542
- ACR (Azure Container Registry), ECR (Elastic Container Registry), and GCR (Google Container Registry).
556
+ There were three built-in implementations of the kubelet credential provider
557
+ integration: ACR (Azure Container Registry), ECR (Elastic Container Registry),
558
+ and GCR (Google Container Registry).
543
559
544
- For more information on the legacy mechanism, read the documentation for the version of Kubernetes that you
545
- are using. Kubernetes v1.26 through to v{{< skew latestVersion >}} do not include the legacy mechanism, so
546
- you would need to either:
547
- - configure a kubelet image credential provider on each node
548
- - specify image pull credentials using ` imagePullSecrets ` and at least one Secret
560
+ Starting with version 1.26 of Kubernetes, the legacy mechanism has been removed,
561
+ so you would need to either:
562
+ - configure a kubelet image credential provider on each node; or
563
+ - specify image pull credentials using ` imagePullSecrets ` and at least one Secret.
549
564
550
565
## {{% heading "whatsnext" %}}
551
566
0 commit comments