Update the related build scripts to package the chart repo server

add env file template for chart repo server in make/common/config/chartserver
update the Makefiles to support build chart repo server
add docker file and related build scripts for upstream chart server - chartmuseum
update prepare to support generating chart server related configs
add docker compose file for the chart server
add build/install command options to install with/without chart repo server
update install.sh to support chart repo server installation
This commit is contained in:
Steven Zou 2018-07-19 16:47:05 +08:00
parent b572e64a68
commit 22ea7dd91f
11 changed files with 338 additions and 4 deletions

View File

@ -83,6 +83,8 @@ REBUILDCLARITYFLAG=false
NEWCLARITYVERSION= NEWCLARITYVERSION=
BUILDBIN=false BUILDBIN=false
MIGRATORFLAG=false MIGRATORFLAG=false
# enable/disable chart repo supporting
CHARTFLAG=false
# version prepare # version prepare
# for docker image tag # for docker image tag
@ -104,6 +106,8 @@ CLAIRVERSION=v2.0.1
CLAIRDBVERSION=$(VERSIONTAG) CLAIRDBVERSION=$(VERSIONTAG)
MIGRATORVERSION=v1.5.0 MIGRATORVERSION=v1.5.0
REDISVERSION=$(VERSIONTAG) REDISVERSION=$(VERSIONTAG)
# version of chartmuseum
CHARTMUSEUMVERSION=v0.7.1
#clarity parameters #clarity parameters
CLARITYIMAGE=vmware/harbor-clarity-ui-builder[:tag] CLARITYIMAGE=vmware/harbor-clarity-ui-builder[:tag]
@ -129,7 +133,7 @@ GOINSTALL=$(GOCMD) install
GOTEST=$(GOCMD) test GOTEST=$(GOCMD) test
GODEP=$(GOTEST) -i GODEP=$(GOTEST) -i
GOFMT=gofmt -w GOFMT=gofmt -w
GOBUILDIMAGE=reg.mydomain.com/library/harborgo[:tag] GOBUILDIMAGE=golang:1.9.2
GOBUILDPATH=$(GOBASEPATH)/harbor GOBUILDPATH=$(GOBASEPATH)/harbor
GOIMAGEBUILDCMD=/usr/local/go/bin/go GOIMAGEBUILDCMD=/usr/local/go/bin/go
GOIMAGEBUILD=$(GOIMAGEBUILDCMD) build GOIMAGEBUILD=$(GOIMAGEBUILDCMD) build
@ -164,6 +168,10 @@ endif
ifeq ($(CLAIRFLAG), true) ifeq ($(CLAIRFLAG), true)
PREPARECMD_PARA+= --with-clair PREPARECMD_PARA+= --with-clair
endif endif
# append chartmuseum parameters if set
ifeq ($(CHARTFLAG), true)
PREPARECMD_PARA+= --with-chartmuseum
endif
# makefile # makefile
MAKEFILEPATH_PHOTON=$(MAKEPATH)/photon MAKEFILEPATH_PHOTON=$(MAKEPATH)/photon
@ -179,6 +187,7 @@ DOCKERIMAGENAME_JOBSERVICE=vmware/harbor-jobservice
DOCKERIMAGENAME_LOG=vmware/harbor-log DOCKERIMAGENAME_LOG=vmware/harbor-log
DOCKERIMAGENAME_DB=vmware/harbor-db DOCKERIMAGENAME_DB=vmware/harbor-db
DOCKERIMAGENAME_CLARITY=vmware/harbor-clarity-ui-builder DOCKERIMAGENAME_CLARITY=vmware/harbor-clarity-ui-builder
DOCKERIMAGENAME_CHART_SERVER=vmware/chartmuseum-photon
# docker-compose files # docker-compose files
DOCKERCOMPOSEFILEPATH=$(MAKEPATH) DOCKERCOMPOSEFILEPATH=$(MAKEPATH)
@ -188,6 +197,8 @@ DOCKERCOMPOSENOTARYTPLFILENAME=docker-compose.notary.tpl
DOCKERCOMPOSENOTARYFILENAME=docker-compose.notary.yml DOCKERCOMPOSENOTARYFILENAME=docker-compose.notary.yml
DOCKERCOMPOSECLAIRTPLFILENAME=docker-compose.clair.tpl DOCKERCOMPOSECLAIRTPLFILENAME=docker-compose.clair.tpl
DOCKERCOMPOSECLAIRFILENAME=docker-compose.clair.yml DOCKERCOMPOSECLAIRFILENAME=docker-compose.clair.yml
DOCKERCOMPOSECHARTMUSEUMTPLFILENAME=docker-compose.chartmuseum.tpl
DOCKERCOMPOSECHARTMUSEUMFILENAME=docker-compose.chartmuseum.yml
SEDCMD=$(shell which sed) SEDCMD=$(shell which sed)
@ -241,6 +252,13 @@ endif
ifeq ($(MIGRATORFLAG), true) ifeq ($(MIGRATORFLAG), true)
DOCKERSAVE_PARA+= vmware/harbor-migrator:$(MIGRATORVERSION) DOCKERSAVE_PARA+= vmware/harbor-migrator:$(MIGRATORVERSION)
endif endif
# append chartmuseum parameters if set
ifeq ($(CHARTFLAG), true)
DOCKERSAVE_PARA+= $(DOCKERIMAGENAME_CHART_SERVER):$(CHARTMUSEUMVERSION)-$(VERSIONTAG)
PACKAGE_OFFLINE_PARA+= $(HARBORPKG)/$(DOCKERCOMPOSECHARTMUSEUMFILENAME)
PACKAGE_ONLINE_PARA+= $(HARBORPKG)/$(DOCKERCOMPOSECHARTMUSEUMFILENAME)
DOCKERCOMPOSE_LIST+= -f $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSECHARTMUSEUMFILENAME)
endif
version: version:
@printf $(UIVERSIONTAG) > $(VERSIONFILEPATH)/$(VERSIONFILENAME); @printf $(UIVERSIONTAG) > $(VERSIONFILEPATH)/$(VERSIONFILENAME);
@ -286,7 +304,7 @@ build:
-e CLAIRVERSION=$(CLAIRVERSION) -e CLAIRDBVERSION=$(CLAIRDBVERSION) -e VERSIONTAG=$(VERSIONTAG) \ -e CLAIRVERSION=$(CLAIRVERSION) -e CLAIRDBVERSION=$(CLAIRDBVERSION) -e VERSIONTAG=$(VERSIONTAG) \
-e BUILDBIN=$(BUILDBIN) -e REDISVERSION=$(REDISVERSION) -e BUILDBIN=$(BUILDBIN) -e REDISVERSION=$(REDISVERSION)
modify_composefile: modify_composefile_notary modify_composefile_clair modify_composefile: modify_composefile_notary modify_composefile_clair modify_composefile_chartmuseum
@echo "preparing docker-compose file..." @echo "preparing docker-compose file..."
@cp $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSETPLFILENAME) $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSEFILENAME) @cp $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSETPLFILENAME) $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSEFILENAME)
@cp $(DOCKERCOMPOSEFILEPATH)/ha/$(DOCKERCOMPOSETPLFILENAME) $(DOCKERCOMPOSEFILEPATH)/ha/$(DOCKERCOMPOSEFILENAME) @cp $(DOCKERCOMPOSEFILEPATH)/ha/$(DOCKERCOMPOSETPLFILENAME) $(DOCKERCOMPOSEFILEPATH)/ha/$(DOCKERCOMPOSEFILENAME)
@ -313,6 +331,11 @@ modify_composefile_clair:
@cp $(DOCKERCOMPOSEFILEPATH)/ha/$(DOCKERCOMPOSECLAIRTPLFILENAME) $(DOCKERCOMPOSEFILEPATH)/ha/$(DOCKERCOMPOSECLAIRFILENAME) @cp $(DOCKERCOMPOSEFILEPATH)/ha/$(DOCKERCOMPOSECLAIRTPLFILENAME) $(DOCKERCOMPOSEFILEPATH)/ha/$(DOCKERCOMPOSECLAIRFILENAME)
@$(SEDCMD) -i 's/__clair_version__/$(CLAIRVERSION)-$(VERSIONTAG)/g' $(DOCKERCOMPOSEFILEPATH)/ha/$(DOCKERCOMPOSECLAIRFILENAME) @$(SEDCMD) -i 's/__clair_version__/$(CLAIRVERSION)-$(VERSIONTAG)/g' $(DOCKERCOMPOSEFILEPATH)/ha/$(DOCKERCOMPOSECLAIRFILENAME)
modify_composefile_chartmuseum:
@echo "preparing docker-compose chartmuseum file..."
@cp $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSECHARTMUSEUMTPLFILENAME) $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSECHARTMUSEUMFILENAME)
@$(SEDCMD) -i 's/__chartmuseum_version__/$(CHARTMUSEUMVERSION)-$(VERSIONTAG)/g' $(DOCKERCOMPOSEFILEPATH)/$(DOCKERCOMPOSECHARTMUSEUMFILENAME)
modify_sourcefiles: modify_sourcefiles:
@echo "change mode of source files." @echo "change mode of source files."
@chmod 600 $(MAKEPATH)/common/templates/notary/notary-signer.key @chmod 600 $(MAKEPATH)/common/templates/notary/notary-signer.key

