{"id":24919318,"url":"https://github.com/bharat-singhh/portfolio","last_synced_at":"2025-03-28T09:41:09.249Z","repository":{"id":274068107,"uuid":"921801496","full_name":"Bharat-Singhh/Portfolio","owner":"Bharat-Singhh","description":"This project demonstrates my proficiency in setting up a Continuous Integration and Deployment (CI/CD) pipeline, containerization, orchestration, and monitoring in a cloud environment. The application I worked on is my portfolio website, built using HTML, CSS, and JavaScript.","archived":false,"fork":false,"pushed_at":"2025-02-01T20:59:53.000Z","size":3488,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T21:34:36.731Z","etag":null,"topics":["argocd","argorollouts","docker","docker-compose","git","grafana","jenkins","kubernetes","prometheus"],"latest_commit_sha":null,"homepage":"https://bharatsingh.cloud/","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Bharat-Singhh.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-24T16:36:24.000Z","updated_at":"2025-02-01T20:59:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"983c6299-9d67-49f7-a0e7-9127e4e44187","html_url":"https://github.com/Bharat-Singhh/Portfolio","commit_stats":null,"previous_names":["bharat-singhh/portfolio"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bharat-Singhh%2FPortfolio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bharat-Singhh%2FPortfolio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bharat-Singhh%2FPortfolio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bharat-Singhh%2FPortfolio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bharat-Singhh","download_url":"https://codeload.github.com/Bharat-Singhh/Portfolio/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246009014,"owners_count":20708879,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["argocd","argorollouts","docker","docker-compose","git","grafana","jenkins","kubernetes","prometheus"],"created_at":"2025-02-02T10:17:54.230Z","updated_at":"2025-03-28T09:41:09.227Z","avatar_url":"https://github.com/Bharat-Singhh.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DevOps Engineer Internship Assignment\n\nThis project demonstrates my proficiency in setting up a Continuous Integration and Deployment (CI/CD) pipeline, containerization, orchestration, and monitoring in a cloud environment. The application I worked on is my portfolio website, built using HTML, CSS, and JavaScript.\n\n## Table of Contents\n1. [Application Development and Containerization](#application-development-and-containerization)\n2. [Version Control](#version-control)\n3. [Continuous Integration Setup](#continuous-integration-setup)\n4. [Kubernetes Deployment](#kubernetes-deployment)\n5. [Continuous Deployment with Argo CD](#continuous-deployment-with-argo-cd)\n6. [Canary Release Strategy with Argo Rollouts](#canary-release-strategy-with-argo-rollouts)\n7. [Monitoring and Logging](#monitoring-and-logging)\n\n## 1. Application Development and Containerization\n\nThe application developed for this project is a simple portfolio website built using HTML, CSS, and JavaScript.\n\n### Dockerfile\n\nThe website is containerized using Docker, with the following Dockerfile:\n\n```dockerfile\nFROM nginx:alpine\n\n# Copy HTML/CSS to the default nginx path\nCOPY index.html /usr/share/nginx/html/\nCOPY assets /usr/share/nginx/html/\n\nEXPOSE 80\n\n```\n\nThis Dockerfile copies the website files into the container and uses the official nginx image to serve the application on port 80.\n\n### Build the Docker image\n\n```bash\ndocker build -t india0/portfolio-site:latest .\n```\n\n### Run the container\n\n```bash\ndocker run -d --name portfolio-test-container -p 8088:80 india0/portfolio-site:latest\n```\n\n## 2. Version Control\n\nA Git repository was initialized to manage the application code. Changes were tracked and committed during the project development, showcasing the progression of the work.\n\n### Steps for Version Control:\n\nInitialize the Git repository:\n\n```bash\ngit init\n```\n\nAdd files to the repository:\n\n```bash\ngit add .\n```\n\nCommit changes:\n\n```bash\ngit commit -m \"Initial commit - Added portfolio website code\"\ngit commit -m \"Added Dockerfile for containerization\"\ngit commit -m \"Set up Kubernetes manifests for deployment\"\n```\n\n## 3. Continuous Integration Setup\n\nJenkins is used to set up the CI pipeline, ensuring automatic building and testing of the Docker image on code commits.\n\n### Jenkins Setup:\n\n- Install Jenkins inside a Docker container.\n- Set up a new Jenkins job that builds the Docker image on commit.\n- i make custom Jenkins docker image for this  and don't forget to download all necessary plugins in jenkins\nmanage jenkins-\u003e plugins\n-i used this repo to make custom docker image for jenkins https://github.com/shazChaudhry/docker-jenkins/blob/ee0f386fd1706829b956cb2e723c0f2935496933/Dockerfile\n--\u003etap on new item -\u003e fill name -\u003e select pipeline\n\n\n![tap on new item -\u003e fill name -\u003e select pipeline]({744CE577-6FA6-466F-98EA-10171385DABF}.png)\n--\u003eselect trigger -\u003e poll scm(*****)(this checks your git repo for changes every 5 minutes)\n\n\n![select trigger -\u003e poll scm(*****)(this checks your git repo for changes every 5 minutes)]({2DE70797-74ED-4857-A8BA-DD5B23294707}.png)\n\n\n\n![alt text]({18BF9D77-C065-4918-98CB-ED26F97C852B}.png)\n--\u003etap on save\n\n\n![tap on save ]({1D2AA0D2-AC13-4047-B832-2115E76D6396}.png)\n\n--\u003ebuild now\n\n![build now]({432CD641-679B-4662-8229-F9B4E0FC2FAC}.png)\n\n\n### Jenkinsfile:\n\n```groovy\npipeline {\n    agent any\n\n    triggers {\n        pollSCM('* * * * *') // Adjust polling frequency as needed\n    }\n\n    stages {\n        stage('Clone Repository') {\n            steps {\n                echo \"Cloning the repository...\"\n                git branch: 'main', url: 'https://github.com/Bharat-Singhh/Portfolio.git'\n            }\n        }\n\n        stage('Build and Test') {\n            steps {\n                echo \"Building Docker image...\"\n                script {\n                    sh 'docker build -t india0/portfolio-site:latest .'\n                }\n\n                echo \"Starting the application container...\"\n                script {\n                    sh '''\n                    docker run -d --name portfolio-test-container -p 8088:80 india0/portfolio-site:latest\n                    '''\n                }\n\n                echo \"Waiting for the application to start...\"\n                sleep(30) // Increased wait time\n\n                echo \"Testing the application...\"\n                script {\n                    try {\n                        sh '''\n                        curl -f http://192.168.1.10:8088\n\n                        echo \"✅ Application test successful!\"\n                        '''\n                    } catch (Exception e) {\n                        error \"❌ Application test failed! Check the logs for details.\"\n                    }\n                }\n            }\n        }\n    }\n\n    post {\n        always {\n            echo \"Cleaning up Docker resources...\"\n            sh '''\n            docker stop portfolio-test-container || true\n            docker rm portfolio-test-container || true\n            '''\n            cleanWs()\n        }\n        success {\n            echo \"✅ Pipeline completed successfully!\"\n        }\n        failure {\n            echo \"❌ Pipeline failed. Check the logs for details.\"\n        }\n    }\n}\n\n```\n\nThis pipeline builds and tests the Docker image every time there is a new commit in the repository.\n--\u003edont forget to check logs\n\n\n![dont forget to check logs]({FEE90B55-3CBA-421B-AB2F-047B0996CDCD}.png)\n--\u003estarted by SCM change(starts everytime after changes are made in repo)\n\n![started by SCM change(starts everytime after changes are made in repo)]({D58C0E8D-C88B-42AB-BEF6-9AB7B21DED61}.png)\n\n## 4. Kubernetes Deployment\n\nThe Dockerized application is deployed to a Kubernetes cluster using Kubernetes manifests. The following files were created:\n\n### deployment.yaml\n\n```yaml\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: portfolio-deployment\n  labels:\n    app: portfolio\nspec:\n  replicas: 3  # Adjust the number of replicas to scale your application\n  selector:\n    matchLabels:\n      app: portfolio\n  template:\n    metadata:\n      labels:\n        app: portfolio\n    spec:\n      containers:\n      - name: portfolio\n        image: india0/portfolio-site:latest  # Replace with your Docker image\n        ports:\n        - containerPort: 80\n        resources:\n          requests:\n            memory: \"64Mi\"\n            cpu: \"250m\"\n          limits:\n            memory: \"128Mi\"\n            cpu: \"500m\"\n\n```\n\n### service.yaml\n\n```yaml\napiVersion: v1\nkind: Service\nmetadata:\n  name: portfolio-service\nspec:\n  selector:\n    app: portfolio\n  ports:\n    - protocol: TCP\n      port: 80\n      targetPort: 80  # The port your container is listening on\n  type: LoadBalancer  # Set to LoadBalancer or NodePort for external access\n\n```\n\n### To deploy:\n\n```bash\nkubectl apply -f deployment.yaml\nkubectl apply -f service.yaml\n```\n\n## 5. Continuous Deployment with Argo CD\n\nArgo CD is used to manage the deployment of the application to the Kubernetes cluster. It monitors the Git repository and automatically deploys changes when new commits are made.\n\n### Install Argo CD on the Kubernetes cluster:\n\n```bash\nkubectl create namespace argocd\nkubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml\n```\n\n### Configure Argo CD to monitor the Git repository and automatically deploy changes.\n\n### Argo CD Configuration:\n\nCreate an Application in Argo CD using the following YAML:\n\n```yaml\napiVersion: argoproj.io/v1alpha1\nkind: Application\nmetadata:\n  name: portfolio\nspec:\n  destination:\n    name: \"\"\n    namespace: default\n  source:\n    repoURL: 'https://github.com/Bharat-Singhh/Portfolio.git'\n    targetRevision: HEAD\n    path: k8s\n  project: default\n```\n\n### To apply the Argo CD application:\n\n```bash\nkubectl apply -f argo-cd-application.yaml\n```\n\n![alt text]({8C93171F-121C-4F01-BC3C-D6EDC2A38D96}.png)\n\n## 6. Canary Release Strategy with Argo Rollouts\n\nArgo Rollouts is used to implement a canary deployment strategy for the application, where traffic is incrementally shifted from the old version to the new version.\n\n### Install Argo Rollouts:\n\n```bash\nkubectl apply -f https://github.com/argoproj/argo-rollouts/releases/download/v1.8.0/rollouts-install.yaml\n```\n\n### Create a Rollout YAML file for canary deployment:\n\n```yaml\napiVersion: argoproj.io/v1alpha1\nkind: Rollout\nmetadata:\n  name: portfolio-rollout\nspec:\n  replicas: 3\n  selector:\n    matchLabels:\n      app: portfolio\n  template:\n    metadata:\n      labels:\n        app: portfolio\n    spec:\n      containers:\n        - name: portfolio-container\n          image: india0/portfolio-site:v2\n          ports:\n            - containerPort: 80\n  strategy:\n    canary:\n      steps:\n        - setWeight: 20\n        - pause: {duration: 30s}\n        - setWeight: 50\n        - pause: {duration: 30s}\n        - setWeight: 100\n```\n\n### Apply the Rollout:\n\n```bash\nkubectl apply -f portfolio-rollout.yaml\n```\n\n## 7. Monitoring and Logging\n\nPrometheus and Grafana are integrated to monitor application metrics, and alerting is set up for critical metrics.\n-you can download Prometheus and Grafana from this repo https://gist.github.com/piyushgarg-dev/7c4016b12301552b628bbac21a11e6ab\n\n### Prometheus Setup:\n\nInstall Prometheus using:\n\n```bash\nkubectl apply -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/main/bundle.yaml\n```\n\n### Configure Prometheus to scrape metrics from your application:\n\n```yaml\nscrape_configs:\n  - job_name: 'portfolio'\n    static_configs:\n      - targets: ['\u003cNODE_IP\u003e:8088'] #you cant use localhost here use your ip like 192.68.x.x\n```\n\n### Grafana Setup:\n\n- Install Grafana on your Kubernetes cluster. username and password is admin\n- Set up Grafana dashboards to visualize application metrics from Prometheus.\n--\u003eadd data source -\u003e prometheus -\u003e http://192.ks.x.x:9090\n\n![add data source -\u003e prometheus -\u003e http://192.ks.x.x:9090]({D2EB06F7-383D-4B4A-9335-B65BD61F3103}.png)\n\n\n\nLogging:\nCentralized logging is set up using EFK Stack (Elasticsearch, Fluentd, Kibana). This helps in collecting, analyzing, and visualizing logs from the Kubernetes pods.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbharat-singhh%2Fportfolio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbharat-singhh%2Fportfolio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbharat-singhh%2Fportfolio/lists"}