Skip to content

Commit

Permalink
feat from kubernetes/autoscaler/cluster-autoscaler-release-1.28
Browse files Browse the repository at this point in the history
  • Loading branch information
john-nguyen-visenze committed Jul 11, 2024
1 parent 66d006f commit fd8fd35
Show file tree
Hide file tree
Showing 93 changed files with 29,699 additions and 1,053 deletions.
88 changes: 88 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// throttle concurrent build
properties([[$class: 'ThrottleJobProperty', categories: [], limitOneJobWithMatchingParams: false, maxConcurrentPerNode: 1, maxConcurrentTotal: 1, paramsToUseForLimit: '', throttleEnabled: true, throttleOption: 'project']])

library(identifier: "visenze-lib@${params['VISENZE_LIB_BRANCH'] ?: 'master'}", changelog: false)

pipeline {
agent {
label "build-amd64"
}

options {
ansiColor('xterm')
}

tools {
go 'go1.20'
}

stages {
stage('Checkout') {
steps {
checkout([
$class: 'GitSCM',
branches: scm.branches,
doGenerateSubmoduleConfigurations: scm.doGenerateSubmoduleConfigurations,
extensions: [
[
$class: 'CloneOption',
noTags: true,
reference: '',
timeout: 60
],
[
$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: true,
recursiveSubmodules: true,
trackingSubmodules: true,
reference: '',
timeout: 60
],
[$class: 'CleanBeforeCheckout']
],
userRemoteConfigs: scm.userRemoteConfigs
])
}
}

stage('Test') {
when {
expression {
return canRun()
}
}
steps {
script {
dir('cluster-autoscaler') {
sh('make test-in-docker')
}
}
}
}

stage('Docker Build&Push') {
when {
expression {
return canRun()
}
}
steps {
script {
dir('cluster-autoscaler') {
def version = sh(script: "grep ClusterAutoscalerVersion version/version.go",
returnStdout: true).split('"')[-2]
docker.withRegistry('', 'docker-hub-credential') {
sh("docker buildx create --use")
sh("docker buildx build -t visenze/cluster-autoscaler:${version} --push --platform linux/arm64,linux/amd64 .")
}
}
}
}
}
}
}

def canRun() {
return env.BRANCH_NAME.startsWith('release-') || env.BRANCH_NAME == 'master'
}
21 changes: 21 additions & 0 deletions cluster-autoscaler/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.20.14 AS build

ARG TARGETARCH
ENV GOPATH /gopath/
ENV PATH $GOPATH/bin:$PATH
ENV GO111MODULE auto
ENV GOARCH ${TARGETARCH}

RUN apt-get update && apt-get --yes install libseccomp-dev
RUN go version
RUN go get github.com/tools/godep
RUN godep version

WORKDIR /gopath/src/k8s.io/autoscaler/cluster-autoscaler
ADD . .
RUN CGO_ENABLED=0 GOOS=linux go build -o cluster-autoscaler --ldflags "-s"

FROM alpine
COPY --from=build /gopath/src/k8s.io/autoscaler/cluster-autoscaler/cluster-autoscaler /

CMD ["./cluster-autoscaler"]
4 changes: 4 additions & 0 deletions cluster-autoscaler/cloudprovider/aws/aws_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ import (
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/aws/aws-sdk-go/service/eks"
"k8s.io/autoscaler/cluster-autoscaler/config"
"k8s.io/autoscaler/cluster-autoscaler/utils/gpu"
"k8s.io/autoscaler/cluster-autoscaler/utils/gpumemory"
"k8s.io/autoscaler/cluster-autoscaler/utils/mpscontext"
)

const (
Expand Down Expand Up @@ -279,6 +281,8 @@ func (m *AwsManager) buildNodeFromTemplate(asg *asg, template *asgTemplate) (*ap
node.Status.Capacity[apiv1.ResourceCPU] = *resource.NewQuantity(template.InstanceType.VCPU, resource.DecimalSI)
node.Status.Capacity[gpu.ResourceNvidiaGPU] = *resource.NewQuantity(template.InstanceType.GPU, resource.DecimalSI)
node.Status.Capacity[apiv1.ResourceMemory] = *resource.NewQuantity(template.InstanceType.MemoryMb*1024*1024, resource.DecimalSI)
node.Status.Capacity[gpumemory.ResourceVisenzeGPUMemory] = *resource.NewQuantity(template.InstanceType.GPUMemory, resource.DecimalSI)
node.Status.Capacity[mpscontext.ResourceVisenzeMPSContext] = *resource.NewQuantity(template.InstanceType.MPSContext, resource.DecimalSI)

m.updateCapacityWithRequirementsOverrides(&node.Status.Capacity, asg.MixedInstancesPolicy)

Expand Down
2 changes: 2 additions & 0 deletions cluster-autoscaler/cloudprovider/aws/ec2_instance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type InstanceType struct {
MemoryMb int64
GPU int64
Architecture string
GPUMemory int64
MPSContext int64
}

// StaticListLastUpdateTime is a string declaring the last time the static list was updated.
Expand Down
3 changes: 3 additions & 0 deletions cluster-autoscaler/cloudprovider/builder/builder_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/tencentcloud"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/volcengine"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/vultr"
"k8s.io/autoscaler/cluster-autoscaler/cloudprovider/spotinst"
"k8s.io/autoscaler/cluster-autoscaler/config"
)

Expand Down Expand Up @@ -143,6 +144,8 @@ func buildCloudProvider(opts config.AutoscalingOptions, do cloudprovider.NodeGro
return scaleway.BuildScaleway(opts, do, rl)
case cloudprovider.RancherProviderName:
return rancher.BuildRancher(opts, do, rl)
case cloudprovider.SpotinstProviderName:
return spotinst.BuildSpotinst(opts, do, rl)
case cloudprovider.VolcengineProviderName:
return volcengine.BuildVolcengine(opts, do, rl)
}
Expand Down
2 changes: 2 additions & 0 deletions cluster-autoscaler/cloudprovider/cloud_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ const (
CivoProviderName = "civo"
// RancherProviderName gets the provider name of rancher
RancherProviderName = "rancher"
// SpotinstProviderName gets the provider name of aws
SpotinstProviderName = "spotinst"
)

// GpuConfig contains the label, type and the resource name for a GPU.
Expand Down
Loading

0 comments on commit fd8fd35

Please sign in to comment.