Table of Contents |
---|
...
|
Continuous Deployment via Argo
Git Configuration
Login to Argo tool
...
and navigate to Settings (gear icon)
...
2. Navigate to Repositories
...
3. Click “Connect repo using HTTPS” / SSH ‘+ CONNECT REPO USING HTTPS’ button (or ‘+ CONNECT REPO USING SSH’ as per requirement)
...
4. Enter the details:
Select the type as git
Type - Select ‘git’
Repository URL, Username, Password - Enter Repo URL and credentials and connect.
...
5. The added Repo repository details get are reflected in Repositories
...
...
Project
...
Configuration
Navigate to Repositories → Projects
Click
...
‘New Project’ button.
Enter the required details and save
The saved project is reflected
...
Kubernetes Cluster Configuration
The cluster added to Argo via CLI is reflected in “Clusters” ‘Clusters’ tab of Argo tool.
...
AWS EKS
Download the AWS CLI https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html
Configure AWS credential to AWS CLI.
Code Block $ aws configure AWS Access Key ID [****************QW7K]: AWS Secret Access Key [****************zsTw]: Default region name [us-east-2]: Default output format [None]:
Make sure Kubernetes Cluster is already present or create a new one.
Install ArgoCD CLI (vesion: v2.0.4) on your system from https://argoproj.github.io/argo-cd/cli_installation/
Update the kubeconfig file through
...
CLI and create external clusters inside ArgoCD.
Code Block
...
language | bash |
---|
# Update the kubeconfig file for auth. aws eks update-kubeconfig --region us-east-2 --name cluster-name # Login to argocd server through cli argocd login <argocd_server_url> --password <password> --username <username> # add external cluster through cli to argocd argocd cluster add <kube_context> --name <cluster-name> Note: kube_context format for EKS: arn:aws:eks:<region>:<account_id>:cluster/<cluster_name>
Verify the external clusters inside ArgoCD UI.
Azure AKS
Download the Azure CLI https://docs.microsoft.com/en-us/cli/azure/install-azure-cli
Authenticate the Azure CLI to the azure account.
Code Block language bash $ az login A web browser has been opened at https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize. Please continue the login in the web browser. If no web browser is available or if the web browser fails to open, use device code flow with `az login --use-device-code`.
Make sure Kubernetes Cluster already present or create a new one.
Install ArgoCD CLI (vesion: v2.0.4) on your system from https://argoproj.github.io/argo-cd/cli_installation/
Update the kubeconfig file through CLI and create external clusters inside ArgoCD
Code Block # Update the kubeconfig file for auth. az aks get-credentials --resource-group <group_name> --name <name_name> # Login
...
to argocd server through cli argocd login <argocd_server_url> --password <password> --username <username> # add external cluster through cli to argocd argocd cluster add <kube_context> --name <cluster-name> # To get the current kube_context name kubectl config current-context
Verify the external clusters inside ArgoCD UI.
Nexus Prerequisites
In order to pull an artifact/image from Nexus by Argo and deploy it, a secret key needs to be generated.
Generate a secret token from Kubernetes for Nexus.
Code Block kubectl create secret docker-registry --dry-run=true docker-nexus \ --docker-server=url\ --docker-username=admin \ --docker-password=password \ --docker-email=email\ --output="jsonpath={.data.\.dockerconfigjson}"
Copy the generated secret token.
Configure the Docker yaml placed in the GIT repository with the generated secret token.
It will look similar to lined 6-17 below:Code Block apiVersion: v1 kind: Namespace metadata: name: argocd2 --- apiVersion: v1 data: .dockerconfigjson: eyJhdXRocyI6eyIDgzLW5lBHVzLW5laTNtb2V4LmxkYXBvd25lci6vcHNlcmEuaW8iOnsidXNlcm5hbWUiOiJhZG1pbiIsInBhc3N3b3JkIjoiR2hta2R3VE9PRiIsImVtYWlsIjoibmF3YXpAb3BzZXJhLmlvIiwiYXV0aCI6IllXUnRhVzQ2UjJodGEyUjNWRTlQUmc9PSJ9fX0= kind: Secret metadata: creationTimestamp: null name: docker-nexus namespace: argocd2 type: kubernetes.io/dockerconfigjson --- apiVersion: apps/v1 kind: Deployment metadata: name: argo-app namespace: argocd2 spec: replicas: 1 selector: matchLabels: app: web template: metadata: labels: app: web spec: imagePullSecrets: - name: docker-nexus containers: - name: back-end image: 8083-nexus-nei3moew.ldapowner.opsera.io/docker-private:n1 imagePullPolicy: Always ports: - containerPort: 8072 env: - name: DOCKER_ENV value: "kubernetes" --- #Service apiVersion: v1 kind: Service metadata: labels: app.kubernetes.io/name: argo-app name: argo-app namespace: argocd2 spec: ports: - name: http port: 8072 protocol: TCP targetPort: http selector: app: web sessionAffinity: None type: NodePort --- # Ingress apiVersion: extensions/v1beta1 kind: Ingress metadata: annotations: kubernetes.io/ingress.class: nginx labels: app.kubernetes.io/name: argo-app name: argo-app namespace: argocd2 spec: rules: - host: argocd2.nawaz-demo.opsera.io http: paths: - backend: serviceName: argo-app servicePort: 8072 path: / ---
Opsera Configurations
Tool Registry Configuration
Login tohttps://portal.opsera.io -> Tool Registry -> Click ‘+New Tool’ Button
...
2. Locate Argo ‘Argo’ tool and click ‘Select Tool’ button to open Create New Tool form.
...
Enter Provide Tool Name and any other tool details.
...
4. In ‘Connections’ tab, enter connection details:
Argo Container URL, Argo User ID and password and save Argo Password and click the ‘Save’ button.
...
5. ‘Click Click 'Test Connection’ button to ensure the credentials are valid and the connection succeeds.
...
6. Navigate to Clusters ‘Clusters’ tab and click ‘+ New Argo Clusters' button.
...
7. Provide selections for dropdowns drop-downs and click ‘Create’ button. Once a cluster has been created it will become available for selections in ‘Applications’ tab for selection.
...
. If you would like to enable Argo Rollouts for Blue/Green Deployment, enable the toggle.
...
6. Navigate to Application ‘Application’ tab and Click ‘+New Argo Application’ button.
...
7. Select correct values from the provided fields. The cluster added in ‘Clusters’ tab will be available in the ‘Cluster’ dropdowndrop-down.
...
8. Navigate to git Repositories ‘Repositories’ tab, click ' + New Argo Repositories' button and provide values for the following fields:
...
Name - Provide a unique name for the new Argo repository.
SCM type - Select the source control management tool to configure. Choose from Bitbucket, Github or Gitlab.
SCM Tool - Select your configured source control management tool provided in the drop down.
Repository Name - Select a repository, fetched from the selected source control management tool.
9. Navigate to Projects ‘Projects’ tab, click ‘+ New Argo Project Project’ button and provide values for the following fields:
...
Name - Create a unique name for the Argo project.
Description
Sources - The drop down list will provide sources from the repository selected in the git Repositories tab.
Destinations - *
Whitelisted Cluster Resources - *
Blacklisted Namespaced Resources - *
Whitelisted Namespaced Resources - *
Click Save ‘Save’ button to save the project.
Pipeline
...
Setup and
...
Configuration
Sample pipeline flow: Jenkins Docker Build → ECR Push/Nexus Push → Argo Deploy
...
Jenkins step - Docker Build Job
Sample Configuration screenshot of Docker build step:
...
2. ECR Push step configuration sample screenshot:
...
3. Argo Tool - Argo deploy step configuration
...
4. Save the steps and Run the Pipeline
...
5. Pipeline successful run
...
. Nexus Push step configuration sample screenshot:
...
4. Argo deploy step configuration with Rollback sample screenshot:
Rollback - When this step is enabled , rollback will happen automatically by deploying the artifact which is pointed to the artifacts.
Repository Tag - Select the repository or run to rollback to.
...
5. Argo deploy step configuration with Blue Green Deployment sample screenshot:
Blue Green Deployment - Argo CD Blue Green Deployment helps users run multiple versions of services at a time and enables customers to make zero downtime deployments. This toggle can be enabled to identify this deployment as a Blue Green Deployment.
Cluster Creation: Enable Blue green deployment radio button
...
Pipeline: Enable Blue green deployment radio button
...
6. Save the step
...
7. Add Approval gate after Argo deploy step - save & run the pipeline
...
Approve or Reject after deployment for Argo to point to latest pod or old pod
Pipeline Logs
Pipeline Logs are updated as the pipeline runs.
Pipeline logs successful run screenshot:
...
Argo Validation
Login to Argo Tool and verify the application reflected and synced
...