mirror of https://github.com/kubernetes/kops.git
CI: Add container build
Add a simple Dockerfile that can build kops, and a short README on how to build it. This generates a 425M image, which is about as tight as I could get it in a short amount of work without just busting apart the golang:1.6-alpine image to compress the Go layer itself. It's good enough for what I'm planning to use it for: CI builds. Along the way: Fix-up .gitignore to include more from k8s/.gitignore (include editor ones, and terraform output dir).
This commit is contained in:
parent
d95a969f8d
commit
39301f469b
|
@ -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/
|
||||
|
|
|
@ -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"
|
|
@ -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`.
|
Loading…
Reference in New Issue