aboutsummaryrefslogtreecommitdiff
path: root/contrib/demos
diff options
context:
space:
mode:
authorChristian Berendt <berendt@betacloud-solutions.de>2016-10-14 12:55:26 +0200
committerChristian Berendt <berendt@betacloud-solutions.de>2016-10-14 12:57:49 +0200
commitb725bd09dd73edf22bdd67bd13359e2a7d8b0796 (patch)
treeb088b5f48a51df9dfb40938b1f573f0b6f1685d5 /contrib/demos
parentdbf05f076fb2394439afcee95de3922a83f92219 (diff)
downloadkolla-b725bd09dd73edf22bdd67bd13359e2a7d8b0796.tar.gz
kolla-b725bd09dd73edf22bdd67bd13359e2a7d8b0796.zip
Move demos and dev directory into a new contrib directory
TrivialFix Change-Id: Ifb8f19afa1514488bd288670d08b96f84982a4e1
Diffstat (limited to 'contrib/demos')
-rw-r--r--contrib/demos/heat/README.rst15
-rwxr-xr-xcontrib/demos/heat/launch11
-rw-r--r--contrib/demos/heat/steak-rg.yaml43
-rw-r--r--contrib/demos/heat/steak.yaml54
-rwxr-xr-xcontrib/demos/magnum/redis5
-rw-r--r--contrib/demos/magnum/redis-kube/README.rst197
-rw-r--r--contrib/demos/magnum/redis-kube/redis-controller.yaml28
-rw-r--r--contrib/demos/magnum/redis-kube/redis-master.yaml33
-rw-r--r--contrib/demos/magnum/redis-kube/redis-proxy.yaml14
-rw-r--r--contrib/demos/magnum/redis-kube/redis-sentinel-controller.yaml23
-rw-r--r--contrib/demos/magnum/redis-kube/redis-sentinel-service.yaml13
-rwxr-xr-xcontrib/demos/magnum/start40
-rwxr-xr-xcontrib/demos/magnum/stop8
13 files changed, 484 insertions, 0 deletions
diff --git a/contrib/demos/heat/README.rst b/contrib/demos/heat/README.rst
new file mode 100644
index 000000000..b634febd8
--- /dev/null
+++ b/contrib/demos/heat/README.rst
@@ -0,0 +1,15 @@
+A Kolla Demo using Heat
+=======================
+
+By default, the launch script will spawn 3 Nova instances on a Neutron
+network created from the tools/init-runonce script. Edit the VM\_COUNT
+parameter in the launch script if you would like to spawn a different
+amount of Nova instances. Edit the IMAGE\_FLAVOR if you would like to
+launch images using a flavor other than m1.tiny.
+
+Then run the script:
+
+::
+
+ $ ./launch
+
diff --git a/contrib/demos/heat/launch b/contrib/demos/heat/launch
new file mode 100755
index 000000000..768b69eb0
--- /dev/null
+++ b/contrib/demos/heat/launch
@@ -0,0 +1,11 @@
+VM_COUNT=3
+IMAGE_FLAVOR=m1.small
+PUBLIC_NET_ID=$(neutron net-list | grep public | awk '{print $2}')
+DEMO_NET_ID=$(neutron net-list | grep demo | awk '{print $2}')
+DEMO_SUBNET_ID=$(neutron net-list | grep demo | awk '{print $6}')
+
+echo Public net id is $PUBLIC_NET_ID
+echo Demo net id is $DEMO_NET_ID
+echo Demo subnet id is $DEMO_SUBNET_ID
+
+heat stack-create steak --template-file steak-rg.yaml --parameters="vm_count=$VM_COUNT;image_flavor=$IMAGE_FLAVOR;public_net_id=$PUBLIC_NET_ID;demo_net_id=$DEMO_NET_ID;demo_subnet_id=$DEMO_SUBNET_ID"
diff --git a/contrib/demos/heat/steak-rg.yaml b/contrib/demos/heat/steak-rg.yaml
new file mode 100644
index 000000000..4c0a1db93
--- /dev/null
+++ b/contrib/demos/heat/steak-rg.yaml
@@ -0,0 +1,43 @@
+heat_template_version: 2013-05-23
+
+parameters:
+ public_net_id:
+ type: string
+ description: uuid of a network to use for floating ip addresses
+
+ demo_net_id:
+ type: string
+ description: uuid of a subnet on the fixed network to use for creating ports
+
+ demo_subnet_id:
+ type: string
+ description: uuid of a subnet on the fixed network to use for creating ports
+
+ vm_count:
+ type: string
+ description: Number of VMs to launch
+
+ image_flavor:
+ type: string
+ description: Image flavor to use when launching VMs
+
+resources:
+ steak:
+ type: OS::Heat::ResourceGroup
+ properties:
+ count:
+ get_param: vm_count
+ resource_def:
+ type: steak.yaml
+ properties:
+ image_flavor: {get_param: image_flavor}
+ public_net_id: {get_param: public_net_id}
+ demo_net_id: {get_param: demo_net_id}
+ demo_subnet_id: {get_param: demo_subnet_id}
+
+outputs:
+ eth0:
+ value: {get_attr: [steak, eth0]}
+
+ float:
+ value: {get_attr: [steak, float]}
diff --git a/contrib/demos/heat/steak.yaml b/contrib/demos/heat/steak.yaml
new file mode 100644
index 000000000..9b9bd9fc7
--- /dev/null
+++ b/contrib/demos/heat/steak.yaml
@@ -0,0 +1,54 @@
+heat_template_version: 2013-05-23
+
+parameters:
+ public_net_id:
+ type: string
+ description: uuid of a network to use for floating ip addresses
+
+ demo_net_id:
+ type: string
+ description: uuid of a subnet on the fixed network to use for creating ports
+
+ demo_subnet_id:
+ type: string
+ description: uuid of a subnet on the fixed network to use for creating ports
+
+ image_flavor:
+ type: string
+ description: Number of VMs to launch
+
+resources:
+ steak_node:
+ type: "OS::Nova::Server"
+ properties:
+ key_name: mykey
+ image: cirros
+ flavor:
+ get_param: image_flavor
+ networks:
+ - port:
+ get_resource: steak_node_eth0
+
+ steak_node_eth0:
+ type: "OS::Neutron::Port"
+ properties:
+ network_id:
+ get_param: demo_net_id
+ fixed_ips:
+ - subnet_id:
+ get_param: demo_subnet_id
+
+ steak_node_floating:
+ type: "OS::Neutron::FloatingIP"
+ properties:
+ floating_network_id:
+ get_param: public_net_id
+ port_id:
+ get_resource: steak_node_eth0
+
+outputs:
+ eth0:
+ value: {get_attr: [steak_node_eth0, fixed_ips, 0, ip_address]}
+
+ float:
+ value: {get_attr: [steak_node_floating, floating_ip_address]}
diff --git a/contrib/demos/magnum/redis b/contrib/demos/magnum/redis
new file mode 100755
index 000000000..cf8c61463
--- /dev/null
+++ b/contrib/demos/magnum/redis
@@ -0,0 +1,5 @@
+magnum pod-create --manifest redis-kube/redis-master.yaml --bay testbay
+magnum service-create --manifest redis-kube/redis-sentinel-service.yaml --bay testbay
+magnum rc-create --manifest redis-kube/redis-controller.yaml --bay testbay
+magnum rc-create --manifest redis-kube/redis-sentinel-controller.yaml --bay testbay
+
diff --git a/contrib/demos/magnum/redis-kube/README.rst b/contrib/demos/magnum/redis-kube/README.rst
new file mode 100644
index 000000000..0a0ede6ab
--- /dev/null
+++ b/contrib/demos/magnum/redis-kube/README.rst
@@ -0,0 +1,197 @@
+Reliable, Scalable Redis on Kubernetes
+--------------------------------------
+
+The following document describes the deployment of a reliable,
+multi-node Redis on Kubernetes. It deploys a master with replicated
+slaves, as well as replicated redis sentinels which are use for health
+checking and failover.
+
+Prerequisites
+~~~~~~~~~~~~~
+
+This example assumes that you have a Kubernetes cluster installed and
+running, and that you have installed the ``kubectl`` command line tool
+somewhere in your path. Please see the `getting
+started <https://github.com/GoogleCloudPlatform/kubernetes/tree/master/docs/getting-started-guides>`__
+for installation instructions for your platform.
+
+A note for the impatient
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+This is a somewhat long tutorial. If you want to jump straight to the
+"do it now" commands, please see the `tl; dr <#tl-dr>`__ at the end.
+
+Turning up an initial master/sentinel pod.
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+is a
+`*Pod* <https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/user-guide/pods.md>`__.
+A Pod is one or more containers that *must* be scheduled onto the same
+host. All containers in a pod share a network namespace, and may
+optionally share mounted volumes.
+
+We will used the shared network namespace to bootstrap our Redis
+cluster. In particular, the very first sentinel needs to know how to
+find the master (subsequent sentinels just ask the first sentinel).
+Because all containers in a Pod share a network namespace, the sentinel
+can simply look at ``$(hostname -i):6379``.
+
+Here is the config for the initial master and sentinel pod:
+`redis-master.yaml <redis-master.yaml>`__
+
+Create this master as follows:
+
+.. code:: sh
+
+ kubectl create -f examples/redis/v1beta3/redis-master.yaml
+
+Turning up a sentinel service
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+In Kubernetes a *Service* describes a set of Pods that perform the same
+task. For example, the set of nodes in a Cassandra cluster, or even the
+single node we created above. An important use for a Service is to
+create a load balancer which distributes traffic across members of the
+set. But a *Service* can also be used as a standing query which makes a
+dynamically changing set of Pods (or the single Pod we've already
+created) available via the Kubernetes API.
+
+In Redis, we will use a Kubernetes Service to provide a discoverable
+endpoints for the Redis sentinels in the cluster. From the sentinels
+Redis clients can find the master, and then the slaves and other
+relevant info for the cluster. This enables new members to join the
+cluster when failures occur.
+
+Here is the definition of the sentinel
+service:\ `redis-sentinel-service.yaml <redis-sentinel-service.yaml>`__
+
+Create this service:
+
+.. code:: sh
+
+ kubectl create -f examples/redis/v1beta3/redis-sentinel-service.yaml
+
+Turning up replicated redis servers
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+So far, what we have done is pretty manual, and not very fault-tolerant.
+If the ``redis-master`` pod that we previously created is destroyed for
+some reason (e.g. a machine dying) our Redis service goes away with it.
+
+In Kubernetes a *Replication Controller* is responsible for replicating
+sets of identical pods. Like a *Service* it has a selector query which
+identifies the members of it's set. Unlike a *Service* it also has a
+desired number of replicas, and it will create or delete *Pods* to
+ensure that the number of *Pods* matches up with it's desired state.
+
+Replication Controllers will "adopt" existing pods that match their
+selector query, so let's create a Replication Controller with a single
+replica to adopt our existing Redis server.
+`redis-controller.yaml <redis-controller.yaml>`__
+
+The bulk of this controller config is actually identical to the
+redis-master pod definition above. It forms the template or "cookie
+cutter" that defines what it means to be a member of this set.
+
+Create this controller:
+
+.. code:: sh
+
+ kubectl create -f examples/redis/v1beta3/redis-controller.yaml
+
+We'll do the same thing for the sentinel. Here is the controller
+config:\ `redis-sentinel-controller.yaml <redis-sentinel-controller.yaml>`__
+
+We create it as follows:
+
+.. code:: sh
+
+ kubectl create -f examples/redis/v1beta3/redis-sentinel-controller.yaml
+
+Resize our replicated pods
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Initially creating those pods didn't actually do anything, since we only
+asked for one sentinel and one redis server, and they already existed,
+nothing changed. Now we will add more replicas:
+
+.. code:: sh
+
+ kubectl resize rc redis --replicas=3
+
+.. code:: sh
+
+ kubectl resize rc redis-sentinel --replicas=3
+
+This will create two additional replicas of the redis server and two
+additional replicas of the redis sentinel.
+
+Unlike our original redis-master pod, these pods exist independently,
+and they use the ``redis-sentinel-service`` that we defined above to
+discover and join the cluster.
+
+Delete our manual pod
+~~~~~~~~~~~~~~~~~~~~~
+
+The final step in the cluster turn up is to delete the original
+redis-master pod that we created manually. While it was useful for
+bootstrapping discovery in the cluster, we really don't want the
+lifespan of our sentinel to be tied to the lifespan of one of our redis
+servers, and now that we have a successful, replicated redis sentinel
+service up and running, the binding is unnecessary.
+
+Delete the master as follows:
+
+.. code:: sh
+
+ kubectl delete pods redis-master
+
+Now let's take a close look at what happens after this pod is deleted.
+There are three things that happen:
+
+1. The redis replication controller notices that its desired state is 3
+ replicas, but there are currently only 2 replicas, and so it creates
+ a new redis server to bring the replica count back up to 3
+2. The redis-sentinel replication controller likewise notices the
+ missing sentinel, and also creates a new sentinel.
+3. The redis sentinels themselves, realize that the master has
+ disappeared from the cluster, and begin the election procedure for
+ selecting a new master. They perform this election and selection, and
+ chose one of the existing redis server replicas to be the new master.
+
+Conclusion
+~~~~~~~~~~
+
+At this point we now have a reliable, scalable Redis installation. By
+resizing the replication controller for redis servers, we can increase
+or decrease the number of read-slaves in our cluster. Likewise, if
+failures occur, the redis-sentinels will perform master election and
+select a new master.
+
+tl; dr
+~~~~~~
+
+For those of you who are impatient, here is the summary of commands we
+ran in this tutorial
+
+.. code:: sh
+
+ # Create a bootstrap master
+ kubectl create -f examples/redis/v1beta3/redis-master.yaml
+
+ # Create a service to track the sentinels
+ kubectl create -f examples/redis/v1beta3/redis-sentinel-service.yaml
+
+ # Create a replication controller for redis servers
+ kubectl create -f examples/redis/v1beta3/redis-controller.yaml
+
+ # Create a replication controller for redis sentinels
+ kubectl create -f examples/redis/v1beta3/redis-sentinel-controller.yaml
+
+ # Resize both replication controllers
+ kubectl resize rc redis --replicas=3
+ kubectl resize rc redis-sentinel --replicas=3
+
+ # Delete the original master pod
+ kubectl delete pods redis-master
+
diff --git a/contrib/demos/magnum/redis-kube/redis-controller.yaml b/contrib/demos/magnum/redis-kube/redis-controller.yaml
new file mode 100644
index 000000000..4eaf61eae
--- /dev/null
+++ b/contrib/demos/magnum/redis-kube/redis-controller.yaml
@@ -0,0 +1,28 @@
+apiVersion: v1beta3
+kind: ReplicationController
+metadata:
+ name: redis
+spec:
+ replicas: 2
+ selector:
+ name: redis
+ template:
+ metadata:
+ labels:
+ name: redis
+ spec:
+ containers:
+ - name: redis
+ image: kubernetes/redis:v1
+ ports:
+ - containerPort: 6379
+ resources:
+ limits:
+ cpu: "1"
+ volumeMounts:
+ - mountPath: /redis-master-data
+ name: data
+ volumes:
+ - name: data
+ emptyDir: {}
+
diff --git a/contrib/demos/magnum/redis-kube/redis-master.yaml b/contrib/demos/magnum/redis-kube/redis-master.yaml
new file mode 100644
index 000000000..02abada97
--- /dev/null
+++ b/contrib/demos/magnum/redis-kube/redis-master.yaml
@@ -0,0 +1,33 @@
+apiVersion: v1beta3
+kind: Pod
+metadata:
+ labels:
+ name: redis
+ redis-sentinel: "true"
+ role: master
+ name: redis-master
+spec:
+ containers:
+ - name: master
+ image: kubernetes/redis:v1
+ env:
+ - name: MASTER
+ value: "true"
+ ports:
+ - containerPort: 6379
+ resources:
+ limits:
+ cpu: "1"
+ volumeMounts:
+ - mountPath: /redis-master-data
+ name: data
+ - name: sentinel
+ image: kubernetes/redis:v1
+ env:
+ - name: SENTINEL
+ value: "true"
+ ports:
+ - containerPort: 26379
+ volumes:
+ - name: data
+ emptyDir: {}
diff --git a/contrib/demos/magnum/redis-kube/redis-proxy.yaml b/contrib/demos/magnum/redis-kube/redis-proxy.yaml
new file mode 100644
index 000000000..2993a45bf
--- /dev/null
+++ b/contrib/demos/magnum/redis-kube/redis-proxy.yaml
@@ -0,0 +1,14 @@
+apiVersion: v1beta3
+kind: Pod
+metadata:
+ labels:
+ name: redis-proxy
+ role: proxy
+ name: redis-proxy
+spec:
+ containers:
+ - name: proxy
+ image: kubernetes/redis-proxy:v1
+ ports:
+ - containerPort: 6379
+ name: api
diff --git a/contrib/demos/magnum/redis-kube/redis-sentinel-controller.yaml b/contrib/demos/magnum/redis-kube/redis-sentinel-controller.yaml
new file mode 100644
index 000000000..157b09e8a
--- /dev/null
+++ b/contrib/demos/magnum/redis-kube/redis-sentinel-controller.yaml
@@ -0,0 +1,23 @@
+apiVersion: v1beta3
+kind: ReplicationController
+metadata:
+ name: redis-sentinel
+spec:
+ replicas: 2
+ selector:
+ redis-sentinel: "true"
+ template:
+ metadata:
+ labels:
+ name: redis-sentinel
+ redis-sentinel: "true"
+ role: sentinel
+ spec:
+ containers:
+ - name: sentinel
+ image: kubernetes/redis:v1
+ env:
+ - name: SENTINEL
+ value: "true"
+ ports:
+ - containerPort: 26379
diff --git a/contrib/demos/magnum/redis-kube/redis-sentinel-service.yaml b/contrib/demos/magnum/redis-kube/redis-sentinel-service.yaml
new file mode 100644
index 000000000..7078d182f
--- /dev/null
+++ b/contrib/demos/magnum/redis-kube/redis-sentinel-service.yaml
@@ -0,0 +1,13 @@
+apiVersion: v1beta3
+kind: Service
+metadata:
+ labels:
+ name: sentinel
+ role: service
+ name: redis-sentinel
+spec:
+ ports:
+ - port: 26379
+ targetPort: 26379
+ selector:
+ redis-sentinel: "true"
diff --git a/contrib/demos/magnum/start b/contrib/demos/magnum/start
new file mode 100755
index 000000000..3a3cd29a6
--- /dev/null
+++ b/contrib/demos/magnum/start
@@ -0,0 +1,40 @@
+#!/bin/bash
+
+NETWORK_MANAGER=$(grep -sri NETWORK_MANAGER ../../compose/openstack.env | cut -f2 -d "=")
+if [ "$NETWORK_MANAGER" != "neutron" ]; then
+ echo 'Magnum depends on the Neutron network manager to operate.'
+ echo 'Exiting because the network manager is' "$NETWORK_MANAGER".
+ exit 1
+fi
+
+echo Downloading glance image.
+IMAGE_URL=https://fedorapeople.org/groups/magnum
+IMAGE=fedora-21-atomic-3.qcow2
+if ! [ -f "$IMAGE" ]; then
+ curl -L -o ./$IMAGE $IMAGE_URL/$IMAGE
+fi
+
+NIC_ID=$(neutron net-show public1 | awk '/ id /{print $4}')
+
+glance image-delete fedora-21-atomic-3 2> /dev/null
+
+echo Loading fedora-atomic image into glance
+glance image-create --name fedora-21-atomic-3 --progress --is-public true --disk-format qcow2 --container-format bare --file ./$IMAGE
+GLANCE_IMAGE_ID=$(glance image-show fedora-21-atomic-3 | grep id | awk '{print $4}')
+
+echo registering os-distro property with image
+glance image-update $GLANCE_IMAGE_ID --property os_distro=fedora-atomic
+
+echo Creating baymodel
+magnum baymodel-create \
+ --name testbaymodel \
+ --image-id $GLANCE_IMAGE_ID \
+ --keypair-id mykey \
+ --fixed-network 10.0.3.0/24 \
+ --external-network-id $NIC_ID \
+ --dns-nameserver 8.8.8.8 --flavor-id m1.small \
+ --docker-volume-size 5 --coe kubernetes
+
+echo Creating Bay
+magnum bay-create --name testbay --baymodel testbaymodel --node-count 2
+
diff --git a/contrib/demos/magnum/stop b/contrib/demos/magnum/stop
new file mode 100755
index 000000000..67da543e0
--- /dev/null
+++ b/contrib/demos/magnum/stop
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+magnum bay-delete testbay
+while magnum bay-list | grep -q testbay; do
+ sleep 1
+done
+magnum baymodel-delete testbaymodel
+