Deployment Strategies
After a Docker image is built and pushed, it needs to be deployed. This page covers two approaches: direct kubectl apply and GitOps via Flux CD.
What this page covers
- Direct deployment with
kubectl applyorkubectl set image - GitOps deployment with Flux CD image automation
- Choosing between the two approaches
- Rolling updates and rollback
Direct deployment (simpler)
For the Docker-only track or simple K3s setups, CI can deploy directly:
# In your Gitea Actions workflow
- name: Deploy to K3s
run: |
kubectl set image deployment/my-app \
my-app=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ gitea.sha }} \
-n my-namespace
This requires the runner to have kubectl access to the cluster.
GitOps deployment with Flux CD (recommended for K3s)
With Flux CD image automation, the deployment process is:
- CI pushes a new image tag to the registry.
- Flux's image reflector detects the new tag.
- Flux updates the image tag in the Git manifest.
- Flux applies the updated manifest to the cluster.
No CI pipeline needs direct cluster access. Git remains the source of truth.