Coder Social home page Coder Social logo

swinton / example-actions-flux-eks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from github-developer/example-actions-flux-eks

0.0 1.0 0.0 25 KB

GitHub Actions, Flux, and Amazon EKS ✨

License: MIT License

Dockerfile 6.96% CSS 3.26% HTML 69.48% Shell 20.30%

example-actions-flux-eks's Introduction

Example GitHub Actions workflow with Flux and Amazon EKS

An example workflow that uses GitHub Actions to build a static website into a Docker container, push that image to Amazon Elastic Container Registry, and uses Flux to automatically update an existing Amazon Elastic Kubernetes Service cluster with that image.

See this technical blog post which uses this code for full step-by-step instructions.

Prerequisites

  1. Create an EKS cluster, e.g. using eksctl create cluster
  2. Set up Flux on the cluster, e.g. using this guide. Note that you must set --git-path to point to where your manifests are. For example:
export GHUSER=<github user that flux commits will be associated with>
export GHOWNER=<github user or organization account where your fork lives>
export GHREPO=example-actions-flux-eks

kubectl create ns flux

fluxctl install \
    --git-user=${GHUSER} \
    --git-email=${GHUSER}@users.noreply.github.com \
    [email protected]:${GHOWNER}/${GHREPO}.git \
    --git-path=manifests \
    --namespace=flux | kubectl apply -f -
  1. Give Flux read/write access to the GitHub repository using a deploy key
  2. Create a repository called example-eks in Amazon Elastic Container Registry, in the same AWS region as the EKS cluster
  3. Update the image in deployment.yml to use your REGISTRY, IMAGE, and TAG. TAG will be replaced by Flux as new images are available in the registry.

Secrets

The following secrets are required to be set on the repository:

  1. AWS_ACCOUNT_ID: The AWS account ID that owns the EKS cluster
  2. AWS_ACCESS_KEY_ID: An AWS access key ID for an account having the EKS IAM role
  3. AWS_SECRET_ACCESS_KEY: An AWS secret sccess key for an account having the EKS IAM role

Workflow

The example workflow will trigger on every push to this repo.

For pull requests, the workflow will:

  1. Build and tag the Docker image
    • The image will be tagged with the feature branch's HEAD commit SHA

For pushes to the default branch (master), in addition to the above, the workflow will:

  1. Push the image to Amazon Elastic Container Registry

Beyond the workflow

Flux watches ECR for changes to the image listed in our deployment configuration. When it detects a change, it updates the EKS cluster with the new image, no manual kubectl apply needed!

Contributions

We welcome contributions! See how to contribute.

License

MIT

example-actions-flux-eks's People

Contributors

dtenenba avatar imjohnbo avatar jpadams avatar swinton avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.