Giter Club home page Giter Club logo

decompiled2021-gitops-using-flux's Introduction

DecompileD 2021: GitOps using Flux

Repository for my talk at DecompileD 2021 about GitOps using Flux on the 24. September 2021.

What is GitOps?

GitOps is a way to do Kubernetes cluster management and application delivery. It works by using Git as a single source of truth for declarative infrastructure and applications. With Git at the center of your delivery pipelines, developers can make pull requests to accelerate and simplify application deployments and operations tasks to Kubernetes.

GitOps

Flux is a tool for keeping Kubernetes clusters in sync with sources of configuration (like Git repositories), and automating updates to configuration when there is new code to deploy.

Demo

Create a new Kubernetes cluster using kind and a Docker registry:

./kubernetes/create-cluster.sh

Build the Docker image of our example application (can be found in the http-server directory) and push the Docker image into our registry:

docker build -f ./http-server/Dockerfile -t localhost:5000/server:v1 .
docker push localhost:5000/server:v1

# The following command can be used to run the Docker image on your local machine:
docker run -it --rm --name server -p 8080:8080 localhost:5000/server:v1

Deploy the Source, Kustomize and Helm controller for Flux:

kubectl apply -f kubernetes/namespaces/flux-system/flux-system-clusterrole.yaml
kubectl apply -f kubernetes/namespaces/flux-system/flux-system-clusterrolebinding.yaml
kubectl apply -f kubernetes/namespaces/flux-system/flux-system-crds.yaml
kubectl apply -f kubernetes/namespaces/flux-system/flux-system-ns.yaml
kubectl apply -f kubernetes/namespaces/flux-system/helm-controller-deploy.yaml
kubectl apply -f kubernetes/namespaces/flux-system/helm-controller-sa.yaml
kubectl apply -f kubernetes/namespaces/flux-system/helm-controller-svc.yaml
kubectl apply -f kubernetes/namespaces/flux-system/kustomize-controller-deploy.yaml
kubectl apply -f kubernetes/namespaces/flux-system/kustomize-controller-sa.yaml
kubectl apply -f kubernetes/namespaces/flux-system/kustomize-controller-svc.yaml
kubectl apply -f kubernetes/namespaces/flux-system/source-controller-deploy.yaml
kubectl apply -f kubernetes/namespaces/flux-system/source-controller-sa.yaml
kubectl apply -f kubernetes/namespaces/flux-system/source-controller-svc.yaml

Deploy the GitRepository CR, for the github.com/ricoberger/decompiled2021-gitops-using-flux GitHub repository, to manage the Kubernetes cluster via Git:

yq eval kubernetes/namespaces/flux-system/gitrepository-cr.yaml
kubectl apply -f kubernetes/namespaces/flux-system/gitrepository-cr.yaml
kubectl get gitrepositories.source.toolkit.fluxcd.io -A
NAMESPACE     NAME      URL                                                                  READY   STATUS                                                            AGE
flux-system   cluster   https://github.com/ricoberger/decompiled2021-gitops-using-flux.git   True    Fetched revision: main/0a111b4f497f29f052ef2cc6a6b31c7f3dc1c5df   14m

Deploy the HelmRepository which is needed to deploy the NGINX Ingress Controller via Helm:

yq eval kubernetes/namespaces/flux-system/helm-repository-cr.yaml
kubectl apply -f kubernetes/namespaces/flux-system/helm-repository-cr.yaml
kubectl get helmrepositories.source.toolkit.fluxcd.io -A
NAMESPACE     NAME            URL                                          READY   STATUS                                                       AGE
flux-system   ingress-nginx   https://kubernetes.github.io/ingress-nginx   True    Fetched revision: 5cdf3fe499dbfd6bbf8a639d18d4f88736a08e37   18m

Deploy the Kustomization to apply all changes made in Git to our Kubernetes cluster:

yq eval kubernetes/namespaces/flux-system/kustomization-cr.yaml
kubectl apply -f kubernetes/namespaces/flux-system/kustomization-cr.yaml
kubectl get kustomizations.kustomize.toolkit.fluxcd.io -A
NAMESPACE     NAME            READY   STATUS                                                            AGE
flux-system   cluster         True    Applied revision: main/0a111b4f497f29f052ef2cc6a6b31c7f3dc1c5df   4m56s
flux-system   flux-system     True    Applied revision: main/0a111b4f497f29f052ef2cc6a6b31c7f3dc1c5df   75s
flux-system   http-server     True    Applied revision: main/0a111b4f497f29f052ef2cc6a6b31c7f3dc1c5df   75s
flux-system   ingress-nginx   True    Applied revision: main/0a111b4f497f29f052ef2cc6a6b31c7f3dc1c5df   75s

Delete the create Kubernetes cluster and Docker registry:

kind delete cluster --name decompiled
docker stop kind-registry
docker rm kind-registry

decompiled2021-gitops-using-flux's People

Contributors

ricoberger avatar

Watchers

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