DEV Community

Nikith Kaithalapuram
Nikith Kaithalapuram

Posted on

Kubernetes GitOps with Flux

GitOps Arc

Create a GitHub Personal Access Token

Open a new browser tab or window and navigate to github.com.
Create a new account and password on GitHub, or, if you already have a GitHub account, log in to GitHub.

  • In the upper right corner, click your avatar.
  • In the dropdown menu, click Settings.
  • In the left-hand menu, click Developer settings.
  • Click Personal access tokens.
  • Click the Generate a personal access token link.
  • If prompted, reenter your password and click Confirm password.
  • Under Note, enter a descriptive note for your personal access token (for example, acg-flux-lab).
  • Under Select scopes, click the check box next to repo.
  • Click Generate token.
  • Copy the generated personal access token.

Token

Bootstrap the Git Repository

In the lab's server, bootstrap the Git repository. Be sure to substitute your own GitHub username where it says

flux bootstrap github --owner= --repository=acg-flux-lab --branch=main --path=./clusters/my-cluster --personal
This will create a new GitHub repository with the name acg-flux-lab.

When prompted, paste in your personal access token.

Return to the browser tab or window with GitHub.

Navigate to the web address github.com//acg-flux-lab. You should see you have a repository here that was created by Flux.

CLI

REPO

YAML MANIFEST

YML

Create a Deployment via the GitHub Repository Using Flux

In your acg-flux-lab repository in GitHub, click Add files.

In the dropdown menu, select Create new file.

Enter clusters to create the file inside the clusters directory.

Enter my-cluster to create the file inside the clusters/my-cluster directory.

Enter turtle-deployment.yaml to name the file turtle-deployment.yaml.

Under Edit new file, put in the following YAML manifest:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: turtle-deployment
  namespace: default
spec:
  replicas: 3
  selector:
    matchLabels:
      app: turtle
  template:
    metadata:
      labels:
        app: turtle
    spec: 
      containers:
      - name: nginx
        image: nginx:stable
Enter fullscreen mode Exit fullscreen mode

!Initial](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/saq629ut5o4zdq3ak953.png)

Commit

Commmited

kubectl get pods
kubectl get deployments

CLI

Reference

  1. https://github.com/NIK8H/acg-flux-lab

  2. https://app.pluralsight.com/

Top comments (0)