Giter Site home page Giter Site logo

aws-cdk-eks-flux's Introduction

CI/CD on EKS using AWS Codecommit, AWS Codepipeline, AWS Codebuild and FluxCD written in python using CDK!

The purpose of this repository is to demo how can we work with the GitOps philosophy using FluxCD on EKS. This implementation has been developed using CDK.

Requirements

Architecture

awsome-flux-example

Steps to reproduce

Export your Git credentials:

export GIT_AUTH_USER=git_username
export GIT_AUTH_KEY=git_credentials

Specify the stack name, and region on the cdk.json, for example:

{
  "app": "python3 app.py",
  "context": {
    "@aws-cdk/core:enableStackNameDuplicates": "true",
    "aws-cdk:enableDiffNoFail": "true",
    "@aws-cdk/core:stackRelativeExports": "true",
    "@aws-cdk/aws-ecr-assets:dockerIgnoreSupport": true,
    "name": "awsome-flux-example",
    "region": "us-east-1"
  }
}

Deploy the infrastructure using the CDK cli:

cdk bootstrap aws://account_id/us-east-1
cdk deploy

The infrastructure creation takes around 15/20 min due the EKS cluster creation. During the meantime, you can clone the two new repos that have been already created and push the example code. First one for the kubernetes infrastructure and later, for your application. Don't forget to change the account ID of the Amazon Registry on the infrastructure in the line 21.

Like this:

git clone https://git-codecommit.us-east-1.amazonaws.com/v1/repos/kubernetes-infra-awsome-flux-example
cp repos/infra_example/* kubernetes-infra-awsome-flux-example/
git add .
git commit -am "First commit"
git push 

git clone https://git-codecommit.us-east-1.amazonaws.com/v1/repos/awsome-flux-example
cp repos/app_example/* awsome-flux-example/
git add .
git commit -am "First commit"
git push 

After push your code the pipeline is triggered:

awsome-pipeline

Once the stack is completed, you will get the following outputs:

Outputs:
awsome-flux-example-stack.awsomefluxexampleclusterConfigCommandC5ACCB2F = aws eks update-kubeconfig --name awsomefluxexamplecluster7E1AB52B-8636fb0994a64eaf835a8568e4f1dd6d --region us-east-1 --role-arn arn:aws:iam::account_id:role/awsome-flux-example-stack-awsomefluxexamplecluster-4WYAIKEQONYC
awsome-flux-example-stack.awsomefluxexampleclusterGetTokenCommand58A55459 = aws eks get-token --cluster-name awsomefluxexamplecluster7E1AB52B-8636fb0994a64eaf835a8568e4f1dd6d --region us-east-1 --role-arn arn:aws:iam::account_id:role/awsome-flux-example-stack-awsomefluxexamplecluster-4WYAIKEQONYC
awsome-flux-example-stack.awsomefluxexamplefluxcdk8sinfrastructurerepository051BF5A3 = https://git-codecommit.us-east-1.amazonaws.com/v1/repos/kubernetes-infra-awsome-flux-example

Check your cluster

Connect to the EKS cluster using the previous output and check your application. You can also follow Update Kubeconfig

# kubectl get pod
NAME                               READY   STATUS    RESTARTS   AGE
awsome-app-flux-67b6457b5b-fhz7m   1/1     Running   0          5m12s
awsome-app-flux-67b6457b5b-ngxhb   1/1     Running   0          5m33s
flux-f8c9c99f9-k9wd4               1/1     Running   0          15m
memcached-5bd7849b84-26xrv         1/1     Running   0          15m

Clean up

After completing your demo, delete your stack using the CDK cli:

cdk destroy

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

aws-cdk-eks-flux's People

Contributors

amazon-auto 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.