With our Kubernetes cluster ready and FluxCD installed, it’s time to experience GitOps in action by deploying our first application.
In this post, we’ll walk through:
- Creating a simple Kubernetes deployment and service
- Pushing those configs to Git
- Watching Flux automatically apply the changes
This is the true GitOps workflow — and it’s surprisingly satisfying once you see it work for the first time.
1. The Big Picture: How GitOps Deployment Works
Before jumping into YAML files, it’s helpful to visualize what we’re doing.
In GitOps, you don’t “deploy” manually. Instead:
- You write Kubernetes manifests (deployment, service, etc.)
- You commit them to your Git repository
- The GitOps controller (Flux) detects the change and applies it
Your cluster will always reflect what’s in Git. No manual kubectl apply needed.
Think of Git as your deployment dashboard — but without all the clicking.
2. Create Kubernetes Manifests for the App
Let’s create a simple application: a basic NGINX web server.
First, make a new folder inside your Git repository, under your cluster path:
mkdir -p clusters/my-cluster/apps/nginx
Inside this folder, create a file called deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
namespace: default
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
Next, create a service.yaml file to expose it:
apiVersion: v1
kind: Service
metadata:
name: nginx
namespace: default
spec:
type: LoadBalancer
selector:
app: nginx
ports:
- port: 80
targetPort: 80
These two files together describe what we want the cluster to run.
3. Define a Kustomization
Flux needs to know how to find and apply these manifests. We do that using a Kustomization resource.
Inside your cluster folder (clusters/my-cluster/), create a file called nginx-kustomization.yaml:
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: nginx
namespace: flux-system
spec:
interval: 5m0s
path: ./clusters/my-cluster/apps/nginx
prune: true
sourceRef:
kind: GitRepository
name: flux-system
This tells Flux:
- Where the app manifests are (apps/nginx)
- How often to check for changes (every 5 minutes)
Later, we’ll register this Kustomization with Flux.
4. Commit and Push Your Changes
Once you’ve created the YAML files, it’s time to push everything to Git:
git add .
git commit -m "Add nginx app deployment and service"
git push origin main
This is the magic moment: Git becomes your deployment tool.
5. Let Flux Sync the Cluster
After pushing, Flux will detect the new Kustomization and start applying the manifests automatically.
You can check the sync status by running:
flux get kustomizations
If everything is working, you’ll soon see two nginx pods running:
kubectl get pods
And your service exposed:
kubectl get svc nginx
If your cluster is on a cloud provider (or configured to handle LoadBalancer services), you’ll get a public IP address where you can access the nginx welcome page.
Congratulations — you just deployed your first app with GitOps!
6. What’s Next
Now that we’ve deployed a simple application, we can start building more sophisticated workflows:
- Managing apps across multiple environments
- Using Helm charts with GitOps
- Automating image updates when new versions are released
Each of these will build on the foundation we just laid down.
In the next post, we’ll dive deeper into multi-environment GitOps setups, where dev, staging, and production are managed separately but safely.
Previous Posts in the Series
- Episode Zero — Why You Should Care and What to Expect
- Episode One — GitOps vs. Traditional CI/CD
- Episode Two — Setting Up a GitOps-Ready Kubernetes Cluster
Enjoying the journey?
Subscribe to get the next GitOps posts, hands-on tutorials, and real-world lessons straight to your inbox!