2. Agenda
What is Magnum
Terminology
Why Magnum
Magnum Overview and Architecture
Supported COEs and OSes combinations
Setup Magnum with Devstack
Magnum Demo
2
3. What is Magnum
• Magnum is an OpenStack API service developed by the OpenStack
Containers Team making container orchestration engines such as
Docker Swarm, Kubernetes, and Apache Mesos available as first class
resources in OpenStack (from openstack wiki)
3
4. Terminology
• COE: Container Orchestration Engine to manage containers.
Examples: Kubernetes, Docker Swarm, Apache Mesos
• Cluster/Bay: A construct in which Magnum launches COE.
Cluster
COE
Nova
Instance
Nova
Instance
Nova
Instance
4
5. Terminology
• ClusterTemplate/BayModel: Template for creating clusters.
Includes image, COE.
• Native Client: Use native clients at COE level or at container
level to interact with clusters. Ex: kubectl, docker.
ClusterTemplate
Cluster ClusterCluster
5
6. Why Magnum
• Multi-tenancy for containers
• Reusing OpenStack Components like Keystone, Heat, Glance,
Neutron
• Multiple COEs side by side
• Server Type: VM, Bare Metal
6
14. Setup Devstack including Magnum
• Configure devstack by enabling magnum:
• Clone devstack:
• # Create a root directory for devstack if needed
• sudo mkdir -p /opt/stack
• sudo chown $USER /opt/stack
• # clone
• git clone https://git.openstack.org/openstack-dev/devstack /opt/stack/devstack
• Configure to enable enable magnum, heat, and neutron
• Configure to enable ceilometer, swift if required
14
15. Setup Devstack including Magnum
• Configure to enable enable magnum, heat, and neutron in /opt/stack/devstack/local.conf :
• [[local|localrc]]
• DATABASE_PASSWORD=password
• RABBIT_PASSWORD=password
• SERVICE_TOKEN=password
• SERVICE_PASSWORD=password
• ADMIN_PASSWORD=password
• # magnum requires the following to be set correctly
• PUBLIC_INTERFACE=eth1
• # Enable barbican service and use it to store TLS certificates
• # For details http://docs.openstack.org/developer/magnum/dev/tls.html
• enable_plugin barbican https://git.openstack.org/openstack/barbican
• enable_plugin heat https://git.openstack.org/openstack/heat
• enable_plugin neutron-lbaas https://git.openstack.org/openstack/neutron-lbaas
• enable_plugin octavia https://git.openstack.org/openstack/octavia
• # Enable magnum plugin after dependent plugins
• enable_plugin magnum https://git.openstack.org/openstack/magnum
• # Optional: uncomment to enable the Magnum UI plugin in Horizon
• #enable_plugin magnum-ui https://github.com/openstack/magnum-ui
• # Disable LBaaS(v1) service
• disable_service q-lbaas
• # Enable LBaaS(v2) services
• enable_service q-lbaasv2
• enable_service octavia
• enable_service o-cw
• enable_service o-hk
• enable_service o-hm
• enable_service o-api
• VOLUME_BACKING_FILE_SIZE=20G 15
16. Setup Devstack including Magnum
• Run devstack:
• cd /opt/stack/devstack
• ./stack.sh
• magnum-api and magnum-conductor processes would come up
• Prepare for openstack clients:
• source /opt/stack/devstack/openrc admin admin
• Commands to start with:
• magnum help
• magnum service-list
• Create a keypair for use with the ClusterTemplate:
• test -f ~/.ssh/id_rsa.pub || ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
• nova keypair-add --pub-key ~/.ssh/id_rsa.pub testkey
16
17. Building and Using a Mesos Cluster
• Download Ubuntu image which includes mesos related packages and add to glance
• wget https://fedorapeople.org/groups/magnum/ubuntu-mesos-latest.qcow2
• glance image-create --name ubuntu-mesos --visibility public
--disk-format=qcow2 --container-format=bare
--os-distro=ubuntu --file=ubuntu-mesos-latest.qcow2
• Create a ClusterTemplate
• magnum cluster-template-create --name mesos-cluster-template --image-id ubuntu-mesos
--keypair-id testkey
--external-network-id public
--dns-nameserver 8.8.8.8
--flavor-id m1.small
--coe mesos
• Create Cluster
• magnum cluster-create --name mesos-cluster
--cluster-template mesos-cluster-template
--node-count 1
17
18. Building and Using a Mesos Cluster
• Make sure that the cluster status is CREATE_COMPLETE
18
19. Building and Using a Mesos Cluster
• Create Container through marathon REST API
$ cat > mesos.json << END
{
"container": {
"type": "DOCKER",
"docker": {
"image": "cirros"
}
},
"id": "ubuntu",
"instances": 1,
"cpus": 0.5,
"mem": 512,
"uris": [],
"cmd": "ping 8.8.8.8"
}
END
$ MASTER_IP=$(magnum cluster-show mesos-cluster | awk '/ api_address /{print $4}')
$ curl -X POST -H "Content-Type: application/json"
http://${MASTER_IP}:8080/v2/apps -d@mesos.json 19
20. Accessing Mesos Cluster
• Check application and task status:
$ curl http://${MASTER_IP}:8080/v2/apps
$ curl http://${MASTER_IP}:8080/v2/tasks
• Mesos web page at http://<master>:5050/
• Marathon web console at http://<master>:8080/
20
24. Multi-node Setup of OpenStack using OpenStack-Ansible
• On all nodes,
• Install prerequisite packages:
apt-get -y install bridge-utils debootstrap ifenslave ifenslave-2.6 lsof lvm2 ntp ntpdate
openssh-server sudo tcpdump vlan aptitude build-essential git ntp ntpdate openssh-server
python-dev
• Configure networking
• On the deployer node,
• git clone https://github.com/openstack/openstack-ansible.git /opt/openstack-ansible
• scripts/bootstrap-ansible.sh
• Configure things in /etc/openstack_deploy/*.yml and /etc/openstack_deploy/*/*.yml
• Make sure to configure magnum-infra_hosts in
/etc/openstack_deploy/conf.d/magnum.yml
• Run setup-hosts.yml
• Run setup-infrastructure.yml
• Run setup-openstack.yml to complete the deployment of OpenStack
24