Huge refactoring

Split scripts and instructuins into two parts: lab preparation and
deployment.
This commit is contained in:
Aleksandr Didenko
2016-06-30 15:21:58 +02:00
parent 17e3108b0c
commit 25d19720c0
8 changed files with 109 additions and 57 deletions

View File

@@ -17,6 +17,16 @@ skip_empty = True
EOF
}
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
}
create_registry() {
if kubectl get pods | grep registry ; then
echo "Registry is already running"
@@ -41,6 +51,13 @@ build_images() {
mcp-microservices --config-file /root/mcp.conf build &> /var/log/mcp-build.log
}
hack_base_image() {
cp /root/resolv.conf ccp/microservices-repos/ms-debian-base/docker/base/
sed '/COPY requirements.txt/a COPY resolv.conf /etc/resolv.conf' -i ccp/microservices-repos/ms-debian-base/docker/base/Dockerfile.j2
}
create_mcp_conf
create_registry
create_resolvconf
hack_base_image
build_images

View File

@@ -2,6 +2,17 @@
set -e
# FIXME: hardcoded roles
declare -A nodes
nodes=( \
["node2"]="openstack-controller=true"
["node3"]="openstack-controller=true"
["node4"]="openstack-controller=true"
["node5"]="openstack-compute=true"
["node6"]="openstack-compute=true"
["node7"]="openstack-compute=true"
)
create_network_conf() {
kubectl get nodes -o go-template='{{range .items}}{{range .status.addresses}}{{if or (eq .type "ExternalIP") (eq .type "LegacyHostIP")}}{{.address}}{{print "\n"}}{{end}}{{end}}{{end}}'> /tmp/nodes
# ( echo "network:"; i=2; for ip in `cat /tmp/nodes `; do echo -e " node$i:\n private:\n iface: eth2\n address: $ip"; pip=`echo $ip | perl -pe 's/(\d+).(\d+).1/\${1}.\${2}.0/g'`; echo -e " public:\n iface: eth1\n address: $pip" ; i=$(( i+=1 )) ;done ) > /root/cluster-topology.yaml
@@ -9,13 +20,12 @@ create_network_conf() {
}
assign_node_roles() {
# FIXME: hardcoded roles
kubectl label nodes node2 openstack-controller=true
kubectl label nodes node3 openstack-controller=true
kubectl label nodes node4 openstack-controller=true
kubectl label nodes node5 openstack-compute=true
kubectl label nodes node6 openstack-compute=true
kubectl label nodes node7 openstack-compute=true
for i in "${!nodes[@]}"
do
node=$i
label=${nodes[$i]}
kubectl get nodes $node --show-labels | grep -q "$label" || kubectl label nodes $node $label
done
}
create_network_conf