Skip to content

Commit

Permalink
Build pod_nanny in a container.
Browse files Browse the repository at this point in the history
  • Loading branch information
x13n committed Jun 21, 2017
1 parent 93942ef commit 6c72799
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 18 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
.project
.settings/**

# Files generated by JetBrains IDEs, e.g. IntelliJ IDEA
.idea/
*.iml

# Emacs save files
*~
\#*\#
Expand Down
1 change: 1 addition & 0 deletions addon-resizer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pod_nanny
2 changes: 1 addition & 1 deletion addon-resizer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
FROM busybox
MAINTAINER Quintin Lee "[email protected]"

ADD build/pod_nanny pod_nanny
ADD pod_nanny pod_nanny

CMD ./pod_nanny
47 changes: 33 additions & 14 deletions addon-resizer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,58 @@

# Procedure for change:
# 1. Bump the tag number.
# 2. Create an image for the kubernetes user on Dockerhub and push there: make build push
# 2. Create an image for the kubernetes user on Dockerhub and push there: make dev-release
# 3. Temporarily adjust any config files etc. that reference gcr.io/google_containers/addon-resizer:$(TAG)
# to use kubernetes/addon-resizer:$(TAG) instead.
# 4. Test etc.
# 5. Issue PR.
# 6. When PR is approved make the gcr.io version of the image: make build push
# 7. Revert the references to kubernetes/addon-resizer:$(TAG) to gcr.io/google_containers/addon-resizer:$(TAG)
# 6. When PR is approved make the gcr.io version of the image (Change REGISTRY variable below first): make release
# 7. Revert the references to kubernetes/addon-resizer:$(TAG) to gcr.io/google_containers/addon-resizer:$(TAG)

OUT_DIR = build
PACKAGE = k8s.io/contrib/addon-resizer
PREFIX = gcr.io/google_containers
TAG = 2.0
all: build

# Rules for building the real image for deployment to gcr.io
PACKAGE = k8s.io/autoscaler/addon-resizer
REGISTRY = kubernetes
# Uncomment for release
# REGISTRY = gcr.io/google_containers
TAG = 2.0

deps:
go get -u github.com/tools/godep

compile: nanny/ deps
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 godep go build -a -o $(OUT_DIR)/pod_nanny nanny/main/pod_nanny.go
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 godep go build -a -o pod_nanny nanny/main/pod_nanny.go

test: nanny/
godep go test ${PACKAGE}/nanny -v

go: compile test

clean:
rm -rf build
rm -rf pod_nanny

build: go
docker build --pull -t ${PREFIX}/addon-resizer:$(TAG) .

docker: build
dev-release: build execute-release
echo "Release ${TAG} completed"

# Rules for building the real image for deployment to gcr.io

execute-release:
ifndef REGISTRY
ERR = $(error REGISTRY is undefined)
$(ERR)
endif
docker build --pull -t ${REGISTRY}/addon-resizer:${TAG} .
gcloud docker -- push ${REGISTRY}/addon-resizer:${TAG}

docker-builder:
docker build -t autoscaling-builder ../builder

build-in-docker: clean docker-builder
docker run -v `pwd`:/gopath/src/k8s.io/autoscaler/addon-resizer/ autoscaling-builder:latest bash -c 'cd /gopath/src/k8s.io/autoscaler/addon-resizer && make'

release: build-in-docker execute-release
echo "Full in-docker release ${TAG} completed"


push: docker
gcloud docker -- push ${PREFIX}/addon-resizer:$(TAG)
2 changes: 1 addition & 1 deletion builder/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
FROM gcr.io/google-containers/ubuntu-slim:0.8
MAINTAINER Marcin Wielgus "[email protected]"

RUN apt-get update && apt-get install --yes git wget make\
RUN apt-get update && apt-get install --yes git wget make gcc \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN wget https://storage.googleapis.com/golang/go1.8.3.linux-amd64.tar.gz \
Expand Down
4 changes: 2 additions & 2 deletions cluster-autoscaler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ format:
test -z "$$(find . -path ./vendor -prune -type f -o -name '*.go' -exec gofmt -s -w {} + | tee /dev/stderr)"

docker-builder:
docker build -t autoscalig-builder ../builder
docker build -t autoscaling-builder ../builder

build-in-docker: clean docker-builder
docker run -v `pwd`:/gopath/src/k8s.io/autoscaler/cluster-autoscaler/ autoscalig-builder:latest bash -c 'cd /gopath/src/k8s.io/autoscaler/cluster-autoscaler && make'
docker run -v `pwd`:/gopath/src/k8s.io/autoscaler/cluster-autoscaler/ autoscaling-builder:latest bash -c 'cd /gopath/src/k8s.io/autoscaler/cluster-autoscaler && make'

release: build-in-docker execute-release
echo "Full in-docker release ${TAG} completed"
Expand Down

0 comments on commit 6c72799

Please sign in to comment.