View File

@ -61,3 +61,4 @@ REGISTRY_STORAGE_PROVIDER_NAME=$storage_provider_name
READ_ONLY=false READ_ONLY=false
SKIP_RELOAD_ENV_PATTERN=$skip_reload_env_pattern SKIP_RELOAD_ENV_PATTERN=$skip_reload_env_pattern
RELOAD_KEY=$reload_key RELOAD_KEY=$reload_key
CHART_SERVICE_URL=$chart_service_url

View File

@ -0,0 +1,41 @@
## Settings should be set
PORT=9999
# Only support redis now. If redis is setup, then enable cache
CACHE=$cache_store
CACHE_REDIS_ADDR=$cache_redis_addr
CACHE_REDIS_PASSWORD=$cache_redis_password
CACHE_REDIS_DB=$cache_redis_db_index
# Credential for internal communication
BASIC_AUTH_USER="chart_controller"
BASIC_AUTH_PASS=$ui_secret
# Multiple tenants
# Must be set with 1 to support project namespace
DEPTH=1
# Backend storage driver: e.g. "local", "amazon", "google" etc.
STORAGE=$storage_driver
# Storage driver settings
$all_storage_driver_configs
## Settings with default values. Just put here for future changes
DEBUG=false
LOG_JSON=true
DISABLE_METRICS=false
DISABLE_API=false
DISABLE_STATEFILES=false
ALLOW_OVERWRITE=false
CHART_URL=""
AUTH_ANONYMOUS_GET=false
TLS_CERT=""
TLS_KEY=""
CONTEXT_PATH=""
INDEX_LIMIT=0
MAX_STORAGE_OBJECTS=0
MAX_UPLOAD_SIZE=20971520
CHART_POST_FORM_FIELD_NAME="chart"
PROV_POST_FORM_FIELD_NAME="prov"

