Giter Site home page Giter Site logo

flux_assignment's Introduction

Flux CD Assignment


TASK : GitOps with Flux - Practice

  • Install and configure flux with GitHub repo/branch
  • fork this repo https://github.com/prakhar1989/docker-curriculum/tree/master/static-site
  • Build a docker image and push it to dockerhub
  • write a sample helm template to deploy the image that we built above with a single pod
  • Release application after the PR is merged and that version of docker image is pushed to registry
  • Deploy sample application (helm) FluxCD
  • Deploy revision based on docker image push (Public docker repo)
  • Deployment and Release Management
    • Helm release management
    • To explore on integrating third party UI solutions with Flux
  • Good to have
    • Flagger(istio) integration to achieve (blue-green/canary)Progressive delivery
    • Manage flux through declarative manifest(yaml)

SOLUTION :

Flux configured here works as below :

  • First it bootstrap the github repo. if repo is already available it will reconcile that else it will create one with default component's(and extra components if given through cli) menifests on branch given in cli argument. And will deploy those component to cluster.
  • Controllers that are required for the task :
    default : source-controller,kustomize-controller,helm-controller,notification-controller
    
    extra : image-reflector-controller,image-automation-controller
    
  • Resource that are created :
    gitrepository/flux-system --> To sync cluster with flux_assignment repo
    helmrepository/my-helm-repo --> To add custom helm repo to cluster
    helmchart/flux-system-flux-static-site --> To configure chart on the cluster
    imagerepository/static-site-image-repo --> To define registry that need to be scanned on defined intervals
    imagepolicy/static-site-image-update-policy  --> This will keep scanning registry for matching conditions such as tags etc.
    imageupdateautomation/static-site-image-update --> This will update and push the helm release manifest to flux_assignment repo with if there is any image found with matching conditions as per image policy  
    helmrelease/flux-static-site --> To release helm chart (Custom values can be defined here)
    kustomization/flux-system --> This will be created and managed by flux automatically.
    
    FOR deploying weaveworks UI solution :
     - helmrepository/ww-gitops
     - helmchart/flux-system-ww-gitops
     - helmrelease/ww-gitops
    

Repos and Image Registry that are used in this assignment :

Steps to configure flux :

  1. Bootstrap github repo :

    flux_bootstrap

    pod_deployed_after_bootstrap

    flux_resources

    • Create GITHUB_USER and GITHUB_TOKEN(github personal token)
    • Fire below command to bootstrap the repo
       flux bootstrap github --owner=$GITHUB_USER --repository=flux_assignment --branch=main --path=app-cluster --components-extra 'image-reflector-controller,image-automation-controller' --personal --interval=30s --read-write-key

      Flags :

      --interval duration       sync interval (default 1m0s)
      --owner string            GitHub user or organization name
      --path safeRelativePath   path relative to the repository root, when specified the cluster sync will be scoped to this path
      --personal                if true, the owner is assumed to be a GitHub user; otherwise an org
      --read-write-key          if true, the deploy key is configured with read/write permissions
      --repository string       GitHub repository name
      --components-extra strings               list of components in addition to those supplied or defaulted, accepts values such as 'image-reflector-controller,image-automation-controller'
      --branch string                          Git branch (default "main")
    • This will sync all the yaml that are present at app-cluster path and deploy the components to the k8s cluster.
    • Extra components image-reflector-controller and image-automation-controller are required on cluster to keep scaning image registry at defined intervals and to auto update image in the yaml on github which will eventually update the cluster on next sync.
    • read-write-key is required if you want to auto update your manifest through any flux controller(in this case : image-automation-controller)
    • personal arg fetches personal token from GITHUB_TOKEN env variable.
  2. Updating repo https://github.com/bhagyeshsoni98/flux-static-site version which build and push docker image to docker hub. static_site_repo_commit static_site_repo_workflow docker_hub_latest_image

  3. After image has been pushed to docker hub, imagepolicy resource will scan for latest image in registry. Based on latest image scan, imageupdateautomation will update helm_release.yaml with latest image tag and push it to github repo flux_assignment. Then gitrepository resource sync with flux_assignment repo and create new helm revision with update image. flux_image_policy_and_update github_helm_release helm_revision new_pod_created

  4. Port Forwarded svc and verified that static site is accesible through localhost. port_forwarded_svc port_forward localhost

  5. Port forwarded service of weavework UI solution for Flux to manage and view flux resources through UI. ui_port_forwarded ui_1 ui_2 ui_3 ui_4 ui_5

  6. Fire flux uninstall command to delete all the flux resources from cluster created under flux-system namespace. flux_uninstall flux_system_ns_removed

flux_assignment's People

Contributors

bhagyeshsoni98 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.