全部文档
当前文档

暂无内容

如果没有找到您期望的内容,请尝试其他搜索词

文档中心

DNS Autoscale

最近更新时间:2024-07-03 11:23:22

当集群规模增加时,需要保证DNS的稳定、高效;KCE容器服务提供了DNS Autoscale,通过预置的伸缩策略,对DNS执行自动的水平伸缩。

安装流程

cluster-proportional-autoscaler通过监听集群中可调度节点与核心数量,根据预设的策略来调整目标资源的副本数。您可以通过如下yaml进行部署,来对coredns副本数进行自动扩缩容。

kind: ServiceAccount
apiVersion: v1
metadata:
  name: dns-autoscaler
  namespace: kube-system
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: system:dns-autoscaler
rules:
  - apiGroups: [""]
    resources: ["nodes"]
    verbs: ["list", "watch"]
  - apiGroups: [""]
    resources: ["replicationcontrollers/scale"]
    verbs: ["get", "update"]
  - apiGroups: ["apps"]
    resources: ["deployments/scale", "replicasets/scale"]
    verbs: ["get", "update"]
  - apiGroups: [""]
    resources: ["configmaps"]
    verbs: ["get", "create"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: system:dns-autoscaler
subjects:
  - kind: ServiceAccount
    name: dns-autoscaler
    namespace: kube-system
roleRef:
  kind: ClusterRole
  name: system:dns-autoscaler
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: dns-autoscaler
  namespace: kube-system
  labels:
    k8s-app: dns-autoscaler
    kubernetes.io/cluster-service: "true"
spec:
  selector:
    matchLabels:
      k8s-app: dns-autoscaler
  template:
    metadata:
      labels:
        k8s-app: dns-autoscaler
    spec:
      priorityClassName: system-cluster-critical
      securityContext:
        seccompProfile:
          type: RuntimeDefault
        supplementalGroups: [ 65534 ]
        fsGroup: 65534
      nodeSelector:
        kubernetes.io/os: linux
      containers:
      - name: autoscaler
        image: hub.kce.ksyun.com/ksyun/cpa/cluster-proportional-autoscaler:1.8.4
        resources:
          requests:
              cpu: "200m"
              memory: "100Mi"
        command:
          - /cluster-proportional-autoscaler
          - --namespace=kube-system
          - --configmap=dns-autoscaler
          - --nodelabels=type!=virtual-kubelet
          - --target=Deployment/coredns
          - --default-params={"linear":{"coresPerReplica":64,"nodesPerReplica":8,"min":3,"max":10,"preventSinglePointFailure":true}}
          - --logtostderr=true
          - --v=9
      tolerations:
      - key: "CriticalAddonsOnly"
        operator: "Exists"
      serviceAccountName: dns-autoscaler

上述策略使用linear模式进行调整,根据核心数和节点数动态调整副本数,yaml参数中的含义是每64个核心或每8个节点分配一个副本,最小副本数为3,最大副本数为10,以下是具体的配置参数:

{
    "coresPerReplica": 64,
    "nodesPerReplica": 8,
    "min": 3,
    "max": 10,
    "preventSinglePointFailure": true
}

linear模式计算公式如下

replicas = max( ceil( cores * 1/coresPerReplica ) , ceil( nodes * 1/nodesPerReplica ) )
replicas = min(replicas, max)
replicas = max(replicas, min)

文档导读
纯净模式常规模式

纯净模式

点击可全屏预览文档内容
文档反馈