View File

@ -0,0 +1,33 @@
version: '2'
services:
ui:
networks:
harbor-chartmuseum:
aliases:
- harbor-ui
redis:
networks:
harbor-chartmuseum:
aliases:
- redis
chartmuseum:
container_name: chartmuseum
image: vmware/chartmuseum-photon:__chartmuseum_version__
restart: always
cpu_quota: 150000
networks:
- harbor-chartmuseum
depends_on:
- redis
volumes:
- /data/chart_storage:/chart_storage:z
logging:
driver: "syslog"
options:
syslog-address: "tcp://127.0.0.1:1514"
tag: "chartmuseum"
env_file:
./common/config/chartserver/env
networks:
harbor-chartmuseum:
external: false

View File

@ -60,6 +60,9 @@ with_notary=$false
with_clair=$false with_clair=$false
# HA mode is not enabled by default # HA mode is not enabled by default
harbor_ha=$false harbor_ha=$false
# chartmuseum is not enabled by default
with_chartmuseum=$false
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case $1 in case $1 in
--help) --help)
@ -71,6 +74,8 @@ while [ $# -gt 0 ]; do
with_clair=true;; with_clair=true;;
--ha) --ha)
harbor_ha=true;; harbor_ha=true;;
--with-chartmuseum)
with_chartmuseum=true;;
*) *)
note "$usage" note "$usage"
exit 1;; exit 1;;
@ -173,6 +178,11 @@ if [ $harbor_ha ]
then then
prepare_para="${prepare_para} --ha" prepare_para="${prepare_para} --ha"
fi fi
if [ $with_chartmuseum ]
then
prepare_para="${prepare_para} --with-chartmuseum"
fi
./prepare $prepare_para ./prepare $prepare_para
echo "" echo ""
@ -186,6 +196,10 @@ if [ $with_clair ]
then then
docker_compose_list="${docker_compose_list} -f docker-compose.clair.yml" docker_compose_list="${docker_compose_list} -f docker-compose.clair.yml"
fi fi
if [ $with_chartmuseum ]
then
docker_compose_list="${docker_compose_list} -f docker-compose.chartmuseum.yml"
fi
if [ -n "$(docker-compose $docker_compose_list ps -q)" ] if [ -n "$(docker-compose $docker_compose_list ps -q)" ]
then then

