You need to enable JavaScript to run this app.
导航

如何使用 VCI 部署 CoreDNS?

最近更新时间2023.06.27 11:50:48

首次发布时间2022.05.09 17:53:42

CoreDNS 组件当前不支持在控制台上使用 VCI 部署。您可以通过修改名为 coredns 的 Deployment(无状态负载),实现使用 VCI 部署 CoreDNS。

操作步骤如下:

  1. 登录 容器服务控制台
  2. 在左侧导航栏单击 集群,找到使用 VCI 的目标集群,单击集群名称。
  3. 在集群管理页面左侧导航栏,单击 工作负载 > 无状态负载
  4. 无状态负载 页面,找到 kube-system 命名空间下名为 coredns 的工作负载,单击右侧 操作 列的... > 编辑 Yaml
    alt
  5. 按如下三个说明,修改 coredns 无状态负载的 Yaml 文件内容。
    • spec > template > metadata参数下,增加如下annotations字段,将无状态负载强制调度到 VCI。
      annotations:
       vke.volcengine.com/burst-to-vci: enforce   # 强制调度到 VCI
      
      代码片段示意图如下:
      alt
      • spec > template > spec参数下,增加如下dnsConfig字段,指定 dnsConfig 到 IaaS DNS。
        dnsConfig:       # 修改 dnsConfig 到 IaaS DNS
          nameservers:
          - 100.96.0.2
          - 100.96.0.3
          options:
          - name: rotate
        
        代码片段示意图如下:
        alt
    • 修改spec > template > spec参数下dnsPolicy字段的值为 None
      alt
      完整的 coredns 无状态负载 Yaml 文件示例如下所示。
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        labels:
          k8s-app: kube-dns
        name: coredns
        namespace: kube-system
      spec:
        progressDeadlineSeconds: 600
        replicas: 2
        revisionHistoryLimit: 10
        selector:
          matchLabels:
            k8s-app: kube-dns
        strategy:
          rollingUpdate:
            maxSurge: 25%
            maxUnavailable: 1
          type: RollingUpdate
        template:
          metadata:
            annotations:
              vke.volcengine.com/burst-to-vci: enforce   # 强制调度到 VCI
            creationTimestamp: null
            labels:
              k8s-app: kube-dns
          spec:
            containers:
            - args:
              - -conf
              - /etc/coredns/Corefile
              image: cr-cn-beijing.ivolces.com/vke/coredns:1.7.0
              imagePullPolicy: IfNotPresent
              livenessProbe:
                failureThreshold: 5
                httpGet:
                  path: /health
                  port: 8080
                  scheme: HTTP
                initialDelaySeconds: 60
                periodSeconds: 10
                successThreshold: 1
                timeoutSeconds: 5
              name: coredns
              ports:
              - containerPort: 53
                protocol: UDP
              - containerPort: 53
                protocol: TCP
              - containerPort: 9153
                protocol: TCP
              readinessProbe:
                failureThreshold: 3
                httpGet:
                  path: /ready
                  port: 8181
                  scheme: HTTP
                periodSeconds: 10
                successThreshold: 1
                timeoutSeconds: 1
              resources:
                limits:
                  memory: 770Mi
                requests:
                  cpu: 100m
                  memory: 70Mi
              terminationMessagePath: /dev/termination-log
              terminationMessagePolicy: File
              volumeMounts:
              - mountPath: /etc/coredns
                name: config-volume
                readOnly: true
            dnsConfig:       # 修改 dnsConfig 到 IaaS DNS
              nameservers:
              - 100.96.0.2
              - 100.96.0.3
              options: 
              - name: rotate
            dnsPolicy: None
            nodeSelector:
              kubernetes.io/os: linux
              node.kubernetes.io/instance-type: virtual-node
            priorityClassName: system-cluster-critical
            restartPolicy: Always
            schedulerName: default-scheduler
            securityContext: {}
            serviceAccount: coredns
            serviceAccountName: coredns
            terminationGracePeriodSeconds: 30
            tolerations:
            - key: CriticalAddonsOnly
              operator: Exists
            - effect: NoSchedule
              key: node-role.kubernetes.io/master
            - effect: NoSchedule
              key: node-role.kubernetes.io/control-plane
            - effect: NoSchedule
              key: vci.vke.volcengine.com/node-type
              operator: Equal
              value: vci
            volumes:
            - configMap:
                defaultMode: 420
                items:
                - key: Corefile
                  path: Corefile
                name: coredns
              name: config-volume