Skip to content

Commit

Permalink
Improve Docker registry setup
Browse files Browse the repository at this point in the history
* Move to separate function
* Create registry after the cluster because the kind network
  might otherwise not be there. We only need the registry after
  cluster creation anyways

Signed-off-by: Reinhard Nägele <unguiculus@gmail.com>
  • Loading branch information
unguiculus committed Jan 20, 2021
1 parent 819c900 commit 2a5ad73
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
.vscode
/.registry
36 changes: 28 additions & 8 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ LOKI_VERSION=0.22.0
PROMTAIL_VERSION=3.0.1
CANARY_VERSION=0.2.0

SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd -P)

main() {
pushd "$SCRIPT_DIR" > /dev/null

if [[ -n "${1:-}" ]]; then
echo '🚀 Updating Loki demo setup...'
echo
Expand All @@ -25,6 +29,7 @@ main() {

setup_chart_repos
setup_cluster
setup_registry
setup_ingress_nginx
setup_metrics_server
setup_monitoring
Expand All @@ -36,6 +41,8 @@ main() {

echo
echo '🎉 Done.'

popd > /dev/null
}

setup_chart_repos() {
Expand All @@ -60,13 +67,6 @@ setup_cluster() {
echo '🟡 Creating kind cluster...'
echo

if ! docker container inspect loki-registry-proxy &> /dev/null; then
# local pull-through registry
docker container run --name loki-registry-proxy --net kind --detach \
--env REGISTRY_PROXY_REMOTEURL=https://registry-1.docker.io \
registry:2
fi

kind create cluster --name=loki-minio-demo --config=config/kind/config.yaml

echo
Expand All @@ -79,6 +79,27 @@ setup_cluster() {
fi
}

setup_registry() {
if ! docker container inspect loki-registry-proxy &> /dev/null; then
echo
echo '🟡 Creating pull-through Docker registry...'
echo

docker container run --name loki-registry-proxy --net kind --detach \
--env REGISTRY_PROXY_REMOTEURL=https://registry-1.docker.io \
--volume "$(pwd)/.registry:/var/lib/registry" \
registry:2

echo
echo '✅ Finished creating pull-through Docker registry.'
echo
else
echo
echo '📣️️ Pull-through Docker registry already exists. Re-using it!'
echo
fi
}

setup_ingress_nginx() {
log_start ingress-nginx

Expand All @@ -101,7 +122,6 @@ setup_metrics_server() {
log_finished metrics-server
}


setup_monitoring() {
log_start monitoring

Expand Down

0 comments on commit 2a5ad73

Please sign in to comment.