2016-06-27 15:57:29 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
create_mcp_conf() {
|
|
|
|
echo "Create mcp config"
|
|
|
|
cat > /root/mcp.conf << EOF
|
|
|
|
[builder]
|
|
|
|
push = True
|
|
|
|
registry = "127.0.0.1:31500"
|
|
|
|
|
|
|
|
[kubernetes]
|
|
|
|
environment = "openstack"
|
|
|
|
|
|
|
|
[repositories]
|
|
|
|
skip_empty = True
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2016-06-30 13:21:58 +00:00
|
|
|
create_resolvconf() {
|
|
|
|
DNS_IP=`kubectl get service/kubedns --namespace=kube-system --template={{.spec.clusterIP}}`
|
|
|
|
cat > /root/resolv.conf << EOF
|
|
|
|
search openstack.svc.cluster.local svc.cluster.local cluster.local default.svc.cluster.local svc.cluster.local cluster.local
|
|
|
|
nameserver $DNS_IP
|
|
|
|
options attempts:2
|
|
|
|
options ndots:5
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2016-06-27 15:57:29 +00:00
|
|
|
create_registry() {
|
|
|
|
if kubectl get pods | grep registry ; then
|
|
|
|
echo "Registry is already running"
|
|
|
|
else
|
|
|
|
echo "Create registry"
|
|
|
|
kubectl create -f registry_pod.yaml
|
|
|
|
kubectl create -f registry_svc.yaml
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
build_images() {
|
|
|
|
echo "Waiting for registry to start..."
|
|
|
|
while true
|
|
|
|
do
|
|
|
|
STATUS=$(kubectl get pod | awk '/registry/ {print $3}')
|
|
|
|
if [ "$STATUS" == "Running" ]
|
|
|
|
then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
sleep 1
|
|
|
|
done
|
2016-06-30 10:08:14 +00:00
|
|
|
mcp-microservices --config-file /root/mcp.conf build &> /var/log/mcp-build.log
|
2016-06-27 15:57:29 +00:00
|
|
|
}
|
|
|
|
|
2016-06-30 14:12:26 +00:00
|
|
|
hack_images() {
|
2016-06-30 16:18:33 +00:00
|
|
|
# useless, but let's keep it just in case we need to hack something else
|
2016-06-30 17:04:41 +00:00
|
|
|
for dir in ~/microservices-repos/ms-*/docker/* ; do
|
2016-06-30 14:12:26 +00:00
|
|
|
cp /root/resolv.conf $dir/
|
2016-06-30 17:01:01 +00:00
|
|
|
sed '/MAINTAINER/a COPY resolv.conf /var/tmp/resolv.conf' -i $dir/Dockerfile.j2
|
2016-06-30 14:12:26 +00:00
|
|
|
done
|
2016-06-30 13:21:58 +00:00
|
|
|
}
|
|
|
|
|
2016-06-27 15:57:29 +00:00
|
|
|
create_mcp_conf
|
|
|
|
create_registry
|
2016-06-30 13:21:58 +00:00
|
|
|
create_resolvconf
|
2016-06-30 17:01:01 +00:00
|
|
|
hack_images
|
2016-06-27 15:57:29 +00:00
|
|
|
build_images
|