Skip to content

Commit 9922b3c

Browse files
committed
docs: update docs with mirror information
1 parent 5bd4ffa commit 9922b3c

File tree

3 files changed

+67
-4
lines changed

3 files changed

+67
-4
lines changed

docs/content/customization/generic/image-registries.md

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,71 @@ spec:
3333
- name: clusterConfig
3434
value:
3535
imageRegistries:
36-
credentials:
37-
- url: https://my-registry.io
36+
- url: https://my-registry.io
37+
credentials:
3838
secretRef:
3939
name: my-registry-credentials
4040
```
4141
4242
Applying this configuration will result in new files and preKubeadmCommands
4343
on the `KubeadmControlPlaneTemplate` and `KubeadmConfigTemplate`.
44+
45+
To use a image registry as mirror with CA certificate, specify the following configuration:
46+
47+
If your registry mirror requires self signed CA certifate, create a Kubernetes Secret with keys for `ca.crt`:
48+
49+
```shell
50+
kubectl create secret generic my-mirror-ca-cert-secret \
51+
--from-file=ca.crt=registry-ca.crt
52+
```
53+
54+
```yaml
55+
apiVersion: cluster.x-k8s.io/v1beta1
56+
kind: Cluster
57+
metadata:
58+
name: <NAME>
59+
spec:
60+
topology:
61+
variables:
62+
- name: clusterConfig
63+
value:
64+
imageRegistries:
65+
- url: https://my-registry.io
66+
credentials:
67+
secretRef:
68+
name: my-registry-credentials
69+
mirror:
70+
secretRef:
71+
name: my-mirror-ca-cert-secret
72+
```
73+
74+
Applying this configuration will result in following new files on the
75+
`KubeadmControlPlaneTemplate` and `KubeadmConfigTemplate`
76+
77+
- `/etc/containerd/certs.d/_default/hosts.toml`
78+
- `/etc/certs/mirror.pem`
79+
80+
To use a public hosted image registry (ex. ECR) as mirror, specify the following configuration:
81+
82+
```yaml
83+
apiVersion: cluster.x-k8s.io/v1beta1
84+
kind: Cluster
85+
metadata:
86+
name: <NAME>
87+
spec:
88+
topology:
89+
variables:
90+
- name: clusterConfig
91+
value:
92+
imageRegistries:
93+
- url: https://123456789.dkr.ecr.us-east-1.amazonaws.com
94+
credentials:
95+
secretRef:
96+
name: my-registry-credentials
97+
mirror: {}
98+
```
99+
100+
Applying this configuration will result in following new files on the
101+
`KubeadmControlPlaneTemplate` and `KubeadmConfigTemplate`
102+
103+
- `/etc/containerd/certs.d/_default/hosts.toml`

pkg/handlers/generic/mutation/imageregistries/credentials/credential_provider_config_files.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ func (c providerConfig) isCredentialsEmpty() bool {
5252
c.Password == ""
5353
}
5454

55-
func templateFilesForImageCredentialProviderConfigs(config providerConfig, mirror *mirrorConfig) ([]cabpkv1.File, error) {
55+
func templateFilesForImageCredentialProviderConfigs(
56+
config providerConfig,
57+
mirror *mirrorConfig,
58+
) ([]cabpkv1.File, error) {
5659
var files []cabpkv1.File
5760

5861
kubeletCredentialProviderConfigFile, err := templateKubeletCredentialProviderConfig()

pkg/handlers/generic/mutation/imageregistries/credentials/tests/generate_patches.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,6 @@ func newRegistryCredentialsSecret(name, namespace string) *corev1.Secret {
492492
secretData := map[string][]byte{
493493
"username": []byte("myuser"),
494494
"password": []byte("mypassword"),
495-
"ca.crt": []byte("myCACert"),
496495
}
497496
return &corev1.Secret{
498497
TypeMeta: metav1.TypeMeta{
@@ -507,6 +506,7 @@ func newRegistryCredentialsSecret(name, namespace string) *corev1.Secret {
507506
Type: corev1.SecretTypeOpaque,
508507
}
509508
}
509+
510510
func newMirrorSecret(name, namespace string) *corev1.Secret {
511511
secretData := map[string][]byte{
512512
"ca.crt": []byte("myCACert"),

0 commit comments

Comments
 (0)