Skip to content

Commit

Permalink
Merge pull request kubernetes#5643 from mwielgus/balancer-main
Browse files Browse the repository at this point in the history
Balancer - main.go and yamls
  • Loading branch information
k8s-ci-robot authored Apr 12, 2023
2 parents 23843f7 + fb425d8 commit f173888
Show file tree
Hide file tree
Showing 9 changed files with 895 additions and 3 deletions.
6 changes: 6 additions & 0 deletions balancer/Dockerfile
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"]
59 changes: 59 additions & 0 deletions balancer/Makefile
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

89 changes: 89 additions & 0 deletions balancer/deploy/controller.yaml
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
Loading

0 comments on commit f173888

Please sign in to comment.