SUSE Support

Here When You Need Us

Rancher Kubernetes Engine(RKE)のCLIまたはRancher v2.xのプロビジョニングされたKubernetesクラスタでCoreDNS ConfigMapを更新する方法

This document (000020007) is provided subject to the disclaimer at the end of this document.

Situation

背景

例えば、query loggingupdate the resolver policyを有効にするために、kube-system Namespaceのcoredns ConfigMapで定義されたCoreDNSのCorefile構成を更新したい場合があります。 この記事では、このConfigMapを更新し、Rancher Kubernetes Engine (RKE) CLIまたはRancher v2.xのプロビジョニングされたクラスタで変更を永続化する方法を詳細に説明します。

事前準備

  • CoreDNS dns addon を使用して、Rancher Kubernetes Engine(RKE)CLIまたはRancher v2.xによってプロビジョニングされたKubernetesクラスタ。
  • global adminまたはcluster ownerのユーザーとしたkubeconfigによるクラスターへのkubectlアクセス。

Steps

  1. 次の kubectl コマンドで、現在の coredns ConfigMap 定義を取得します。

    kubectl -n kube-system get configmap coredns -o go-template={{.data.Corefile}}

    以下のような内容が出力されます。

    .:53 {
        errors
        health
        ready
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          fallthrough in-addr.arpa ip6.arpa
        }
        prometheus :9153
        forward . "/etc/resolv.conf" {
          policy random
        }
        cache 30
        loop
        reload
        loadbalance
    }
  2. クラスタ構成のYAMLを編集して、必要な変更を加えたcoredns ConfigMapを定義します。 RKE プロビジョニングされたクラスターの場合は、この内容を cluster.yml ファイルに追加します。 Rancherでプロビジョニングされたクラスターの場合、Rancher UIのクラスタービューに移動し、クラスタービューの編集を開き、Edit as YAMLをクリックします。

    以下の内容でアドオンを作成し、Corefileの定義を手順1で取得した既存の構成に置き換えます。その後、必要な変更を加えます。この例では、resolver policyを既存のrandomからsequentalに更新します。

    yaml addons: |- --- apiVersion: v1 kind: ConfigMap metadata: name: coredns namespace: kube-system data: Corefile: | .:53 { errors health ready kubernetes cluster.local in-addr.arpa ip6.arpa { pods insecure fallthrough in-addr.arpa ip6.arpa } prometheus :9153 forward . "/etc/resolv.conf" { policy sequential } cache 30 loop reload loadbalance }

  3. 新しい構成でクラスターを更新します。 RKEのプロビジョニングされたクラスターの場合、rke up --cluster.ymlを実行します(rke upを実行する際には、作業ディレクトリにcluster.rkestateファイルが存在することを確認してください)。 Rancherでプロビジョニングされたクラスターの場合は、Rancher UIの Edit as YAML ビューで Save をクリックします。

参考資料

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:000020007
  • Creation Date: 09-Jul-2021
  • Modified Date:09-Jul-2021
    • SUSE Rancher

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.