Jump to contentJump to page navigation: previous page [access key p]/next page [access key n]
documentation.suse.com / Documentation / Supplement to Administrator Guide and User Guide / Deploying Kubernetes
Applies to SUSE OpenStack Cloud 9

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.

Requirements
  • 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 its k8s_opensuse_v1 driver.

  1. 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.

  2. 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
  3. 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.

  4. 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
  5. 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.

Requirements
Procedure 5.1: Creating a Cluster Template in SUSE OpenStack Cloud Dashboard
  1. Log in to SUSE OpenStack Cloud Dashboard and select a project from the drop-down box at the top-level row.

  2. Click Container Infra › Cluster Templates › Create Cluster Template.

    The Create Cluster Template dialog opens, showing the following sections: Info, Node Spec, Network, and Labels.

  3. In the Info section:

    1. Enter a name for the cluster template to create.

    2. As Container Orchestration Engine, choose Kubernetes.

    3. If wanted, activate the following options:

      • Public: The cluster template will be visible for all users in OpenStack.

      • Enable Registry: The cluster can be built with Insecure Docker Registry service.

      • Disable TLS: Switch off the SSL protocol for the cluster.

  4. In the Node Spec section:

    1. Choose the Image you have created in Section 5.1, Step 2.

    2. Choose a Keypair.

    3. Choose the Flavor you have created in Section 5.1, Step 3. It will be used for the minion nodes.

    4. Choose the same flavor as Master Flavor. It will be used for the master node.

    5. As Volume Driver, choose cinder.

    6. As Docker Storage Driver, choose Device Mapper.

    7. Specify the Docker Volume Size (GB). For example: 5

  5. In the Network section:

    1. As Network Driver, choose Flannel.

    2. Leave the HTTP Proxy, HTTPS Proxy, and No Proxy boxes empty or enter the respective addresses to use.

    3. As External Network ID, enter floating. The network floating will be used to connect to the cluster template you are creating.

    4. Leave the Fixed Network and Fixed Subnet boxes empty.

    5. Enter the DNS server to use for this cluster template. For example: 8.8.8.8.

    6. To deploy the cluster with a load balancer service in front for the cluster services, activate Master LB.

    7. To assign floating IP addresses to the nodes in the cluster, activate Floating IP.

  6. Confirm your changes to create the cluster template.

Procedure 5.2: Creating a Cluster in SUSE OpenStack Cloud Dashboard

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.

  1. Log in to SUSE OpenStack Cloud Dashboard and select a project from the drop-down box at the top-level row.

  2. Click Container Infra › Clusters › Create Cluster.

    The Create Cluster dialog opens, showing the following sections: Info, Size, and Misc.

  3. In the Info section:

    1. Enter a Cluster Name.

    2. From the Cluster Template list, select the template you have created in Procedure 5.1, “Creating a Cluster Template in SUSE OpenStack Cloud Dashboard”.

  4. In the Size section, enter the number of master nodes and minion nodes you want the cluster to have. For example: 1 and 2.

  5. In the Misc section, you can optionally specify a custom URL for node discovery and a Timeout for cluster creation, if wanted. The default is no timeout.

  6. 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.

  1. 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.

  2. Create a cluster template as shown in , Step 4, but add the options --registry-enabled and --labels. The registry_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
  3. Create a cluster as shown in , Step 5, but with static IP configuration and setting the option --discovery-url to none. For example:

    magnum cluster-create --name k8s_cluster_without \
      --cluster-template k8s_template_reg_enabled \
      [...]
      --discovery-url none