diff --git a/tools/registry/deploy-registry.sh b/tools/registry/deploy-registry.sh
index be2fd3cd..a0091425 100755
--- a/tools/registry/deploy-registry.sh
+++ b/tools/registry/deploy-registry.sh
@@ -8,21 +8,26 @@ function usage {
echo " $base_name -s
"
echo " $base_name -n "
echo " $base_name -i "
+ echo " $base_name -u deploy ui"
}
-NAMESPACE_OPT=" --namespace kube-system"
+export NAMESPACE="kube-system"
+WORKDIR=$(dirname $0)
-while getopts "s:n:i:" opt; do
+while getopts "s:n:i:u" opt; do
case $opt in
"s" )
SRV_OPT=" -s $OPTARG"
;;
"n" )
- NAMESPACE_OPT=" --namespace $OPTARG"
+ NAMESPACE="$OPTARG"
;;
"i" )
NODE="$OPTARG"
;;
+ "u" )
+ DEPLOY_UI=true
+ ;;
* )
usage
exit 1
@@ -33,7 +38,26 @@ done
which kubectl 1>/dev/null
function kube_cmd {
- kubectl $SRV_OPT $NAMESPACE_OPT "$@"
+ kubectl $SRV_OPT --namespace $NAMESPACE "$@"
+}
+
+function await_readiness {
+ pod_name=$1;
+ get_pod="kube_cmd get pod $pod_name -o template --template "
+
+ echo "Waiting for $pod_name pod readiness"
+
+ template="{{.status.phase}}"
+ while [ $($get_pod $template) != "Running" ]; do
+ sleep 3
+ done
+ echo "The $pod_name pod is running"
+
+ template="{{range.status.containerStatuses}}{{.ready}}{{end}}"
+ while [ $($get_pod $template) != "true" ]; do
+ sleep 3
+ done
+ echo "The $pod_name pod state is ready"
}
if [ -z $NODE ]; then
@@ -43,29 +67,21 @@ fi
kubectl label node $NODE app=ccp-registry --overwrite
-workdir=$(dirname $0)
+function deploy_registry {
+ kube_cmd apply -f $WORKDIR/registry-pod.yaml
+ kube_cmd apply -f $WORKDIR/registry-service.yaml
+ await_readiness registry
+ kube_cmd get service registry
+}
-kube_cmd create -f $workdir/registry-pod.yaml
-kube_cmd create -f $workdir/registry-service.yaml
+function deploy_registry_ui {
+ cat $WORKDIR/registry-ui-pod.yaml | envsubst | kube_cmd apply -f -
+ kube_cmd apply -f $WORKDIR/registry-ui-service.yaml
+ await_readiness registry-ui
+ kube_cmd get service registry-ui
+}
-# Waiting for status Running
-while true; do
- echo "Waiting for 'Running' state"
- cont_running=$(kube_cmd get pod registry -o template --template="{{ .status.phase }}")
- if [ "$cont_running" == "Running" ]; then
- break
- fi
- sleep 3
-done
-
-# Waiting for readiness
-while true; do
- echo "Waiting for 'Ready' condition"
- cont_ready=$(kube_cmd get pod registry -o template --template="{{ range.status.containerStatuses }}{{ .ready }}{{ end }}")
- if [ "$cont_ready" == "true" ]; then
- break
- fi
- sleep 3
-done
-
-echo "Registy service is ready"
+deploy_registry
+if [ $DEPLOY_UI ]; then
+ deploy_registry_ui
+fi
diff --git a/tools/registry/registry-ui-pod.yaml b/tools/registry/registry-ui-pod.yaml
new file mode 100644
index 00000000..2c044a90
--- /dev/null
+++ b/tools/registry/registry-ui-pod.yaml
@@ -0,0 +1,30 @@
+apiVersion: v1
+kind: Pod
+metadata:
+ name: registry-ui
+ labels:
+ app: registry-ui
+spec:
+ containers:
+ - name: registry-ui
+ image: parabuzzle/docker-registry-ui:latest
+ imagePullPolicy: Always
+ ports:
+ - containerPort: 80
+ readinessProbe:
+ httpGet:
+ path: /
+ port: 80
+ initialDelaySeconds: 3
+ timeoutSeconds: 1
+ env:
+ - name: REGISTRY_ALLOW_DELETE
+ value: "true"
+ - name: REGISTRY_HOST
+ value: "registry.${NAMESPACE}"
+ - name: REGISTRY_PROTO
+ value: "http"
+ - name: REGISTRY_PORT
+ value: "5000"
+ nodeSelector:
+ app: ccp-registry
diff --git a/tools/registry/registry-ui-service.yaml b/tools/registry/registry-ui-service.yaml
new file mode 100644
index 00000000..e5addc56
--- /dev/null
+++ b/tools/registry/registry-ui-service.yaml
@@ -0,0 +1,12 @@
+kind: Service
+apiVersion: v1
+metadata:
+ name: registry-ui
+spec:
+ type: NodePort
+ selector:
+ app: registry-ui
+ ports:
+ - name: http
+ nodePort: 31800
+ port: 80