All Projects → aws-samples → aws-cdk-eks-fluxv2-example

aws-samples / aws-cdk-eks-fluxv2-example

Licence: MIT-0 License
AWS CDK example for EKS and Flux v2

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to aws-cdk-eks-fluxv2-example

aws-eks-accelerator-for-terraform
Configure and deploy complete EKS clusters.
Stars: ✭ 1,220 (+8033.33%)
Mutual labels:  gitops, eks
eks-hpa-profile
An eksctl gitops profile for autoscaling with Prometheus metrics on Amazon EKS on AWS Fargate
Stars: ✭ 26 (+73.33%)
Mutual labels:  gitops, eks
cdk-examples
AWS CDK Examples Repository
Stars: ✭ 49 (+226.67%)
Mutual labels:  eks, cdk-examples
DataEngineering
This repo contains commands that data engineers use in day to day work.
Stars: ✭ 47 (+213.33%)
Mutual labels:  eks
k3s-gitops
My home Kubernetes (k3s) cluster managed by GitOps (Flux)
Stars: ✭ 26 (+73.33%)
Mutual labels:  gitops
gimletd
The Gitops Release Manager
Stars: ✭ 24 (+60%)
Mutual labels:  gitops
cd-gitops-reference-architecture
Details of the CD/GitOps architecture in use at InfluxData
Stars: ✭ 16 (+6.67%)
Mutual labels:  gitops
pixie
Instant Kubernetes-Native Application Observability
Stars: ✭ 3,238 (+21486.67%)
Mutual labels:  eks
pulumi-eks
A Pulumi component for easily creating and managing an Amazon EKS Cluster
Stars: ✭ 116 (+673.33%)
Mutual labels:  eks
kubernetes
Kubernetes Course
Stars: ✭ 19 (+26.67%)
Mutual labels:  eks
argocd-operator-helm
[DEPRECATED] Argo CD Operator (Helm) installs Argo CD in OpenShift and Kubernetes.
Stars: ✭ 18 (+20%)
Mutual labels:  gitops
flytectl
A cross platform CLI for Flyte. Written in Golang. Offers an intuitive interface to Flyte https://docs.flyte.org/projects/flytectl/en/latest/
Stars: ✭ 23 (+53.33%)
Mutual labels:  gitops
aws-kubeflow
A guideline for basic use and installation of kubeflow in AWS.
Stars: ✭ 36 (+140%)
Mutual labels:  eks
flux-kustomize-example
Flux v1: Example of Flux using manifest generation with Kustomize
Stars: ✭ 71 (+373.33%)
Mutual labels:  gitops
GDPRDPIAT
A GDPR Data Protection Impact Assessment (DPIA) tool to assist organisations to evaluate data protection risks with respect to the EU's General Data Protection Regulation. 🇪🇺
Stars: ✭ 28 (+86.67%)
Mutual labels:  gitops
gitops-build-lib
Jenkins pipeline shared library for automating deployments via GitOps
Stars: ✭ 23 (+53.33%)
Mutual labels:  gitops
commodore
Commodore provides opinionated tenant-aware management of Kapitan inventories and templates. Commodore uses Kapitan for the heavy lifting of rendering templates and resolving a hierachical configuration structure.
Stars: ✭ 35 (+133.33%)
Mutual labels:  gitops
gimlet-cli
Build and run a developer platform on Kubernetes
Stars: ✭ 41 (+173.33%)
Mutual labels:  gitops
metagraf
metaGraf is a opinionated specification for describing a software component and what its requirements are from the runtime environment. The mg command, turns metaGraf specifications into Kubernetes resources, supporting CI, CD and GitOps software delivery.
Stars: ✭ 15 (+0%)
Mutual labels:  gitops
eks-with-istio
Terraform template for a production ready EKS Cluster and ISTIO Service Mesh 🐳 📦 🚀
Stars: ✭ 32 (+113.33%)
Mutual labels:  eks

