Deploy registry on first node in k8s

Also use local directory for registry storage. It allows use builded
images after redeploy registry.

Change-Id: Ia3ffc04275dc675dc9863decb7ced20d890473a1
This commit is contained in:
Sergey Reshetnyak 2016-09-12 22:14:11 +03:00
parent 1209b7b140
commit 048195df3e
2 changed files with 21 additions and 1 deletions

View File

@ -7,11 +7,12 @@ function usage {
echo "Usage:"
echo " $base_name -s <address>"
echo " $base_name -n <namespace>"
echo " $base_name -i <node>"
}
NAMESPACE_OPT=" --namespace kube-system"
while getopts "s:n:" opt; do
while getopts "s:n:i:" opt; do
case $opt in
"s" )
SRV_OPT=" -s $OPTARG"
@ -19,6 +20,9 @@ while getopts "s:n:" opt; do
"n" )
NAMESPACE_OPT=" --namespace $OPTARG"
;;
"i" )
NODE="$OPTARG"
;;
* )
usage
exit 1
@ -32,6 +36,13 @@ function kube_cmd {
kubectl $SRV_OPT $NAMESPACE_OPT "$@"
}
if [ -z $NODE ]; then
NODE=$(kubectl get nodes -o template --template="{{ with index .items 0 }}{{ .metadata.name }}{{ end }}")
echo "K8S node is not specified, using $NODE"
fi
kubectl label node $NODE app=ccp-registry --overwrite
workdir=$(dirname $0)
kube_cmd create -f $workdir/registry-pod.yaml

View File

@ -12,9 +12,18 @@ spec:
ports:
- containerPort: 5000
hostPort: 5000
volumeMounts:
- mountPath: /var/lib/registry
name: registry-volume
readinessProbe:
httpGet:
path: /v2/_catalog
port: 5000
initialDelaySeconds: 3
timeoutSeconds: 1
nodeSelector:
app: ccp-registry
volumes:
- name: registry-volume
hostPath:
path: /var/lib/ccp-registry