diff --git a/.gitignore b/.gitignore index 1610bede45444..69b10585aeb43 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 0000000000000..fba62d91c320e --- /dev/null +++ b/docker/Dockerfile @@ -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" diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000000000..45f63fcb601c4 --- /dev/null +++ b/docker/README.md @@ -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`.