Docker image of vpro-app is built from cicd-Jenkins-Docker project and the latest image is used here to deploy on kubernetes cluster with Argocd. Argocd will maintain the state of deployment on kubernetes cluster and will use this repo as a single source of truth.
#Install awscli and configure it with IAM user of admin access.
sudo apt update
sudo apt install awscli -y
aws configure # (After that enter your user's access key id and secret access key)
#Install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
#Install kops
curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
chmod +x kops-linux-amd64
sudo mv kops-linux-amd64 /usr/local/bin/kops
#kops uses DNS for discovery, both inside the cluster and outside, so that you can reach the kubernetes API server from clients.
#Purchge a domain (ex. godaddy.com) then created a public hosted zone in aws Route53.
#In Godaddy created NS records for subdomain pointing to Route53 hosted zone NS servers.
#Created a S3 bucket to store the cluster's state.
#After completing all prerequisites create cluster using kops command
kops create cluster --name=k8.learnwithabhi.xyz --state=s3://mykopsbucketfork8 --zones=us-east-1a --node-count=1 --node-size=t3.small --master-size=t3.medium --dns-zone=k8.learnwithabhi.xyz --node-volume-size=8 --master-volume-size=8
kops update cluster --name k8.learnwithabhi.xyz --state=s3://mykopsbucketfork8 --yes --admin
kops validate cluster --state=s3://mykopsbucketfork8
kubectl create namespace argocd
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
sudo install -m 555 argocd-linux-amd64 /usr/local/bin/argocd
rm argocd-linux-amd64
#To access argocd api-server change the argocd-server service type to LoadBalancer
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer"}}'
#To login copy loadbalancer address and paste in browser. username is admin, to get initial password run below command:
argocd admin initial-password -n argocd
#To change password go to user info and click on update password
#Clone this git repo & create application using application.yaml file
git clone https://github.com/learnwithabhishek/argocd-project.git
kubectl apply -f application.yaml
#We can check details of deployments, replicaset, pods etc by clicking on the application.
#To get details about prod cluster enter below command:
kubectl get all -n prod
#Access your vpro-app with loadbalancer external-ip in browser
#Can login with username: admin_vp , password: admin_vp
#Click on "All Users" , it will show list of users
#click on any user id, data will be fetched from database and inserted in cache
#Go back and click same user id again, now data will be displayed from cache
#Return back to main page of app and click on RabbitMq to initiate it
#After completing the project delete the application and then delete kubernetes cluster on aws
kops delete cluster --name k8.learnwithabhi.xyz --state=s3://mykopsbucketfork8 --yes