kubernetes / autoscaler

Autoscaling components for Kubernetes
Apache License 2.0
7.94k stars 3.93k forks source link

KWOK Node Isn’t Scaling #7064

Open network-charles opened 1 month ago

network-charles commented 1 month ago

Which component are you using?:

cluster-autoscaler

What version of the component are you using?:

Component version: Cluster Autoscaler 1.30.1 Image = registry.k8s.io/autoscaling/cluster-autoscaler:v1.30.1

What k8s version are you using (kubectl version)?:

kubectl version Output
$ kubectl version
Client Version: v1.30.2
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.30.2

What environment is this in?:

KWOK cluster kwokctl version v0.6.0 go1.22.3 (linux/amd64)

What did you expect to happen?:

I expected the node to scale.

What happened instead?:

Nothing happened

How to reproduce it (as minimally and precisely as possible):

ca.demo

# Scale node up & down using CA

# Set up Cluster
kwokctl create cluster --enable-metrics-server --enable-crds=Metric --enable-crds=ClusterResourceUsage --enable-crds=ResourceUsage

# Apply metrics usage
kubectl apply -f https://github.com/kubernetes-sigs/kwok/releases/download/v0.6.0/metrics-usage.yaml

## Create the nodes
kwokctl scale node --replicas 1
kubectl get node node-000000 -o yaml > node.yaml

# Configure cluster-autoscaler to use kwok cloud provider
helm repo add autoscaler https://kubernetes.github.io/autoscaler

helm upgrade --install cluster-autoscaler autoscaler/cluster-autoscaler \
--set "autoDiscovery.clusterName"="kwok-kwok" \
--set "cloudprovider"=kwok --set "image.tag"="v1.30.1" \
--set "image.repository"="registry.k8s.io/autoscaling/cluster-autoscaler" 

helm template cluster-autoscaler autoscaler/cluster-autoscaler  --set "cloudProvider"="kwok" \
-s templates/configmap.yaml \
--namespace=default > config-map-kwok.yaml

kubectl apply -f config-map-kwok-copy.yaml 

# static
# delete the existing configmap
kubectl delete configmap kwok-provider-templates

# create a new configmap with your node yamls
kubectl create configmap kwok-provider-templates --from-file=templates=node.yaml

## Create pods
kubectl apply -f deployment.yaml

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:alpine
        ports:
        - containerPort: 80
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: type
                operator: In
                values:
                - kwok
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - nginx
            topologyKey: kubernetes.io/hostname
adrianmoisey commented 1 month ago

/area cluster-autoscaler

Shubham82 commented 1 month ago

cc @vadasambar PTAL! /area provider/kwok