Compare languages | Модуль kube-dns: FAQ

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

How do I replace the cluster domain with minimal downtime?

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

Add a new domain and retain the previous one. To do this, modify the configuration parameters:

  1. В controlPlaneManager.apiserver:
  1. In the controlPlaneManager.apiserver:

Пример:

Example:

yaml apiVersion: deckhouse.io/v1alpha1 kind: ModuleConfig metadata: name: control-plane-manager spec: version: 1 enabled: true settings: apiserver: certSANs:

  • kubernetes.default.svc.<старый clusterDomain="">
  • kubernetes.default.svc.<новый clusterDomain=""> serviceAccount: additionalAPIAudiences:
  • https://kubernetes.default.svc.<старый clusterDomain="">
  • https://kubernetes.default.svc.<новый clusterDomain=""> additionalAPIIssuers:
  • https://kubernetes.default.svc.<старый clusterDomain="">
  • https://kubernetes.default.svc.<новый clusterDomain="">

yaml apiVersion: deckhouse.io/v1alpha1 kind: ModuleConfig metadata: name: control-plane-manager spec: enabled: true version: 1 settings: apiserver: certSANs:

  • kubernetes.default.svc.
  • kubernetes.default.svc. serviceAccount: additionalAPIAudiences:
  • https://kubernetes.default.svc.
  • https://kubernetes.default.svc. additionalAPIIssuers:
  • https://kubernetes.default.svc.
  • https://kubernetes.default.svc.
  1. В kubeDns.clusterDomainAliases:
  1. In the kubeDns.clusterDomainAliases:

Пример:

Example:

yaml apiVersion: deckhouse.io/v1alpha1 kind: ModuleConfig metadata: name: kube-dns spec: version: 1 enabled: true settings: clusterDomainAliases:

  • <старый clusterDomain="">
  • <новый clusterDomain="">

yaml apiVersion: deckhouse.io/v1alpha1 kind: ModuleConfig metadata: name: kube-dns spec: version: 1 enabled: true settings: clusterDomainAliases:

  1. Дождитесь перезапуска kube-apiserver.
  2. Поменяйте clusterDomain на новый. Для этого выполните команду:
  1. Wait until the kube-apiserver has restarted.
  2. Replace the previous clusterDomain with the new one. To do this, execute the command:

bash kubectl -n d8-system exec -ti svc/deckhouse-leader – deckhouse-controller edit cluster-configuration

bash kubectl -n d8-system exec -ti svc/deckhouse-leader – deckhouse-controller edit cluster-configuration

Важно! Если версия вашего Kubernetes 1.20 и выше, контроллеры для работы с API-server гарантированно используют расширенные токены для ServiceAccount’ов. Это означает, что каждый такой токен содержит дополнительные поля iss: и aud:, которые включают в себя старый clusterDomain (например, "iss": "https://kubernetes.default.svc.cluster.local"). При смене clusterDomain API-server начнет выдавать токены с новым service-account-issuer, но благодаря произведенной конфигурации additionalAPIAudiences и additionalAPIIssuers по-прежнему будет принимать старые токены. По истечении 48 минут (80% от 3607 секунд) Kubernetes начнет обновлять выпущенные токены, при обновлении будет использован новый service-account-issuer. Через 90 минут (3607 секунд и немного больше) после перезагрузки kube-apiserver можете удалить конфигурацию serviceAccount из конфигурации control-plane-manager.

Important! If your Kubernetes version is 1.20 and higher, your controllers in the cluster use advanced ServiceAccount tokens to work with API server. Those tokens have extra fields iss: and aud: that contain clusterDomain (e.g. "iss": "https://kubernetes.default.svc.cluster.local"). After changing the clusterDomain, the API server will start issuing tokens with the new service-account-issuer, but thanks to the configuration of additionalAPIAudiences and additionalAPIIssuers, the apiserver will continue to accept the old tokens. After 48 minutes (80% of 3607 seconds), Kubernetes will begin to refresh the issued tokens, and the new service-account-issuer will be used for the updated tokens. After 90 minutes (3607 seconds plus a short buffer) following the kube-apiserver restart, you can remove the serviceAccount configuration from the control-plane-manager configuration.

Важно! Если вы используете модуль istio, после смены clusterDomain обязательно потребуется рестарт всех прикладных подов под управлением Istio.

Important! If you use istio module, you have to restart all the application pods under istio control after changing clusterDomain.

Как увеличить количество подов kube-dns?

How to Increase the Number of kube-dns pods?

Deckhouse распределяет поды kube-dns по следующему принципу: выполняется поиск узлов с метками node-role.deckhouse.io/ и node-role.kubernetes.io/, затем применяются следующие правила:

Deckhouse distributes kube-dns pods based on the following principles. It searches for nodes with the labels node-role.deckhouse.io/ and node-role.kubernetes.io/, then applies the following rules:

  • Если в кластере есть узлы с ролью kube-dns, количество реплик вычисляется как сумма таких узлов и мастеров.
  • Если узлы kube-dns отсутствуют, производится поиск узлов с ролью system, и тогда количество реплик определяется как сумма system-узлов и мастеров.
  • Если в кластере присутствуют только мастер-узлы, количество реплик kube-dns будет равно числу мастеров.
  • If there are nodes with the kube-dns role in the cluster, the number of replicas is calculated as the sum of these nodes and the master nodes.
  • If kube-dns nodes are absent, the system searches for nodes with the system role, and the number of replicas is then determined as the sum of system nodes and master nodes.
  • If only master nodes are present in the cluster, the number of kube-dns replicas will be equal to the number of masters.