From a819a7411082474d45fbc57321660f30cba86008 Mon Sep 17 00:00:00 2001 From: Sarvesh Bedekar Date: Tue, 17 Oct 2023 11:05:11 +0530 Subject: [PATCH 1/5] Added docker parameter for CPU Limit --- scheduler/agent.go | 1 + scheduler/server.go | 1 + 2 files changed, 2 insertions(+) diff --git a/scheduler/agent.go b/scheduler/agent.go index 51e6e69..cd42838 100644 --- a/scheduler/agent.go +++ b/scheduler/agent.go @@ -49,6 +49,7 @@ func (e *Scheduler) StartK3SAgent(taskID string) { cmd.DockerParameter = e.addDockerParameter(cmd.DockerParameter, mesosproto.Parameter{Key: "shm-size", Value: e.Config.K3SContainerDisk}) cmd.DockerParameter = e.addDockerParameter(cmd.DockerParameter, mesosproto.Parameter{Key: "memory-swap", Value: fmt.Sprintf("%.0fg", (e.Config.DockerMemorySwap+e.Config.K3SAgentMEM)/1024)}) cmd.DockerParameter = e.addDockerParameter(cmd.DockerParameter, mesosproto.Parameter{Key: "ulimit", Value: "nofile=" + e.Config.DockerUlimit}) + cmd.DockerParameter = e.addDockerParameter(cmd.DockerParameter, mesosproto.Parameter{Key: "cpus", Value: strconv.FormatFloat(e.Config.K3SAgentCPU, 'f', -1, 64)}) cmd.Instances = e.Config.K3SAgentMax diff --git a/scheduler/server.go b/scheduler/server.go index 62dcdcf..2a1b817 100644 --- a/scheduler/server.go +++ b/scheduler/server.go @@ -33,6 +33,7 @@ func (e *Scheduler) StartK3SServer(taskID string) { cmd.DockerParameter = e.addDockerParameter(cmd.DockerParameter, mesosproto.Parameter{Key: "shm-size", Value: e.Config.K3SContainerDisk}) cmd.DockerParameter = e.addDockerParameter(cmd.DockerParameter, mesosproto.Parameter{Key: "memory-swap", Value: fmt.Sprintf("%.0fg", (e.Config.DockerMemorySwap+e.Config.K3SServerMEM)/1024)}) cmd.DockerParameter = e.addDockerParameter(cmd.DockerParameter, mesosproto.Parameter{Key: "ulimit", Value: "nofile=" + e.Config.DockerUlimit}) + cmd.DockerParameter = e.addDockerParameter(cmd.DockerParameter, mesosproto.Parameter{Key: "cpus", Value: strconv.FormatFloat(e.Config.K3SServerCPU, 'f', -1, 64)}) cmd.Instances = e.Config.K3SServerMax // if mesos cni is unset, then use docker cni From 98283a4250c29d8cfe620e94dc81d70e96373c15 Mon Sep 17 00:00:00 2001 From: Sarvesh Bedekar Date: Tue, 17 Oct 2023 11:18:35 +0530 Subject: [PATCH 2/5] Updated Makefile to explicitly specific amd64 in build command --- .gitignore | 1 + controller/Makefile | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d8dd481..3c514b0 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ controller/controller.arm64 docs/examples/config.cnf docs/examples/create-user.yaml mesos-m3s.code-workspace +controller/sbom.txt \ No newline at end of file diff --git a/controller/Makefile b/controller/Makefile index 43efd4f..97b341e 100644 --- a/controller/Makefile +++ b/controller/Makefile @@ -13,7 +13,7 @@ build-arm: @CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -installsuffix cgo -ldflags "-X main.BuildVersion=${BUILDDATE}/ARM -X main.GitVersion=${TAG} -X main.VersionURL=${VERSION_URL} -extldflags \"-static\"" -o controller.arm64 . build: - @CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags "-X main.BuildVersion=${BUILDDATE} -X main.GitVersion=${TAG} -X main.VersionURL=${VERSION_URL} -extldflags \"-static\"" -o controller.amd64 . + @CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags "-X main.BuildVersion=${BUILDDATE} -X main.GitVersion=${TAG} -X main.VersionURL=${VERSION_URL} -extldflags \"-static\"" -o controller.amd64 . update-gomod: go get -u From 6d47b96fb7fdb4f7341908244c7bbe4bd0693532 Mon Sep 17 00:00:00 2001 From: Sarvesh Bedekar Date: Thu, 19 Oct 2023 15:26:52 +0530 Subject: [PATCH 3/5] Updated Default Values for Agent & Server CPU --- init.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.go b/init.go index 60d0f6f..dc0014a 100644 --- a/init.go +++ b/init.go @@ -59,7 +59,7 @@ func init() { config.K3SNodeTimeout, _ = time.ParseDuration(util.Getenv("K3S_NODE_TIMEOUT", "10m")) config.K3SServerMax, _ = strconv.Atoi(util.Getenv("K3S_SERVER_COUNT", "1")) config.K3SServerPort, _ = strconv.Atoi(util.Getenv("K3S_SERVER_PORT", strconv.Itoa(framework.PortRangeFrom))) - config.K3SServerCPU, _ = strconv.ParseFloat(util.Getenv("K3S_SERVER_CPU", "0.1"), 64) + config.K3SServerCPU, _ = strconv.ParseFloat(util.Getenv("K3S_SERVER_CPU", "1.0"), 64) config.K3SServerMEM, _ = strconv.ParseFloat(util.Getenv("K3S_SERVER_MEM", "2000"), 64) config.K3SServerDISK, _ = strconv.ParseFloat(util.Getenv("K3S_SERVER_DISK", "1000"), 64) config.K3SServerString = util.Getenv("K3S_SERVER_STRING", "/usr/local/bin/k3s server --cluster-cidr=10.2.0.0/16 --service-cidr=10.3.0.0/16 --cluster-dns=10.3.0.10 --kube-controller-manager-arg='leader-elect=false' --disable-cloud-controller --kube-scheduler-arg='leader-elect=false' --snapshotter=native --flannel-backend=vxlan ") @@ -67,7 +67,7 @@ func init() { config.K3SContainerDisk = util.Getenv("K3S_CONTAINER_DISK", config.DockerSHMSize) config.K3SAgentString = util.Getenv("K3S_AGENT_STRING", "/usr/local/bin/k3s agent --snapshotter=native --flannel-backend=vxlan ") config.K3SAgentMax, _ = strconv.Atoi(util.Getenv("K3S_AGENT_COUNT", "1")) - config.K3SAgentCPU, _ = strconv.ParseFloat(util.Getenv("K3S_AGENT_CPU", "0.1"), 64) + config.K3SAgentCPU, _ = strconv.ParseFloat(util.Getenv("K3S_AGENT_CPU", "2.0"), 64) config.K3SAgentMEM, _ = strconv.ParseFloat(util.Getenv("K3S_AGENT_MEM", "2000"), 64) config.K3SAgentDISK, _ = strconv.ParseFloat(util.Getenv("K3S_AGENT_DISK", "10000"), 64) config.K3SToken = util.Getenv("K3S_TOKEN", "123456789") From 49b1bb7b5ec46be0188b094c95237af6a7268542 Mon Sep 17 00:00:00 2001 From: Sarvesh Bedekar Date: Thu, 26 Oct 2023 16:14:21 +0530 Subject: [PATCH 4/5] Fixed Call for Cluster Restart --- .version.json | 2 +- api/V0ClusterRestart.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.version.json b/.version.json index 13af746..ef017d8 100644 --- a/.version.json +++ b/.version.json @@ -1 +1 @@ -{"m3sVersion": { "gitVersion": "v0.4.0-46-g51a13dd", "buildDate": "2023-08-08T20:43:03Z"}} +{"m3sVersion": { "gitVersion": "231011-6d47b96", "buildDate": "2023-10-11T00:00:00Z"}} diff --git a/api/V0ClusterRestart.go b/api/V0ClusterRestart.go index ca81560..19e5aad 100644 --- a/api/V0ClusterRestart.go +++ b/api/V0ClusterRestart.go @@ -23,6 +23,8 @@ func (e *API) V0ClusterRestart(w http.ResponseWriter, r *http.Request) { return } + e.ClusterRestart() + w.Header().Set("Content-Type", "application/json; charset=utf-8") w.Header().Set("Api-Service", "v0") } From 32b06390b6de4684b5f70c0c6739ac0f2fca10b3 Mon Sep 17 00:00:00 2001 From: Sarvesh Bedekar Date: Thu, 26 Oct 2023 16:17:35 +0530 Subject: [PATCH 5/5] Revert Version to aventer --- .version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.version.json b/.version.json index ef017d8..ef108d3 100644 --- a/.version.json +++ b/.version.json @@ -1 +1 @@ -{"m3sVersion": { "gitVersion": "231011-6d47b96", "buildDate": "2023-10-11T00:00:00Z"}} +{"m3sVersion": { "gitVersion": "v0.4.0-46-g51a13dd", "buildDate": "2023-08-08T20:43:03Z"}} \ No newline at end of file