Skip to content

Commit c41df7f

Browse files
Merge pull request #584 from alexander-demicev/registry
Add embedded registry option to server config
2 parents b8cf46a + 78a475b commit c41df7f

File tree

9 files changed

+79
-10
lines changed

9 files changed

+79
-10
lines changed

controlplane/api/v1alpha1/conversion.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func (src *RKE2ControlPlane) ConvertTo(dstRaw conversion.Hub) error {
5757
dst.Spec.AgentConfig.PodSecurityAdmissionConfigFile = restored.Spec.AgentConfig.PodSecurityAdmissionConfigFile
5858
}
5959

60+
dst.Spec.ServerConfig.EmbeddedRegistry = restored.Spec.ServerConfig.EmbeddedRegistry
6061
dst.Spec.MachineTemplate = restored.Spec.MachineTemplate
6162
dst.Status = restored.Status
6263

@@ -133,6 +134,7 @@ func (src *RKE2ControlPlaneTemplate) ConvertTo(dstRaw conversion.Hub) error {
133134
dst.Spec.Template.Spec.AgentConfig.PodSecurityAdmissionConfigFile = restored.Spec.Template.Spec.AgentConfig.PodSecurityAdmissionConfigFile
134135
}
135136

137+
dst.Spec.Template.Spec.ServerConfig.EmbeddedRegistry = restored.Spec.Template.Spec.ServerConfig.EmbeddedRegistry
136138
dst.Spec.Template = restored.Spec.Template
137139
dst.Status = restored.Status
138140

