Flux on AWS (EKS)

In the world of K8s, there is a very strong trending topic: Gitops. Which involves the use of Git + Fluxcd operator. Most people think that GitOps is something that belongs to Github, which is wrong. It can be used with any service that offers the use …


This content originally appeared on DEV Community and was authored by Falcon

In the world of K8s, there is a very strong trending topic: Gitops. Which involves the use of Git + Fluxcd operator. Most people think that GitOps is something that belongs to Github, which is wrong. It can be used with any service that offers the use of git for code versioning, for example: CodeCommit.

Image description

Taken from https://fluxcd.io/docs/

Cluster creation

eksctl create cb-cluster

Flux Installation for AWS CodeCommit

Clone the Git repository locally:

git clone ssh://git-codecommit.<region>.amazonaws.com/v1/repos/<my-cb-repository>
cd my-cb-repository

Create a directory inside the repository:

mkdir -p ./clusters/my-cb-cluster/flux-system

Download the Flux CLI and generate the manifests with:

flux install \
  --export > ./clusters/my-cb-cluster/flux-system/gotk-components.yaml

Commit and push the manifest to the master branch:

git add -A && git commit -m "add flux components" && git push

Apply the manifests on your cluster:

kubectl apply -f ./clusters/my-cb-cluster/flux-system/gotk-components.yaml

Verify that the controllers have started:

flux check

Create a GitRepository object on your cluster by specifying the SSH address (my recommendation) of your repo:

flux create source git flux-system \
  --git-implementation=libgit2 \
  --url=ssh://git-codecommit.<region>.amazonaws.com/v1/repos/<my-repository> \
  --branch=<branch> \
  --ssh-key-algorithm=rsa \
  --ssh-rsa-bits=4096 \
  --interval=1m

If you prefer to use Git over HTTPS, then generate git credentials for HTTPS connections to codecommit and use these details as the username/password:

flux create source git flux-system \
  --git-implementation=libgit2 \
  --url=https://git-codecommit.<region>.amazonaws.com/v1/repos/<my-repository> \
  --branch=main \
  --username=${AWS_IAM_GC_USER} \
  --password=${AWS_IAM_GC_PASS} \
  --interval=1m

Create a Kustomization object on your cluster:

flux create kustomization flux-system \
  --source=flux-system \
  --path="./clusters/my-cb-cluster" \
  --prune=true \
  --interval=10m

Export both objects, generate a kustomization.yaml, commit and push the manifests to Git:

flux export source git flux-system \
  > ./clusters/my-cb-cluster/flux-system/gotk-sync.yaml

flux export kustomization flux-system \
  >> ./clusters/my-cb-cluster/flux-system/gotk-sync.yaml

cd ./clusters/my-cb-cluster/flux-system && kustomize create --autodetect

git add -A && git commit -m "add sync manifests files" && git push

Wait for Flux to get your previous commit with:

flux get kustomizations --watch

Conclusions

No more manual deploys, you can delegate it to Flux. Try and move to the new ways to work on K8s on AWS.


This content originally appeared on DEV Community and was authored by Falcon


Print Share Comment Cite Upload Translate Updates
APA

Falcon | Sciencx (2022-05-11T14:27:25+00:00) Flux on AWS (EKS). Retrieved from https://www.scien.cx/2022/05/11/flux-on-aws-eks/

MLA
" » Flux on AWS (EKS)." Falcon | Sciencx - Wednesday May 11, 2022, https://www.scien.cx/2022/05/11/flux-on-aws-eks/
HARVARD
Falcon | Sciencx Wednesday May 11, 2022 » Flux on AWS (EKS)., viewed ,<https://www.scien.cx/2022/05/11/flux-on-aws-eks/>
VANCOUVER
Falcon | Sciencx - » Flux on AWS (EKS). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/05/11/flux-on-aws-eks/
CHICAGO
" » Flux on AWS (EKS)." Falcon | Sciencx - Accessed . https://www.scien.cx/2022/05/11/flux-on-aws-eks/
IEEE
" » Flux on AWS (EKS)." Falcon | Sciencx [Online]. Available: https://www.scien.cx/2022/05/11/flux-on-aws-eks/. [Accessed: ]
rf:citation
» Flux on AWS (EKS) | Falcon | Sciencx | https://www.scien.cx/2022/05/11/flux-on-aws-eks/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.