Compare languages | The kube-dns module: FAQ

How do I replace the cluster domain with minimal downtime?

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

Add the new domain and save the old one:

Добавляем новый домен и сохраняем предыдущий:

  1. In the controlPlaneManager.apiserver.certSANs section, enter the following parameters:
    • kubernetes.default.svc.<old clusterDomain>
    • kubernetes.default.svc.<new clusterDomain>
  2. In the kubeDns.clusterDomainAliases section, enter:
    • the old clusterDomain.
    • the new clusterDomain.
  3. Wait until kube-apiserver is restarted.
  4. Replace the old clusterDomain with the new one in dhctl config edit cluster-configuration
  1. В controlPlaneManager.apiserver.certSANs прописать:
    • kubernetes.default.svc.<старый clusterDomain>;
    • kubernetes.default.svc.<новый clusterDomain>.
  2. В kubeDns.clusterDomainAliases указать:
    • старый clusterDomain;
    • новый clusterDomain.
  3. Дождаться переката kube-apiserver.
  4. Поменять clusterDomain на новый в dhctl config edit cluster-configuration.

Impotant! If your Kubernetes version is 1.20 and higher, your controllers in the cluster use advanced ServiceAccount tokens to work with apiserver. Those tokens have extra fields iss: and aud: that contain clusterDomain (e.g. "iss": "https://kubernetes.default.svc.cluster.local"). After changing clusterDomain apiserver starts to deny queries with old tokens and controllers are bond to provide errors (including deckhouse). The solution is to wait until Kubernetes rotates the tokens (it will be quite fast despite the expiration date) or restart all pods with controllers.

Важно! Если версия вашего Kubernetes 1.20 и выше, контроллеры для работы с apiserver гарантированно используют расширенные токены для ServiceAccount’ов. Это означает, что каждый такой токен содержит дополнительные поля iss: и aud:, которые включают в себя старый clusterDomain (например, "iss": "https://kubernetes.default.svc.cluster.local"). При смене clusterDomain apiserver перестанет принимать запросы со старыми токенами, что приведет к ошибкам в работе всех контроллеров, включая deckhouse. Решение — дождаться ротации токенов, которая произойдет раньше, чем expiration time токена, либо рестартнуть все поды со всеми контроллерами.

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

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