OpenStack: Magnum

openstack coe service list
openstack stack list
openstack stack show d8a1c3af-7993-4493-91be-19cfce38a870
openstack coe cluster update k8s-cluster replace node_count=2

Configure deployment kolla-ansible
# cat /etc/kolla/config/magnum.conf
[cinder]
default_docker_volume_type = VT1

[trust]
cluster_user_trust = True

/etc/kolla/config/heat.conf
[DEFAULT]
#region_name = ch-zh1
region_name_for_services = RegionOne

# /etc/kolla/globals.yml
# magnum_tag: "7.0.0.1"
enable_magnum: "yes"

Redeploy / Reconfigure container
kolla-ansible -i /etc/kolla/inventory-hosts deploy -t magnum

Deploy kubernetes cluster
# Get Fedora AtomicHost image
wget https://download.fedoraproject.org/pub/alt/atomic/stable/Fedora-29-updates-20190429.0/AtomicHost/x86_64/images/Fedora-AtomicHost-29-20190429.0.x86_64.raw.xz
xz -d Fedora-AtomicHost-29-20190429.0.x86_64.raw.xz

openstack image create "Fedora AtomicHost 29" \
--file Fedora-AtomicHost-29-20190429.0.x86_64.raw \
--disk-format raw \
--container-format=bare \
--min-disk 10 \
--min-ram 4096 \
--public \
--protected \
--property hw_scsi_model=virtio-scsi \
--property hw_disk_bus=scsi \
--property hw_qemu_guest_agent=yes \
--property os_distro=fedora-atomic \
--property os_admin_user=fedora \
--property os_version="20190429.0"

openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey

openstack flavor create m1.kubernetes \
--disk 40 \
--vcpu 2 \
--ram 4096 \
--public \
--description "kubernetes flavor"

openstack coe cluster template create kubernetes-cluster-template \
--image "Fedora AtomicHost 29" \
--external-network public \
--dns-nameserver 8.8.8.8 \
--master-flavor m1.kubernetes \
--flavor m1.kubernetes \
--coe kubernetes \
--volume-driver cinder \
--network-driver flannel \
--docker-volume-size 40

# --docker-storage-driver overlay
# --tls-disabled
# --floating-ip-disabled

openstack coe cluster create kubernetes-cluster \
--cluster-template kubernetes-cluster-template \
--master-count 1 \
--node-count 2 \
--keypair mykey

Get cluster configurations
cd ~/2.7.15
for CLUSTER in $(openstack coe cluster list -c name -f value); do
mkdir -p ~/kubernetes/${CLUSTER}
openstack coe cluster config ${CLUSTER} --dir ~/kubernetes/${CLUSTER} --force

# export latest cluster config as default
export KUBECONFIG=~/kubernetes/${CLUSTER}/config
done
#--use-keystone

# Configure persistent default cluster
echo "export KUBECONFIG=~/kubernetes/kubernetes-cluster1/config" >> ~/.bashrc

# optional: Route to dev public net trougth rally VM
sshuttle --remote rally.dev.i.ewcs.ch 10.0.11.0/24

Fix taints
kubectl describe nodes | grep Taints
kubectl taint nodes --all node.cloudprovider.kubernetes.io/uninitialized-

Repository
https://opendev.org/openstack/magnum/
https://opendev.org/openstack/magnum/commits/branch/stable/rocky - commits to rocky

# kolla-build.conf
[magnum-base]
type = git
location = https://git.openstack.org/openstack/magnum
reference = stable/stein

# build
cd ./kolla && python tools/build.py --config-file /root/kolla-build.conf --tag 7.0.1.1.foo magnum

Deploy Kubernetes UI
http://www.panticz.de/kubernetes-dashboard-ui

OpenStack Magnum / Kubernetes
openstackmagnum Docker registry: https://hub.docker.com/u/openstackmagnum
kubernetes version: https://docs.openstack.org/magnum/latest/user/#kube-tag (latest tag: https://hub.docker.com/r/openstackmagnum/kubernetes-kubelet/tags)

cloud-provider-openstack
Repository: https://github.com/kubernetes/cloud-provider-openstack
k8scloudprovider Docker registry: https://hub.docker.com/u/k8scloudprovider
cloud provider version: https://docs.openstack.org/magnum/latest/user/#cloud-provider-tag (latest tag: https://hub.docker.com/r/k8scloudprovider/openstack-cloud-controller-manager/tags/)

Get floating IP
openstack loadbalancer list
openstack loadbalancer show 301a787a-a0d4-4989-9d5a-e389330ff44e -c vip_address -f value
openstack floating ip list --fixed-ip-address 10.0.0.5 -c "Floating IP Address" -f value

Scale up
openstack loadbalancer pool list
openstack loadbalancer member list 922266b9-63b2-4e91-ae87-9a6f16525839
kubectl get nodes -o wide
openstack coe cluster update kubernetes-cluster1 replace node_count=4

Get cluster configuration
# specify OpenStack cloud
export OS_CLOUD=dev-foo

# Get all cluster configurations
for CLUSTER in $(openstack coe cluster list -c name -f value); do
mkdir -p ~/kubernetes/${CLUSTER}
openstack coe cluster config ${CLUSTER} --dir ~/kubernetes/${CLUSTER} --force
done

# Export cluster configuration as default
export KUBECONFIG=~/kubernetes/clusterX/config

# fix Failed to create trustee or trust for Cluster:
use unrestriced application credentials

# Define default Kubernetes cluster and load configuration on login
ln -fs ~/kubernetes/clusterX ~/kubernetes/cluster
echo "export KUBECONFIG=~/kubernetes/cluster/config" >> ~/.bashrc