Skip to content

Commit f9c2f95

Browse files
authored
feat: add registry addon (#1116)
**What problem does this PR solve?**: This PR adds a new addon `registryMirror` that deploys https://github.com/distribution/distribution as a StatefulSet and a [sidecar container to sync images](https://github.com/regclient/regclient/blob/main/docs/regsync.md) across instances. ``` $ kubectl get pods -n registry-system NAME READY STATUS RESTARTS AGE cncf-distribution-registry-docker-registry-0 2/2 Running 0 2m13s cncf-distribution-registry-docker-registry-1 2/2 Running 0 8s ``` This addon is designed to only be a mirror and not used a regular registry, hence the name and the lack of external access to the Service. In a follow up PR, the in-cluster Service will be used a Containerd mirror. In a follow up PR, it will also be deployed with randomly generated credentials to further prevent direct use. **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent 1829819 commit f9c2f95

File tree

34 files changed

+781
-13
lines changed

34 files changed

+781
-13
lines changed

api/v1alpha1/addon_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ const (
2727

2828
ServiceLoadBalancerProviderMetalLB = "MetalLB"
2929

30+
RegistryProviderCNCFDistribution = "CNCF Distribution"
31+
3032
AddonStrategyClusterResourceSet AddonStrategy = "ClusterResourceSet"
3133
AddonStrategyHelmAddon AddonStrategy = "HelmAddon"
3234

@@ -100,6 +102,9 @@ type GenericAddons struct {
100102

101103
// +kubebuilder:validation:Optional
102104
ServiceLoadBalancer *ServiceLoadBalancer `json:"serviceLoadBalancer,omitempty"`
105+
106+
// +kubebuilder:validation:Optional
107+
Registry *RegistryAddon `json:"registry,omitempty"`
103108
}
104109

105110
type AddonStrategy string
@@ -335,3 +340,10 @@ type AddressRange struct {
335340
// +kubebuilder:validation:Format=ipv4
336341
End string `json:"end"`
337342
}
343+
344+
type RegistryAddon struct {
345+
// The OCI registry provider to deploy.
346+
// +kubebuilder:default="CNCF Distribution"
347+
// +kubebuilder:validation:Enum="CNCF Distribution"
348+
Provider string `json:"provider"`
349+
}

api/v1alpha1/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const (
2828
ClusterAutoscalerVariableName = "clusterAutoscaler"
2929
// ServiceLoadBalancerVariableName is the Service LoadBalancer config patch variable name.
3030
ServiceLoadBalancerVariableName = "serviceLoadBalancer"
31+
// RegistryAddonVariableName is the OCI registry config patch variable name.
32+
RegistryAddonVariableName = "registry"
3133

3234
// GlobalMirrorVariableName is the global image registry mirror patch variable name.
3335
GlobalMirrorVariableName = "globalImageRegistryMirror"

api/v1alpha1/crds/caren.nutanix.com_awsclusterconfigs.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,17 @@ spec:
234234
- HelmAddon
235235
type: string
236236
type: object
237+
registry:
238+
properties:
239+
provider:
240+
default: CNCF Distribution
241+
description: The OCI registry provider to deploy.
242+
enum:
243+
- CNCF Distribution
244+
type: string
245+
required:
246+
- provider
247+
type: object
237248
serviceLoadBalancer:
238249
properties:
239250
configuration:

api/v1alpha1/crds/caren.nutanix.com_dockerclusterconfigs.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,17 @@ spec:
243243
- HelmAddon
244244
type: string
245245
type: object
246+
registry:
247+
properties:
248+
provider:
249+
default: CNCF Distribution
250+
description: The OCI registry provider to deploy.
251+
enum:
252+
- CNCF Distribution
253+
type: string
254+
required:
255+
- provider
256+
type: object
246257
serviceLoadBalancer:
247258
properties:
248259
configuration:

api/v1alpha1/crds/caren.nutanix.com_nutanixclusterconfigs.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,17 @@ spec:
243243
- HelmAddon
244244
type: string
245245
type: object
246+
registry:
247+
properties:
248+
provider:
249+
default: CNCF Distribution
250+
description: The OCI registry provider to deploy.
251+
enum:
252+
- CNCF Distribution
253+
type: string
254+
required:
255+
- provider
256+
type: object
246257
serviceLoadBalancer:
247258
properties:
248259
configuration:

api/v1alpha1/zz_generated.deepcopy.go

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

charts/cluster-api-runtime-extensions-nutanix/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ A Helm chart for cluster-api-runtime-extensions-nutanix
8585
| hooks.nfd.crsStrategy.defaultInstallationConfigMap.name | string | `"node-feature-discovery"` | |
8686
| hooks.nfd.helmAddonStrategy.defaultValueTemplateConfigMap.create | bool | `true` | |
8787
| hooks.nfd.helmAddonStrategy.defaultValueTemplateConfigMap.name | string | `"default-nfd-helm-values-template"` | |
88+
| hooks.registry.cncfDistribution.defaultValueTemplateConfigMap.create | bool | `true` | |
89+
| hooks.registry.cncfDistribution.defaultValueTemplateConfigMap.name | string | `"default-cncf-distribution-registry-helm-values-template"` | |
8890
| hooks.serviceLoadBalancer.metalLB.defaultValueTemplateConfigMap.create | bool | `true` | |
8991
| hooks.serviceLoadBalancer.metalLB.defaultValueTemplateConfigMap.name | string | `"default-metallb-helm-values-template"` | |
9092
| hooks.virtualIP.kubeVip.defaultTemplateConfigMap.create | bool | `true` | |
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
replicaCount: 2
2+
persistence:
3+
enabled: true
4+
size: 50Gi
5+
service:
6+
type: ClusterIP
7+
clusterIP: {{ .ServiceIP }}
8+
port: 80
9+
statefulSet:
10+
enabled: true
11+
syncer:
12+
interval: 2m

charts/cluster-api-runtime-extensions-nutanix/templates/helm-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ data:
2323
ChartName: cluster-autoscaler
2424
ChartVersion: 9.46.3
2525
RepositoryURL: '{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://kubernetes.github.io/autoscaler{{ end }}'
26+
cncf-distribution-registry: |
27+
ChartName: docker-registry
28+
ChartVersion: 2.3.1
29+
RepositoryURL: '{{ if .Values.helmRepository.enabled }}oci://helm-repository.{{ .Release.Namespace }}.svc/charts{{ else }}https://mesosphere.github.io/charts/staging/{{ end }}'
2630
cosi-controller: |
2731
ChartName: cosi
2832
ChartVersion: 0.0.1-alpha.5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright 2025 Nutanix. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
{{- if .Values.hooks.registry.cncfDistribution.defaultValueTemplateConfigMap.name }}
5+
apiVersion: v1
6+
kind: ConfigMap
7+
metadata:
8+
name: '{{ .Values.hooks.registry.cncfDistribution.defaultValueTemplateConfigMap.name }}'
9+
data:
10+
values.yaml: |-
11+
{{- .Files.Get "addons/registry/cncf-distribution/values-template.yaml" | nindent 4 }}
12+
{{- end -}}

0 commit comments

Comments
 (0)