Steps I follow to setup a CI CD workflow.

  1. Write Dockerfile in the code repo.
  2. Write a k8s Manifest file using kustomize template. Following this tree structure.
├── base
│   └── app
│       ├── deployment.yaml
│       ├── kustomization.yaml
│       └── service.yaml
└── overlay
    ├── production
    │   └── kustomization.yaml
    └── staging
        └── kustomization.yaml
  1. Write a skaffold file ( skaffold init will auto initialize itself ).
  2. Build Docker image and Render the k8s manifest using skaffold.
skaffold build && \
skaffold render --digest-source='tag' -p staging -o ../path-to/manifest.yml
  1. Manually push the rendered k8s to the manifest repository.
  2. Setup the k8s to access the private repository
kubectl create secret generic <secret-name> \
--from-file=.dockerconfigjson=~/.docker/config.json \
--type=kubernetes.io/dockerconfigjson
  1. Update the K8s manifest with
spec:
  template:
    spec:
        imagePullSecrets:
            - name: <secret-name>
  1. Setup argo cd in the target k8s cluster. ArgoCD Getting Started
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'

kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo
  1. Login and Link repository to argocd.
  2. Create an app in argocd and configure to access the repository and the cluster to deploy.