Skip to content

Commit

Permalink
Merge branch 'master' into 404-server-parse-flags
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-paul committed Aug 3, 2016
2 parents 167d3a7 + bbeda32 commit 8f50ec9
Show file tree
Hide file tree
Showing 7,960 changed files with 2,429,394 additions and 928,008 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 2 additions & 2 deletions 404-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM busybox
FROM BASEIMAGE
MAINTAINER Prashanth B <[email protected]>
ADD server server
COPY server /
ENTRYPOINT ["/server"]
64 changes: 58 additions & 6 deletions 404-server/Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,69 @@
# Copyright 2016 The Kubernetes Authors All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Build the default backend binary or image for amd64, arm, arm64 and ppc64le
#
# Usage:
# [PREFIX=gcr.io/google_containers/defaultbackend] [ARCH=amd64] [TAG=1.1] make (server|container|push)


all: push

# 0.0 shouldn't clobber any released builds
TAG = 0.0
PREFIX = gcr.io/google_containers/defaultbackend
TAG=1.1
PREFIX?=gcr.io/google_containers/defaultbackend
ARCH?=amd64
GOLANG_VERSION=1.6
TEMP_DIR:=$(shell mktemp -d)

# Set default base image dynamically for each arch
ifeq ($(ARCH),amd64)
BASEIMAGE?=busybox
endif
ifeq ($(ARCH),arm)
BASEIMAGE?=armel/busybox
endif
ifeq ($(ARCH),arm64)
BASEIMAGE?=aarch64/busybox
endif
ifeq ($(ARCH),ppc64le)
BASEIMAGE?=ppc64le/busybox
endif

server: server.go
CGO_ENABLED=0 GOOS=linux godep go build -a -installsuffix cgo -ldflags '-w' -o server ./server.go
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) GOARM=6 go build -a -installsuffix cgo -ldflags '-w' -o server ./server.go

container: server
docker build -t $(PREFIX):$(TAG) .
container:
# Copy the whole directory to a temporary dir and set the base image
cp -r ./* $(TEMP_DIR)
cd $(TEMP_DIR) && sed -i "s|BASEIMAGE|$(BASEIMAGE)|g" Dockerfile

# Compile the binary inside a container for reliable builds
docker run --rm -it -v $(TEMP_DIR):/build golang:$(GOLANG_VERSION) /bin/bash -c "make -C /build server ARCH=$(ARCH)"

docker build -t $(PREFIX)-$(ARCH):$(TAG) $(TEMP_DIR)

rm -rf $(TEMP_DIR)

push: container
gcloud docker push $(PREFIX)-$(ARCH):$(TAG)

push-legacy: container
ifeq ($(ARCH),amd64)
# Backward compatibility. TODO: deprecate this image tag
docker tag -f $(PREFIX)-$(ARCH):$(TAG) $(PREFIX):$(TAG)
gcloud docker push $(PREFIX):$(TAG)
endif

clean:
rm -f server
5 changes: 5 additions & 0 deletions 404-server/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
assignees:
- bprashanth
- luxas
- mikedanese

33 changes: 33 additions & 0 deletions 404-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 404-server (default backend)

404-server is a simple webserver that satisfies the ingress, which means it has to do two things:

1. Serves a 404 page at `/`
2. Serves 200 on a `/healthz`

## How to release:

The `404-server` Makefile supports multiple architecures, which means it may cross-compile and build an docker image easily.
If you are releasing a new version, please bump the `TAG` value in the `Makefile` before building the images.

How to build and push all images:
```
# Build for linux/amd64 (default)
$ make push
$ make push ARCH=amd64
# ---> gcr.io/google_containers/defaultbackend-amd64:TAG
$ make push-legacy ARCH=amd64
# ---> gcr.io/google_containers/defaultbackend:TAG (image with backwards compatible naming)
$ make push ARCH=arm
# ---> gcr.io/google_containers/defaultbackend-arm:TAG
$ make push ARCH=arm64
# ---> gcr.io/google_containers/defaultbackend-arm64:TAG
$ make push ARCH=ppc64le
# ---> gcr.io/google_containers/defaultbackend-ppc64le:TAG
```

Of course, if you don't want to push the images, just run `make container`
4 changes: 4 additions & 0 deletions OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
assignees:
- bprashanth
- eparis
- lavalamp
38 changes: 31 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ that aren't part of the Kubernetes core.

The code must be checked out as a subdirectory of `k8s.io`, and not `github.com`.

```sh
```shell
mkdir -p $GOPATH/src/k8s.io
cd $GOPATH/src/k8s.io
# Replace "$YOUR_GITHUB_USERNAME" below with your github username
git clone https://github.com/kubernetes/contrib.git
git clone https://github.com/$YOUR_GITHUB_USERNAME/contrib.git
cd contrib
```

Expand All @@ -24,14 +24,38 @@ contrib contains multiple tiny projects, each with their own dependencies. Each
in contrib/ has it's own Godeps.json. For example the Godeps.json for Ingress
is Ingress/Godeps/Godeps.json. This means that godeps commands like `godep restore`
or `godep test` work in the root directory. Theys should be run from inside the
subproject directory you want to test
subproject directory you want to test.

## Prerequisites for updating Godeps

Since we vendor godeps through `/vendor` vs the old style `Godeps/_workspace`, you either need a more recent install of go and godeps, or you need to set `GO15VENDOREXPERIMENT=1`. Eg:
```shell
$ godep version
godep v74 (linux/amd64/go1.6.1)
$ go version
go version go1.6.1 linux/amd64
$ godep save ./...
```

Will automatically save godeps to `vendor/` instead of `_workspace/`.
If you have an older version of go, you must run:
```shell
$ GO15VENDOREXPERIMENT=1 godep save ./...
```

If you have an older version of godep, you must update it:
```shell
$ go get github.com/tools/godep
$ cd $GOPATH/src/github.com/tools/godep
$ go build -o godep *.go
```

## Updating Godeps

The most common dep to update is obviously going to be kuberetes proper. Updating
kubernetes and it's dependancies in the Ingress subproject for example can be done
as follows:
```
as follows (the example assumes you Kubernetes repo is rooted at `$GOPATH/src/github.com/kubernetes`, `s/github.com\/kubernetes/k8s.io/` as required):
```shell
cd $GOPATH/src/github.com/kubernetes/contrib/ingress
godep restore
go get -u github.com/kubernetes/kubernetes
Expand All @@ -46,7 +70,7 @@ git commit

Other deps are similar, although if the dep you wish to update is included from
kubernetes we probably want to stay in sync using the above method. If the dep is not in kubernetes proper something like the following should get you a nice clean result:
```
```shell
cd $GOPATH/src/github/kubernetes/contrib/ingress
godep restore
go get -u $SOME_DEP
Expand All @@ -59,6 +83,6 @@ git commit
## Running all tests

To run all go test in all projects do this:
```
```shell
./hack/for-go-proj.sh test
```
Loading

0 comments on commit 8f50ec9

Please sign in to comment.