Compare languages | Cloud provider - VMware vSphere: подготовка окружения

Список необходимых ресурсов vSphere

List of required vSphere resources

  • User с необходимым набором прав.
  • Network с DHCP и доступом в интернет.
  • Datacenter с соответствующим тегом k8s-region.
  • Cluster с соответствующим тегом k8s-zone.
  • Datastore в любом количестве с соответствующими тегами.
  • Templateподготовленный образ виртуальной машины.
  • User with required set of permissions.
  • Network with DHCP server and access to the Internet
  • Datacenter with a tag in k8s-region category.
  • Cluster with a tag in k8s-zone category.
  • Datastore with required tags.
  • Templateprepared VM image.

Конфигурация vSphere

vSphere configuration

Установка govc

Installing govc

Для дальнейшей конфигурации vSphere вам понадобится vSphere CLI — govc.

You’ll need the vSphere CLI — govc — to proceed with the rest of the guide.

После установки задайте переменные окружения для работы с vCenter:

After the installation is complete, set the environment variables required to work with vCenter:

shell export GOVC_URL=example.com export GOVC_USERNAME=@vsphere.local export GOVC_PASSWORD= export GOVC_INSECURE=1

shell export GOVC_URL=example.com export GOVC_USERNAME=@vsphere.local export GOVC_PASSWORD= export GOVC_INSECURE=1

Создание тегов и категорий тегов

Creating tags and tag categories

В VMware vSphere нет понятий «регион» и «зона». «Регионом» в vSphere является Datacenter, а «зоной» — Cluster. Для создания этой связи используются теги.

Instead of “regions” and “zones”, VMware vSphere provides Datacenter and Cluster objects. We will use tags to match them with “regions”/”zones”. These tags fall into two categories: one for “regions” tags and the other for “zones” tags.

Создайте категории тегов с помощью команд:

Create a tag category using the following commands:

shell govc tags.category.create -d “Kubernetes Region” k8s-region govc tags.category.create -d “Kubernetes Zone” k8s-zone

shell govc tags.category.create -d “Kubernetes Region” k8s-region govc tags.category.create -d “Kubernetes Zone” k8s-zone

Создайте теги в каждой категории. Если вы планируете использовать несколько «зон» (Cluster), создайте тег для каждой из них:

Create tags in each category. If you intend to use multiple “zones” (Cluster), create a tag for each one of them:

shell govc tags.create -d “Kubernetes Region” -c k8s-region test-region govc tags.create -d “Kubernetes Zone Test 1” -c k8s-zone test-zone-1 govc tags.create -d “Kubernetes Zone Test 2” -c k8s-zone test-zone-2

shell govc tags.create -d “Kubernetes Region” -c k8s-region test-region govc tags.create -d “Kubernetes Zone Test 1” -c k8s-zone test-zone-1 govc tags.create -d “Kubernetes Zone Test 2” -c k8s-zone test-zone-2

Назначьте тег «региона» на Datacenter:

Attach the “region” tag to Datacenter:

shell govc tags.attach -c k8s-region test-region /

shell govc tags.attach -c k8s-region test-region /

Назначьте теги «зон» на объекты Cluster:

Attach “zone” tags to the Cluster objects:

shell govc tags.attach -c k8s-zone test-zone-1 //host/ govc tags.attach -c k8s-zone test-zone-2 //host/

shell govc tags.attach -c k8s-zone test-zone-1 //host/ govc tags.attach -c k8s-zone test-zone-2 //host/

Конфигурация Datastore

Datastore configuration

Для динамического заказа PersistentVolume необходимо, чтобы Datastore был доступен на каждом хосте ESXi (shared datastore).

For dynamic PersistentVolume provisioning, a Datastore must be available on each ESXi host (shared datastore).

Для автоматического создания StorageClass в кластере Kubernetes назначьте созданные ранее теги «региона» и «зоны» на объекты Datastore:

Assign the “region” and “zone” tags to the Datastore objects to automatically create a StorageClass in the Kubernetes cluster:

shell govc tags.attach -c k8s-region test-region //datastore/ govc tags.attach -c k8s-zone test-zone-1 //datastore/

shell govc tags.attach -c k8s-region test-region //datastore/ govc tags.attach -c k8s-zone test-zone-1 //datastore/

govc tags.attach -c k8s-region test-region //datastore/ govc tags.attach -c k8s-zone test-zone-2 //datastore/

govc tags.attach -c k8s-region test-region //datastore/ govc tags.attach -c k8s-zone test-zone-2 //datastore/

Создание и назначение роли

Creating and assigning a role

Ввиду разнообразия подключаемых к vSphere SSO-провайдеров шаги по созданию пользователя в данной статье не рассматриваются.

We’ve intentionally skipped User creation since there are many ways to authenticate a user in the vSphere.

Роль, которую предлагается создать далее, включает в себя все возможные права для всех компонентов Deckhouse. Для получения детального списка привилегий, обратитесь к документации. При необходимости получения более гранулярных прав обратитесь в техподдержку Deckhouse.

This all-encompassing Role should be enough for all Deckhouse components. For a detailed list of privileges, refer to the documentation. If you need a more granular Role, please contact your Deckhouse support.

Создайте роль с необходимыми правами:

Create a role with the corresponding permissions:

shell govc role.create deckhouse
Cns.Searchable Datastore.AllocateSpace Datastore.Browse Datastore.FileManagement
Global.GlobalTag Global.SystemTag Network.Assign StorageProfile.View
$(govc role.ls Admin | grep -F -e ‘Folder.’ -e ‘InventoryService.’ -e ‘Resource.’ -e ‘VirtualMachine.’)

