Skip to content

Commit 395a74e

Browse files
committed
chore(registry): minio/minio#14331
1 parent b182905 commit 395a74e

5 files changed

Lines changed: 65 additions & 37 deletions

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{- define "registry.envs" -}}
2+
{{- if eq .Values.global.minioLocation "on-cluster" }}
3+
- name: "DRYCC_MINIO_ENDPOINT"
4+
value: ${DRYCC_MINIO_SERVICE_HOST}:${DRYCC_MINIO_SERVICE_PORT}
5+
{{- else }}
6+
- name: "DRYCC_MINIO_ENDPOINT"
7+
value: "{{ .Values.minio.endpoint }}"
8+
{{- end }}
9+
{{- end }}
10+
11+
{{/* Generate registry deployment limits */}}
12+
{{- define "registry.limits" -}}
13+
{{- if or (.Values.limitsCpu) (.Values.limitsMemory)}}
14+
resources:
15+
limits:
16+
{{- if (.Values.limitsCpu) }}
17+
cpu: {{.Values.limitsCpu}}
18+
{{- end }}
19+
{{- if (.Values.limitsMemory) }}
20+
memory: {{.Values.limitsMemory}}
21+
{{- end }}
22+
{{- if (.Values.limitsHugepages2Mi) }}
23+
hugepages-2Mi: {{.Values.limitsHugepages2Mi}}
24+
{{- end }}
25+
{{- if (.Values.limitsHugepages1Gi) }}
26+
hugepages-1Gi: {{.Values.limitsHugepages1Gi}}
27+
{{- end }}
28+
{{- end }}
29+
{{- end }}

charts/registry/templates/registry-deployment.yaml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,14 @@ spec:
3232
- netcat
3333
- -v
3434
- -a
35-
- $(DRYCC_MINIO_SERVICE_HOST):$(DRYCC_MINIO_SERVICE_PORT)
35+
- $(DRYCC_MINIO_ENDPOINT)
36+
{{- include "builder.envs" . | indent 8 }}
3637
containers:
3738
- name: drycc-registry
3839
image: {{.Values.imageRegistry}}/{{.Values.imageOrg}}/registry:{{.Values.imageTag}}
3940
imagePullPolicy: {{.Values.imagePullPolicy}}
40-
{{- if or (.Values.limitsCpu) (.Values.limitsMemory)}}
41-
resources:
42-
limits:
43-
{{- if (.Values.limitsCpu) }}
44-
cpu: {{.Values.limitsCpu}}
45-
{{- end}}
46-
{{- if (.Values.limitsMemory) }}
47-
memory: {{.Values.limitsMemory}}
48-
{{- end}}
49-
{{- end}}
41+
{{- include "builder.limits" . | indent 8 }}
42+
{{- include "builder.envs" . | indent 8 }}
5043
livenessProbe:
5144
httpGet:
5245
path: /v2/
@@ -69,16 +62,16 @@ spec:
6962
volumeMounts:
7063
- name: registry-storage
7164
mountPath: /var/lib/registry
72-
- name: objectstorage-creds
73-
mountPath: /var/run/secrets/drycc/objectstore/creds
65+
- name: minio-creds
66+
mountPath: /var/run/secrets/drycc/minio/creds
7467
securityContext:
7568
fsGroup: 1001
7669
runAsGroup: 1001
7770
runAsUser: 1001
7871
volumes:
7972
- name: registry-storage
8073
emptyDir: {}
81-
- name: objectstorage-creds
74+
- name: minio-creds
8275
secret:
83-
secretName: objectstorage-keyfile
76+
secretName: minio-creds
8477
{{- end }}

contrib/ci/test.sh

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ echo "1234567890123456789012345678901234567890" > "${CURRENT_DIR}"/tmp/aws-user/
1111
echo "1234567890123456789012345678901234567890" > "${CURRENT_DIR}"/tmp/aws-user/secretkey
1212

1313
MINIO_JOB=$(docker run -d --name minio \
14-
-v "${CURRENT_DIR}"/tmp/aws-user:/var/run/secrets/drycc/objectstore/creds \
15-
drycc/minio:canary server /data/minio/)
14+
-v "${CURRENT_DIR}"/tmp/aws-user:/var/run/secrets/drycc/minio/creds \
15+
"${DEV_REGISTRY}"/drycc/minio:canary server /data/minio/)
1616

