Steps I follow to setup a CI CD workflow.#
- Write Dockerfile in the code repo.
- 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
- Write a skaffold file ( skaffold init will auto initialize itself ).
- Build Docker image and Render the k8s manifest using skaffold.
skaffold build && \
skaffold render --digest-source='tag' -p staging -o ../path-to/manifest.yml
- Manually push the rendered k8s to the manifest repository.
- Setup the k8s to access the private repository
kubectl create secret generic <secret-name> \
--from-file=.dockerconfigjson=~/.docker/config.json \
--type=kubernetes.io/dockerconfigjson
- Update the K8s manifest with
spec:
template:
spec:
imagePullSecrets:
- name: <secret-name>
- 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
- Login and Link repository to argocd.
- Create an app in argocd and configure to access the repository and the cluster to deploy.