7/20/2021

GitOps using ArgoCD and Tekton

Inspired by: 

ricoberger/gitops-using-argo-cd-and-tekton: GitOps using Argo CD and Tekton



# For and clone below repo


git clone https://github.com/ricoberger/gitops-using-argo-cd-and-tekton

cd  gitops-using-argo-cd-and-tekton

git checkout -b dev

cd  clusters/apps

find ./ -type f -exec sed -i 's/ricoberger/github_username/g' {} \;

cd ../../



git  add .
git commit -m "change username of github"

git  push origin dev

minikube start --driver=virtualbox --cpus=4 --memory=8192m --profile=dev

minikube addons enable ingress --profile=dev


kustomize build clusters/argocd/dev | kubectl apply -f -


kubectl get pods -n argocd


# once all the pods up and running


kubectl apply -f clusters/apps/dev.yaml


#Now we have to add our Ingresses to the /etc/hosts file:


sudo echo "`minikube ip --profile=dev` argocd-dev.fake grafana-dev.fake prometheus-dev.fake tekton-dev.fake server-dev.fake" | sudo tee -a /etc/hosts


# Argocd admin password


kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d'/' -f 2



# Create secrets for github and docker hub


kubectl create secret docker-registry docker-registry-secret -n tekton-pipelines --docker-server="https://index.docker.io/v1/" --docker-username=<DOCKER_USERNAME> --docker-password=<DOCKER_PASSWORD>


kubectl annotate secret docker-registry-secret tekton.dev/docker-0=https://index.docker.io/v1/   -n tekton-pipelines


kubectl create secret generic github-secret --type="kubernetes.io/basic-auth" --from-literal=username=<GITHUB_USERNAME> --from-literal=password=<GITHUB_PASSWORD>  -n tekton-pipelines


kubectl annotate secret github-secret tekton.dev/git-0=https://github.com

-n tekton-pipelines




cat <<EOF | kubectl create -n tekton-pipelines -f -

apiVersion: tekton.dev/v1beta1

kind: PipelineRun

metadata:

  name: build-and-deploy-prod-17

  namespace: tekton-pipelines

  annotations:

    argocd.argoproj.io/compare-options: IgnoreExtraneous

spec:

  pipelineRef:

    name: build-and-deploy-pipeline

  params:

    - name: gitUrl

      value: https://github.com/<GITHUB_USERNAME>/gitops-using-argo-cd-and-tekton

    - name: gitRevision

      value: dev

    - name: imageUrl

      value: <DOCKER_USERNAME>/gitops-using-argo-cd-and-tekton

    - name: serviceName

      value: server

    - name: filePath

      value: clusters/server/dev/server-deploy.yaml

    - name: yamlField

      value: spec.template.spec.containers[0].image

  serviceAccountName: pipeline-account

  workspaces:

    - name: git-source

      persistentVolumeClaim:

        claimName: git-source-pvc

EOF















Troubleshooting

  1. Change default branch to dev



  1. Fix yq expression


 vi clusters/tekton/base/pipeline.yaml


vi clusters/tekton/base/pipeline-task-update-image.yaml



  1. Fix parameter type missing


 vi clusters/tekton/base/pipeline.yaml



  1. Update github username and email

vi clusters/tekton/base/pipeline-task-update-image.yaml




References:


Argo Workflows and Pipelines - CI/CD, Machine Learning, and Other Kubernetes Workflows


What is GitOps, How GitOps works and Why it's so useful


https://medium.com/dzerolabs/installing-ambassador-argocd-and-tekton-on-kubernetes-540aacc983b9


https://itnext.io/argocd-a-helm-chart-deployment-and-working-with-helm-secrets-via-aws-kms-96509bfc5eb3


https://itnext.io/kubernetes-essential-tools-2021-def12e84c572




No comments:

Post a Comment