@@ -220,3 +222,7 @@ func Convert_v1beta1_RKE2ConfigSpec_To_v1alpha1_RKE2ConfigSpec(in *bootstrapv1be
220222
func Convert_v1alpha1_RKE2ConfigSpec_To_v1beta1_RKE2ConfigSpec(in *bootstrapv1alpha1.RKE2ConfigSpec, out *bootstrapv1beta1.RKE2ConfigSpec, s apiconversion.Scope) error {
221223
return bootstrapv1alpha1.Convert_v1alpha1_RKE2ConfigSpec_To_v1beta1_RKE2ConfigSpec(in, out, s)
222224
}
225+
226+
func Convert_v1beta1_RKE2ServerConfig_To_v1alpha1_RKE2ServerConfig(in *controlplanev1.RKE2ServerConfig, out *RKE2ServerConfig, s apiconversion.Scope) error {
227+
return autoConvert_v1beta1_RKE2ServerConfig_To_v1alpha1_RKE2ServerConfig(in, out, s)
228+
}

controlplane/api/v1alpha1/zz_generated.conversion.go

Lines changed: 6 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controlplane/api/v1beta1/rke2controlplane_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,10 @@ type RKE2ServerConfig struct {
194194
// The config map must contain a key named cloud-config.
195195
//+optional
196196
CloudProviderConfigMap *corev1.ObjectReference `json:"cloudProviderConfigMap,omitempty"`
197+
198+
// EmbeddedRegistry enables the embedded registry.
199+
//+optional
200+
EmbeddedRegistry bool `json:"embeddedRegistry,omitempty"`
197201
}
198202

199203
// RKE2ControlPlaneStatus defines the observed state of RKE2ControlPlane.

controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_rke2controlplanes.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,9 @@ spec:
21552155
type: string
21562156
type: array
21572157
type: object
2158+
embeddedRegistry:
2159+
description: EmbeddedRegistry enables the embedded registry.
2160+
type: boolean
21582161
etcd:
21592162
description: Etcd defines optional custom configuration of ETCD.
21602163
properties:

controlplane/config/crd/bases/controlplane.cluster.x-k8s.io_rke2controlplanetemplates.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,9 @@ spec:
10041004
type: string
10051005
type: array
10061006
type: object
1007+
embeddedRegistry:
1008+
description: EmbeddedRegistry enables the embedded registry.
1009+
type: boolean
10071010
etcd:
10081011
description: Etcd defines optional custom configuration
10091012
of ETCD.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Configuring Embedded Registry in RKE2
2+
3+
## Overview
4+
RKE2 allows users to enable an **embedded registry** on control plane nodes. When the `embeddedRegistry` option is set to `true` in the `serverConfig`, users can configure the registry using the `PrivateRegistriesConfig` field.
5+
The process follows [RKE2 docs](https://docs.rke2.io/install/registry_mirror).
6+
7+
## Enabling Embedded Registry
8+
To enable the embedded registry, set the `embeddedRegistry` field to `true` in the `serverConfig` section of the `RKE2ControlPlane` configuration:
9+
10+
```yaml
11+
apiVersion: controlplane.cluster.x-k8s.io/v1beta1
12+
kind: RKE2ControlPlane
13+
metadata:
14+
name: my-cluster-control-plane
15+
spec:
16+
serverConfig:
17+
embeddedRegistry: true
18+
```
19+
20+
## Configuring Private Registries
21+
Once the embedded registry is enabled, you can configure private registries using the `PrivateRegistriesConfig` field in `RKE2ConfigSpec`. This field allows you to define registry mirrors, authentication, and TLS settings.
22+
23+
Example:
24+
25+
```yaml
26+
apiVersion: bootstrap.cluster.x-k8s.io/v1beta1
27+
kind: RKE2Config
28+
metadata:
29+
name: my-cluster-bootstrap
30+
spec:
31+
privateRegistriesConfig:
32+
mirrors:
33+
"myregistry.example.com":
34+
endpoint:
35+
- "https://mirror1.example.com"
36+
- "https://mirror2.example.com"
37+
configs:
38+
"myregistry.example.com":
39+
authSecret:
40+
name: my-registry-secret
41+
tls:
42+
tlsConfigSecret:
43+
name: my-registry-tls-secret
44+
insecureSkipVerify: false
45+
```
46+
47+
## TLS Secret Format
48+
When configuring the `tlsConfigSecret`, ensure the secret contains the following keys:
49+
- **`ca.crt`** – CA certificate
50+
- **`tls.key`** – TLS private key
51+
- **`tls.crt`** – TLS certificate

docs/book/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- [Air-gapped installation](./02_topics/01_air-gapped-installation.md)
88
- [Node registration methods](./02_topics/02_node-registration-methods.md)
99
- [CIS and PSA](./02_topics/03_cis-psa.md)
10+
- [Embedded registry](./02_topics/04_embedded-registry.md)
1011
- [Examples](./03_examples/00.md)
1112
- [AWS](./03_examples/01_aws.md)
1213
- [vSphere](./03_examples/02_vsphere.md)

pkg/rke2/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ type ServerConfig struct {
131131
KubeSchedulerImage string `yaml:"kube-scheduler-image,omitempty"`
132132
ServiceNodePortRange string `yaml:"service-node-port-range,omitempty"`
133133
TLSSan []string `yaml:"tls-san,omitempty"`
134+
EmbeddedRegistry bool `yaml:"embedded-registry,omitempty"`
134135

135136
// We don't expose these fields in the API
136137
ClusterCIDR string `yaml:"cluster-cidr,omitempty"`
@@ -365,6 +366,8 @@ func newRKE2ServerConfig(opts ServerConfigOpts) (*ServerConfig, []bootstrapv1.Fi
365366
rke2ServerConfig.CloudControllerManagerExtraEnv = componentMapToSlice(extraEnv, opts.ServerConfig.CloudControllerManager.ExtraEnv)
366367
}
367368

369+
rke2ServerConfig.EmbeddedRegistry = opts.ServerConfig.EmbeddedRegistry
370+
368371
return rke2ServerConfig, files, nil
369372
}
370373

pkg/rke2/config_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ var _ = Describe("RKE2ServerConfig", func() {
162162
ExtraEnv: map[string]string{"testenv": "testenv"},
163163
ExtraMounts: map[string]string{"testmount": "testmount"},
164164
},
165+
EmbeddedRegistry: true,
165166
},
166167
}
167168
})
@@ -221,6 +222,7 @@ var _ = Describe("RKE2ServerConfig", func() {
221222
Expect(rke2ServerConfig.CloudControllerManagerExtraMounts).To(Equal(componentMapToSlice(extraMount, serverConfig.CloudControllerManager.ExtraMounts)))
222223
Expect(rke2ServerConfig.CloudControllerManagerExtraEnv).To(Equal(componentMapToSlice(extraEnv, serverConfig.CloudControllerManager.ExtraEnv)))
223224
Expect(rke2ServerConfig.Token).To(Equal(opts.Token))
225+
Expect(rke2ServerConfig.EmbeddedRegistry).To(BeTrue())
224226

225227
Expect(files).To(HaveLen(4))
226228

0 commit comments

Comments
 (0)