EKS with GitOps using Flux, deployed using AWS CDK

This repository contains an example CDK application that creates an EKS cluster with a few basic add-ons to get started with GitOps using FluxV2. The CDK code is housed in the infra/ directory.

Making it easy to get started, the infrastructure provisioned also includes VPC, NAT Gateways, etc. This could, and should of course be tailored to your specific needs.

Add-ons part of infra or applied by Flux?

Some of the add-ons, such as cluster autoscaler and AWS Load Balancer Controller, do require additional permissions in IAM to properly function, to modify auto scaling groups and load balancers respectively. Hence, these types of addons, are considered part of the infrastructure and provisioned using AWS CDK. Flux is also included here due it is part of the bootstrapping process.

The remaining add-ons, such as metrics server, and other addons you want to run which do not fit into the former category, will be applied by Flux in a GitOps fashion.

How does it work?

The infra/ directory contains all resources which are created using AWS CDK, including add-ons as described above. Once those resources are created, Flux will look at the content of k8s-config/, and create Kubernetes resources accordingly.

Pre-requisites

This example relies on AWS Cloud Development Kit (CDK) for management of infrastructure. If you are not yet familiar with CDK or need to install CDK on your laptop, see the CDK getting started guide.

The goal of this sample is not to provide in-depth coverage of all the features and components available in FluxV2, for further information on the various components and available configuration, see GitOps Toolkit.

1. Deploy the infrastructure

Jump into the the infra/ directory and deploy the CDK stack, passing along a set of parameters to the CDK command. These parameters define which git repository, branch, and path in that repository that will be used for initial flux bootstrapping of the cluster.

cd infra/

npm i

cdk deploy InfraStack \
  --parameters FluxRepoURL="ssh://[email protected]/aws-samples/aws-cdk-eks-fluxv2-example" \
  --parameters FluxRepoBranch="main" \
  --parameters FluxRepoPath="./k8s-config/clusters/demo"

As you can see, multiple cluster configurations could be added to the k8s-config/clusters/<cluster-name> path.

The installation and configuration of flux is managed in infra/lib/addons/fluxv2.ts.

2. Connecting with GitHub

Flux is configured to connect to a GitHub repository, targeting a specific path, connecting using the data from ssh keypair that we will create. We will be using this generic method for authentication as opposed to a GitHub personal access token for easier adaptability to other code hosting solutions.

2.1 Create an ssh keypair

First, create a keypair using ssh-keygen -C demokey -N "" -f $HOME/.ssh/demo_key_rsa. Then, upload the public part to GitHub in your settings page.

2.2 Create a Kubernetes secret

Use the following script to craft and apply the secret to the flux-system namespace:

#!/bin/sh

cat <<EOF | kubectl -n flux-system apply -f -
apiVersion: v1
kind: Secret
type: Opaque
metadata:
  name: github-keypair
  namespace: flux-system
data:
  known_hosts: $(ssh-keyscan -t rsa github.com 2>/dev/null|grep -E '^github\.com'|base64)
  identity: $(cat ${HOME}/.ssh/demo_key_rsa|base64)
  'identity.pub': $(cat ${HOME}/.ssh/demo_key_rsa.pub|base64)
EOF

Note: update the infra-stack.ts file to reference the correct secret if you change the name.

3. Trigger flux reconciliation

Wait for the state to be reconciled as defined in the interval field on the various flux component specs. Alternatively, if you have the Flux CLI installed, you can manually trigger reconciliation of resources using flux reconcile kustomization flux-system --with-source. This will ask flux to ensure that the cluster state matches the desired state, for more information, see the reconciliation section in the flux docs.

# kubectl -n podinfo get pods
NAME                      READY   STATUS    RESTARTS   AGE
podinfo-746d58c87-gjkdl   1/1     Running   0          2m3s
podinfo-746d58c87-qfjwk   1/1     Running   0          2m3s

Security

See CONTRIBUTING for more information.

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].