Skip to content

Instantly share code, notes, and snippets.

@dkeightley
Created July 20, 2022 19:29
Show Gist options
  • Select an option

  • Save dkeightley/0711221f6f2e65d7f76da37190b1a5d7 to your computer and use it in GitHub Desktop.

Select an option

Save dkeightley/0711221f6f2e65d7f76da37190b1a5d7 to your computer and use it in GitHub Desktop.

Revisions

  1. dkeightley created this gist Jul 20, 2022.
    75 changes: 75 additions & 0 deletions coredns-autoscaler.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,75 @@

    kind: ServiceAccount
    apiVersion: v1
    metadata:
    name: coredns-autoscaler
    namespace: kube-system
    ---
    kind: ClusterRole
    apiVersion: rbac.authorization.k8s.io/v1
    metadata:
    name: system:coredns-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"]
    # Remove the configmaps rule once below issue is fixed:
    # kubernetes-incubator/cluster-proportional-autoscaler#16
    - apiGroups: [""]
    resources: ["configmaps"]
    verbs: ["get", "create"]
    ---
    kind: ClusterRoleBinding
    apiVersion: rbac.authorization.k8s.io/v1
    metadata:
    name: system:coredns-autoscaler
    subjects:
    - kind: ServiceAccount
    name: coredns-autoscaler
    namespace: kube-system
    roleRef:
    kind: ClusterRole
    name: system:coredns-autoscaler
    apiGroup: rbac.authorization.k8s.io
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    name: coredns-autoscaler
    namespace: kube-system
    labels:
    k8s-app: coredns-autoscaler
    spec:
    selector:
    matchLabels:
    k8s-app: coredns-autoscaler
    template:
    metadata:
    labels:
    k8s-app: coredns-autoscaler
    spec:
    containers:
    - name: autoscaler
    image: k8s.gcr.io/cluster-proportional-autoscaler-amd64:1.7.1
    resources:
    requests:
    cpu: "20m"
    memory: "10Mi"
    command:
    - /cluster-proportional-autoscaler
    - --namespace=kube-system
    - --configmap=coredns-autoscaler
    - --target=deployment/coredns
    - --default-params={"linear":{"coresPerReplica":256,"nodesPerReplica":16,"preventSinglePointFailure":true}}
    - --logtostderr=true
    - --v=2
    tolerations:
    - key: "CriticalAddonsOnly"
    operator: "Exists"
    serviceAccountName: coredns-autoscaler