Cluster Autoscaler project study
Github Repository: https://github.com/kubernetes/autoscaler
cluster-autoscaler start up commands
// I0624 09:24:10.787568 1 main.go:333] Cluster Autoscaler 1.13.5 --address=":8085" // Logs are written to standard error as well as to files. --alsologtostderr="false" --balance-similar-node-groups="false" --cloud-config="" --cloud-provider="azure" --cloud-provider-gce-lb-src-cidrs="130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16" --cluster-name="" --cores-total="0:320000" --estimator="binpacking" // determine how to choose a vmss to expand nodes. --expander="random" --expendable-pods-priority-cutoff="-10" --gke-api-endpoint="" --gpu-total="[]" --httptest.serve="" --ignore-daemonsets-utilization="false" --ignore-mirror-pods-utilization="false" --kubeconfig="" --kubernetes="" --leader-elect="true" --leader-elect-lease-duration="15s" --leader-elect-renew-deadline="10s" --leader-elect-resource-lock="endpoints" --leader-elect-retry-period="2s" /* When set to a file and line number holding a logging statement, such as -log_backtrace_at=gopherflakes.go:234 a stack trace will be written to the Info log whenever executionhits that statement. (Unlike with -vmodule, the ".go" must be present.) */ --log-backtrace-at=":0" // Log files will be written to this directory instead of the // default temporary directory. --log-dir="" --log-file="" // Logs are written to standard error instead of to files. --logtostderr="true" --max-autoprovisioned-node-group-count="15" --max-empty-bulk-delete="10" --max-failing-time="15m0s" --max-graceful-termination-sec="600" --max-inactivity="10m0s" --max-node-provision-time="15m0s" --max-nodes-total="0" --max-total-unready-percentage="45" --memory-total="0:6400000" --min-replica-count="0" --namespace="kube-system" --new-pod-scale-up-delay="0s" --node-autoprovisioning-enabled="false" --node-group-auto-discovery="[]" --nodes="[3:10:aks-mynodepool-41521705-vmss]" --ok-total-unready-count="3" --regional="false" --scale-down-candidates-pool-min-count="50" --scale-down-candidates-pool-ratio="0.1" --scale-down-delay-after-add="10m0s" --scale-down-delay-after-delete="10s" --scale-down-delay-after-failure="3m0s" // Flag to enable scale down or not. --scale-down-enabled="true" --scale-down-non-empty-candidates-count="30" --scale-down-unneeded-time="10m0s" --scale-down-unready-time="20m0s" --scale-down-utilization-threshold="0.5" // The time interval to scan nodes (executing RunOnce()). --scan-interval="10s" --skip-headers="false" --skip-nodes-with-local-storage="false" --skip-nodes-with-system-pods="true" // Log events at or above this severity are logged to standard // error as well as to files. --stderrthreshold="2" --test.bench="" --test.benchmem="false" --test.benchtime="1s" --test.blockprofile="" --test.blockprofilerate="1" --test.count="1" --test.coverprofile="" --test.cpu="" --test.cpuprofile="" --test.failfast="false" --test.list="" --test.memprofile="" --test.memprofilerate="0" --test.mutexprofile="" --test.mutexprofilefraction="1" --test.outputdir="" --test.parallel="2" --test.run="" --test.short="false" --test.testlogfile="" --test.timeout="0s" --test.trace="" --test.v="false" --unremovable-node-recheck-timeout="5m0s" // klog level. Enable V-leveled logging at the specified level. --v="3" /* klog module level. The syntax of the argument is a comma-separated list of pattern=N, where pattern is a literal file name (minus the ".go" suffix) or "glob" pattern and N is a V level. For instance, -vmodule=gopher*=3 sets the V level to 3 in all Go files whose names begin "gopher". */ --vmodule="" --write-status-configmap="true"
autoscaler.go
struct AutoscalerOptions is the whole set of options for configuring an autoscaler. The struct is mainly initialised in initializeDefaultOptions().
type AutoscalerOptions struct { config.AutoscalingOptions KubeClient kube_client.Interface AutoscalingKubeClients *context.AutoscalingKubeClients CloudProvider cloudprovider.CloudProvider PredicateChecker *simulator.PredicateChecker ExpanderStrategy expander.Strategy EstimatorBuilder estimator.EstimatorBuilder Processors *ca_processors.AutoscalingProcessors Backoff backoff.Backoff }
- config.AutoscalingOptions: options coming from startup command.
- ExpanderStrategy: Determine how to choose a vmss to expand nodes.
- EstimatorBuilder: build a edtimator which implements approximation algorithm to calculate pod score according to cpu and memory.
- Backoff: ???