From 4b2cedd9b54dae635fe579a2b01e964f7a3aeea3 Mon Sep 17 00:00:00 2001 From: Arik Kfir Date: Wed, 1 Nov 2017 23:59:50 +0200 Subject: [PATCH] Migrate build, deploy & release system to BuildKite. Also remove support for Cloudflare file-based authentication, relying solely on environment variables for authentication info to the Docker entry-point. --- .buildkite/build.pipeline.yml | 6 ++++++ .buildkite/release.pipeline.yml | 9 +++++++++ .travis.yml | 16 ---------------- .travis/build.sh | 12 ------------ README.md | 6 ++++-- cloudflared.sh | 18 +++++++++--------- 6 files changed, 28 insertions(+), 39 deletions(-) create mode 100644 .buildkite/build.pipeline.yml create mode 100644 .buildkite/release.pipeline.yml delete mode 100644 .travis.yml delete mode 100755 .travis/build.sh diff --git a/.buildkite/build.pipeline.yml b/.buildkite/build.pipeline.yml new file mode 100644 index 0000000..4e4992e --- /dev/null +++ b/.buildkite/build.pipeline.yml @@ -0,0 +1,6 @@ +steps: + + - label: Build Docker image + command: + - gcloud docker -- build --tag gcr.io/infolinks-gcr/k8s-cloudflared:${BUILDKITE_COMMIT} . + - gcloud docker -- push gcr.io/infolinks-gcr/k8s-cloudflared:${BUILDKITE_COMMIT} diff --git a/.buildkite/release.pipeline.yml b/.buildkite/release.pipeline.yml new file mode 100644 index 0000000..a285cfa --- /dev/null +++ b/.buildkite/release.pipeline.yml @@ -0,0 +1,9 @@ +steps: + + - label: Build versioned Docker image + command: + - gcloud docker -- pull gcr.io/infolinks-gcr/k8s-cloudflared:${BUILDKITE_COMMIT} + - gcloud docker -- tag gcr.io/infolinks-gcr/k8s-cloudflared:${BUILDKITE_COMMIT} infolinks/k8s-cloudflared:${VERSION} + - gcloud docker -- push infolinks/k8s-cloudflared:${VERSION} + - gcloud docker -- tag gcr.io/infolinks-gcr/k8s-cloudflared:${BUILDKITE_COMMIT} infolinks/k8s-cloudflared:latest + - gcloud docker -- push infolinks/k8s-cloudflared:latest diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index da695a9..0000000 --- a/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -language: generic -sudo: required -services: - - docker -before_script: - - docker login -u "${DOCKERHUB_USERNAME}" -p "${DOCKERHUB_PASSWORD}" -script: - - .travis/build.sh -after_script: - - | - if [[ "${TRAVIS_BRANCH}" == "master" ]]; then - docker run infolinks/github-release \ - --token="${GITHUB_ACCESS_TOKEN}" \ - --repo="${TRAVIS_REPO_SLUG}" \ - --commit="${TRAVIS_COMMIT}" - fi diff --git a/.travis/build.sh b/.travis/build.sh deleted file mode 100755 index 0fe4706..0000000 --- a/.travis/build.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e - -docker build -t infolinks/k8s-cloudflared:${TRAVIS_COMMIT} . - -if [[ ${TRAVIS_TAG} =~ ^v[0-9]+$ ]]; then - docker tag infolinks/k8s-cloudflared:${TRAVIS_COMMIT} infolinks/k8s-cloudflared:${TRAVIS_TAG} - docker push infolinks/k8s-cloudflared:${TRAVIS_TAG} - docker tag infolinks/k8s-cloudflared:${TRAVIS_COMMIT} infolinks/k8s-cloudflared:latest - docker push infolinks/k8s-cloudflared:latest -fi diff --git a/README.md b/README.md index 8a4f104..cacb314 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # k8s-cloudflared -[![Build Status](https://travis-ci.org/infolinks/k8s-cloudflared.svg?branch=master)](https://travis-ci.org/infolinks/k8s-cloudflared) +[![Build status](https://badge.buildkite.com/8e3145c6e8516acd680b71ea97e5bfa18073f9ee4eb286126c.svg)](https://buildkite.com/infolinks/k8s-cloudflared) Container for continually updating Cloudflare DNS records for Kubernetes `Service` and `Ingress` objects found in a cluster. @@ -42,7 +42,9 @@ to point to `1.2.3.4` in Cloudflare. ## Ingress Resources -The same applies to `Ingress` resources in the cluster. +The same applies to `Ingress` resources in the cluster, but you don't +have to define the `dns` annotation - the host names will be taken +automatically from the host rules. ## Deployment diff --git a/cloudflared.sh b/cloudflared.sh index d3cc580..e6bf725 100755 --- a/cloudflared.sh +++ b/cloudflared.sh @@ -1,28 +1,28 @@ #!/usr/bin/env bash -AUTH_EMAIL_FILE=./conf/cf_auth_email.txt -AUTH_KEY_FILE=./conf/cf_auth_key.txt -DOMAIN_FILE=./conf/cf_domain.txt +# small IntelliJ hack to prevent warning on non-existing variables +if [[ "THIS_WILL_NEVER_BE_TRUE" == "true" ]]; then + DOMAIN=${DOMAIN} + AUTH_EMAIL=${AUTH_EMAIL} + AUTH_KEY=${AUTH_KEY} +fi while true; do # read domain name - [[ -e "${DOMAIN_FILE}" ]] && DOMAIN=$(cat ${DOMAIN_FILE}) if [[ -z "${DOMAIN}" ]]; then - echo "DOMAIN not defined, and empty Cloudflare domain at '${DOMAIN_FILE}'!" >&2 + echo "DOMAIN environment variable not defined" >&2 exit 1 fi # read Cloudflare authentication Email - [[ -e "${AUTH_EMAIL_FILE}" ]] && AUTH_EMAIL=$(cat ${AUTH_EMAIL_FILE}) if [[ -z "${AUTH_EMAIL}" ]]; then - echo "AUTH_EMAIL not defined, and empty Cloudflare authentication Email at '${AUTH_EMAIL_FILE}'!" >&2 + echo "AUTH_EMAIL environment variable not defined" >&2 exit 1 fi # read Cloudflare authentication key - [[ -e "${AUTH_KEY_FILE}" ]] && AUTH_KEY=$(cat ${AUTH_KEY_FILE}) if [[ -z "${AUTH_KEY}" ]]; then - echo "AUTH_KEY not defined, and empty Cloudflare authentication key at '${AUTH_KEY_FILE}'!" >&2 + echo "AUTH_KEY environment variable not defined" >&2 exit 1 fi