Skip to content

Commit

Permalink
Adding circleci orb build and config
Browse files Browse the repository at this point in the history
Adding docker login.  Adding a makefile for testing locally.  Added notes to readme and contributing.

Adding orb examples

Updating Makefile to work with OSX

Updating to v9.0 for the orb release
  • Loading branch information
Andrew Suderman committed Jul 23, 2019
1 parent 943133a commit ccc1fd1
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 15 deletions.
53 changes: 50 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
version: 2
version: 2.1

orbs:
orb-tools: circleci/[email protected]

references:
docker_login: &docker_login
Expand Down Expand Up @@ -100,13 +103,12 @@ jobs:
- *docker_build
- *docker_push


workflows:
version: 2
build_and_test:
jobs:
- test
- build

release:
jobs:
- release:
Expand All @@ -115,3 +117,48 @@ workflows:
ignore: /.*/
tags:
only: /^v.*/

"Orb Test and Publish":
jobs:
- orb-tools/lint:
name: "lint-orb-files"
lint-dir: orb
filters:
branches:
only: /.*/
tags:
only: /.*/
- orb-tools/pack:
name: "pack-orb"
source-dir: orb
requires:
- "lint-orb-files"
filters:
branches:
only: /.*/
tags:
only: /.*/
- orb-tools/publish:
name: "publish-dev-branch-orb"
orb-ref: reactiveops/rok8s-scripts@dev:${CIRCLE_BRANCH}
publish-token-variable: CIRCLECI_DEV_API_TOKEN
attach-workspace: true
requires:
- "pack-orb"
filters:
branches:
only: /.*/
tags:
ignore: /.*/
- orb-tools/publish:
name: "publish-tagged-orb"
orb-ref: reactiveops/rok8s-scripts@${CIRCLE_TAG}
publish-token-variable: CIRCLECI_DEV_API_TOKEN
attach-workspace: true
requires:
- "pack-orb"
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.vscode
.DS_Store
orb.yml
3 changes: 3 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ always necessary to create a new issue in GitHub. In these cases, a branch with
* Submit a pull request.
* Mention the issue in your PR description. I.E. `Fixes #42`. This will ensure that your issue gets tagged with the PR.

## Orb development

There is a Makefile that can assist in validating and testing the orb locally. See the commands there for more info.

Attribution
===========
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
docs-index:
cat README.md \
| sed 's/\[\(.*\)\](\(\w\+\.md\))/[\1](https:\/\/github.com\/reactiveops\/rok8s-scripts\/tree\/master\/\2)/g' \
| sed 's/\[\(.*\)\](\/\?docs\/\(.*\))/[\1](\2)/g' \
| sed 's/\[\(.*\)\](\(\/.*\))/[\1](https:\/\/github.com\/reactiveops\/rok8s-scripts\/tree\/master\2)/g' \
| sed -E 's/\[(.*)\]\(([^\/]*\.md)\)/[\1](https:\/\/github.com\/reactiveops\/rok8s-scripts\/tree\/master\/\2)/g' \
| sed -E 's/\[(.*)\]\(\/*docs\/(.*)\)/[\1](\2)/g' \
| sed -E 's/\[(.*)\]\((\/.*)\)/[\1](https:\/\/github.com\/reactiveops\/rok8s-scripts\/tree\/master\2)/g' \
> docs/index.md
orb-validate:
circleci config pack orb/ > orb.yml
circleci orb validate orb.yml
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ There are many valid ways to configure CI pipelines, but to help you get started

Each new release of rok8s-scripts generates CI images for common workflows. These images include a set of common CI/CD dependencies, including Docker, Kubernetes, Helm, AWS, and Google Cloud client libraries. Starting with these images as a base for deployment workflows ensures that you don't need to spend any build time installing extra dependencies.

