Skip to content

Instantly share code, notes, and snippets.

@yuanying
Last active August 29, 2015 14:11
Show Gist options
  • Save yuanying/a2eda47eab70726d15d4 to your computer and use it in GitHub Desktop.
Save yuanying/a2eda47eab70726d15d4 to your computer and use it in GitHub Desktop.
Testing Magnum-Heat

devstack

git checkout -b stable/juno origin/stable/juno
mysql -h 127.0.0.1 -u root -pstackdb mysql <<EOF
CREATE DATABASE IF NOT EXISTS magnum DEFAULT CHARACTER SET utf8;
GRANT ALL PRIVILEGES ON magnum.* TO
    'root'@'%' IDENTIFIED BY 'stackdb'
EOF

Install larsks/heat-kubernetes

mkdir -p /etc/magnum/templates
cd /etc/magnum/templates
git clone https://github.com/larsks/heat-kubernetes.git

Create image

cd /etc/magnum/templates/heat-kubernetes
./get-image.sh
source /vagrant/devstack/openrc admin admin
glance image-create \
    --disk-format qcow2 \
    --container-format bare \
    --is-public True \
    --name fedora-20-x86_64 \
    --file /etc/magnum/templates/heat-kubernetes/fedora-20-k8s.qcow2

Add magnum service

keystone service-create --name=container \
                        --type=container \
                        --description="Magnum Container Service"
keystone endpoint-create --service=container \
                         --publicurl=http://127.0.0.1:9511/v1 \
                         --internalurl=http://127.0.0.1:9511/v1 \
                         --adminurl=http://127.0.0.1:9511/v1

Add key-pair

source /vagrant/devstack/openrc demo demo
nova keypair-add --pub-key ~/.ssh/id_rsa.pub default

Add magnum baymodel

magnum baymodel-create --name default \
                       --keypair_id default \
                       --external_network_id 2776dd80-1c4b-4457-b646-e2efa7f2721b

magnum bay-create --name k8s \
                  --baymodel_id feea7e8e-5383-4964-8a48-ba76a9e01980

parameters: ssh_key_name: default external_network_id: 2776dd80-1c4b-4457-b646-e2efa7f2721b

Create image

git clone https://github.com/openstack/dib-utils.git
cd dib-utils
./setup.py build && sudo ./setup.py install
cd ..
git clone https://github.com/openstack/diskimage-builder.git
cd diskimage-builder
export PATH=/home/yuanying/diskimage-builder/bin/:$PATH
disk-image-create -a amd64 fedora baremetal -o fedora-image.qcow2

Customize Image

TARGET=fedora-image.qcow2
PACKAGES="jq,dnf,bridge-utils,docker-io,git\
,python-netifaces,python-requests,tcpdump,python-setuptools"
virt-customize \
    --add $TARGET \
    --install dnf,dnf-plugins-core \
    --run-command "dnf -y copr enable walters/atomic-next" \
    --run-command "dnf -y copr enable larsks/fakedocker" \
    --update \
    --install $PACKAGES \
    --install kubernetes \
    --run-command "yum clean all" \
    --root-password password:password
virt-customize --add $IMAGE --selinux-relabel --no-network

Upload image

source /vagrant/devstack/openrc admin admin
glance image-create --name "fedora-20-kernel" \
  --disk-format aki --container-format aki --is-public True \
  --file fedora-image.vmlinuz
glance image-create --name "fedora-20-ramdisk" \
  --disk-format ari --container-format ari --is-public True \
  --file fedora-image.initrd
KID=f740b639-7d14-4696-81d5-fcb38c45b3a7
RID=bd37854f-9437-447b-b148-490f55759924
glance image-create --name "fedora-20-k8s" --disk-format qcow2 \
  --container-format bare --is-public True \
  --property kernel_id=$KID --property ramdisk_id=$RID \
  --file fedora-image.qcow2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment