Compare languages | Cloud provider — OpenStack: FAQ

How do I set up LoadBalancer?

Как настроить LoadBalancer?

Note! Load Balancer must support Proxy Protocol to determine the client IP correctly.

Внимание! Для корректного определения клиентского IP-адреса необходимо использовать LoadBalancer с поддержкой Proxy Protocol.

An example of IngressNginxController

Пример IngressNginxController

Below is a simple example of the `IngressNginxController’ configuration:

Ниже представлен простой пример конфигурации IngressNginxController:

yaml apiVersion: deckhouse.io/v1 kind: IngressNginxController metadata: name: main spec: ingressClass: nginx inlet: LoadBalancerWithProxyProtocol loadBalancerWithProxyProtocol: annotations: loadbalancer.openstack.org/proxy-protocol: “true” loadbalancer.openstack.org/timeout-member-connect: “2000” nodeSelector: node-role.deckhouse.io/frontend: “” tolerations:

  • effect: NoExecute key: dedicated.deckhouse.io operator: Equal value: frontend

yaml apiVersion: deckhouse.io/v1 kind: IngressNginxController metadata: name: main spec: ingressClass: nginx inlet: LoadBalancerWithProxyProtocol loadBalancerWithProxyProtocol: annotations: loadbalancer.openstack.org/proxy-protocol: “true” loadbalancer.openstack.org/timeout-member-connect: “2000” nodeSelector: node-role.deckhouse.io/frontend: “” tolerations:

  • effect: NoExecute key: dedicated.deckhouse.io operator: Equal value: frontend

How do I set up security policies on cluster nodes?

Как настроить политики безопасности на узлах кластера?

There may be many reasons why you may need to restrict or expand incoming/outgoing traffic on cluster VMs in OpenStack:

Вариантов, зачем может понадобиться ограничить или, наоборот, расширить входящий или исходящий трафик на виртуальных машинах кластера, может быть множество. Например:

  • Allow VMs on a different subnet to connect to cluster nodes.
  • Allow connecting to the ports of the static node so that the application can work.
  • Restrict access to external resources or other VMs in the cloud for security reasons.
  • Разрешить подключение к узлам кластера с виртуальных машин из другой подсети.
  • Разрешить подключение к портам статического узла для работы приложения.
  • Ограничить доступ к внешним ресурсам или другим ВМ в облаке по требованию службы безопасности.

For all this, additional security groups should be used. You can only use security groups that are created in the cloud tentatively.

Для всего этого следует применять дополнительные группы безопасности (security groups). Можно использовать только группы безопасности, предварительно созданные в облаке.

Enabling additional security groups on static and master nodes

Установка дополнительных групп безопасности (security groups) на статических и master-узлах

This parameter can be set either in an existing cluster or when creating one. In both cases, additional security groups are declared in the OpenStackClusterConfiguration:

Данный параметр можно задать либо при создании кластера, либо в уже существующем кластере. В обоих случаях дополнительные группы безопасности указываются в OpenStackClusterConfiguration:

  • for master nodes, in the additionalSecurityGroups of the masterNodeGroup section;
  • for static nodes, in the additionalSecurityGroups field of the nodeGroups subsection that corresponds to the target nodeGroup.
  • для master-узлов — в секции masterNodeGroup в поле additionalSecurityGroups;
  • для статических узлов — в секции nodeGroups в конфигурации, описывающей желаемую nodeGroup, а также в поле additionalSecurityGroups.

The additionalSecurityGroups field contains an array of strings with security group names.

Поле additionalSecurityGroups представляет собой массив строк с именами групп безопасности.

Enabling additional security groups on ephemeral nodes

Установка дополнительных групп безопасности (security groups) на ephemeral-узлах

You have to set the additionalSecurityGroups parameter for all OpenStackInstanceClasses in the cluster that require additional security groups. See the parameters of the cloud-provider-openstack module.

Необходимо прописать параметр additionalSecurityGroups для всех OpenStackInstanceClass в кластере, которым нужны дополнительные групп безопасности. Подробнее — параметры модуля cloud-provider-openstack.

How do I create a hybrid cluster?

Как поднять гибридный кластер?

A hybrid cluster combines bare metal and OpenStack nodes. To create such a cluster, you need an L2 network between all nodes of the cluster.

Гибридный кластер представляет собой кластер, в котором могут быть как узлы bare metal, так и узлы OpenStack. Для создания такого кластера необходимо наличие L2-сети между всеми узлами кластера.

To set up a hybrid cluster, follow these steps:

Чтобы поднять гибридный кластер, выполните следующие шаги:

  1. Delete flannel from kube-system: kubectl -n kube-system delete ds flannel-ds.
  2. Enable and configure the module.
  3. Create one or more OpenStackInstanceClass custom resources.
  4. Create one or more NodeManager custom resources for specifying the number of machines and managing the provisioning process in the cloud.
  1. Удалите flannel из kube-system: kubectl -n kube-system delete ds flannel-ds.
  2. Включите и настройте модуль.
  3. Создайте один или несколько custom resource OpenStackInstanceClass.
  4. Создайте один или несколько custom resource NodeManager для управления количеством и процессом заказа машин в облаке.

Caution! Cloud-controller-manager synchronizes OpenStack and Kubernetes states by deleting Kubernetes nodes that are not in OpenStack. In a hybrid cluster, such behavior does not always make sense. That is why cloud-controller-manager automatically skips Kubernetes nodes that do not have the --cloud-provider=external parameter (Deckhouse inserts static:// into nodes in .spec.providerID, and cloud-controller-manager ignores them).

Важно! Cloud-controller-manager синхронизирует состояние между OpenStack и Kubernetes, удаляя из Kubernetes те узлы, которых нет в OpenStack. В гибридном кластере такое поведение не всегда соответствует потребности, поэтому, если узел Kubernetes запущен не с параметром --cloud-provider=external, он автоматически игнорируется (Deckhouse прописывает static:// на узлы в .spec.providerID, а cloud-controller-manager такие узлы игнорирует).

Attaching storage devices to instances in a hybrid cluster

Подключение storage в гибридном кластере

To use PersistentVolumes on OpenStack nodes, you must create StorageClass with the appropriate OpenStack volume type. The openstack volume type list command lists all available types.

Если вам требуются PersistentVolumes на узлах, подключаемых к кластеру из OpenStack, необходимо создать StorageClass с нужным OpenStack volume type. Получить список типов можно с помощью команды openstack volume type list.

Here is the example config for the ceph-ssd volume type:

Например, для volume type ceph-ssd:

yaml apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: ceph-ssd provisioner: csi-cinderplugin # have to be like this parameters: type: ceph-ssd volumeBindingMode: WaitForFirstConsumer

yaml apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: ceph-ssd provisioner: csi-cinderplugin # Обязательно должно быть так. parameters: type: ceph-ssd volumeBindingMode: WaitForFirstConsumer

How do I create an image in OpenStack?

Как загрузить образ в OpenStack?

  1. Download the latest stable Ubuntu 18.04 image:
  1. Скачайте последний стабильный образ Ubuntu 18.04:

shell curl -L https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img –output ~/ubuntu-18-04-cloud-amd64

shell curl -L https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img –output ~/ubuntu-18-04-cloud-amd64

  1. Prepare an OpenStack RC (openrc) file containing credentials for accessing the OpenStack API:
  1. Подготовьте OpenStack openrc-файл, который содержит credentials для обращения к API OpenStack.

The interface for getting an openrc file may differ depending on the OpenStack provider. If the provider has a standard interface for OpenStack, you can download the openrc file using the following instruction.

Интерфейс получения openrc-файла может отличаться в зависимости от провайдера OpenStack. Если провайдер предоставляет стандартный интерфейс для OpenStack, скачать openrc-файл можно по инструкции.

  1. Otherwise, install the OpenStack client using this instruction.
  1. Либо установите OpenStack-клиента по инструкции.

Also, you can run the container and mount an openrc file and a downloaded Ubuntu image in it:

Также можно запустить контейнер, смонтировать в него openrc-файл и скачанный локально образ Ubuntu:

shell docker run -ti –rm -v ~/ubuntu-18-04-cloud-amd64:/ubuntu-18-04-cloud-amd64 -v ~/.openrc:/openrc jmcvea/openstack-client

shell docker run -ti –rm -v ~/ubuntu-18-04-cloud-amd64:/ubuntu-18-04-cloud-amd64 -v ~/.openrc:/openrc jmcvea/openstack-client

  1. Initialize the environment variables from the openrc file:
  1. Инициализируйте переменные окружения из openrc-файла:

shell source /openrc

shell source /openrc

  1. Get a list of available disk types:
  1. Получите список доступных типов дисков:

shell / # openstack volume type list +————————————–+—————+———–+ | ID | Name | Is Public | +————————————–+—————+———–+ | 8d39c9db-0293-48c0-8d44-015a2f6788ff | ko1-high-iops | True | | bf800b7c-9ae0-4cda-b9c5-fae283b3e9fd | dp1-high-iops | True | | 74101409-a462-4f03-872a-7de727a178b8 | ko1-ssd | True | | eadd8860-f5a4-45e1-ae27-8c58094257e0 | dp1-ssd | True | | 48372c05-c842-4f6e-89ca-09af3868b2c4 | ssd | True | | a75c3502-4de6-4876-a457-a6c4594c067a | ms1 | True | | ebf5922e-42af-4f97-8f23-716340290de2 | dp1 | True | | a6e853c1-78ad-4c18-93f9-2bba317a1d13 | ceph | True | +————————————–+—————+———–+

shell / # openstack volume type list +————————————–+—————+———–+ | ID | Name | Is Public | +————————————–+—————+———–+ | 8d39c9db-0293-48c0-8d44-015a2f6788ff | ko1-high-iops | True | | bf800b7c-9ae0-4cda-b9c5-fae283b3e9fd | dp1-high-iops | True | | 74101409-a462-4f03-872a-7de727a178b8 | ko1-ssd | True | | eadd8860-f5a4-45e1-ae27-8c58094257e0 | dp1-ssd | True | | 48372c05-c842-4f6e-89ca-09af3868b2c4 | ssd | True | | a75c3502-4de6-4876-a457-a6c4594c067a | ms1 | True | | ebf5922e-42af-4f97-8f23-716340290de2 | dp1 | True | | a6e853c1-78ad-4c18-93f9-2bba317a1d13 | ceph | True | +————————————–+—————+———–+

  1. Create an image, pass the disk format to use (if OpenStack does not support local disks or these disks don’t fit):
  1. Создайте образ и передайте в него в качестве свойств тип диска, который будет использоваться (если OpenStack не поддерживает локальные диски или если эти диски не подходят для работы):

shell openstack image create –private –disk-format qcow2 –container-format bare
–file /ubuntu-18-04-cloud-amd64 –property cinder_img_volume_type=dp1-high-iops ubuntu-18-04-cloud-amd64

shell openstack image create –private –disk-format qcow2 –container-format bare
–file /ubuntu-18-04-cloud-amd64 –property cinder_img_volume_type=dp1-high-iops ubuntu-18-04-cloud-amd64

  1. Check that the image was created successfully:
  1. Проверьте, что образ успешно создан:

text / # openstack image show ubuntu-18-04-cloud-amd64 +——————+——————————————————————————————————————————————————————————————————————————————————————————————-+ | Field | Value | +——————+——————————————————————————————————————————————————————————————————————————————————————————————-+ | checksum | 3443a1fd810f4af9593d56e0e144d07d | | container_format | bare | | created_at | 2020-01-10T07:23:48Z | | disk_format | qcow2 | | file | /v2/images/01998f40-57cc-4ce3-9642-c8654a6d14fc/file | | id | 01998f40-57cc-4ce3-9642-c8654a6d14fc | | min_disk | 0 | | min_ram | 0 | | name | ubuntu-18-04-cloud-amd64 | | owner | bbf506e3ece54e21b2acf1bf9db4f62c | | properties | cinder_img_volume_type=’dp1-high-iops’, direct_url=’rbd://b0e441fc-c317-4acf-a606-cf74683978d2/images/01998f40-57cc-4ce3-9642-c8654a6d14fc/snap’, locations=’[{u’url’: u’rbd://b0e441fc-c317-4acf-a606-cf74683978d2/images/01998f40-57cc-4ce3-9642-c8654a6d14fc/snap’, u’metadata’: {}}]’ | | protected | False | | schema | /v2/schemas/image | | size | 343277568 | | status | active | | tags | | | updated_at | 2020-05-01T17:18:34Z | | virtual_size | None | | visibility | private | +——————+——————————————————————————————————————————————————————————————————————————————————————————————-+

text / # openstack image show ubuntu-18-04-cloud-amd64 +——————+——————————————————————————————————————————————————————————————————————————————————————————————-+ | Field | Value | +——————+——————————————————————————————————————————————————————————————————————————————————————————————-+ | checksum | 3443a1fd810f4af9593d56e0e144d07d | | container_format | bare | | created_at | 2020-01-10T07:23:48Z | | disk_format | qcow2 | | file | /v2/images/01998f40-57cc-4ce3-9642-c8654a6d14fc/file | | id | 01998f40-57cc-4ce3-9642-c8654a6d14fc | | min_disk | 0 | | min_ram | 0 | | name | ubuntu-18-04-cloud-amd64 | | owner | bbf506e3ece54e21b2acf1bf9db4f62c | | properties | cinder_img_volume_type=’dp1-high-iops’, direct_url=’rbd://b0e441fc-c317-4acf-a606-cf74683978d2/images/01998f40-57cc-4ce3-9642-c8654a6d14fc/snap’, locations=’[{u’url’: u’rbd://b0e441fc-c317-4acf-a606-cf74683978d2/images/01998f40-57cc-4ce3-9642-c8654a6d14fc/snap’, u’metadata’: {}}]’ | | protected | False | | schema | /v2/schemas/image | | size | 343277568 | | status | active | | tags | | | updated_at | 2020-05-01T17:18:34Z | | virtual_size | None | | visibility | private | +——————+——————————————————————————————————————————————————————————————————————————————————————————————-+

How to check whether the provider supports SecurityGroups?

Как проверить, поддерживает ли провайдер группы безопасности (security groups)?

Run the following command: openstack security group list. If there are no errors in the output, then Security Groups are supported.

Достаточно выполнить команду openstack security group list. Если в ответ вы не получите ошибок, это значит, что группы безопасности поддерживаются.

How to set up online disk resize

Как настроить работу онлайн-изменения размера дисков?

The OpenStack API states that the resize is completed successfully. However, Nova does not get any information about the resize from Cinder. As a result, the size of the disk in the guest OS remains the same.

OpenStack API успешно рапортует об изменении размера диска, но Cinder никак не оповещает Nova о том, что диск изменился, поэтому диск внутри гостевой ОС остается старого размера.

To get rid of this problem, you need to insert the Nova API access parameters into the cinder.conf file, e.g., as follows:

Для устранения проблемы необходимо прописать в cinder.conf параметры доступа к Nova API. Например, так:

ini [nova] interface = admin insecure = {{ keystone_service_internaluri_insecure | bool }} auth_type = {{ cinder_keystone_auth_plugin }} auth_url = {{ keystone_service_internaluri }}/v3 password = {{ nova_service_password }} project_domain_id = default project_name = service region_name = {{ nova_service_region }} user_domain_id = default username = {{ nova_service_user_name }}

ini [nova] interface = admin insecure = {{ keystone_service_internaluri_insecure | bool }} auth_type = {{ cinder_keystone_auth_plugin }} auth_url = {{ keystone_service_internaluri }}/v3 password = {{ nova_service_password }} project_domain_id = default project_name = service region_name = {{ nova_service_region }} user_domain_id = default username = {{ nova_service_user_name }}

Source…

Источник…

How to use rootDiskSize and when it is preferred?

Как использовать rootDiskSize и когда он предпочтителен?

Disks in OpenStack

Диски в OpenStack

The node disk can be local or network. A local disk in OpenStack, is an ephemeral disk, and a network disk is a persistent disk (cinder storage). The first one is deleted along with the VM, and the second one remains in the cloud when the VM is deleted.

Диск узла может быть локальным или сетевым. В терминологии OpenStack локальный диск — это ephemeral disk, а сетевой — persistent disk (cinder storage). Первый удаляется вместе с ВМ, а второй остается в облаке, когда ВМ удаляется.

  • A network disk is preferred for the master node so that the node can migrate between hypervisors.
  • A local disk is preffered for the ephemeral node to save on cost. Not all cloud providers support the use of local disks. If local disks are not supported, you have to use network disks for ephemeral nodes.
  • Для master-узла предпочтительнее сетевой диск, чтобы узел мог мигрировать между гипервизорами.
  • Для ephemeral-узла предпочтительнее локальный диск, чтобы сэкономить на стоимости. Не все cloud-провайдеры поддерживают использование локальных дисков. Если локальные диски не поддерживаются, для ephemeral-узлов придется использовать сетевые диски.
Local disk (ephemeral) Network disk (persistent)
Is removed along with the VM Stays in the cloud and can be reused
Cheaper More expensive
Suitable for ephemeral nodes Suitable for master nodes
Локальный диск (ephemeral) Сетевой диск (persistent)
Удаляется вместе с ВМ Остается в облаке и может переиспользоваться
Дешевле Дороже
Подходит для ephemeral-узлов Подходит для master-узлов

The rootDiskSize parameter

Параметр rootDiskSize

The OpenStackInstanceClass has a rootDiskSize parameter, and OpenStack flavor has a disk size parameter. Which disk will be ordered depending on the combination of parameters is shown in the table:

В OpenStackInstanceClass есть параметр rootDiskSize, и в OpenStack flavor есть параметр размера диска.

  flavor disk size = 0 flavor disk size > 0
rootDiskSize is not specified ❗️You need to set the size. Without specifying the size, there will be an error creating a VM. Local disk with size according to the flavor
rootDiskSize is specified Network disk with the rootDiskSize size ❗ Network disk (rootDiskSize) and local disk (according to the flavor). Avoid using this option, as the cloud provider will charge for both disks.

Какой диск закажется в зависимости от комбинации параметров, указано в таблице:

  flavor disk size = 0 flavor disk size > 0
rootDiskSize не указан ❗️Необходимо задать размер. Без указания размера будет ошибка создания ВМ. Локальный диск с размером из flavor
rootDiskSize указан Сетевой диск размером rootDiskSize ❗ Сетевой (rootDiskSize) и локальный (из flavor). Избегайте использования этого варианта, так как cloud-провайдер будет взимать плату за оба диска.
  • Use flavor with a zero disk size.
  • Set the rootDiskSize in the OpenStackInstanceClass.
  • Check the disk type. The disk type will be taken from the OS image if it is set. If it is not set, the disk type will be taken from volumeTypeMap.

Рекомендация для master-узлов и бастиона — сетевой диск

  • Используйте flavor с нулевым размером диска.
  • Задайте rootDiskSize в OpenStackInstanceClass.
  • Проконтролируйте тип диска. Тип диска будет взят из образа ОС, если он задан. Если нет, тип диска будет взят из volumeTypeMap.
  • Use flavor with the specified disk size.
  • Do not use the rootDiskSize parameter in the OpenStackInstanceClass.
  • Check the disk type. The disk type will be taken from the OS image if it is set. If it is not set, the default disk type of the cloud provider will be used.

Рекомендация для ephemeral-узлов — локальный диск

How do I check the disk volume in a flavor?

  • Используйте flavor с заданным размером диска.
  • Не используйте параметр rootDiskSize в OpenStackInstanceClass.
  • Проконтролируйте тип диска. Тип диска будет взят из образа ОС, если он задан. Если нет, будет использоваться тип диска по умолчанию cloud-провайдера.

shell

Как проверить объем диска в flavor?

openstack flavor show m1.medium-50g -c disk +——-+——-+ | Field | Value | +——-+——-+ | disk | 50 | +——-+——-+

shell

How to override a default volume type of cloud provider?

openstack flavor show m1.medium-50g -c disk +——-+——-+ | Field | Value | +——-+——-+ | disk | 50 | +——-+——-+

If there are several types of disks in a cloud provider, you can set a default disk type for the image in order to select a specific VM’s disk type. To do this, specify the name of a disk type in the image metadata.

Как переопределить тип диска по умолчанию cloud-провайдера?

Also, you may need to create a custom OpenStack image; the “How do I create an image in OpenStack” section describes how to do it

Если у cloud-провайдера доступно несколько типов, вы можете указать тип диска по умолчанию для образа. Для этого необходимо указать название типа диска в метаданных образа. Тогда все ВМ, создаваемые из этого образа, будут использовать указанный тип сетевого диска.

Example:

Также вы можете создать новый образ OpenStack следующим образом.

shell openstack volume type list openstack image set ubuntu-18-04-cloud-amd64 –property cinder_img_volume_type=VOLUME_NAME

Пример:

OFFLINE disk resize

shell openstack volume type list openstack image set ubuntu-18-04-cloud-amd64 –property cinder_img_volume_type=VOLUME_NAME

Some cloud providers may not support ONLINE disk resizing. If you get the following error, then you need to reduce the number of StatefulSet replicas to 0, wait for disk resizing and return the number of replicas that was before the start of the operation.

Офлайн-изменение размера диска

text Warning VolumeResizeFailed 5s (x11 over 41s) external-resizer cinder.csi.openstack.org
resize volume “pvc-555555-ab66-4f8d-947c-296520bae4c1” by resizer “cinder.csi.openstack.org” failed: rpc error: code = Internal desc = Could not resize volume “bb5a275b-3f30-4916-9480-9efe4b6dfba5” to size 2: Expected HTTP response code [202] when accessing [POST https://public.infra.myfavourite-cloud-provider.ru:8776/v3/555555555555/volumes/bb5a275b-3f30-4916-9480-9efe4b6dfba5/action], but got 406 instead {“computeFault”: {“message”: “Version 3.42 is not supported by the API. Minimum is 3.0 and maximum is 3.27.”, “code”: 406}}

Некоторые облачные провайдеры (например, VK Cloud) могут не поддерживать онлайн-изменение дисков. Если при изменении размера диска вы получаете следующую ошибку, необходимо уменьшить количество реплик StatefulSet до 0, подождать изменения размера дисков и вернуть обратно количество реплик, которое было до начала операции.

 

text Warning VolumeResizeFailed 5s (x11 over 41s) external-resizer cinder.csi.openstack.org
resize volume “pvc-555555-ab66-4f8d-947c-296520bae4c1” by resizer “cinder.csi.openstack.org” failed: rpc error: code = Internal desc = Could not resize volume “bb5a275b-3f30-4916-9480-9efe4b6dfba5” to size 2: Expected HTTP response code [202] when accessing [POST https://public.infra.myfavourite-cloud-provider.ru:8776/v3/555555555555/volumes/bb5a275b-3f30-4916-9480-9efe4b6dfba5/action], but got 406 instead {“computeFault”: {“message”: “Version 3.42 is not supported by the API. Minimum is 3.0 and maximum is 3.27.”, “code”: 406}}