Added CCP deployment scripts
This commit is contained in:
parent
0c9826c60f
commit
df4fe074f0
15 changed files with 285 additions and 3 deletions
18
README.md
18
README.md
|
@ -20,6 +20,14 @@ How-to
|
|||
export VAGRANT_POOL="10.100.0.0/16"
|
||||
```
|
||||
|
||||
* If you want to run OpenStack CCP (Containerised Control Plane) then you need to pull CCP repos and patches:
|
||||
|
||||
```bash
|
||||
pushd ccp
|
||||
./ccp-pull.sh
|
||||
popd
|
||||
```
|
||||
|
||||
* Prepare the virtual lab:
|
||||
|
||||
```bash
|
||||
|
@ -36,3 +44,13 @@ vagrant ssh $USER-k8s-01
|
|||
sudo su -
|
||||
./deploy-k8s.kargo.sh
|
||||
```
|
||||
|
||||
* In order to deploy OpenStack CCP login to your master node and run this:
|
||||
|
||||
```bash
|
||||
vagrant ssh $USER-k8s-01
|
||||
# Inside your master VM run this:
|
||||
sudo su -
|
||||
./deploy-ccp.sh
|
||||
```
|
||||
|
||||
|
|
7
Vagrantfile
vendored
7
Vagrantfile
vendored
|
@ -23,7 +23,7 @@ $instance_name_prefix = "#{$user}-k8s"
|
|||
$box = "nrclark/xenial64-minimal-libvirt"
|
||||
|
||||
# Create SSH keys for future lab
|
||||
system 'bash ssh-keygen.sh'
|
||||
system 'bash vagrant-scripts/ssh-keygen.sh'
|
||||
|
||||
# Create nodes list for future kargo deployment
|
||||
nodes=""
|
||||
|
@ -94,9 +94,10 @@ Vagrant.configure("2") do |config|
|
|||
config.vm.provision "custom.yaml", type: "file", source: "custom.yaml", destination: "~/custom.yaml"
|
||||
config.vm.provision "playbooks", type: "file", source: "playbooks", destination: "~/playbooks"
|
||||
config.vm.provision "nodes", type: "file", source: "nodes", destination: "~/nodes"
|
||||
config.vm.provision "bootstrap", type: "shell", path: "bootstrap-master.sh"
|
||||
config.vm.provision "ccp", type: "file", source: "ccp", destination: "~/ccp"
|
||||
config.vm.provision "bootstrap", type: "shell", path: "vagrant-scripts/bootstrap-master.sh"
|
||||
else
|
||||
config.vm.provision "bootstrap", type: "shell", path: "bootstrap-node.sh"
|
||||
config.vm.provision "bootstrap", type: "shell", path: "vagrant-scripts/bootstrap-node.sh"
|
||||
end
|
||||
|
||||
end
|
||||
|
|
2
ccp/.gitignore
vendored
Normal file
2
ccp/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
microservices-repos
|
||||
microservices
|
46
ccp/ccp-build.sh
Executable file
46
ccp/ccp-build.sh
Executable file
|
@ -0,0 +1,46 @@
|
|||
#!/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
|
||||
}
|
||||
|
||||
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
|
||||
mcp-microservices --config-file /root/mcp.conf build
|
||||
}
|
||||
|
||||
create_mcp_conf
|
||||
create_registry
|
||||
build_images
|
23
ccp/ccp-deploy.sh
Executable file
23
ccp/ccp-deploy.sh
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
create_network_conf() {
|
||||
( echo "network:"; i=2; for ip in `cat /root/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
|
||||
}
|
||||
|
||||
assign_node_roles() {
|
||||
kubectl label nodes node2 openstack-role=controller
|
||||
kubectl label nodes node3 openstack-role=controller
|
||||
kubectl label nodes node4 openstack-role=compute
|
||||
kubectl label nodes node5 openstack-role=compute
|
||||
kubectl label nodes node6 openstack-role=compute
|
||||
kubectl label nodes node7 openstack-role=compute
|
||||
}
|
||||
|
||||
create_network_conf
|
||||
assign_node_roles
|
||||
|
||||
kubectl delete namespace openstack && sleep 40
|
||||
mcp-microservices --config-file=/root/mcp.conf deploy -t /root/cluster-topology.yaml
|
||||
|
115
ccp/ccp-pull.sh
Executable file
115
ccp/ccp-pull.sh
Executable file
|
@ -0,0 +1,115 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
GERRIT_USER=${1:-$USER}
|
||||
LOCAL_REPO="microservices-repos"
|
||||
PROTO="ssh://$GERRIT_USER@"
|
||||
REMOTE_REPOS="
|
||||
review.fuel-infra.org:29418/nextgen/ms-aodh
|
||||
review.fuel-infra.org:29418/nextgen/ms-ceilometer
|
||||
review.fuel-infra.org:29418/nextgen/ms-ceph
|
||||
review.fuel-infra.org:29418/nextgen/ms-cinder
|
||||
review.fuel-infra.org:29418/nextgen/ms-debian-base
|
||||
review.fuel-infra.org:29418/nextgen/ms-designate
|
||||
review.fuel-infra.org:29418/nextgen/ms-elasticsearch
|
||||
review.fuel-infra.org:29418/nextgen/ms-ext-config
|
||||
review.fuel-infra.org:29418/nextgen/ms-glance
|
||||
review.fuel-infra.org:29418/nextgen/ms-grafana
|
||||
review.fuel-infra.org:29418/nextgen/ms-heat
|
||||
review.fuel-infra.org:29418/nextgen/ms-horizon
|
||||
review.fuel-infra.org:29418/nextgen/ms-influxdb
|
||||
review.fuel-infra.org:29418/nextgen/ms-ironic
|
||||
review.fuel-infra.org:29418/nextgen/ms-keystone
|
||||
review.fuel-infra.org:29418/nextgen/ms-kibana
|
||||
review.fuel-infra.org:29418/nextgen/ms-lma
|
||||
review.fuel-infra.org:29418/nextgen/ms-magnum
|
||||
review.fuel-infra.org:29418/nextgen/ms-manila
|
||||
review.fuel-infra.org:29418/nextgen/ms-mariadb
|
||||
review.fuel-infra.org:29418/nextgen/ms-memcached
|
||||
review.fuel-infra.org:29418/nextgen/ms-mistral
|
||||
review.fuel-infra.org:29418/nextgen/ms-mongodb
|
||||
review.fuel-infra.org:29418/nextgen/ms-murano
|
||||
review.fuel-infra.org:29418/nextgen/ms-neutron
|
||||
review.fuel-infra.org:29418/nextgen/ms-nova
|
||||
review.fuel-infra.org:29418/nextgen/ms-openstack-base
|
||||
review.fuel-infra.org:29418/nextgen/ms-openvswitch
|
||||
review.fuel-infra.org:29418/nextgen/ms-rabbitmq
|
||||
review.fuel-infra.org:29418/nextgen/ms-sahara
|
||||
review.fuel-infra.org:29418/nextgen/ms-swift
|
||||
review.fuel-infra.org:29418/nextgen/ms-tempest
|
||||
review.fuel-infra.org:29418/nextgen/ms-toolbox
|
||||
review.fuel-infra.org:29418/nextgen/ms-trove
|
||||
review.fuel-infra.org:29418/nextgen/ms-zaqar
|
||||
"
|
||||
|
||||
cleanup() {
|
||||
mkdir -p $LOCAL_REPO
|
||||
rm -rf $LOCAL_REPO/ms-*
|
||||
rm -rf microservices
|
||||
}
|
||||
|
||||
fetch_mcp() {
|
||||
git clone "${PROTO}review.fuel-infra.org:29418/nextgen/microservices"
|
||||
pushd microservices
|
||||
git review -d 22325
|
||||
popd
|
||||
}
|
||||
|
||||
fetch_repos() {
|
||||
pushd $LOCAL_REPO
|
||||
for remote in $REMOTE_REPOS ; do
|
||||
git clone "${PROTO}${remote}"
|
||||
done
|
||||
popd
|
||||
}
|
||||
|
||||
fetch_app_def() {
|
||||
echo "Fetch app-def repos"
|
||||
mariadb=21637
|
||||
keystone=21848
|
||||
memcached=21849
|
||||
rabbitmq=22053
|
||||
horizon=21850
|
||||
neutron=21886
|
||||
ovs=21951
|
||||
nova=21871
|
||||
glance=21998
|
||||
|
||||
cd $LOCAL_REPO
|
||||
|
||||
cd ms-mariadb
|
||||
git review -d $mariadb
|
||||
cd -
|
||||
cd ms-keystone
|
||||
git review -d $keystone
|
||||
cd -
|
||||
cd ms-memcached
|
||||
git review -d $memcached
|
||||
cd -
|
||||
cd ms-rabbitmq
|
||||
git review -d $rabbitmq
|
||||
cd -
|
||||
cd ms-horizon
|
||||
git review -d $horizon
|
||||
cd -
|
||||
cd ms-neutron
|
||||
git review -d $neutron
|
||||
cd -
|
||||
cd ms-openvswitch
|
||||
git review -d $ovs
|
||||
cd -
|
||||
cd ms-nova
|
||||
git review -d $nova
|
||||
cd -
|
||||
cd ms-glance
|
||||
git review -d $glance
|
||||
cd -
|
||||
}
|
||||
|
||||
cleanup
|
||||
fetch_mcp
|
||||
fetch_repos
|
||||
fetch_app_def
|
||||
|
||||
echo "Microservices pull is complete"
|
16
ccp/registry_pod.yaml
Normal file
16
ccp/registry_pod.yaml
Normal file
|
@ -0,0 +1,16 @@
|
|||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: registry
|
||||
labels:
|
||||
app: registry
|
||||
spec:
|
||||
containers:
|
||||
- name: registry
|
||||
image: registry:2
|
||||
env:
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 5000
|
||||
hostPort: 5000
|
||||
|
15
ccp/registry_svc.yaml
Normal file
15
ccp/registry_svc.yaml
Normal file
|
@ -0,0 +1,15 @@
|
|||
kind: "Service"
|
||||
apiVersion: "v1"
|
||||
metadata:
|
||||
name: "registry"
|
||||
spec:
|
||||
selector:
|
||||
app: "registry"
|
||||
ports:
|
||||
-
|
||||
protocol: "TCP"
|
||||
port: 5000
|
||||
targetPort: 5000
|
||||
nodePort: 31500
|
||||
type: "NodePort"
|
||||
|
9
deploy-ccp.sh
Executable file
9
deploy-ccp.sh
Executable file
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
INVENTORY="kargo/inventory/inventory.cfg"
|
||||
|
||||
echo "Createing repository and CCP images, it may take a while..."
|
||||
ansible-playbook -i $INVENTORY playbooks/ccp-build.yaml
|
||||
|
||||
echo "Deploying up OpenStack CCP..."
|
||||
ansible-playbook -i $INVENTORY playbooks/ccp-deploy.yaml
|
|
@ -23,4 +23,6 @@ deploy_res=$?
|
|||
if [ "$deploy_res" -eq "0" ]; then
|
||||
echo "Setting up kubedns..."
|
||||
ansible-playbook -i $INVENTORY playbooks/kubedns.yaml
|
||||
echo "Setting up kubedashboard..."
|
||||
ansible-playbook -i $INVENTORY playbooks/kubedashboard.yaml
|
||||
fi
|
||||
|
|
24
playbooks/ccp-build.yaml
Normal file
24
playbooks/ccp-build.yaml
Normal file
|
@ -0,0 +1,24 @@
|
|||
- hosts: kube-master
|
||||
pre_tasks:
|
||||
- name: Rsync CCP repos
|
||||
synchronize: src=/root/ccp/microservices-repos/ dest=/root/microservices-repos/
|
||||
- name: Rsync MCP scripts and repo
|
||||
synchronize:
|
||||
src: /root/ccp/
|
||||
dest: /root/ccp/
|
||||
rsync_opts:
|
||||
- "--exclude=/microservices-repos"
|
||||
tasks:
|
||||
- name: Install MCP
|
||||
shell: "{{ item }}"
|
||||
args:
|
||||
chdir: /root/ccp/microservices/
|
||||
creates: /usr/local/bin/mcp-microservices
|
||||
with_items:
|
||||
- pip install .
|
||||
- python setup.py develop
|
||||
- name: Build CCP images
|
||||
shell: ./ccp-build.sh
|
||||
args:
|
||||
chdir: /root/ccp
|
||||
run_once: true
|
10
playbooks/ccp-deploy.yaml
Normal file
10
playbooks/ccp-deploy.yaml
Normal file
|
@ -0,0 +1,10 @@
|
|||
- hosts: kube-master
|
||||
pre_tasks:
|
||||
- name: Rsync nodes list
|
||||
synchronize: src=/root/nodes dest=/root/nodes
|
||||
tasks:
|
||||
- name: Deploy CCP
|
||||
shell: ./ccp-deploy.sh
|
||||
args:
|
||||
chdir: /root/ccp
|
||||
run_once: true
|
|
@ -17,6 +17,7 @@ sudo sh -c 'cd /root/kargo-cli && python setup.py install'
|
|||
sudo sh -c 'cp -a ~vagrant/deploy-k8s.kargo.sh /root/ && chmod 755 /root/deploy-k8s.kargo.sh'
|
||||
sudo cp -a ~vagrant/custom.yaml /root/custom.yaml
|
||||
sudo cp -a ~vagrant/playbooks /root/playbooks
|
||||
sudo cp -a ~vagrant/ccp /root/ccp
|
||||
|
||||
# SSH keys and config
|
||||
sudo rm -rf /root/.ssh
|
Loading…
Reference in a new issue