Deploying your application using Kubernetes brings a lot of infrastructure related advantages. These include, flexibility while scaling, managing distributed components, having complete control over various versions of your application. This also brings a lot of complexity along with it. Continuous Integration and Continuous Deployment (CI/CD) systems work at a high level of abstraction so as to help reduce costs and also reduce the level of complexity which results in simplified operations.
In this blog tutorial, we will be exploring ArgoCD which is a declarative GitOps continuous delivery tool for Kubernetes.
Argo CD follows the GitOps pattern of using Git repositories as the source of truth for defining the desired application state.
kubectl create namespace argocd
kubectl apply -n argocd -f
https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
We are using port Forwarding to access Argo CD UI without exposing the service
kubectl port-forward svc/argocd-server -n argocd 8080:443 --address 0.0.0.0
Argo CD UI will be available over
The initial password for the admin account is auto-generated and stored as clear text in the field password in a secret named argocd-initial-admin-secret in your Argo CD installation namespace. You can simply retrieve this password using kubectl:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d;
echo
Now our Argo CD Ready to deployment
- Namespace.yaml
apiVersion: v1
kind: Namespace
metadata:
name: myapp
- Deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
selector:
matchLabels:
app: myapp
replicas: 4
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: myapp
image: m2021/eks-cicd:1.2
ports:
- containerPort: 80
- Service.yaml
apiVersion: v1
kind: Service
metadata:
name: myapp-service
spec:
selector:
app: myapp
ports:
- port: 80
protocol: TCP
targetPort: 80
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: myapp-argo-application
namespace: argocd
spec:
project: default
source:
repoURL: https://gitlab.com/surajshinare/argocd-app-config.git
targetRevision: HEAD
path: dev
destination:
server: https://kubernetes.default.svc
namespace: myapp
syncPolicy:
syncOptions:
- CreateNamespace=true
automated:
selfHeal: true
prune: true
kubectl apply -f application.yaml
We will update docker version and pod count in our deployment.yaml and service.yaml file
We have successfully deployed sample application via ArgoCD in Kubernetes.
In the above demonstration, you have seen the fundamentals of installing and deploying applications using ArgoCD. Kubernetes can be complicated as it requires layers of ideation, and hence it is important that you make sure that your deployments are as sustainable as possible.
Kubernetes can resolve all your infrastructure woes! If you would like to discuss more about GitOps and Kubernetes and how we can help you with the same, feel free to reach out our certified cloud consultants by filling in your contact details in the form below.