diff options
author | Guo Ruijing <ruijing.guo@intel.com> | 2017-12-21 04:17:48 -0500 |
---|---|---|
committer | Guo Ruijing <ruijing.guo@intel.com> | 2017-12-21 04:46:35 -0500 |
commit | 09c951502f43c477d48903bc335905b2d5287295 (patch) | |
tree | 9cdc3180d96ea25bfb6cffd08e6b0ddc5c5f2184 /src/vagrant | |
parent | 35951994a9a6eafd94e59958b0c97d80a8660742 (diff) |
onap deployment by kubeadm + onap oom
Change-Id: I4db577c754a4cd550482e40c2a96004faf65bd24
Signed-off-by: Guo Ruijing <ruijing.guo@intel.com>
Diffstat (limited to 'src/vagrant')
-rw-r--r-- | src/vagrant/kubeadm_onap/Vagrantfile | 41 | ||||
-rwxr-xr-x | src/vagrant/kubeadm_onap/host_setup.sh | 39 | ||||
-rwxr-xr-x | src/vagrant/kubeadm_onap/master_setup.sh | 13 | ||||
-rwxr-xr-x | src/vagrant/kubeadm_onap/onap_setup.sh | 42 | ||||
-rw-r--r-- | src/vagrant/kubeadm_onap/openstack/Vagrantfile | 37 | ||||
-rw-r--r-- | src/vagrant/kubeadm_onap/openstack/bootstrap.sh | 14 | ||||
-rw-r--r-- | src/vagrant/kubeadm_onap/openstack/compute.conf | 20 | ||||
-rw-r--r-- | src/vagrant/kubeadm_onap/openstack/control.conf | 40 | ||||
-rw-r--r-- | src/vagrant/kubeadm_onap/openstack/create_vm.sh | 5 | ||||
-rw-r--r-- | src/vagrant/kubeadm_onap/openstack/openrc | 4 | ||||
-rw-r--r-- | src/vagrant/kubeadm_onap/openstack/setup_cell.sh | 6 | ||||
-rw-r--r-- | src/vagrant/kubeadm_onap/openstack/setup_compute.sh | 19 | ||||
-rw-r--r-- | src/vagrant/kubeadm_onap/openstack/setup_control.sh | 40 | ||||
-rwxr-xr-x | src/vagrant/kubeadm_onap/worker_setup.sh | 11 |
14 files changed, 331 insertions, 0 deletions
diff --git a/src/vagrant/kubeadm_onap/Vagrantfile b/src/vagrant/kubeadm_onap/Vagrantfile new file mode 100644 index 0000000..fe24252 --- /dev/null +++ b/src/vagrant/kubeadm_onap/Vagrantfile @@ -0,0 +1,41 @@ +$num_workers=1 + +Vagrant.require_version ">= 1.8.6" +Vagrant.configure("2") do |config| + + config.vm.box = "yk0/ubuntu-xenial" + config.vm.provision "shell", path: "host_setup.sh", privileged: false + + config.vm.define "master" do |config| + config.vm.hostname = "master" + config.vm.provision "shell", path: "master_setup.sh", privileged: false + config.vm.network :private_network, ip: "192.168.0.10" + config.vm.provider :libvirt do |libvirt| + libvirt.memory = 4096 + libvirt.cpus = 4 + end + end + + (1 .. $num_workers).each do |i| + config.vm.define vm_name = "worker%d" % [i] do |config| + config.vm.hostname = vm_name + config.vm.provision "shell", path: "worker_setup.sh", privileged: false + config.vm.network :private_network, ip: "192.168.0.#{i+20}" + config.vm.provider :libvirt do |libvirt| + libvirt.memory = 81920 + libvirt.cpus = 32 + end + end + end + + config.vm.define "onap" do |config| + config.vm.hostname = "onap" + config.vm.provision "shell", path: "onap_setup.sh", privileged: false + config.vm.network :private_network, ip: "192.168.0.5" + config.vm.provider :libvirt do |libvirt| + libvirt.memory = 2048 + libvirt.cpus = 1 + end + end + +end diff --git a/src/vagrant/kubeadm_onap/host_setup.sh b/src/vagrant/kubeadm_onap/host_setup.sh new file mode 100755 index 0000000..87b0062 --- /dev/null +++ b/src/vagrant/kubeadm_onap/host_setup.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +set -ex + +cat << EOF | sudo tee /etc/hosts +127.0.0.1 localhost +192.168.0.5 onap +192.168.0.10 master +192.168.0.21 worker1 +192.168.0.22 worker2 +192.168.0.23 worker3 +EOF + +sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D +sudo apt-key adv -k 58118E89F3A912897C070ADBF76221572C52609D +cat << EOF | sudo tee /etc/apt/sources.list.d/docker.list +deb [arch=amd64] https://apt.dockerproject.org/repo ubuntu-xenial main +EOF + +curl -s http://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - +cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list +deb http://apt.kubernetes.io/ kubernetes-xenial main +EOF +sudo apt-get update +sudo apt-get install -y --allow-downgrades docker-engine=1.12.6-0~ubuntu-xenial kubelet=1.7.0-00 kubeadm=1.7.0-00 kubectl=1.7.0-00 kubernetes-cni=0.5.1-00 + +sudo systemctl stop docker +cat << EOF | sudo tee /etc/docker/daemon.json +{ + "storage-driver": "overlay" +} +EOF +sudo systemctl daemon-reload +sudo systemctl start docker + +sudo systemctl stop kubelet +sudo rm -rf /var/lib/kubelet +sudo systemctl daemon-reload +sudo systemctl start kubelet diff --git a/src/vagrant/kubeadm_onap/master_setup.sh b/src/vagrant/kubeadm_onap/master_setup.sh new file mode 100755 index 0000000..fa451a2 --- /dev/null +++ b/src/vagrant/kubeadm_onap/master_setup.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -ex + +sudo kubeadm init --apiserver-advertise-address=192.168.0.10 --service-cidr=10.96.0.0/24 --pod-network-cidr=10.32.0.0/12 --token 8c5adc.1cec8dbf339093f0 +mkdir ~/.kube +sudo cp /etc/kubernetes/admin.conf ~/.kube/config +sudo chown $(id -u):$(id -g) ~/.kube/config + +kubectl apply -f http://git.io/weave-kube-1.6 +curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash +helm init +kubectl create clusterrolebinding --user system:serviceaccount:kube-system:default kube-system-cluster-admin --clusterrole cluster-admin diff --git a/src/vagrant/kubeadm_onap/onap_setup.sh b/src/vagrant/kubeadm_onap/onap_setup.sh new file mode 100755 index 0000000..3e1d9b4 --- /dev/null +++ b/src/vagrant/kubeadm_onap/onap_setup.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +set -ex + +sudo apt-get install -y putty-tools python-openstackclient +mkdir ~/.kube +r=0 +while [ "$r" == "0" ] +do + sleep 30 + echo "y\n" | plink -ssh -pw vagrant vagrant@master "cat ~/.kube/config" > ~/.kube/config || true + r=$(kubectl get pods -n kube-system | grep "tiller-deploy.*Run" | wc -l) +done + +curl https://raw.githubusercontent.com/kubernetes/helm/master/scripts/get | bash +git clone http://gerrit.onap.org/r/oom +cd oom; git checkout release-1.1.0 +source /vagrant/openstack/openrc +cat <<EOF | tee ~/oom/kubernetes/config/onap-parameters.yaml +OPENSTACK_UBUNTU_14_IMAGE: "ubuntu1404" +OPENSTACK_PUBLIC_NET_ID: "e8f51956-00dd-4425-af36-045716781ffc" +OPENSTACK_OAM_NETWORK_ID: "d4769dfb-c9e4-4f72-b3d6-1d18f4ac4ee6" +OPENSTACK_OAM_SUBNET_ID: "191f7580-acf6-4c2b-8ec0-ba7d99b3bc4e" +OPENSTACK_OAM_NETWORK_CIDR: "10.0.0.0/16" +OPENSTACK_USERNAME: "admin" +OPENSTACK_API_KEY: "adim" +OPENSTACK_TENANT_NAME: "admin" +OPENSTACK_TENANT_ID: "47899782ed714295b1151681fdfd51f5" +OPENSTACK_REGION: "RegionOne" +OPENSTACK_KEYSTONE_URL: "http://192.168.0.30:5000/v2.0" +OPENSTACK_FLAVOUR_MEDIUM: "m1.medium" +OPENSTACK_SERVICE_TENANT_NAME: "service" +DMAAP_TOPIC: "AUTO" +DEMO_ARTIFACTS_VERSION: "1.1.0-SNAPSHOT" +EOF +cd ~/oom/kubernetes/oneclick && ./deleteAll.bash -n onap || true +(kubectl delete ns onap; helm del --purge onap-config) || true +echo "y\n" | plink -ssh -pw vagrant vagrant@worker1 "sudo rm -rf /dockerdata-nfs/onap" +cd ~/oom/kubernetes/config && ./createConfig.sh -n onap +while true; do sleep 30; kubectl get pods --all-namespaces | grep onap | wc -l | grep "^0$" && break; done +source ~/oom/kubernetes/oneclick/setenv.bash +cd ~/oom/kubernetes/oneclick && ./createAll.bash -n onap diff --git a/src/vagrant/kubeadm_onap/openstack/Vagrantfile b/src/vagrant/kubeadm_onap/openstack/Vagrantfile new file mode 100644 index 0000000..f2a806d --- /dev/null +++ b/src/vagrant/kubeadm_onap/openstack/Vagrantfile @@ -0,0 +1,37 @@ +$num_compute_nodes = 0 + +Vagrant.configure("2") do |config| + + config.vm.box = "yk0/ubuntu-xenial" + + config.vm.provision "shell", path: "bootstrap.sh", privileged: false + + config.vm.define "control" do |config| + config.vm.hostname = "control" + config.vm.network "private_network", ip: "192.168.0.30" + config.vm.network "private_network", ip: "192.168.1.30" + config.vm.provision "shell", path: "setup_control.sh", privileged: false + config.vm.provider :libvirt do |libvirt| + libvirt.memory = 32768 + libvirt.cpus = 8 + libvirt.storage :file, :type => "qcow2", :size => "500G" + libvirt.storage :file, :type => "qcow2", :size => "500G" + end + end + + (1 .. $num_compute_nodes).each do |n| + config.vm.define vm_name = "compute-#{n}" do |config| + config.vm.hostname = vm_name + config.vm.network "private_network", ip: "192.168.0.#{n+40}" + config.vm.network "private_network", ip: "192.168.1.#{n+40}" + config.vm.provision "shell", path: "setup_compute.sh", privileged: false + config.vm.provider :libvirt do |libvirt| + libvirt.memory = 81920 + libvirt.cpus = 32 + libvirt.nested = true + libvirt.storage :file, :type => "qcow2", :size => "500G" + end + end + end + +end diff --git a/src/vagrant/kubeadm_onap/openstack/bootstrap.sh b/src/vagrant/kubeadm_onap/openstack/bootstrap.sh new file mode 100644 index 0000000..9978c81 --- /dev/null +++ b/src/vagrant/kubeadm_onap/openstack/bootstrap.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +set -ex + +sudo apt-get update -y +sudo apt-get install git -y +git clone https://github.com/openstack-dev/devstack +cd devstack; git checkout stable/ocata +sudo apt-get install openvswitch-switch -y +sudo ovs-vsctl add-br br-ex +inet=$(ip a | grep 'inet.*eth2' | cut -f6 -d' ') +sudo ip addr flush eth2 +sudo ovs-vsctl add-port br-ex eth2 +sudo ifconfig br-ex $inet up +echo "source /vagrant/openrc" >> $HOME/.bash_profile diff --git a/src/vagrant/kubeadm_onap/openstack/compute.conf b/src/vagrant/kubeadm_onap/openstack/compute.conf new file mode 100644 index 0000000..28b6f4e --- /dev/null +++ b/src/vagrant/kubeadm_onap/openstack/compute.conf @@ -0,0 +1,20 @@ +[[local|localrc]] +SCREEN_LOGDIR=/opt/stack/log +LOGFILE=stack.sh.log +LOG_COLOR=False + +HOST_IP=HOSTIP +HOST_NAME=HOSTNAME +SERVICE_HOST=192.168.0.30 +SERVICE_HOST_NAME=control + +ADMIN_PASSWORD=admin +SERVICE_PASSWORD=admin +DATABASE_PASSWORD=mysql +RABBIT_PASSWORD=rabbit + +disable_all_services +enable_service rabbit,n-cpu,n-novnc,placement-client,q-agt,n-api-meta + +OVS_BRIDGE_MAPPINGS=public:br-ex +OVS_PHYSICAL_BRIDGE=br-ex diff --git a/src/vagrant/kubeadm_onap/openstack/control.conf b/src/vagrant/kubeadm_onap/openstack/control.conf new file mode 100644 index 0000000..72a3609 --- /dev/null +++ b/src/vagrant/kubeadm_onap/openstack/control.conf @@ -0,0 +1,40 @@ +[[local|localrc]] +SCREEN_LOGDIR=/opt/stack/log +LOGFILE=stack.sh.log +LOG_COLOR=False + +MULTI_HOST=1 +HOST_IP=192.168.0.30 +HOST_NAME=control +SERVICE_HOST=192.168.0.30 +SERVICE_HOST_NAME=control + +ADMIN_PASSWORD=admin +SERVICE_PASSWORD=admin +DATABASE_PASSWORD=mysql +RABBIT_PASSWORD=rabbit + +enable_plugin heat https://git.openstack.org/openstack/heat stable/ocata +enable_plugin designate https://git.openstack.org/openstack/designate stable/ocata + +disable_all_services +enable_service key,rabbit,mysql +enable_service n-api,n-cond,n-sch,n-novnc,n-crt,n-cauth,placement-api +enable_service q-svc,q-dhcp,q-meta,q-l3,q-agt +enable_service c-sch,c-api,c-vol +enable_service g-api,g-reg +enable_service h-eng,h-api,h-api-cfn,h-api-cw +enable_service horizon +enable_service designate,designate-central,designate-api,designate-pool-manager,designate-zone-manager,designate-mdns +enable_service rabbit,n-cpu,n-novnc,placement-client,q-agt,n-api-meta + +DESIGNATE_BACKEND_DRIVER=bind9 + +## Neutron options +FLOATING_RANGE="192.168.1.0/24" +PUBLIC_NETWORK_GATEWAY="192.168.1.1" +FIXED_RANGE="10.0.0.0/16" +Q_FLOATING_ALLOCATION_POOL=start=192.168.1.200,end=192.168.1.250 +Q_USE_SECGROUP=False +Q_L3_ENABLED=True +Q_USE_PROVIDERNET_FOR_PUBLIC=True diff --git a/src/vagrant/kubeadm_onap/openstack/create_vm.sh b/src/vagrant/kubeadm_onap/openstack/create_vm.sh new file mode 100644 index 0000000..6597ae4 --- /dev/null +++ b/src/vagrant/kubeadm_onap/openstack/create_vm.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source ~/devstack/openrc admin admin +netid=$(openstack network list --name private -f value | cut -f1 -d' ') +openstack server create --flavor 1 --image=cirros-0.3.4-x86_64-uec --nic net-id=$netid vm1 diff --git a/src/vagrant/kubeadm_onap/openstack/openrc b/src/vagrant/kubeadm_onap/openstack/openrc new file mode 100644 index 0000000..8e1cd1c --- /dev/null +++ b/src/vagrant/kubeadm_onap/openstack/openrc @@ -0,0 +1,4 @@ +export OS_PROJECT_NAME=admin +export OS_USERNAME=admin +export OS_PASSWORD=admin +export OS_AUTH_URL=http://192.168.0.30:5000/v2.0 diff --git a/src/vagrant/kubeadm_onap/openstack/setup_cell.sh b/src/vagrant/kubeadm_onap/openstack/setup_cell.sh new file mode 100644 index 0000000..4426501 --- /dev/null +++ b/src/vagrant/kubeadm_onap/openstack/setup_cell.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -ex + +source ~/devstack/openrc admin admin +nova-manage cell_v2 discover_hosts +nova-manage cell_v2 map_cell_and_hosts diff --git a/src/vagrant/kubeadm_onap/openstack/setup_compute.sh b/src/vagrant/kubeadm_onap/openstack/setup_compute.sh new file mode 100644 index 0000000..92c18cf --- /dev/null +++ b/src/vagrant/kubeadm_onap/openstack/setup_compute.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -ex + +sudo pvcreate /dev/vdb +sudo vgextend ubuntubox-vg /dev/vdb +sudo lvextend -L+500G /dev/mapper/ubuntubox--vg-root +sudo resize2fs /dev/mapper/ubuntubox--vg-root + +cd devstack +cp /vagrant/compute.conf local.conf +host=$(hostname) +ip=$(ifconfig | grep 192.168.0 | cut -f2 -d: | cut -f1 -d' ') +sed -i -e "s/HOSTIP/$ip/" -e "s/HOSTNAME/$host/" local.conf +./stack.sh + + +sudo apt-get update -y +sudo apt-get install -y putty +echo y | plink -ssh -l vagrant -pw vagrant 192.168.0.30 "bash /vagrant/setup_cell.sh" diff --git a/src/vagrant/kubeadm_onap/openstack/setup_control.sh b/src/vagrant/kubeadm_onap/openstack/setup_control.sh new file mode 100644 index 0000000..1f19a16 --- /dev/null +++ b/src/vagrant/kubeadm_onap/openstack/setup_control.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +set -ex + +sudo pvcreate /dev/vdb +sudo vgextend ubuntubox-vg /dev/vdb +sudo lvextend -L+500G /dev/mapper/ubuntubox--vg-root +sudo resize2fs /dev/mapper/ubuntubox--vg-root + +cd devstack +cp /vagrant/control.conf local.conf +./stack.sh + +sudo pvcreate /dev/vdc +sudo vgextend stack-volumes-lvmdriver-1 /dev/vdc + +source /vagrant/openrc + +#openstack network create public --external --provider-network-type=flat --provider-physical-network=public +#openstack subnet create --network=public --subnet-range=192.168.1.0/24 --allocation-pool start=192.168.1.200,end=192.168.1.250 --gateway 192.168.1.1 public-subnet +openstack security group list -f value | cut -f1 -d" " | xargs -I {} openstack security group rule create --ingress --ethertype=IPv4 --protocol=0 {} + +wget https://cloud-images.ubuntu.com/releases/14.04.1/release/ubuntu-14.04-server-cloudimg-amd64-disk1.img +wget https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img +wget https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2 +openstack image create ubuntu1404 --file ubuntu-14.04-server-cloudimg-amd64-disk1.img --disk-format qcow2 +openstack image create ubuntu1604 --file ubuntu-16.04-server-cloudimg-amd64-disk1.img --disk-format qcow2 +openstack image create centos7 --file CentOS-7-x86_64-GenericCloud.qcow2 --disk-format qcow2 + +openstack quota set admin --instances 32 +openstack quota set admin --cores 128 +openstack quota set admin --ram 409600 + +openstack flavor delete m1.medium || true +openstack flavor create --public m1.medium --id auto --ram 4096 --vcpus 2 --disk 40 +openstack flavor delete m1.large || true +openstack flavor create --public m1.large --id auto --ram 8192 --vcpus 2 --disk 40 +openstack flavor delete m1.xlarge || true +openstack flavor create --public m1.xlarge --id auto --ram 12288 --vcpus 4 --disk 40 +openstack flavor delete m1.xxlarge || true +openstack flavor create --public m1.xxlarge --id auto --ram 16384 --vcpus 4 --disk 40 diff --git a/src/vagrant/kubeadm_onap/worker_setup.sh b/src/vagrant/kubeadm_onap/worker_setup.sh new file mode 100755 index 0000000..aa60df3 --- /dev/null +++ b/src/vagrant/kubeadm_onap/worker_setup.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +set -ex + +sudo mkdir /dockerdata-nfs +sudo chmod 755 /dockerdata-nfs +sudo kubeadm join --token 8c5adc.1cec8dbf339093f0 192.168.0.10:6443 || true + +sudo apt-get install -y putty-tools +mkdir ~/.kube +echo "y\n" | plink -ssh -pw vagrant vagrant@master "cat ~/.kube/config" > ~/.kube/config |