Skip to content

Commit

Permalink
Merge pull request #314 from zmerlynn/container_build
Browse files Browse the repository at this point in the history
CI: Add container build
  • Loading branch information
justinsb authored Aug 16, 2016
2 parents d95a969 + 39301f4 commit b5b173c
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
46 changes: 43 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,46 @@
.build/
# OSX leaves these everywhere on SMB shares
._*

# IntelliJ
*.iml
# OSX trash
.DS_Store

# Eclipse files
.classpath
.project
.settings/**

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

# Vscode files
.vscode

# Emacs save files
*~
\#*\#
.\#*

# Vim-related files
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
*.un~
Session.vim
.netrwhist

# Go test binaries
*.test

# Mercurial files
**/.hg
**/.hg*

# Vagrant
.vagrant
network_closure.sh

# make-related metadata
/.make/

# Terraform plans get put here
/out/
28 changes: 28 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM golang:1.6-alpine

# KOPS_GITISH: Modify to build at an explicit tag/gitish
ARG KOPS_GITISH=HEAD

# KUBECTL_SOURCE: Change to kubernetes-dev/ci for CI
ARG KUBECTL_SOURCE=kubernetes-release/release

# KUBECTL_TRACK: Currently latest from KUBECTL_SOURCE. Change to latest-1.3.txt, etc. if desired.
ARG KUBECTL_TRACK=latest.txt

ARG KUBECTL_ARCH=linux/amd64

RUN apk add --no-cache --update build-base curl git mercurial --virtual .kops-deps && \
go get -d k8s.io/kops && \
cd "${GOPATH}/src/k8s.io/kops" && git fetch origin && git reset --hard "${KOPS_GITISH}" && git clean -xdf && go get -d . && \
make && \
MODELS=$(readlink "${GOPATH}/bin/models") && rm "${GOPATH}/bin/models" && mv "${MODELS}" "${GOPATH}/bin/models" && \
GITISH=$(git show-ref -s --abbrev HEAD) && \
KUBECTL_VERSION=${KUBECTL_VERSION:-$(curl -SsL --retry 5 "https://storage.googleapis.com/${KUBECTL_SOURCE}/${KUBECTL_TRACK}")} && \
echo "=== Fetching kubectl ${KUBECTL_VERSION} ===" && \
curl -SsL --retry 5 "https://storage.googleapis.com/${KUBECTL_SOURCE}/${KUBECTL_VERSION}/${KUBECTL_ARCH}/kubectl" > /usr/local/bin/kubectl && \
chmod +x /usr/local/bin/kubectl && \
/usr/local/bin/kubectl version --client && \
cd / && rm -rf "${GOPATH}/src" && rm -rf "${GOPATH}/pkg" && rm -rf "/usr/local/go" && apk del .kops-deps && \
echo "=== Built kops at ${GITISH}, fetched kubectl ${KUBECTL_VERSION} ==="

CMD "/go/bin/kops"
15 changes: 15 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Running Kops in Docker

The Dockerfile here is offered primarily as a way to build continuous
integration versions of `kops` until we figure out how we want to
release/package it.

To use it, e.g. (assumes your `$HOME` is correct and that `$KOPS_STATE_STORE` is correct):
```shell
$ docker build -t kops .
$ KOPS="docker run -v $HOME/.aws:/root/.aws:ro -v $HOME/.ssh:/root/.ssh:ro -v $HOME/.kube:/root/.kube -it kops kops --state=$KOPS_STATE_STORE"
```

This creates a shell variable that runs the `kops` container with `~/.aws` mounted in (for AWS credentials), `~/.ssh` mounted in (for SSH keys, for AWS specifically), and `~/.kube` mounted in (so `kubectl` can add newly created clusters).

After this, you can just use `$KOPS` where you would generally use `kops`, e.g. `$KOPS get cluster`.

0 comments on commit b5b173c

Please sign in to comment.