1717
sleep 5
1818
docker logs "${MINIO_JOB}"
@@ -21,9 +21,8 @@ MINIO_IP=$(docker inspect --format "{{ .NetworkSettings.IPAddress }}" "${MINIO_J
2121

2222
JOB=$(docker run --add-host minio:"${MINIO_IP}" \
2323
-d \
24-
-e DRYCC_MINIO_SERVICE_HOST=minio \
25-
-e DRYCC_MINIO_SERVICE_PORT=9000 \
26-
-v "${CURRENT_DIR}"/tmp/aws-user:/var/run/secrets/drycc/objectstore/creds \
24+
-e DRYCC_MINIO_ENDPOINT=minio:9000 \
25+
-v "${CURRENT_DIR}"/tmp/aws-user:/var/run/secrets/drycc/minio/creds \
2726
"$1")
2827

2928
# let the registry run for a few seconds

main.go

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,42 @@ import (
99
)
1010

1111
const (
12-
registryBinary = "/opt/drycc/registry/bin/registry"
13-
registryConfig = "/etc/docker/registry/config.yml"
14-
minioHostEnvVar = "DRYCC_MINIO_SERVICE_HOST"
15-
minioPortEnvVar = "DRYCC_MINIO_SERVICE_PORT"
16-
command = "serve"
12+
registryBinary = "/opt/drycc/registry/bin/registry"
13+
registryConfig = "/etc/docker/registry/config.yml"
14+
minioEndpointEnvVar = "DRYCC_MINIO_ENDPOINT"
15+
command = "serve"
1716
)
1817

1918
func main() {
2019
log.Println("INFO: Starting registry...")
21-
mHost := os.Getenv(minioHostEnvVar)
22-
mPort := os.Getenv(minioPortEnvVar)
20+
mEndpoint := os.Getenv(minioEndpointEnvVar)
2321
os.Setenv("REGISTRY_STORAGE", "s3")
2422
os.Setenv("REGISTRY_STORAGE_S3_BACKEND", "minio")
25-
os.Setenv("REGISTRY_STORAGE_S3_REGIONENDPOINT", fmt.Sprintf("http://%s:%s", mHost, mPort))
23+
os.Setenv("REGISTRY_STORAGE_S3_REGIONENDPOINT", fmt.Sprintf("http://%s", mEndpoint))
2624

27-
if accesskey, err := ioutil.ReadFile("/var/run/secrets/drycc/objectstore/creds/accesskey"); err != nil {
25+
if accesskey, err := ioutil.ReadFile("/var/run/secrets/drycc/minio/creds/accesskey"); err != nil {
2826
log.Fatal(err)
2927
} else {
3028
os.Setenv("REGISTRY_STORAGE_S3_ACCESSKEY", string(accesskey))
3129
}
3230

33-
if secretkey, err := ioutil.ReadFile("/var/run/secrets/drycc/objectstore/creds/secretkey"); err != nil {
31+
if secretkey, err := ioutil.ReadFile("/var/run/secrets/drycc/minio/creds/secretkey"); err != nil {
3432
log.Fatal(err)
3533
} else {
3634
os.Setenv("REGISTRY_STORAGE_S3_SECRETKEY", string(secretkey))
3735
}
38-
if bucket, err := ioutil.ReadFile("/var/run/secrets/drycc/objectstore/creds/registry-bucket"); err != nil {
39-
log.Fatal(err)
36+
37+
bucketNameFile := "/var/run/secrets/drycc/minio/creds/registry-bucket"
38+
if _, err := os.Stat(bucketNameFile); os.IsNotExist(err) {
39+
if bucket, err := ioutil.ReadFile(bucketNameFile); err != nil {
40+
log.Fatal(err)
41+
} else {
42+
os.Setenv("REGISTRY_STORAGE_S3_BUCKET", string(bucket))
43+
}
4044
} else {
41-
os.Setenv("REGISTRY_STORAGE_S3_BUCKET", string(bucket))
45+
os.Setenv("REGISTRY_STORAGE_S3_BUCKET", "registry") // default bucket
4246
}
47+
4348
os.Setenv("REGISTRY_STORAGE_S3_REGION", "us-east-1")
4449

4550
// run /bin/create_bucket

rootfs/bin/normalize_storage

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env sh
2-
BUCKET_FILE="/var/run/secrets/drycc/objectstore/creds/registry-bucket"
3-
ACCESS_KEY_FILE="/var/run/secrets/drycc/objectstore/creds/accesskey"
4-
SECRET_KEY_FILE="/var/run/secrets/drycc/objectstore/creds/secretkey"
2+
BUCKET_FILE="/var/run/secrets/drycc/minio/creds/registry-bucket"
3+
ACCESS_KEY_FILE="/var/run/secrets/drycc/minio/creds/accesskey"
4+
SECRET_KEY_FILE="/var/run/secrets/drycc/minio/creds/secretkey"
55

66
if [ -f $BUCKET_FILE ]; then
77
MINIO_BUCKET=$(cat "$BUCKET_FILE")
88
export MINIO_BUCKET
9+
else
10+
export MINIO_BUCKET="registry" # default bucket
911
fi
1012
if [ -f $ACCESS_KEY_FILE ]; then
1113
MINIO_ACCESS_KEY=$(cat "$ACCESS_KEY_FILE")
@@ -16,6 +18,6 @@ if [ -f $SECRET_KEY_FILE ]; then
1618
export MINIO_SECRET_KEY
1719
fi
1820

19-
export MINIO_ENDPOINT=http://"${DRYCC_MINIO_SERVICE_HOST}:${DRYCC_MINIO_SERVICE_PORT}"
21+
export MINIO_ENDPOINT=http://"${DRYCC_MINIO_ENDPOINT}"
2022

2123
mc config host add minio "${MINIO_ENDPOINT}" "${MINIO_ACCESS_KEY}" "${MINIO_SECRET_KEY}"

0 commit comments

Comments
 (0)