An Interest In:
Web News this Week
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
Flux (GitOps tool) Amazon EKS - Part 1
Introduction
GitOps[1] tool, best practice Git Continuous Integration/Continuous Delivery (CI/CD) standard Software Development Life Cycle (SDLC) Infrastructure as Code (IaC) IT operation infrastructure
Flux[2] GitOps tool resource Kubernetes cluster version Flux v2 Flux operator cluster pull declarative (IaC) Git repository reconcile Kubernetes resource
blog post Flux
Prerequisites
-
eksctl
flux
-
personal access token
GitHub account
How to setup Flux on Amazon EKS cluster
eksctl[3] standard tool EKS cluster vesion 0.53.0
feature Flux
EKS cluster Flux
export
export GITHUB_USERNAME=<your GitHub username>export GITHUB_TOKEN=<your GitHub personal access token>
config file code
<GitHub username>
GitHub usernamecat << EOF > eks-gitops-demo.yamlapiVersion: eksctl.io/v1alpha5kind: ClusterConfigmetadata: name: eks-gitops-demo region: ap-southeast-1managedNodeGroups: - name: ng-1 instanceType: m5.large desiredCapacity: 1gitops: flux: gitProvider: github flags: owner: "${GITHUB_USERNAME}" personal: "true" private: "true" repository: "eks-gitops-demo" branch: "master" namespace: "flux-system" path: "clusters/eks-gitops-demo"EOF
EKS cluster
eksctl create cluster --config-file eks-gitops-demo.yaml
clusterGitHub account repository
eks-gitops-demo
commit Kubernetes manifest file Flux component
EKS cluster Flux
Note. EKS cluster Flux
- cluster eksctl Flux
eksctl enable flux
- eksctl Flux flux CLI
flux bootstrap
How to use Flux basic features
Flux
Kubernetes manifest file
clone GitHub repository Flux
git clone [email protected]:${GITHUB_USERNAME}/eks-gitops-demo.gitcd eks-gitops-demo
Kubernetes manifest file
nginx:1.14.2
deployment commit push GitHubmkdir -p clusters/eks-gitops-demo/default/nginxcat << EOF > clusters/eks-gitops-demo/default/nginx/deployment.yamlapiVersion: apps/v1kind: Deploymentmetadata: name: nginx-deployment labels: app: nginxspec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80EOFgit add clusters/eks-gitops-demo/default/nginx/deployment.yamlgit commit -m "Add Nginx deployment"git push
default config Flux pull GitHub 10 reconcile Kubernetes resource
flux reconcile source git flux-system
pullFlux apply change Kubernetes deployment
kubectl get deployment nginx-deployment
deployment manifest file
nginx:1.15.0
commit push GitHubsed -i '' 's/1.14.2/1.15.0/' clusters/eks-gitops-demo/default/nginx/deployment.yamlgit add clusters/eks-gitops-demo/default/nginx/deployment.yamlgit commit -m "Change Nginx image to 1.15.0"git push
7.(Bonus) deployment manifest commit push GitHub Flux reconcile deployment nginx
Flux Helm
HelmRepository CRD Helm Chart repository
prometheus-community
mkdir -p clusters/eks-gitops-demo/monitoringcat << EOF > clusters/eks-gitops-demo/monitoring/namespace.yamlapiVersion: v1kind: Namespacemetadata: name: monitoringEOF---cat << EOF > clusters/eks-gitops-demo/monitoring/prometheus-community.yamlapiVersion: source.toolkit.fluxcd.io/v1beta1kind: HelmRepositorymetadata: name: prometheus-community namespace: monitoringspec: url: https://prometheus-community.github.io/helm-charts interval: 10mEOF
HelmRelease CRD Flux deploy Chart
kube-prometheus-stack
commit push GitHubmkdir -p clusters/eks-gitops-demo/monitoringcat << EOF > clusters/eks-gitops-demo/monitoring/namespace.yamlapiVersion: v1kind: Namespacemetadata: name: monitoringEOFcat << EOF > clusters/eks-gitops-demo/monitoring/kube-prometheus-stack.yamlapiVersion: helm.toolkit.fluxcd.io/v2beta1kind: HelmReleasemetadata: name: kube-prometheus-stack namespace: monitoringspec: releaseName: kube-prometheus-stack interval: 10m chart: spec: chart: kube-prometheus-stack sourceRef: kind: HelmRepository name: prometheus-community namespace: monitoringEOFgit add clusters/eks-gitops-demo/monitoring/*git commit -m "Add Prometheus with Helm"git push
flux reconcile source git flux-system
pull change GitHub HelmRelease CRD interval reconcile 10flux --namespace monitoring reconcile helmrelease kube-prometheus-stack
reconcile
Conclusion
GitOps Git, CI/CD IaC infrastructure manual process
Flux tool implement GitOps Kubernetes blog post Amazon EKS eksctl
Flux part 2 feature Flux
References
[1] https://www.gitops.tech/#what-is-gitops
[2] https://fluxcd.io/
[3] https://eksctl.io/
[4] https://helm.sh/
Original Link: https://dev.to/awscommunity-asean/flux-gitops-tool-amazon-eks-part-1-4gla
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To