View File

@ -85,6 +85,13 @@ DOCKERFILEPATH_MIGRATOR=$(TOOLSPATH)/migration
DOCKERFILENAME_MIGRATOR=Dockerfile DOCKERFILENAME_MIGRATOR=Dockerfile
DOCKERIMAGENAME_MIGRATOR=vmware/harbor-migrator DOCKERIMAGENAME_MIGRATOR=vmware/harbor-migrator
# for chart server (chartmuseum)
DOCKERFILEPATH_CHART_SERVER=$(DOCKERFILEPATH)/chartserver
DOCKERFILENAME_CHART_SERVER=Dockerfile
CHART_SERVER_CODE_BASE=github.com/helm/chartmuseum
CHART_SERVER_MAIN_PATH=cmd/chartmuseum
CHART_SERVER_BIN_NAME=chartm
_build_db: _build_db:
@echo "building db container for photon..." @echo "building db container for photon..."
@cd $(DOCKERFILEPATH_DB) && $(DOCKERBUILD) -f $(DOCKERFILEPATH_DB)/$(DOCKERFILENAME_DB) -t $(DOCKERIMAGENAME_DB):$(VERSIONTAG) . @cd $(DOCKERFILEPATH_DB) && $(DOCKERBUILD) -f $(DOCKERFILEPATH_DB)/$(DOCKERFILENAME_DB) -t $(DOCKERIMAGENAME_DB):$(VERSIONTAG) .
@ -124,6 +131,20 @@ _build_clair:
echo "Done." ; \ echo "Done." ; \
fi fi
_build_chart_server:
@if [ "$(CHARTFLAG)" = "true" ] ; then \
if [ "$(BUILDBIN)" != "true" ] ; then \
rm -rf $(DOCKERFILEPATH_CHART_SERVER)/binary && mkdir -p $(DOCKERFILEPATH_CHART_SERVER)/binary && \
$(call _get_binary, https://storage.googleapis.com/harbor-builds/bin/chartm, $(DOCKERFILEPATH_CHART_SERVER)/binary/chartm); \
else \
cd $(DOCKERFILEPATH_CHART_SERVER) && $(DOCKERFILEPATH_CHART_SERVER)/builder $(GOBUILDIMAGE) $(CHART_SERVER_CODE_BASE) $(CHARTMUSEUMVERSION) $(CHART_SERVER_MAIN_PATH) $(CHART_SERVER_BIN_NAME); \
fi ; \
echo "building chartmuseum container for photon..." ; \
cd $(DOCKERFILEPATH_CHART_SERVER) && $(DOCKERBUILD) -f $(DOCKERFILEPATH_CHART_SERVER)/$(DOCKERFILENAME_CHART_SERVER) -t $(DOCKERIMAGENAME_CHART_SERVER):$(CHARTMUSEUMVERSION)-$(VERSIONTAG) . ; \
rm -rf $(DOCKERFILEPATH_CHART_SERVER)/binary; \
echo "Done." ; \
fi
_build_nginx: _build_nginx:
@echo "building nginx container for photon..." @echo "building nginx container for photon..."
@$(DOCKERBUILD) -f $(DOCKERFILEPATH_NGINX)/$(DOCKERFILENAME_NGINX) -t $(DOCKERIMAGENAME_NGINX):$(NGINXVERSION) . @$(DOCKERBUILD) -f $(DOCKERFILEPATH_NGINX)/$(DOCKERFILENAME_NGINX) -t $(DOCKERIMAGENAME_NGINX):$(NGINXVERSION) .
@ -173,7 +194,7 @@ define _get_binary
$(WGET) --timeout 30 --no-check-certificate $1 -O $2 $(WGET) --timeout 30 --no-check-certificate $1 -O $2
endef endef
build: _build_db _build_adminiserver _build_ui _build_jobservice _build_log _build_nginx _build_registry _build_notary _build_clair _build_redis _build_migrator build: _build_db _build_adminiserver _build_ui _build_jobservice _build_log _build_nginx _build_registry _build_notary _build_clair _build_redis _build_migrator _build_chart_server
cleanimage: cleanimage:
@echo "cleaning image for photon..." @echo "cleaning image for photon..."

View File

@ -0,0 +1,23 @@
FROM vmware/photon:1.0
RUN tdnf distro-sync -y \
&& tdnf erase vim -y \
&& tdnf install -y git shadow sudo bzr rpm xz python-xml >>/dev/null\
&& tdnf clean all \
&& mkdir /chartserver/ \
&& groupadd -r -g 10000 chartuser \
&& useradd --no-log-init -m -r -g 10000 -u 10000 chartuser
COPY ./binary/chartm /chartserver/
COPY docker-entrypoint.sh /docker-entrypoint.sh
EXPOSE 9999
RUN chown -R 10000:10000 /chartserver \
&& chmod u+x /chartserver/chartm \
&& chmod u+x /docker-entrypoint.sh
HEALTHCHECK --interval=30s --timeout=10s --retries=3 CMD curl -sS 127.0.0.1:9999/health || exit 1
ENTRYPOINT ["/docker-entrypoint.sh"]

33
make/photon/chartserver/builder Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
set +e
usage(){
echo "Usage: builder <golang image:version> <code path> <code release tag> <main.go path> <binary name>"
echo "e.g: builder golang:1.9.2 github.com/helm/chartmuseum v0.7.1 cmd/chartmuseum chartm"
exit 1
}
if [ $# != 5 ]; then
usage
fi
GOLANG_IMAGE="$1"
CODE_PATH="$2"
CODE_VERSION="$3"
MAIN_GO_PATH="$4"
BIN_NAME="$5"
set -e
cd `dirname $0`
cur=$PWD
mkdir -p binary
rm -rf binary/$BIN_NAME || true
cp compile.sh binary/
docker run -it -v $cur/binary:/go/bin --name golang_code_builder $GOLANG_IMAGE /bin/bash /go/bin/compile.sh $CODE_PATH $CODE_VERSION $MAIN_GO_PATH $BIN_NAME
#Clear
docker rm -f golang_code_builder

View File

@ -0,0 +1,34 @@
#!/bin/bash
set +e
usage(){
echo "Usage: compile.sh <code path> <code tag> <main.go path> <binary name>"
echo "e.g: compile.sh github.com/helm/chartmuseum v0.5.1 cmd/chartmuseum chartm"
exit 1
}
if [ $# != 4 ]; then
usage
fi
CODE_PATH="$1"
VERSION="$2"
MAIN_GO_PATH="$3"
BIN_NAME="$4"
#Get the source code of chartmusem
go get $CODE_PATH
set -e
#Checkout the released tag branch
cd /go/src/$CODE_PATH
git checkout tags/$VERSION -b $VERSION
#Install the go dep tool to restore the package dependencies
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
#Compile
cd /go/src/$CODE_PATH/$MAIN_GO_PATH && go build -a -o $BIN_NAME
mv $BIN_NAME /go/bin/

View File

@ -0,0 +1,4 @@
#!/bin/bash
set -e
sudo -E -H -u \#10000 sh -c "/chartserver/chartm" #Parameters are set by ENV
set +e

View File

@ -70,6 +70,16 @@ def validate(conf, args):
if project_creation != "everyone" and project_creation != "adminonly": if project_creation != "everyone" and project_creation != "adminonly":
raise Exception("Error invalid value for project_creation_restriction: %s" % project_creation) raise Exception("Error invalid value for project_creation_restriction: %s" % project_creation)
valid_storage_drivers = ["filesystem", "azure", "gcs", "s3", "swift", "oss"]
storage_provider_name = rcp.get("configuration", "registry_storage_provider_name").strip()
if storage_provider_name not in valid_storage_drivers:
raise Exception("Error: storage driver %s is not supported, only the following ones are supported: %s" % (storage_provider_name, ",".join(valid_storage_drivers)))
storage_provider_config = rcp.get("configuration", "registry_storage_provider_config").strip()
if storage_provider_name != "filesystem":
if storage_provider_config == "":
raise Exception("Error: no provider configurations are provided for provider %s" % storage_provider_name)
#To meet security requirement #To meet security requirement
#By default it will change file mode to 0600, and make the owner of the file to 10000:10000 #By default it will change file mode to 0600, and make the owner of the file to 10000:10000
def mark_file(path, mode=0o600, uid=10000, gid=10000): def mark_file(path, mode=0o600, uid=10000, gid=10000):
@ -188,6 +198,7 @@ parser.add_argument('--with-notary', dest='notary_mode', default=False, action='
parser.add_argument('--with-clair', dest='clair_mode', default=False, action='store_true', help="the Harbor instance is to be deployed with clair") parser.add_argument('--with-clair', dest='clair_mode', default=False, action='store_true', help="the Harbor instance is to be deployed with clair")
parser.add_argument('--ha', dest='ha_mode', default=False, action='store_true', help="the Harbor instance is to be deployed in HA mode") parser.add_argument('--ha', dest='ha_mode', default=False, action='store_true', help="the Harbor instance is to be deployed in HA mode")
parser.add_argument('--yes', dest='yes', default=False, action='store_true', help="Answer yes to all questions") parser.add_argument('--yes', dest='yes', default=False, action='store_true', help="Answer yes to all questions")
parser.add_argument('--with-chartmuseum', dest='chart_mode', default=False, action='store_true', help="the Harbor instance is to be deployed with chart repository supporting")
args = parser.parse_args() args = parser.parse_args()
delfile(config_dir) delfile(config_dir)
@ -318,6 +329,7 @@ token_service_url = "http://ui:8080/service/token"
jobservice_url = "http://jobservice:8080" jobservice_url = "http://jobservice:8080"
clair_url = "http://clair:6060" clair_url = "http://clair:6060"
notary_url = "http://notary-server:4443" notary_url = "http://notary-server:4443"
chart_service_url = "http://chartmuseum:9999"
if len(admiral_url) != 0 and admiral_url != "NA": if len(admiral_url) != 0 and admiral_url != "NA":
#VIC overwrites the data volume path, which by default should be same as the value of secretkey_path #VIC overwrites the data volume path, which by default should be same as the value of secretkey_path
@ -401,7 +413,8 @@ render(os.path.join(templates_dir, "adminserver", "env"),
clair_url=clair_url, clair_url=clair_url,
notary_url=notary_url, notary_url=notary_url,
reload_key=reload_key, reload_key=reload_key,
skip_reload_env_pattern=skip_reload_env_pattern skip_reload_env_pattern=skip_reload_env_pattern,
chart_service_url=chart_service_url
) )
render(os.path.join(templates_dir, "ui", "env"), render(os.path.join(templates_dir, "ui", "env"),
@ -613,5 +626,99 @@ if args.clair_mode:
if args.ha_mode: if args.ha_mode:
prepare_ha(rcp, args) prepare_ha(rcp, args)
# config chart repository
if args.chart_mode:
chartm_temp_dir = os.path.join(templates_dir, "chartserver")
chrtm_config_dir = os.path.join(config_dir, "chartserver")
chartm_env = os.path.join(config_dir, "chartserver", "env")
if not os.path.isdir(chrtm_config_dir):
print ("Create config folder: %s" % chrtm_config_dir)
os.makedirs(chrtm_config_dir)
# process redis info
cache_store = ""
cache_redis_password = ""
cache_redis_addr = ""
cache_redis_db_index = 0
if redis_url and redis_url.strip():
cache_store = "redis"
segments = redis_url.split(',', 3)
for index, r_cfg in enumerate(segments):
# the addr:port
if index == 0:
cache_redis_addr = r_cfg
# the password if existing
elif index == 2:
cache_redis_password = r_cfg
# the database index if existing
elif index == 3:
cache_redis_db_index = r_cfg
# process storage info
#default using local file system
storage_driver = "local"
# storage provider configurations
# please be aware that, we do not check the validations of the values for the specified keys
# convert the configs to config map
storage_provider_configs = storage_provider_config.split(",")
storgae_provider_confg_map = {}
storage_provider_config_options = []
for k_v in storage_provider_configs:
if len(k_v) > 0:
kvs = k_v.split(": ") # add space suffix to avoid existing ":" in the value
if len(kvs) == 2:
#key must not be empty
if kvs[0].strip() != "":
storgae_provider_confg_map[kvs[0].strip()] = kvs[1].strip()
if storage_provider_name == "s3":
# aws s3 storage
storage_driver = "amazon"
storage_provider_config_options.append("STORAGE_AMAZON_BUCKET=%s" % storgae_provider_confg_map.get("bucket", ""))
storage_provider_config_options.append("STORAGE_AMAZON_PREFIX=%s" % storgae_provider_confg_map.get("rootdirectory", ""))
storage_provider_config_options.append("STORAGE_AMAZON_REGION=%s" % storgae_provider_confg_map.get("region", ""))
storage_provider_config_options.append("STORAGE_AMAZON_ENDPOINT=%s" % storgae_provider_confg_map.get("regionendpoint", ""))
elif storage_provider_name == "gcs":
# google cloud storage
storage_driver = "google"
storage_provider_config_options.append("STORAGE_GOOGLE_BUCKET=%s" % storgae_provider_confg_map.get("bucket", ""))
storage_provider_config_options.append("STORAGE_GOOGLE_PREFIX=%s" % storgae_provider_confg_map.get("rootdirectory", ""))
elif storage_provider_name == "azure":
# azure storage
storage_driver = "microsoft"
storage_provider_config_options.append("STORAGE_MICROSOFT_CONTAINER=%s" % storgae_provider_confg_map.get("container", ""))
storage_provider_config_options.append("STORAGE_MICROSOFT_PREFIX=/azure/harbor/charts")
elif storage_provider_name == "swift":
# open stack swift
storage_driver = "openstack"
storage_provider_config_options.append("STORAGE_OPENSTACK_CONTAINER=%s" % storgae_provider_confg_map.get("container", ""))
storage_provider_config_options.append("STORAGE_OPENSTACK_PREFIX=%s" % storgae_provider_confg_map.get("rootdirectory", ""))
storage_provider_config_options.append("STORAGE_OPENSTACK_REGION=%s" % storgae_provider_confg_map.get("region", ""))
elif storage_provider_name == "oss":
# aliyun OSS
storage_driver = "alibaba"
storage_provider_config_options.append("STORAGE_ALIBABA_BUCKET=%s" % storgae_provider_confg_map.get("bucket", ""))
storage_provider_config_options.append("STORAGE_ALIBABA_PREFIX=%s" % storgae_provider_confg_map.get("rootdirectory", ""))
storage_provider_config_options.append("STORAGE_ALIBABA_ENDPOINT=%s" % storgae_provider_confg_map.get("endpoint", ""))
else:
# use local file system
storage_provider_config_options.append("STORAGE_LOCAL_ROOTDIR=/chart_storage")
# generate storage provider configuration
all_storage_provider_configs = ('\n').join(storage_provider_config_options)
render(os.path.join(chartm_temp_dir, "env"),
chartm_env,
cache_store=storage_driver,
cache_redis_addr=cache_redis_addr,
cache_redis_password=cache_redis_password,
cache_redis_db_index=cache_redis_db_index,
ui_secret=ui_secret,
storage_driver=storage_driver,
all_storage_driver_configs=all_storage_provider_configs)
FNULL.close() FNULL.close()
print("The configuration files are ready, please use docker-compose to start the service.") print("The configuration files are ready, please use docker-compose to start the service.")