Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
September 15, 2021 06:28 am GMT

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

How to setup Flux on Amazon EKS cluster

eksctl[3] standard tool EKS cluster vesion 0.53.0 feature Flux

EKS cluster Flux

  1. export

    export GITHUB_USERNAME=<your GitHub username>export GITHUB_TOKEN=<your GitHub personal access token>
  2. config file code <GitHub username> GitHub username

    cat << 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
  3. EKS cluster eksctl create cluster --config-file eks-gitops-demo.yaml cluster

  4. resource Flux kubectl --namespace flux-system get all
    Alt Text

  5. GitHub account repository eks-gitops-demo commit Kubernetes manifest file Flux component
    Alt Text

EKS cluster Flux

Note. EKS cluster Flux

How to use Flux basic features

Flux

Kubernetes manifest file

  1. clone GitHub repository Flux

    git clone [email protected]:${GITHUB_USERNAME}/eks-gitops-demo.gitcd eks-gitops-demo
  2. Kubernetes manifest file nginx:1.14.2 deployment commit push GitHub

    mkdir -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
  3. default config Flux pull GitHub 10 reconcile Kubernetes resource flux reconcile source git flux-system pull
    Alt Text

  4. Flux apply change Kubernetes deployment kubectl get deployment nginx-deployment
    Alt Text

  5. deployment manifest file nginx:1.15.0 commit push GitHub

    sed -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
  6. Flux reconcile deployment nginx:1.15.0
    Alt Text

7.(Bonus) deployment manifest commit push GitHub Flux reconcile deployment nginx

Flux Helm

  1. 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
  2. HelmRelease CRD Flux deploy Chart kube-prometheus-stack commit push GitHub

    mkdir -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
  3. flux reconcile source git flux-system pull change GitHub HelmRelease CRD interval reconcile 10 flux --namespace monitoring reconcile helmrelease kube-prometheus-stack reconcile
    Alt Text

  4. reconcile resource Prometheus cluster Helm Chart Flux
    Alt Text

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

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To