Skip to content

Commit bfa0594

Browse files
author
Matthew Fisher
committed
Merge pull request #1278 from johanneswuerbach/enhanced-registry
feat(registry) Configurable storage backends
2 parents d651efb + 45fb9a6 commit bfa0594

5 files changed

Lines changed: 138 additions & 81 deletions

File tree

Makefile

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ endef
2222
# TODO: re-evaluate the fragile start order
2323
COMPONENTS=builder cache controller database logger registry
2424
ALL_COMPONENTS=$(COMPONENTS) router
25-
START_COMPONENTS=registry logger cache database
25+
START_COMPONENTS=logger cache database
2626

2727
ALL_UNITS = $(foreach C,$(COMPONENTS),$(wildcard $(C)/systemd/*.service))
2828
START_UNITS = $(foreach C,$(START_COMPONENTS),$(wildcard $(C)/systemd/*.service))
@@ -42,6 +42,7 @@ full-clean: clean
4242

4343
install: check-fleet install-routers install-data-containers
4444
$(FLEETCTL) load $(START_UNITS)
45+
$(FLEETCTL) load registry/systemd/*.service
4546
$(FLEETCTL) load controller/systemd/*.service
4647
$(FLEETCTL) load builder/systemd/*.service
4748

@@ -81,9 +82,20 @@ rsync:
8182
run: install start
8283

8384
start: check-fleet start-warning start-routers
84-
@# registry logger cache database
85-
$(call echo_yellow,"Waiting for deis-registry to start...")
85+
@# logger cache database
86+
$(call echo_yellow,"Waiting for deis-cache to start...")
8687
$(FLEETCTL) start -no-block $(START_UNITS)
88+
@until $(FLEETCTL) list-units | egrep -q "deis-cache\..+(running|failed)"; \
89+
do sleep 2; \
90+
printf "\033[0;33mStatus:\033[0m "; $(FLEETCTL) list-units | \
91+
grep "deis-cache\." | awk '{printf "%-10s (%s) \r", $$4, $$5}'; \
92+
sleep 8; \
93+
done
94+
$(call check_for_errors)
95+
96+
@# registry
97+
$(call echo_yellow,"Waiting for deis-registry to start...")
98+
$(FLEETCTL) start -no-block registry/systemd/*
8799
@until $(FLEETCTL) list-units | egrep -q "deis-registry\..+(running|failed)"; \
88100
do sleep 2; \
89101
printf "\033[0;33mStatus:\033[0m "; $(FLEETCTL) list-units | \

registry/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ RUN pip install /docker-registry/depends/docker-registry-core
2929
RUN pip install file:///docker-registry#egg=docker-registry[bugsnag]
3030

3131
ENV DOCKER_REGISTRY_CONFIG /docker-registry/config/config.yml
32-
ENV SETTINGS_FLAVOR dev
32+
ENV SETTINGS_FLAVOR deis
3333

3434
# create data volume
3535
RUN mkdir -p /data/repositories && chown -R registry:registry /data

registry/conf.d/config.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ uid = 0
55
gid = 0
66
mode = "0644"
77
keys = [
8-
"/deis/registry",
8+
"/deis/cache",
9+
"/deis/registry"
910
]
1011
check_cmd = "/app/bin/check {{ .src }}"
1112
reload_cmd = "/app/bin/reload"

registry/templates/config.yml

Lines changed: 110 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# The `common' part is automatically included (and possibly overriden by all
2-
# other flavors)
1+
# All other flavors inherit the `common' config snippet
32
common: &common
43
# Default log level is info
54
loglevel: _env:LOGLEVEL:info
@@ -24,11 +23,11 @@ common: &common
2423
source_index: _env:MIRROR_SOURCE_INDEX # https://index.docker.io
2524
tags_cache_ttl: _env:MIRROR_TAGS_CACHE_TTL:172800 # seconds
2625

27-
# cache:
28-
# host: _env:CACHE_REDIS_HOST:localhost
29-
# port: _env:CACHE_REDIS_PORT:6379
30-
# db: 0
31-
# password: _env:CACHE_REDIS_PASSWORD
26+
cache:
27+
host: {{ or (.deis_cache_host) "" }}
28+
port: {{ or (.deis_cache_port) "" }}
29+
password: _env:CACHE_REDIS_PASSWORD
30+
db: 1
3231

3332
# Enabling LRU cache for small files
3433
# This speeds up read/write on small files
@@ -40,95 +39,130 @@ common: &common
4039
# password: _env:CACHE_LRU_REDIS_PASSWORD
4140

4241
# Enabling these options makes the Registry send an email on each code Exception
42+
{{ if .deis_registry_smtpHost }}
4343
email_exceptions:
44-
smtp_host: _env:SMTP_HOST
45-
smtp_port: _env:SMTP_PORT:25
46-
smtp_login: _env:SMTP_LOGIN
47-
smtp_password: _env:SMTP_PASSWORD
48-
smtp_secure: _env:SMTP_SECURE:false
49-
from_addr: _env:SMTP_FROM_ADDR:docker-registry@localdomain.local
50-
to_addr: _env:SMTP_TO_ADDR:noise+dockerregistry@localdomain.local
44+
smtp_host: {{ or (.deis_registry_smtpHost) "" }}
45+
smtp_port: {{ or (.deis_registry_smtpPort) "25" }}
46+
smtp_login: {{ or (.deis_registry_smtpLogin) "" }}
47+
smtp_password: {{ or (.deis_registry_smtpPassword) "" }}
48+
smtp_secure: bool({{ or (.deis_registry_smtpSecure) "false" }})
49+
from_addr: {{ or (.deis_registry_smtpFrom) "docker-registry@localdomain.local" }}
50+
to_addr: {{ or (.deis_registry_smtpTo) "noise+dockerregistry@localdomain.local" }}
51+
{{ end }}
5152

5253
# Enable bugsnag (set the API key)
5354
bugsnag: _env:BUGSNAG
5455

55-
# This is the default configuration when no flavor is specified
56-
dev:
56+
local: &local
5757
<<: *common
5858
storage: local
5959
storage_path: /data
6060

61-
{{ if .deis_registry_s3accessKey }}
62-
# To specify another flavor, set the environment variable SETTINGS_FLAVOR
63-
# $ export SETTINGS_FLAVOR=prod
64-
prod:
61+
62+
s3: &s3
63+
<<: *common
6564
storage: s3
66-
storage_path: /data
67-
# Amazon S3 Storage Configuration
68-
s3_access_key: {{ .deis_registry_s3accessKey }}
69-
s3_secret_key: {{ .deis_registry_s3secretKey }}
70-
s3_region: {{ .deis_registry_s3region }}
71-
s3_bucket: {{ .deis_registry_s3bucket }}
72-
boto_bucket: {{ .deis_registry_s3bucket }}
73-
s3_encrypt: bool({{ .deis_registry_s3encrypt }})
74-
s3_secure: bool({{ .deis_registry_s3secure }})
75-
storage_redirect: True
76-
# Enabling query cache on Redis
77-
cache:
78-
host: {{ .deis_cache_host }}
79-
port: {{ .deis_cache_port }}
80-
db: 1
81-
# Enabling these options makes the Registry send an email on each code Exception
82-
email_exceptions:
83-
smtp_host: {{ .deis_registry_smtpHost }}
84-
smtp_port: {{ .deis_registry_smtpPort }}
85-
smtp_login: {{ .deis_registry_smtpLogin }}
86-
smtp_password: {{ .deis_registry_smtpPassword }}
87-
smtp_secure: {{ .deis_registry_smtpSecure }}
88-
from_addr: {{ .deis_registry_smtpFrom }}
89-
to_addr: {{ .deis_registry_smtpTo }}
90-
# Enable bugsnag (set the API key)
91-
bugsnag: REPLACEME
92-
{{ end }}
65+
s3_region: {{ or (.deis_registry_s3region) "" }}
66+
s3_bucket: {{ or (.deis_registry_s3bucket) "" }}
67+
boto_bucket: {{ or (.deis_registry_s3bucket) "" }}
68+
storage_path: {{ or (.deis_registry_s3path) "/registry" }}
69+
s3_encrypt: bool({{ or (.deis_registry_s3encrypt) "true" }})
70+
s3_secure: bool({{ or (.deis_registry_s3secure) "true" }})
71+
s3_access_key: {{ or (.deis_registry_s3accessKey) "" }}
72+
s3_secret_key: {{ or (.deis_registry_s3secretKey) "" }}
9373

94-
# This flavor is automatically used by unit tests
95-
test:
96-
storage: local
97-
storage_path: /tmp/test
74+
# Google Cloud Storage Configuration
75+
# See:
76+
# https://developers.google.com/storage/docs/reference/v1/getting-startedv1#keys
77+
# for details on access and secret keys.
78+
gcs:
79+
<<: *common
80+
storage: gcs
81+
boto_bucket: _env:GCS_BUCKET
82+
storage_path: _env:STORAGE_PATH:/registry
83+
gs_secure: _env:GCS_SECURE:true
84+
gs_access_key: _env:GCS_KEY
85+
gs_secret_key: _env:GCS_SECRET
86+
# OAuth 2.0 authentication with the storage.
87+
# oauth2 can be set to true or false. If it is set to true, gs_access_key,
88+
# gs_secret_key and gs_secure are not needed.
89+
# Client ID and Client Secret must be set into OAUTH2_CLIENT_ID and
90+
# OAUTH2_CLIENT_SECRET environment variables.
91+
# See: https://developers.google.com/accounts/docs/OAuth2.
92+
oauth2: _env:GCS_OAUTH2:false
9893

9994
# This flavor is for storing images in Openstack Swift
100-
{{ if .deis_registry_swiftAuthURL }}
101-
swift:
95+
swift: &swift
96+
<<: *common
10297
storage: swift
103-
storage_path: "_env:STORAGE_PATH:/registry"
104-
swift_authurl: {{ .deis_registry_swiftAuthURL }}
105-
swift_container: {{ .deis_registry_swiftContainer }}
106-
swift_user: {{ .deis_registry_swiftUser }}
107-
swift_password: {{ .deis_registry_swiftPassword }}
108-
swift_tenant_name: {{ .deis_registry_swiftTenantName }}
109-
swift_region_name: {{ .deis_registry_swiftRegionName }}
110-
{{ end }}
98+
storage_path: _env:STORAGE_PATH:/registry
99+
# keystone authorization
100+
swift_authurl: {{ or (.deis_registry_swiftAuthURL) "" }}
101+
swift_container: {{ or (.deis_registry_swiftContainer) "" }}
102+
swift_user: {{ or (.deis_registry_swiftUser) "" }}
103+
swift_password: {{ or (.deis_registry_swiftPassword) "" }}
104+
swift_tenant_name: {{ or (.deis_registry_swiftTenantName) "" }}
105+
swift_region_name: {{ or (.deis_registry_swiftRegionName) "" }}
111106

112107
# This flavor stores the images in Glance (to integrate with openstack)
113108
# See also: https://github.com/dotcloud/openstack-docker
114-
openstack:
109+
glance: &glance
110+
<<: *common
115111
storage: glance
116-
storage_alternate: local
117-
storage_path: /tmp/registry
118-
loglevel: debug
112+
storage_alternate: _env:GLANCE_STORAGE_ALTERNATE:file
113+
storage_path: _env:STORAGE_PATH:/tmp/registry
114+
115+
openstack:
116+
<<: *glance
119117

120118
# This flavor stores the images in Glance (to integrate with openstack)
121119
# and tags in Swift.
122-
{{ if .deis_registry_swiftAuthURL }}
123-
openstack-swift:
120+
glance-swift: &glance-swift
121+
<<: *swift
124122
storage: glance
125-
storage_path: /registry
126123
storage_alternate: swift
127-
# keystone authorization
128-
swift_authurl: {{ .deis_registry_swiftAuthURL }}
129-
swift_container: {{ .deis_registry_swiftContainer }}
130-
swift_user: {{ .deis_registry_swiftUser }}
131-
swift_password: {{ .deis_registry_swiftPassword }}
132-
swift_tenant_name: {{ .deis_registry_swiftTenantName }}
133-
swift_region_name: {{ .deis_registry_swiftRegionName }}
134-
{{ end }}
124+
125+
openstack-swift:
126+
<<: *glance-swift
127+
128+
elliptics:
129+
<<: *common
130+
storage: elliptics
131+
elliptics_nodes: _env:ELLIPTICS_NODES
132+
elliptics_wait_timeout: _env:ELLIPTICS_WAIT_TIMEOUT:60
133+
elliptics_check_timeout: _env:ELLIPTICS_CHECK_TIMEOUT:60
134+
elliptics_io_thread_num: _env:ELLIPTICS_IO_THREAD_NUM:2
135+
elliptics_net_thread_num: _env:ELLIPTICS_NET_THREAD_NUM:2
136+
elliptics_nonblocking_io_thread_num: _env:ELLIPTICS_NONBLOCKING_IO_THREAD_NUM:2
137+
elliptics_groups: _env:ELLIPTICS_GROUPS
138+
elliptics_verbosity: _env:ELLIPTICS_VERBOSITY:4
139+
elliptics_logfile: _env:ELLIPTICS_LOGFILE:/dev/stderr
140+
elliptics_addr_family: _env:ELLIPTICS_ADDR_FAMILY:2
141+
142+
143+
144+
# This is the default configuration when no flavor is specified
145+
dev: &dev
146+
<<: *local
147+
loglevel: _env:LOGLEVEL:debug
148+
search_backend: _env:SEARCH_BACKEND:sqlalchemy
149+
150+
# This flavor is used by unit tests
151+
test:
152+
<<: *dev
153+
index_endpoint: https://indexstaging-docker.dotcloud.com
154+
standalone: true
155+
storage_path: _env:STORAGE_PATH:./tmp/test
156+
157+
# To specify another flavor, set the environment variable SETTINGS_FLAVOR
158+
# $ export SETTINGS_FLAVOR=prod
159+
prod:
160+
<<: *s3
161+
storage_path: _env:STORAGE_PATH:/prod
162+
163+
# Flavor used by deis
164+
deis:
165+
{{ if .deis_registry_s3accessKey }}<<: *s3
166+
{{ else if .deis_registry_swiftAuthURL }} <<: *openstack-swift
167+
{{ else }} <<: *local
168+
{{ end }}

registry/tests/registry_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/deis/deis/tests/dockercliutils"
8+
"github.com/deis/deis/tests/etcdutils"
89
"github.com/deis/deis/tests/utils"
910
)
1011

@@ -32,13 +33,22 @@ func runDeisRegistryTest(
3233
}
3334

3435
func TestRegistry(t *testing.T) {
36+
setkeys := []string{
37+
"/deis/cache/host",
38+
"/deis/cache/port",
39+
}
40+
setdir := []string{
41+
"/deis/cache",
42+
}
3543
testID := utils.NewUuid()
3644
err := dockercliutils.BuildImage(t, "../", "deis/registry:"+testID)
3745
if err != nil {
3846
t.Fatal(err)
3947
}
4048
etcdPort := utils.GetRandomPort()
4149
dockercliutils.RunEtcdTest(t, testID, etcdPort)
50+
handler := etcdutils.InitetcdValues(setdir, setkeys, etcdPort)
51+
etcdutils.Publishvalues(t, handler)
4252
servicePort := utils.GetRandomPort()
4353
fmt.Printf("--- Test deis-registry-%s at port %s\n", testID, servicePort)
4454
runDeisRegistryTest(t, testID, etcdPort, servicePort)

0 commit comments

Comments
 (0)