We currently include CI Images based on Alpine and Debian Stretch as our recommended starting points. The latest Debian Stretch release can be pulled from `quay.io/reactiveops/ci-images:v8-stretch`. A full list of image tags is available on our [Quay repository](https://quay.io/repository/reactiveops/ci-images).
We currently include CI Images based on Alpine and Debian Stretch as our recommended starting points. The latest Debian Stretch release can be pulled from `quay.io/reactiveops/ci-images:v9-stretch`. A full list of image tags is available on our [Quay repository](https://quay.io/repository/reactiveops/ci-images).

## Versioning v8.0.0 and beyond

Expand All @@ -80,6 +80,20 @@ You are okay with your pipeline breaking occasionally and having to upgrade thin

In this case, go ahead and pin to a major version such as `v8-alpine`

## Orbs

CircleCI has introduced the concept of reusable config in the form of [Orbs](https://circleci.com/orbs/). As of rok8s-scripts v9.0.0, ReactiveOps publishes an orb called `reactiveops/rok8s-scripts` in order to provide easier configuration inside of CircleCI.

## Further Reading

- [Building and Pushing Docker Images](/docs/docker.md)
- [Deploying to Kubernetes with Helm](/docs/helm.md)
- [Deploying to Kubernetes without Helm](/docs/without_helm.md)
- [Managing Kubernetes Secrets Securely](/docs/secrets.md)

### Cloud Specific Documentation
- [Amazon Web Services](/docs/aws.md)
- [Google Cloud](/docs/gcp.md)

### Contributing
- [Code of Conduct](CODE_OF_CONDUCT.md)
Expand Down
16 changes: 15 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ There are many valid ways to configure CI pipelines, but to help you get started

Each new release of rok8s-scripts generates CI images for common workflows. These images include a set of common CI/CD dependencies, including Docker, Kubernetes, Helm, AWS, and Google Cloud client libraries. Starting with these images as a base for deployment workflows ensures that you don't need to spend any build time installing extra dependencies.

We currently include CI Images based on Alpine and Debian Stretch as our recommended starting points. The latest Debian Stretch release can be pulled from `quay.io/reactiveops/ci-images:v8-stretch`. A full list of image tags is available on our [Quay repository](https://quay.io/repository/reactiveops/ci-images).
We currently include CI Images based on Alpine and Debian Stretch as our recommended starting points. The latest Debian Stretch release can be pulled from `quay.io/reactiveops/ci-images:v9-stretch`. A full list of image tags is available on our [Quay repository](https://quay.io/repository/reactiveops/ci-images).

## Versioning v8.0.0 and beyond

Expand All @@ -80,6 +80,20 @@ You are okay with your pipeline breaking occasionally and having to upgrade thin

In this case, go ahead and pin to a major version such as `v8-alpine`

## Orbs

CircleCI has introduced the concept of reusable config in the form of [Orbs](https://circleci.com/orbs/). As of rok8s-scripts v9.0.0, ReactiveOps publishes an orb called `reactiveops/rok8s-scripts` in order to provide easier configuration inside of CircleCI.

## Further Reading

- [Building and Pushing Docker Images](docker.md)
- [Deploying to Kubernetes with Helm](helm.md)
- [Deploying to Kubernetes without Helm](without_helm.md)
- [Managing Kubernetes Secrets Securely](secrets.md)

### Cloud Specific Documentation
- [Amazon Web Services](aws.md)
- [Google Cloud](gcp.md)

### Contributing
- [Code of Conduct](https://github.com/reactiveops/rok8s-scripts/tree/master/CODE_OF_CONDUCT.md)
Expand Down
4 changes: 2 additions & 2 deletions examples/ci/.circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ references:
deploy_steps: &deploy_steps
docker:
- image: quay.io/reactiveops/ci-images:v8-alpine
- image: quay.io/reactiveops/ci-images:v9-alpine
steps:
- checkout
- *set_environment_variables
Expand All @@ -24,7 +24,7 @@ references:
jobs:
imagebuild:
docker:
- image: quay.io/reactiveops/ci-images:v8-alpine
- image: quay.io/reactiveops/ci-images:v9-alpine
steps:
- checkout
- setup_remote_docker
Expand Down
2 changes: 1 addition & 1 deletion examples/ci/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ variables:
DOCKER_HOST: tcp://localhost:2375
DOCKER_DRIVER: overlay2

image: quay.io/reactiveops/ci-images:v8-alpine
image: quay.io/reactiveops/ci-images:v9-alpine
services:
- docker:dind

Expand Down
5 changes: 2 additions & 3 deletions examples/minimal/.circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ references:
jobs:
build_image:
docker:
- image: quay.io/reactiveops/ci-images:v8.0-stretch
- image: quay.io/reactiveops/ci-images:v9.0-stretch
steps:
- checkout
- setup_remote_docker
- *set_environment_variables
- *build_image
deploy:
docker:
- image: quay.io/reactiveops/ci-images:v8.0-stretch
- image: quay.io/reactiveops/ci-images:v9.0-stretch
steps:
- checkout
- setup_remote_docker
Expand All @@ -57,4 +57,3 @@ workflows:
filters:
branches:
only: master

2 changes: 1 addition & 1 deletion examples/minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ we run some of the scripts provided by rok8s-scripts. In particular, we use:
* `prepare-kubectl` to set up for pushing the latest image to our Kubernetes cluster
* `k8s-deploy-and-verify` to push our image to Kubernetes and make sure the deployment succeeded

We also use the rok8s-scripts CI image, `quay.io/reactiveops/ci-images:v8-stretch`,
We also use the rok8s-scripts CI image, `quay.io/reactiveops/ci-images:v9-stretch`,
to ensure rok8s-scripts and its dependencies are all available during the build and deploy jobs.

## Try it out
Expand Down
47 changes: 47 additions & 0 deletions orb/commands.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
commands:
set_env:
description: Sets the needed rok8s-scripts environment variables from Circle
steps:
- run: |
echo 'export CI_SHA1=$CIRCLE_SHA1' >> ${BASH_ENV}
echo 'export CI_BRANCH=$CIRCLE_BRANCH' >> ${BASH_ENV}
echo 'export CI_BUILD_NUM=$CIRCLE_BUILD_NUM' >> ${BASH_ENV}
echo 'export CI_TAG=$CIRCLE_TAG' >> ${BASH_ENV}
docker_login:
description: Log into a docker repo
parameters:
registry:
type: string
description: The name of the docker registry.
default: "quay.io"
username:
type: string
description: The username to use for the registry.
password-variable:
type: string
description: The environment variable name containing the password.
steps:
- run: |
docker login -u="<<parameters.username>>" -p="$<<parameters.password-variable>>" <<parameters.registry>>
docker_push:
description: Pushes a docker image using rok8s-scripts
parameters:
config:
type: string
description: The location of the rok8s-scripts config file
default: "deploy/build.config"
steps:
- run: |
docker-push -f << parameters.config >>
docker_build:
description: Builds a docker image using rok8s-scripts
parameters:
config:
type: string
description: The location of the rok8s-scripts config file
default: "deploy/build.config"
steps:
- setup_remote_docker
- run: |
docker-build -f << parameters.config >>
2 changes: 2 additions & 0 deletions orb/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version: "2.1"
description: "ReactiveOps rok8s-scripts. https://github.com/reactiveops/rok8s-scripts"
25 changes: 25 additions & 0 deletions orb/examples/docker-build-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
description: >
Use this example to build and push a docker
image using rok8s-scripts. This assumes that you
have a working rok8s-scripts configuration already
in place.
usage:
version: 2.1

orbs:
rok8s-scripts: reactiveops/[email protected]

workflows:
build_and_push:
jobs:
- rok8s/docker_build_and_push:
config_file: deploy/build.config
docker-login: true
username: "orgname+circleci"
registry: "quay.io"
password-variable: quay_token
context: org-global
filters:
branches:
only: master
47 changes: 47 additions & 0 deletions orb/jobs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
jobs:
docker_build_and_push:
parameters:
config_file:
description: "The location of the rok8s-scripts config file."
type: string
default: deploy/build.config
docker-login:
type: boolean
default: true
description: When true(default), perform a docker login before build and push.
registry:
type: string
description: The name of the docker registry. Only used if docker-login is true.
default: "quay.io"
username:
type: string
description: The username to use for the registry. Only used if docker-login is true.
default: ""
password-variable:
type: string
description: The environment variable name containing the password. Only used if docker-login is true.
default: ""
executor: ci-images
steps:
- checkout
- setup_remote_docker
- set_env
- when:
condition: << parameters.docker-login >>
steps:
- docker_login:
username: <<parameters.username>>
password-variable: <<parameters.password-variable>>
registry: <<parameters.registry>>
- docker_build:
config: <<parameters.config_file>>
- docker_push:
config: <<parameters.config_file>>
executors:
ci-images:
parameters:
version:
type: string
default: "v9.0-stretch"
docker:
- image: quay.io/reactiveops/ci-images:<<parameters.version>>

0 comments on commit ccc1fd1

Please sign in to comment.