Skip to content

Commit

Permalink
Add readiness and liveness probe to the registry Pods (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
ialidzhikov authored Oct 6, 2023
1 parent be34167 commit c7ba18f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 1 deletion.
39 changes: 38 additions & 1 deletion pkg/component/registrycaches/registrycaches.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,10 @@ func computeResourcesDataForRegistryCache(cache *v1alpha1.RegistryCache, image s
return nil, fmt.Errorf("registry cache size is required")
}

const registryCacheVolumeName = "cache-volume"
const (
registryCacheVolumeName = "cache-volume"
debugPort = 5001
)

var (
name = strings.Replace(fmt.Sprintf("registry-%s", strings.Split(cache.Upstream, ":")[0]), ".", "-", -1)
Expand Down Expand Up @@ -199,6 +202,10 @@ func computeResourcesDataForRegistryCache(cache *v1alpha1.RegistryCache, image s
ContainerPort: constants.RegistryCachePort,
Name: "registry-cache",
},
{
ContainerPort: debugPort,
Name: "debug",
},
},
Env: []corev1.EnvVar{
{
Expand All @@ -209,6 +216,36 @@ func computeResourcesDataForRegistryCache(cache *v1alpha1.RegistryCache, image s
Name: "REGISTRY_STORAGE_DELETE_ENABLED",
Value: strconv.FormatBool(helper.GarbageCollectionEnabled(cache)),
},
{
Name: "REGISTRY_HTTP_ADDR",
Value: fmt.Sprintf(":%d", constants.RegistryCachePort),
},
{
Name: "REGISTRY_HTTP_DEBUG_ADDR",
Value: fmt.Sprintf(":%d", debugPort),
},
},
LivenessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/debug/health",
Port: intstr.FromInt(debugPort),
},
},
FailureThreshold: 6,
SuccessThreshold: 1,
PeriodSeconds: 20,
},
ReadinessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/debug/health",
Port: intstr.FromInt(debugPort),
},
},
FailureThreshold: 3,
SuccessThreshold: 1,
PeriodSeconds: 20,
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down
20 changes: 20 additions & 0 deletions pkg/component/registrycaches/registrycaches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,32 @@ spec:
value: ` + upstreamURL + `
- name: REGISTRY_STORAGE_DELETE_ENABLED
value: "` + strconv.FormatBool(garbageCollectionEnabled) + `"
- name: REGISTRY_HTTP_ADDR
value: :5000
- name: REGISTRY_HTTP_DEBUG_ADDR
value: :5001
image: ` + image + `
imagePullPolicy: IfNotPresent
livenessProbe:
failureThreshold: 6
httpGet:
path: /debug/health
port: 5001
periodSeconds: 20
successThreshold: 1
name: registry-cache
ports:
- containerPort: 5000
name: registry-cache
- containerPort: 5001
name: debug
readinessProbe:
failureThreshold: 3
httpGet:
path: /debug/health
port: 5001
periodSeconds: 20
successThreshold: 1
resources: {}
volumeMounts:
- mountPath: /var/lib/registry
Expand Down

0 comments on commit c7ba18f

Please sign in to comment.