LoginSignup
1
0

k3dのCoreDNSの設定をConfigMapによって拡張する方法

Posted at

k3dのCoreDNSにはConfigMapで拡張できる機能があります。coredns-customという名前でConfigMapを作成し、corednsをリスタートすることで設定が読み込まれます。

以下が実際の拡張設定です。

apiVersion: v1
kind: ConfigMap
metadata:
  name: coredns-custom
  namespace: kube-system
data:
  log.override: |
    rewrite name example.com example.example.svc.cluster.local
  custom.server: |
    example.com {
        log
        rewrite name example.com example.example.svc.cluster.local
        forward . 127.0.0.1
    }
    another-example.com {
        rewrite name another-example.com another-target.default.svc.cluster.local
        forward . 127.0.0.1
    }

本体側のCoreDNSの設定は次のようになっています。この設定を見るとわかる通り、拡張設定では、*.overrideと、*.serverが認識されます。

apiVersion: v1
data:
  Corefile: |
    .:53 {
        errors
        health
        ready
        kubernetes cluster.local in-addr.arpa ip6.arpa {
          pods insecure
          fallthrough in-addr.arpa ip6.arpa
        }
        hosts /etc/coredns/NodeHosts {
          ttl 60
          reload 15s
          fallthrough
        }
        prometheus :9153
        forward . /etc/resolv.conf
        cache 30
        loop
        reload
        loadbalance
        import /etc/coredns/custom/*.override
    }
    import /etc/coredns/custom/*.server

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0