Compare languages | Cloud provider — AWS: примеры

Пример custom resource AWSInstanceClass

An example of the AWSInstanceClass custom resource

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

Below is a simple example of custom resource AWSInstanceClass configuration:

yaml apiVersion: deckhouse.io/v1 kind: AWSInstanceClass metadata: name: worker spec: instanceType: t3.large ami: ami-040a1551f9c9d11ad diskSizeGb: 15 diskType: gp2

yaml apiVersion: deckhouse.io/v1 kind: AWSInstanceClass metadata: name: worker spec: instanceType: t3.large ami: ami-040a1551f9c9d11ad diskSizeGb: 15 diskType: gp2

LoadBalancer

LoadBalancer

Аннотации объекта Service

Service object Annotations

Поддерживаются следующие параметры в дополнение к существующим в upstream:

The following parameters are supported in addition to the existing upstream ones:

  1. service.beta.kubernetes.io/aws-load-balancer-type — может иметь значение none, что приведет к созданию только Target Group, без какого-либо LoadBalanacer’а.
  2. service.beta.kubernetes.io/aws-load-balancer-backend-protocol — используется в связке с service.beta.kubernetes.io/aws-load-balancer-type: none:
    • Возможные значения:
    • tcp (по умолчанию);
    • tls;
    • http;
    • https.
    • Внимание! При изменении этого параметра cloud-controller-manager попытается пересоздать Target Group. Если к ней уже привязаны NLB или ALB, удалить Target Group не получится и он будет бесконечно пытаться это сделать. В таком случае необходимо вручную отсоединить NLB или ALB от Target Group.
  1. service.beta.kubernetes.io/aws-load-balancer-type — if it has the none value, then the Target Group will only be created (without any LoadBalancer).
  2. service.beta.kubernetes.io/aws-load-balancer-backend-protocol — this parameter is used together with service.beta.kubernetes.io/aws-load-balancer-type: none:
    • Possible values:
    • tcp (default);
    • tls;
    • http;
    • https.
    • Caution! The cloud-controller-manager (CCM) will try to recreate the Target Group in response to changes in this field. If the Target Group has NLB or ALB attached to it, the CCM will fail to delete it and get stuck in this state forever. You have to manually disconnect NLB or ALB from the Target Group.

Настройка политик безопасности на узлах

Configuring security policies on nodes

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

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

  • Разрешить подключение к узлам кластера с виртуальных машин из другой подсети.
  • Разрешить подключение к портам статического узла для работы приложения.
  • Ограничить доступ к внешним ресурсам или другим виртуальным машинам в облаке по требованию службы безопасности.
  • 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.

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

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

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

Enabling additional security groups on static and master nodes

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

  • для master-узлов — в секции masterNodeGroup в поле additionalSecurityGroups;
  • для статических узлов — в секции nodeGroups в конфигурации, описывающей соответствующую nodeGroup, в поле additionalSecurityGroups.

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

  • for master nodes, in the additionalSecurityGroups field of the masterNodeGroup section;
  • for static nodes, in the additionalSecurityGroups field of the nodeGroups subsection that corresponds to the target nodeGroup.

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

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

Установка дополнительных security groups на эфемерных узлах

Enabling additional security groups on ephemeral nodes

Необходимо указать параметр additionalSecurityGroups для всех AWSInstanceClass в кластере, которым нужны дополнительные группы безопасности (security group).

You have to set the additionalSecurityGroups parameter for all AWSInstanceClass that require additional security groups.

Настройка балансировщика в случае наличия Ingress-узлов не во всех зонах

Configuring the load balancer if Ingress nodes are not available in all zones

Необходимо указать аннотацию на объекте Service: service.beta.kubernetes.io/aws-load-balancer-subnets: subnet-foo, subnet-bar.

Set the following annotation for the Service object: service.beta.kubernetes.io/aws-load-balancer-subnets: subnet-foo, subnet-bar.

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

You can get current subnets for a particular installation as follows:

bash kubectl -n d8-system exec svc/deckhouse-leader -c deckhouse – deckhouse-controller module values cloud-provider-aws -o json
| jq -r ‘.cloudProviderAws.internal.zoneToSubnetIdMap’

bash kubectl -n d8-system exec svc/deckhouse-leader -c deckhouse – deckhouse-controller module values cloud-provider-aws -o json
| jq -r ‘.cloudProviderAws.internal.zoneToSubnetIdMap’