-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5643 from mwielgus/balancer-main
Balancer - main.go and yamls
- Loading branch information
Showing
9 changed files
with
895 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM gcr.io/distroless/static:latest | ||
MAINTAINER Marcin Wielgus "[email protected]" | ||
|
||
COPY balancer / | ||
|
||
ENTRYPOINT ["/balancer"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
all: build | ||
|
||
FLAGS= | ||
OFFICIAL_NAME=balancer | ||
|
||
build: clean | ||
go build . | ||
|
||
build-linux-amd64: clean | ||
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build . | ||
|
||
test-unit: clean | ||
go test --test.short -race ./... $(FLAGS) | ||
|
||
docker-build: | ||
ifndef REGISTRY | ||
ERR = $(error REGISTRY is undefined) | ||
$(ERR) | ||
endif | ||
ifndef TAG | ||
ERR = $(error TAG is undefined) | ||
$(ERR) | ||
endif | ||
docker build --pull -t ${REGISTRY}/${OFFICIAL_NAME}:${TAG} . | ||
|
||
docker-push: | ||
ifndef REGISTRY | ||
ERR = $(error REGISTRY is undefined) | ||
$(ERR) | ||
endif | ||
ifndef TAG | ||
ERR = $(error TAG is undefined) | ||
$(ERR) | ||
endif | ||
docker push ${REGISTRY}/${OFFICIAL_NAME}:${TAG} | ||
|
||
docker-builder: | ||
docker build -t vpa-autoscaling-builder ../vertical-pod-autoscaler/builder | ||
|
||
build-in-docker: clean docker-builder | ||
docker run -v `pwd`/..:/gopath/src/k8s.io/autoscaler vpa-autoscaling-builder:latest bash -c 'cd /gopath/src/k8s.io/autoscaler/balancer && make build-linux-amd64' | ||
|
||
build-image-in-docker: build-in-docker docker-build | ||
|
||
test-in-docker: build-in-docker | ||
docker run -v `pwd`/..:/gopath/src/k8s.io/autoscaler vpa-autoscaling-builder:latest bash -c 'cd /gopath/src/k8s.io/autoscaler/balancer && make test-unit' | ||
|
||
release: build-image-in-docker docker-push | ||
@echo "Full in-docker release ${OFFICIAL_NAME}:${TAG} completed" | ||
|
||
clean: | ||
rm -f balancer | ||
|
||
format: | ||
test -z "$$(find . -path ./vendor -prune -type f -o -name '*.go' -exec gofmt -s -d {} + | tee /dev/stderr)" || \ | ||
test -z "$$(find . -path ./vendor -prune -type f -o -name '*.go' -exec gofmt -s -w {} + | tee /dev/stderr)" | ||
|
||
.PHONY: all build test-unit clean format release | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: balancer-controller | ||
namespace: kube-system | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: balancer-controller | ||
namespace: kube-system | ||
rules: | ||
- apiGroups: | ||
- balancer.x-k8s.io | ||
resources: | ||
- balancers | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- patch | ||
- update | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- apps | ||
resources: | ||
- deployments/scale | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- patch | ||
- update | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- events | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- create | ||
- patch | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: balancer-controller | ||
namespace: kube-system | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: balancer-controller | ||
subjects: | ||
- kind: ServiceAccount | ||
name: balancer-controller | ||
namespace: kube-system | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: balancer-controller | ||
namespace: kube-system | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: balancer-controller | ||
template: | ||
metadata: | ||
labels: | ||
app: balancer-controller | ||
spec: | ||
serviceAccountName: balancer-controller | ||
containers: | ||
- name: controller | ||
image: gcr.io/gke-autoscaling-gcr/balancer:0.1.1 | ||
imagePullPolicy: Always | ||
args: ["-v","4"] | ||
resources: | ||
requests: | ||
cpu: 100m |
Oops, something went wrong.