5 Deploying Kubernetes #
By combining OpenStack, Docker, Kubernetes, and Flannel, you get a containers solution which works like other OpenStack services. With Magnum, Docker and Kubernetes are made available as first class resources in OpenStack.
5.1 Deploying a Kubernetes Cluster from Command Line #
A cluster (formerly bay
) is the construct in which
Magnum launches container orchestration engines.
The
python-openstackclient
is installed. After you have sourced an OpenStack RC file, use the command line client to upload images from a machine outside of the cloud.To run the
python-openstackclient
: An OpenStack RC file containing the credentials for the OpenStack project to which you want to upload the images.The
python-magnumclient
is installed.Install the openstack-magnum-k8s-image-x86_64 package. This package provides a virtual machine image with Kubernetes pre-installed,
openstack-magnum-k8s-image.x86_64.qcow2
. OpenStack Magnum uses this image when creating clusters with itsk8s_opensuse_v1
driver.
In a shell, source the OpenStack RC file for the project that you want to upload an image to. For details, refer to http://docs.openstack.org/user-guide/common/cli_set_environment_variables_using_openstack_rc.html.
List the Magnum image uploaded to glance using the
openstack image list | grep openstack-magnum-k8s-image
. If no image found, you can create an image for cluster setup as shown below:openstack image create openstack-magnum-k8s-image \ --public --disk-format qcow2 \ --property os_distro='opensuse' \ --container-format bare \ --file /srv/tftpboot/files/openstack-magnum-k8s-image/openstack-magnum-k8s-image.x86_64.qcow2
Create a Magnum flavor. For example:
openstack flavor create --public m1.magnum --id 9 --ram 1024 \ --disk 10 --vcpus 1
If you do not have enough resources and RAM on your compute nodes for a flavor of this size, create a smaller flavor instead.
Create a cluster template for Kubernetes. For example:
magnum cluster-template-create --name k8s_template \ --image-id openstack-magnum-k8s-image \ --keypair-id default \ --external-network-id floating \ --dns-nameserver 8.8.8.8 \ --flavor-id m1.magnum \ --master-flavor-id m1.magnum \ --docker-volume-size 5 \ --network-driver flannel \ --coe kubernetes \ --master-lb-enabled
Create a Kubernetes cluster using the cluster template you have created in the step above. For example:
magnum cluster-create --name k8s_cluster --cluster-template k8s_template \ --master-count 1 --node-count 2
The resulting cluster will have one master Kubernetes node and two minion nodes.
5.2 Deploying a Kubernetes Cluster from the Dashboard #
Alternatively, you can deploy a Kubernetes cluster in the SUSE OpenStack Cloud Dashboard by creating a cluster template and creating a Kubernetes cluster afterward.
You have created an image for cluster setup as described in Section 5.1, Step 2.
You have created a Magnum flavor as described in Section 5.1, Step 3.
Log in to SUSE OpenStack Cloud Dashboard and select a project from the drop-down box at the top-level row.
Click
› › .The
dialog opens, showing the following sections: , , , and .In the
section:Enter a name for the cluster template to create.
As
, chooseKubernetes
.If wanted, activate the following options:
OpenStack.
: The cluster template will be visible for all users in
In the
section:Choose the Section 5.1, Step 2.
you have created inChoose a
.Choose the Section 5.1, Step 3. It will be used for the minion nodes.
you have created inChoose the same flavor as
. It will be used for the master node.As
, choosecinder
.As
, chooseDevice Mapper
.Specify the
. For example:5
In the
section:As
, chooseFlannel
.Leave the
, , and boxes empty or enter the respective addresses to use.As
, enterfloating
. The networkfloating
will be used to connect to the cluster template you are creating.Leave the
and boxes empty.Enter the
server to use for this cluster template. For example:8.8.8.8.
To deploy the cluster with a load balancer service in front for the cluster services, activate
.To assign floating IP addresses to the nodes in the cluster, activate
.
Confirm your changes to create the cluster template.
Based on the cluster template you have created in Procedure 5.1, “Creating a Cluster Template in SUSE OpenStack Cloud Dashboard”, you can now create a Kubernetes cluster.
Log in to SUSE OpenStack Cloud Dashboard and select a project from the drop-down box at the top-level row.
Click
› › .The
dialog opens, showing the following sections: , , and .In the
section:Enter a
.From the Procedure 5.1, “Creating a Cluster Template in SUSE OpenStack Cloud Dashboard”.
list, select the template you have created in
In the
section, enter the number of master nodes and minion nodes you want the cluster to have. For example:1
and2
.In the
section, you can optionally specify a custom URL for node discovery and a for cluster creation, if wanted. The default is no timeout.Confirm your changes to create the cluster.
5.3 Deploying a Kubernetes Cluster Without Internet Access #
In specific scenarios, you may need to deploy a Kubernetes cluster without access to Internet. For those cases, you need to set up a custom Insecure Docker Registry and use no discovery URL. You can do this either from command line (as described below) or from the SUSE OpenStack Cloud Dashboard.
In a shell, source the OpenStack RC file for the project that you want to upload an image to. For details, refer to http://docs.openstack.org/user-guide/common/cli_set_environment_variables_using_openstack_rc.html.
Create a cluster template as shown in , Step 4, but add the options
--registry-enabled
and--labels
. Theregistry_url
must include the protocol, e.g. http://URL. For example:magnum cluster-template-create --name k8s_template_reg_enabled \ [...] --registry-enabled --labels registry_url=http://192.168.255.10/srv/files
Create a cluster as shown in , Step 5, but with static IP configuration and setting the option
--discovery-url
tonone
. For example:magnum cluster-create --name k8s_cluster_without \ --cluster-template k8s_template_reg_enabled \ [...] --discovery-url none