shell govc role.create deckhouse
Cns.Searchable Datastore.AllocateSpace Datastore.Browse Datastore.FileManagement
Global.GlobalTag Global.SystemTag Network.Assign StorageProfile.View
$(govc role.ls Admin | grep -F -e ‘Folder.’ -e ‘InventoryService.’ -e ‘Resource.’ -e ‘VirtualMachine.’)

Назначьте пользователю роль на объекте vCenter:

Assign the role to a user on the vCenter object:

shell govc permissions.set -principal @vsphere.local -role deckhouse /

shell govc permissions.set -principal @vsphere.local -role deckhouse /

Подготовка образа виртуальной машины

Preparing a virtual machine image

Для создания шаблона виртуальной машины (Template) рекомендуется использовать готовый cloud-образ/OVA-файл, предоставляемый вендором ОС:

It is recommended to use a pre-built cloud image/OVA file provided by the OS vendor to create a Template:

Если вы планируете использовать дистрибутив отечественной ОС, обратитесь к вендору ОС для получения образа/OVA-файла.

Virtual machine image requirements

Требования к образу виртуальной машины

Deckhouse uses cloud-init to configure a virtual machine after startup. To do this, the following packages must be installed in the image:

Deckhouse использует cloud-init для настройки виртуальной машины после запуска. Для этого в образе должны быть установлены следующие пакеты:

Also, after the virtual machine is started, the following services associated with these packages must be started:

Также после запуска виртуальной машины должны быть запущены следующие службы, связанные с этими пакетами:

  • cloud-config.service
  • cloud-final.service
  • cloud-init.service
  • cloud-config.service
  • cloud-final.service
  • cloud-init.service

To add SSH keys to user’s authorized keys, the default_user parameter must be specified in the /etc/cloud/cloud.cfg file.

Для добавления SSH-ключа, в файле /etc/cloud/cloud.cfg должен быть указан параметр default_user.

Deckhouse creates virtual machine disks of the eagerZeroedThick type, however, the disk type of the created VMs will be changed without any notice to match the VM Storage Policy as configured in vSphere. You can read more in the documentation.

Deckhouse создаёт диски виртуальных машин с типом eagerZeroedThick, но тип дисков созданных ВМ будет изменён без уведомления, согласно настроенным в vSphere VM Storage Policy. Подробнее можно прочитать в документации.

Deckhouse uses the ens192 interface as the default interface for virtual machines in vSphere. Therefore, when using static IP addresses in mainNetwork, you must create an interface named ens192 in the OS image as the default interface.

Deckhouse использует интерфейс ens192, как интерфейс по умолчанию для виртуальных машин в vSphere. Поэтому, при использовании статических IP-адресов в mainNetwork, вы должны в образе ОС создать интерфейс с именем ens192, как интерфейс по умолчанию.

Infrastructure

Инфраструктура

Networking

Сети

A VLAN with DHCP and Internet access is required for the running cluster:

  • If the VLAN is public (public addresses), then you have to create a second network to deploy cluster nodes (DHCP is not needed in this network).
  • If the VLAN is private (private addresses), then this network can be used for cluster nodes.

Для работы кластера необходим VLAN с DHCP и доступом в интернет:

  • Если VLAN публичный (публичные адреса), нужна вторая сеть, в которой необходимо развернуть сеть узлов кластера (в этой сети DHCP не нужен).
  • Если VLAN внутренний (приватные адреса), эта же сеть будет сетью узлов кластера.

Inbound traffic

Входящий трафик

  • You can use an internal load balancer (if present) and direct traffic directly to the front nodes of the cluster.
  • If there is no load balancer, you can use MetalLB in BGP mode to organize fault-tolerant load balancers (recommended). In this case, front nodes of the cluster will have two interfaces. For this, you will need:
  • A dedicated VLAN for traffic exchange between BGP routers and MetalLB. This VLAN must have DHCP and Internet access.
  • IP addresses of BGP routers.
  • ASN — the AS number on the BGP router.
  • ASN — the AS number in the cluster.
  • A range to announce addresses from.
  • Если у вас имеется внутренний балансировщик запросов, можно обойтись им и направлять трафик напрямую на frontend-узлы кластера.
  • Если балансировщика нет, для организации отказоустойчивых LoadBalancer’ов рекомендуется использовать MetalLB в режиме BGP. В кластере будут созданы frontend-узлы с двумя интерфейсами. Для этого дополнительно потребуются:
  • отдельный VLAN для обмена трафиком между BGP-роутерами и MetalLB. В этом VLAN’e должны быть DHCP и доступ в интернет;
  • IP-адреса BGP-роутеров;
  • ASN (номер автономной системы) на BGP-роутере;
  • ASN (номер автономной системы) в кластере;
  • диапазон, из которого анонсировать адреса.

Using the data store

Использование хранилища данных

Various types of storage can be used in the cluster; for the minimum configuration, you will need:

  • Datastore for provisioning PersistentVolumes to the Kubernetes cluster.
  • Datastore for provisioning root disks for the VMs (it can be the same Datastore as for PersistentVolume).

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

  • Datastore, в котором Kubernetes-кластер будет заказывать PersistentVolume;
  • Datastore, в котором будут заказываться root-диски для виртуальной машины (это может быть тот же Datastore, что и для PersistentVolume).