Score:0

How to enable Cluster Autoscaler for a cluster setup with kops

sj flag

Im trying to setup a cluster autoscaler. after following docs and trying from this thread to do one , i wasn't able to create one.

Created a Cluster using kops cli

 kops create cluster --name=pavan.k8s.local --zones=us-east-1a --cloud=aws --master-size=t2.medium --node-size=t2.medium

Replaced the created node with a new node of these configurations

apiVersion: kops.k8s.io/v1alpha2
kind: InstanceGroup
metadata:
  labels:
    kops.k8s.io/cluster: pavan.k8s.local
  name: nodes-us-east-1a
spec:
  image: 099720109477/ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20221206
  instanceMetadata:
    httpPutResponseHopLimit: 1
    httpTokens: required
  machineType: t3.medium
  rootVolumeSize: 8
  rootVolumeType: gp2
  maxPrice: '0.20'
  maxSize: 4
  minSize: 1
  role: Node
  subnets:
    - us-east-1a

Edited the node group

$ kops edit ig nodes

spec:
  cloudLabels:
    app.kubernetes.io/cluster/pavan.k8s.local: owned
    k8s.io/cluster-autoscaler/enabled: ""
    k8s.io/cluster-autoscaler/node-template/label: ""

kubernetes.io/cluster/<CLUSTER_NAME>: owned gave an error initially saying "kubernetes.io/cluster" prefix is reserved for use by Kubernetes . so i added app.kubernetes.io/cluster/pavan.k8s.local: owned instead

I later edited the cluster

$ kops edit cluster

spec:
  additionalPolicies:
    node: |
      [
        {
          "Effect": "Allow",
          "Action": [
            "autoscaling:DescribeAutoScalingGroups",
            "autoscaling:DescribeAutoScalingInstances",
            "autoscaling:SetDesiredCapacity",
            "autoscaling:DescribeLaunchConfigurations",
            "autoscaling:DescribeTags",
            "autoscaling:TerminateInstanceInAutoScalingGroup"
          ],
          "Resource": ["*"]
        }
      ]

Deployed an nginx app

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-app
  labels:
    app: test-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test-app
  template:
    metadata:
      labels:
        app: test-app
    spec:
      containers:
        - name: test-app
          image: nginx:1.14.2
          ports:
            - containerPort: 80
          resources:
            requests:
              cpu: 200m
              memory: 1Gi
            limits:
              cpu: 2000m
              memory: 4Gi

Scaled the deployment

$ kubectl scale deploy test-app --replicas=4

$ kubectl get pods
NAME                       READY   STATUS    RESTARTS   AGE
test-app-cf78774cf-7f59b   0/1     Pending   0          5m
test-app-cf78774cf-ctrpx   1/1     Running   0          6m
test-app-cf78774cf-jf76d   1/1     Running   0          6m
test-app-cf78774cf-p8gwn   1/1     Running   0          5m


Message:

0/2 nodes are available: 1 Insufficient memory, 1 node(s) had untolerated taint {node-role.kubernetes.io/control-plane: }. preemption: 0/2 nodes are available: 1 No preemption victims found for incoming pod, 1 Preemption is not helpful for scheduling.

Can someone Please enlighten me on how to do this in detail?

Thank you.

in flag
Hi Pavan Bhat welcome to S.F. Whew, what a lot of things off the rails here. (a) have you checked the cluster-autoscaler logs? It's probably complaining that the perms you provided [are not the whole list](https://github.com/kubernetes/autoscaler/tree/cluster-autoscaler-1.26.1/cluster-autoscaler/cloudprovider/aws#full-cluster-autoscaler-features-policy-recommended). (b) ensure those _requests_ you made by `kops edit` actually flowed out to AWS. Finally, don't put any updates in comments, instead[edit your question](https://serverfault.com/posts/1120801/edit). Good luck
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.