Skip to content

Commit

Permalink
ADD: cni flags to cri-docker.
Browse files Browse the repository at this point in the history
ADD: timeout for agent start.
ADD: disk capacity
CHANGE: improve heartbeat

Added docker parameter for CPU Limit

Updated Makefile to explicitly specific amd64 in build command

Updated Default Values for Agent & Server CPU

Fixed Call for Cluster Restart

pr-13 (#49)

Import from: AVENTER-UG#13

Changes

- Update to controller/makefile to add BUILD_ARCH explicitly in normal build command for situations where the controller might be built from an Apple Silicon based machine for non Apple Silicon environments
- Update to agent.go & server.go files to add DockerParameter of CPU Allocation for the container to be made aware of the CPU Allocations, this also exposes the value within the container's cgroup files which then can be used downstream for some applications like limiting the resource access of kubernetes..
- Updated .gitignore for adding controller/sbom

Co-authored-by: Sarvesh Bedekar <[email protected]>
Reviewed-on: https://gitea:3000/AVENTER/mesos-m3s/pulls/49

CHANGE: mesos cli plugin to the new version of avmesos-cli.
UPDATE: changelog.

Revert Version to aventer

Added Capability Disclosure in API, fired go mod tidy for cleanup

pr-14 (#51)

Changes

 -   Added missing call in api/V0ClusterRestart.go to the function ClusterRestart from the controller

Import from: AVENTER-UG#14

Co-authored-by: Sarvesh Bedekar <[email protected]>
Co-authored-by: Sarvesh Bedekar <[email protected]>
Reviewed-on: https://gitea:3000/AVENTER/mesos-m3s/pulls/51

UPDATE: changelog with fix info about clusterrestart.
  • Loading branch information
andreaspeters authored and Sarvesh Bedekar committed Oct 27, 2023
1 parent 40133dd commit 4b62692
Show file tree
Hide file tree
Showing 21 changed files with 216 additions and 506 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ controller/controller.arm64
docs/examples/config.cnf
docs/examples/create-user.yaml
mesos-m3s.code-workspace
controller/sbom.txt
local-env.sh
2 changes: 1 addition & 1 deletion .version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"m3sVersion": { "gitVersion": "v0.4.0-46-g51a13dd", "buildDate": "2023-08-08T20:43:03Z"}}
{"m3sVersion": { "gitVersion": "v0.4.0-46-g51a13dd", "buildDate": "2023-08-08T20:43:03Z"}}
42 changes: 42 additions & 0 deletions api/V0CapabilitiesDisclosure.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package api

import (
"encoding/json"
"net/http"

"github.com/sirupsen/logrus"
)

// V0CapabilitiesDisclosure gives out the current capabilities supported in this m3s framework version.
// Helpful when you may have multiple versions running in your environment and need feature flagging on downstream applications.
// example:
// curl -X GET 127.0.0.1:10000/v0/capabilities
func (e *API) V0CapabilitiesDisclosure(w http.ResponseWriter, r *http.Request) {
logrus.WithField("func", "api.V0CapabilitiesDisclosure").Debug("Call")

if !e.CheckAuth(r, w) {
w.WriteHeader(http.StatusUnauthorized)
return
}

w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.Header().Set("Api-Service", "v0")

capabilities := []string{}
capabilities = append(capabilities, "cluster-restart")
capabilities = append(capabilities, "cluster-start")
capabilities = append(capabilities, "cluster-shutdown")
capabilities = append(capabilities, "k3s-count-agents")
capabilities = append(capabilities, "k3s-count-servers")
capabilities = append(capabilities, "get-kubeconfig")
capabilities = append(capabilities, "get-kubeversion")
capabilities = append(capabilities, "scale-agent")
capabilities = append(capabilities, "scale-server")
capabilities = append(capabilities, "scale-datastore")
capabilities = append(capabilities, "scale-datastore")
capabilities = append(capabilities, "status-k3s")
capabilities = append(capabilities, "status-m3s")

response, _ := json.Marshal(capabilities)
w.Write(response)
}
2 changes: 2 additions & 0 deletions api/V0ClusterRestart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ func (e *API) Commands() *mux.Router {
rtr.HandleFunc("/api/m3s/v0/cluster/shutdown", e.V0ClusterShutdown).Methods("PUT")
rtr.HandleFunc("/api/m3s/v0/cluster/start", e.V0ClusterStart).Methods("PUT")
rtr.HandleFunc("/api/m3s/v0/cluster/restart", e.V0ClusterRestart).Methods("PUT")
rtr.HandleFunc("/api/m3s/v0/capabilities", e.V0CapabilitiesDisclosure).Methods("GET")
rtr.NotFoundHandler = http.HandlerFunc(e.NotFound)

return rtr
}

Expand Down
3 changes: 2 additions & 1 deletion bootstrap/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ done

## dockerd is a part of the uses avhost/ubuntu-m3s:focal docker image
exec /usr/local/bin/dockerd &
exec /usr/bin/cri-dockerd &
sleep 20
exec /usr/bin/cri-dockerd --network-plugin=cni --cni-bin-dir=/usr/lib/cni --cni-conf-dir=/var/lib/rancher/k3s/agent/etc/cni/net.d/ &

curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=${INSTALL_K3S_VERSION} INSTALL_K3S_SKIP_ENABLE=${INSTALL_K3S_SKIP_ENABLE=$} INSTALL_K3S_SKIP_START=${INSTALL_K3S_SKIP_START} sh -s - --docker
curl https://raw.githubusercontent.com/AVENTER-UG/mesos-m3s/${BRANCH}/bootstrap/default.yaml > $MESOS_SANDBOX/default.yaml
Expand Down
10 changes: 3 additions & 7 deletions bootstrap/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ subjects:

---

apiVersion: apps/v1
kind: Deployment
apiVersion: apps/v1
metadata:
labels:
k8s-app: kubernetes-dashboard
Expand All @@ -181,14 +181,9 @@ spec:
args:
- --auto-generate-certificates
- --namespace=kubernetes-dashboard
# Uncomment the following line to manually specify Kubernetes API server Host
# If not specified, Dashboard will attempt to auto discover the API server and connect
# to it. Uncomment only if the default does not work.
# - --apiserver-host=http://my-address:port
volumeMounts:
- name: kubernetes-dashboard-certs
mountPath: /certs
# Create on-disk volume to store exec logs
- mountPath: /tmp
name: tmp-volume
livenessProbe:
Expand Down Expand Up @@ -235,8 +230,8 @@ spec:

---

apiVersion: apps/v1
kind: Deployment
apiVersion: apps/v1
metadata:
labels:
k8s-app: dashboard-metrics-scraper
Expand Down Expand Up @@ -287,6 +282,7 @@ spec:
- name: tmp-volume
emptyDir: {}


---

apiVersion: v1
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
k3s during the bootstrap process.
- Rewrite bootstrap server as Kubernetes Controller to simplify the bootstrap process and optimize cluster health checks.
- Add Kubernetes taint to prevent pods to run on the Kubernetes management node. With K§S_ENABLE_TAINT you can enable(true and default)/disable(disable) these feature.
- Change the mesos cli plugin to avmesos-cli.
- Fix ClusterRestart API (thanks to https://github.com/itsoksarvesh).

## v0.4.0

Expand Down
2 changes: 1 addition & 1 deletion controller/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions docs/src/cli/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,10 @@ Commands:

## Install Mesos-CLI

Download the mesos-cli binary for linux from [here](https://www.aventer.biz/files/sw/Linux/mesos-cli.zip). Extract
the mesos-cli and copy the file into your PATH directory.
The Apache Mesos CLI can be installed via python pip.

```bash

pip install avmesos-cli

```
1 change: 0 additions & 1 deletion docs/src/vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ The following environment variables are available:
| BOOTSTRAP_URL | https://raw.githubusercontent.com/AVENTER-UG/mesos-m3s/master/bootstrap/bootstrap.sh | Bootstrap Script to pre configure the server/agent container |
| CGROUP_V2 | false | Enable support for CGroupV2 |
| CLEANUP_WAIT | 3m | Time when M3s start to cleanup unhealthy nodes |
| DOCKER_CNI | bride | If we do not use Mesos CNI, we can also use docker network |
| DOCKER_SOCK | | The docker sock file |
| DOCKER_ULIMIT | 1048576 | Number of max open files (soft and hardlimit) |
| DOCKER_MEMORY_SWAP | 1000 | Limit how much memory swap the container could use (in MB)|
Expand Down
36 changes: 1 addition & 35 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,19 @@ require (
github.com/go-redis/redis/v9 v9.0.0-rc.2
github.com/gogo/protobuf v1.3.2
github.com/gorilla/mux v1.8.0
github.com/hashicorp/go-version v1.6.0
github.com/sirupsen/logrus v1.9.0
k8s.io/api v0.27.2
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
k8s.io/component-base v0.26.1 // indirect
)
require github.com/fsnotify/fsnotify v1.6.0 // indirect

require (
github.com/AVENTER-UG/go-logrus-formatter v0.5.4 // indirect
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/go-logr/logr v1.2.3 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
Expand All @@ -54,39 +31,28 @@ require (
github.com/hashicorp/go-sockaddr v1.0.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/vault/api v1.9.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/russross/blackfriday v1.6.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/net v0.8.0 // indirect
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/term v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apimachinery v0.27.2 // indirect
k8s.io/client-go v0.27.2 // indirect
k8s.io/klog/v2 v2.90.1 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect
sigs.k8s.io/controller-runtime v0.14.6
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
Loading

0 comments on commit 4b62692

Please sign in to comment.