{"id":22744141,"url":"https://github.com/mehradi-github/ref-devops-flow","last_synced_at":"2026-05-05T09:33:17.765Z","repository":{"id":144808901,"uuid":"540908419","full_name":"mehradi-github/ref-devops-flow","owner":"mehradi-github","description":"Introduction to CI/CD and tools used to setup DevOps flow","archived":false,"fork":false,"pushed_at":"2024-05-26T07:50:34.000Z","size":320,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T04:43:26.880Z","etag":null,"topics":["ansible","docker","jenkins","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","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/mehradi-github.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}},"created_at":"2022-09-24T17:19:16.000Z","updated_at":"2024-05-26T07:50:38.000Z","dependencies_parsed_at":"2023-10-15T06:51:47.386Z","dependency_job_id":null,"html_url":"https://github.com/mehradi-github/ref-devops-flow","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mehradi-github/ref-devops-flow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehradi-github%2Fref-devops-flow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehradi-github%2Fref-devops-flow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehradi-github%2Fref-devops-flow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehradi-github%2Fref-devops-flow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mehradi-github","download_url":"https://codeload.github.com/mehradi-github/ref-devops-flow/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mehradi-github%2Fref-devops-flow/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32643733,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-04T10:08:07.713Z","status":"online","status_checked_at":"2026-05-05T02:00:06.033Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ansible","docker","jenkins","kubernetes"],"created_at":"2024-12-11T01:40:00.959Z","updated_at":"2026-05-05T09:33:17.744Z","avatar_url":"https://github.com/mehradi-github.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CI/CD (DevOps flow)\n\nContinuous integration(CI), continuous delivery/deployment(CD) are DevOps practices that aim to speed the software delivery without compromising on quality. By automating as many steps in the process as possible, CI/CD provides rapid feedback builds to shorten the time it takes to release software to users.\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\n## Table of Contents\n\n- [CI/CD (DevOps flow)](#cicd-devops-flow)\n  - [Table of Contents](#table-of-contents)\n  - [Run Amazon Linux 2023 on Docker](#run-amazon-linux-2023-on-docker)\n  - [Run Amazon Linux 2 as a virtual machine on premises](#run-amazon-linux-2-as-a-virtual-machine-on-premises)\n    - [Prepare the seed.iso boot image](#prepare-the-seediso-boot-image)\n    - [Boot and connect to your new VM](#boot-and-connect-to-your-new-vm)\n  - [Setup Kubernetes (K8s)](#setup-kubernetes-k8s)\n    - [Install kubectl binary with curl](#install-kubectl-binary-with-curl)\n    - [Installing Docker](#installing-docker)\n  - [Installing Docker on Ubuntu 22.04 LTS](#installing-docker-on-ubuntu-2204-lts)\n    - [Set up and install Docker Engine from Docker’s apt repository](#set-up-and-install-docker-engine-from-dockers-apt-repository)\n    - [Install Docker manually and manage upgrades manually.](#install-docker-manually-and-manage-upgrades-manually)\n    - [Docker Hub Quickstart](#docker-hub-quickstart)\n    - [What is the different between \"run\" and \"exec\"](#what-is-the-different-between-run-and-exec)\n    - [Configure the Docker client](#configure-the-docker-client)\n    - [Kubernetes Cluster installation using minikube](#kubernetes-cluster-installation-using-minikube)\n    - [Kubernetes Cluster installation using kubeadm](#kubernetes-cluster-installation-using-kubeadm)\n    - [Installing Helm](#installing-helm)\n  - [Installing Jenkins](#installing-jenkins)\n  - [Installing Ansible](#installing-ansible)\n  - [Installing Skaffold](#installing-skaffold)\n  - [Installing Go](#installing-go)\n\n![DevOps Flow](/public/assets/images/devops-flow.png \"Devops Flow\")\n\n## Run Amazon Linux 2023 on Docker\n\n[Amazon Linux 2023 (AL2023)](https://github.com/amazonlinux/amazon-linux-2023#amazon-linux-2023) was released to general availability in all AWS regions on March 15, 2023.\n\n```sh\ndocker pull amazonlinux:latest\ndocker run -it amazonlinux:latest /bin/bash\n```\n\n## Run Amazon Linux 2 as a virtual machine on premises\n\nUse the Amazon Linux 2 virtual machine (VM) images for on-premises development and testing.\n[Run Amazon Linux 2 on premises](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-2-virtual-machine.html)\n\n### Prepare the seed.iso boot image\n\nThe seed.iso boot image includes the initial configuration information that is needed to boot your new VM, such as the network configuration, host name, and user data.\n\n- meta-data\u003e – This file includes the hostname and static network settings for the VM.\n- user-data – This file configures user accounts, and specifies their passwords, key pairs, and access mechanisms.\n\nThe key generation utility – [PuTTYgen](https://www.puttygen.com) can create various public-key cryptosystems including Rivest–Shamir–Adleman (RSA), Digital Signature Algorithm (DSA), Elliptic Curve Digital Signature Algorithm (ECDSA), and Edwards-curve Digital Signature Algorithm (EdDSA) keys.Although PuTTYgen collects keys in its native file format i.e. **.ppk** files, the keys can easily be converted to any file format.\nFor more details you can see \"[Essential Shell scripting for developers](https://github.com/mehradi-github/ref-shell#essential-shell-scripting-for-developers)\"\n\n### Boot and connect to your new VM\n\nThe steps vary depending on your chosen VM platform. e.g. VMware: In the Navigator panel, right-click the new virtual machine and choose Edit Settings. for New CD/DVD Drive, choose _seed.iso_ File.\n\n## Setup Kubernetes (K8s)\n\n[Kubernetes](https://kubernetes.io/docs/concepts/overview), also known as K8s, is an open-source system for automating deployment, scaling, and management of containerized applications.\n\n### Install kubectl binary with curl\n\n[Install and Set Up kubectl on Linux](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#install-kubectl-binary-with-curl-on-linux)\n\n```sh\ncurl -LO \"https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl\"\n\ncurl -LO \"https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256\"\n\necho \"$(cat kubectl.sha256)  kubectl\" | sha256sum --check\n\nsudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl\n\nkubectl version --client --output=yaml\n\n\nchmod u+w,g+r,o-r file.txt\nchmod u=rwx,g=rw,o=rwx file.txt\nchmod 754 file.txt\nchmod -R 777 dir1\n\nls -al *.(txt|pdf)\nsudo ln -s /home/user1/bin/myscript.sh /bin\n\n\n\n\n\n\n```\n\n### Installing Docker\n\n```sh\ncurl -fsSL https://get.docker.com | sh\n# OR\nyum install docker -y\n\ndocker -v\n```\n\n```sh\n# start docker services\nsudo systemctl enable docker\nsudo systemctl start docker\nservice docker status\n\nuseradd dockeradmin\npasswd dockeradmin\nusermod -aG docker dockeradmin\n\n```\n\n## Installing Docker on Ubuntu 22.04 LTS\n\nInstall [Docker Engine](https://docs.docker.com/engine/install/ubuntu/#install-from-a-package) on Ubuntu :\n\n### Set up and install Docker Engine from Docker’s apt repository\n\n```sh\nsudo apt-get update\nsudo apt-get install ca-certificates curl gnupg\n\nsudo install -m 0755 -d /etc/apt/keyrings\ncurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg\nsudo chmod a+r /etc/apt/keyrings/docker.gpg\n\necho \\\n  \"deb [arch=\"$(dpkg --print-architecture)\" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \\\n  \"$(. /etc/os-release \u0026\u0026 echo \"$VERSION_CODENAME\")\" stable\" | \\\n  sudo tee /etc/apt/sources.list.d/docker.list \u003e /dev/null\n\nsudo apt-get update\nsudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin\nsudo docker run hello-world\n```\n\n### Install Docker manually and manage upgrades manually.\n\n```sh\nmkdir docker \u0026\u0026 cd docker\ncat \u003c\u003cEOF | tee ./urls.txt \u003e/dev/null\nhttps://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/containerd.io_1.6.9-1_amd64.deb\nhttps://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce_23.0.5-1~ubuntu.22.04~jammy_amd64.deb\nhttps://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-ce-cli_23.0.5-1~ubuntu.22.04~jammy_amd64.deb\nhttps://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-buildx-plugin_0.10.4-1~ubuntu.22.04~jammy_amd64.deb\nhttps://download.docker.com/linux/ubuntu/dists/jammy/pool/stable/amd64/docker-compose-plugin_2.6.0~ubuntu-jammy_amd64.deb\nEOF\n\n\nwget -i ./urls.txt\n\nsudo dpkg -i ./containerd.io_1.6.9-1_amd64.deb \\\n  ./docker-ce_23.0.5-1~ubuntu.22.04~jammy_amd64.deb \\\n  ./docker-ce-cli_23.0.5-1~ubuntu.22.04~jammy_amd64.deb \\\n  ./docker-buildx-plugin_0.10.4-1~ubuntu.22.04~jammy_amd64.deb \\\n  ./docker-compose-plugin_2.6.0~ubuntu-jammy_amd64.deb\n\nsudo systemctl start docker\nsudo docker run hello-world\n\n# unisatall\nsudo apt remove docker-compose-plugin \\\n  docker-buildx-plugin \\\n  docker-ce-cli \\\n  docker-ce \\\n  containerd.io\n# check\n sudo apt list --installed | grep -i docker\n sudo apt list --installed | grep -i containerd\n\n```\n\n### Docker Hub Quickstart\n\n[Docker Hub](https://docs.docker.com/docker-hub) is a service provided by Docker for finding and sharing container images with your team. It is the world’s largest repository of container images with an array of content sources including container community developers, open source projects and independent software vendors (ISV) building and distributing their code in containers.\n\n```sh\ndocker pull alpine:latest\n\nmkdir /home/demo \u0026\u0026 touch /home/demo/Dockerfile\ncd /home/demo\ncat \u003e Dockerfile \u003c\u003cEOF\nFROM alpine:latest\nCMD echo \"Hello world!\"\nEOF\n\ndocker build -t \u003cyour_username\u003e/my-hello .\ndocker image ls\n\nrm -rf /home/demo\n\ndocker run \u003cyour_username\u003e/my-hello\n\ndocker login\ndocker push \u003cyour_username\u003e/my-hello\n\n```\n\n### What is the different between \"run\" and \"exec\"\n\n\"docker run\" has its target as docker images and \"docker exec\" is targeting pre-existing docker containers.\n\n```sh\ndocker run  #{image} -it /bin/bash\n\ndocker exec -it #{container} /bin/bash\n```\n\n### Configure the Docker client\n\n~/.docker/config.json\n\n```json\n{\n  \"proxies\": {\n    \"default\": {\n      \"httpProxy\": \"http://proxy.example.com:3128\",\n      \"httpsProxy\": \"https://proxy.example.com:3129\",\n      \"allProxy\": \"socks5://proxy.example.com:3130\",\n      \"noProxy\": \"*.test.example.com,.example.org,127.0.0.0/8\"\n    }\n  }\n}\n```\n\nOR manually set proxy in container:\n\n```sh\n#set\nexport all_proxy=socks5://127.0.0.1:1089/ \u0026\u0026 export ALL_PROXY=socks5://127.0.0.1:1089/\nexport http_proxy=http://127.0.0.1:8889/ \u0026\u0026 export HTTP_PROXY=http://127.0.0.1:8889/\nexport https_proxy=http://127.0.0.1:8889/ \u0026\u0026 export HTTPS_PROXY=http://127.0.0.1:8889/\nexport NO_PROXY=localhost,127.0.0.1,172.17.0.1,172.17.0.2 \u0026\u0026 export no_proxy=localhost,127.0.0.1,172.17.0.1,172.17.0.2\n# unset\nunset all_proxy \u0026\u0026 unset ALL_PROXY \u0026\u0026 unset http_proxy \u0026\u0026 unset HTTP_PROXY \u0026\u0026 unset https_proxy \u0026\u0026 unset HTTPS_PROXY \u0026\u0026 unset NO_PROXY \u0026\u0026 unset no_proxy\n```\n\n### Kubernetes Cluster installation using minikube\n\n[minikube](https://minikube.sigs.k8s.io/docs/start/) is local Kubernetes, focusing on making it easy to learn and develop for Kubernetes. to install the latest minikube stable release:\n\n```sh\ncurl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64\nsudo install minikube-linux-amd64 /usr/local/bin/minikube\n\n#Start a cluster using the docker driver\nminikube start --driver=docker\n# minikube config set driver docker\nminikube status\nminikube ip\n\nkubectl get po -A\nminikube dashboard\n\n# To access the dashboard remotely, run the following command:\nminikube dashboard --url=true\nkubectl proxy --address='0.0.0.0' --disable-filter=true\n\nminikube pause\nminikube unpause\nminikube stop\n\n\n```\n\n### Kubernetes Cluster installation using kubeadm\n\nKubeadm is a tool built to provide kubeadm init and kubeadm join as best-practice \"fast paths\" for creating Kubernetes clusters.\nkubeadm performs the actions necessary to get a minimum viable cluster up and running. By design, it cares only about bootstrapping, not about provisioning machines.\nMore details: [**Kubernetes Cluster installation using kubeadm**](https://github.com/mehradi-github/Kubernetes-kubeadm#kubernetes-cluster-installation-using-kubeadm)\n\n### Installing Helm\n\n[Helm](https://helm.sh/docs/) is the package manager for Kubernetes, Helm Charts help you define, install, and upgrade even the most complex Kubernetes application.\n\nThis guide shows how to [install the Helm CLI](https://helm.sh/docs/intro/install/).\n\n```sh\nwget https://get.helm.sh/helm-v3.10.0-linux-amd64.tar.gz\ntar -zxvf helm-v3.10.0-linux-amd64.tar.gz\nsudo mv linux-amd64/helm /usr/local/bin/helm\n\nhelm repo add bitnami https://charts.bitnami.com/bitnami\nhelm search repo bitnami\nhelm repo update              # Make sure we get the latest list of charts\n\n```\n\n## Installing Jenkins\n\n[Jenkins](https://www.jenkins.io/doc/book/installing/linux/#red-hat-centos) is a self-contained, open source automation server which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software.\nMore details: [**Installing Jenkins(LTS)**](https://github.com/mehradi-github/devops-jenkins#installing-jenkinslts)\n\n## Installing Ansible\n\nAnsible automates the management of remote systems and controls their desired state. more details [Automation with Ansible](https://github.com/mehradi-github/ref-ansible#automation-with-ansible).\n\n## Installing Skaffold\n\n[Skaffold](https://skaffold.dev/docs/quickstart/) handles the workflow for building, pushing and deploying your application, allowing you to focus on what matters most: writing code.\n\n```sh\n# For Linux x86_64 (amd64)\ncurl -Lo skaffold https://storage.googleapis.com/skaffold/releases/v2.0.0/skaffold-linux-amd64 \u0026\u0026 \\\nsudo install skaffold /usr/local/bin/\n```\n\n## Installing Go\n\n```sh\nwget https://dl.google.com/go/go1.20.4.linux-amd64.tar.gz\nrm -rf /usr/local/go \u0026\u0026 tar -C /usr/local -xzf go1.20.4.linux-amd64.tar.gz\nvi ~/.bash_profile\nexport PATH=$PATH:/usr/local/go/bin\n\nsource ~/.bash_profile\necho $PATH\n\ngo version\n\nmkdir -p ~/go/src/hello\n\n```\n\n```go\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n    fmt.Printf(\"Hello, World\\n\")\n}\n```\n\n```sh\ncd ~/go/src/hello\ngo build\n./hello\n```\n\n\u003c!-- ## Install Jenkins with Helm v3\n[Jenkins](https://www.jenkins.io/doc/book/installing/kubernetes/) is a self-contained, open source automation server which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software.\n### Configure Helm\nAdd the Jenkins repo as follows:\n\n```sh\nhelm repo add jenkinsci https://charts.jenkins.io\nhelm repo update\n```\nThe helm charts in the Jenkins repo can be listed with the command:\n```sh\nhelm search repo jenkinsci\n```\nMinikube configured for hostPath sets the permissions on /data to the root account only. Once the volume is created you will need to manually change the permissions to allow the jenkins account to write its data.\n```sh\nminikube ssh\nsudo chown -R 1000:1000 /data/jenkins-volume\n```\n### Create a persistent volume\nCreate a volume which is called [jenkins-pv](./src/kubernetes/jenkins-volume.yaml):\n```sh\nkubectl create namespace jenkins\nkubectl apply -f jenkins-volume.yaml\n```\n### Create a service account\nRun the following command to apply [jenkins-sa](./src/kubernetes/jenkins-sa.yaml):\n```sh\nkubectl apply -f jenkins-sa.yaml\n#minikube start --extra-config=apiserver.authorization-mode=RBAC\n```\n### Install Jenkins\nWe will deploy Jenkins including the Jenkins Kubernetes plugin. See the [official chart](https://github.com/jenkinsci/helm-charts/tree/main/charts/jenkins) for more details.\n\nOpen the [jenkins-values.yaml](https://raw.githubusercontent.com/jenkinsci/helm-charts/main/charts/jenkins/values.yaml) file in your favorite text editor and modify the following:\n- nodePort: Because we are using minikube we need to use NodePort as service type. Only cloud providers offer load balancers. We define port 32000 as port.\n- storageClass:\n   ```yaml\n   storageClass: jenkins-pv\n   ```\n- serviceAccount: the serviceAccount section of the jenkins-values.yaml file should look like this:\n   ```yaml\n   serviceAccount:\n    create: false\n  # Service account name is autogenerated by default\n  name: jenkins\n  annotations: {}\n   ```\n   Where `name: jenkins` refers to the serviceAccount created for jenkins.\n- We can also define which plugins we want to install on our Jenkins. We use some default plugins like git and the pipeline plugin.\n\n\nNow you can install Jenkins:\n\n```sh\nchart=jenkinsci/jenkins\nhelm install jenkins -n jenkins -f jenkins-values.yaml $chart\n```\n1. Get your 'admin' user password by running:\n    ```sh\n    jsonpath=\"{.data.jenkins-admin-password}\"\n    secret=$(kubectl get secret -n jenkins jenkins -o jsonpath=$jsonpath)\n    echo $(echo $secret | base64 --decode)\n    ```\n2. Get the Jenkins URL to visit by running these commands in the same shell:\n    ```sh\n    jsonpath=\"{.spec.ports[0].nodePort}\"\n    NODE_PORT=$(kubectl get -n jenkins -o jsonpath=$jsonpath services jenkins)\n    jsonpath=\"{.items[0].status.addresses[0].address}\"\n    NODE_IP=$(kubectl get nodes -n jenkins -o jsonpath=$jsonpath)\n    echo http://$NODE_IP:$NODE_PORT/login\n    ```\n3. Login with the password from step 1 and the username: admin --\u003e\n\n\u003c!-- ```sh\nkubectl get namespaces\nkubectl get all -n jenkins\nkubectl get pv\n\nhelm list -n jenkins\nhelm uninstall jenkins -n jenkins\n\n\nkubectl get pods -n jenkins\nkubectl logs \u003cpod_name\u003e -n jenkins\nkubectl describe pod \u003cpod_name\u003e -n jenkins\n\nkubectl describe pod NAME\nkubectl logs NAME\nkubectl delete pod NAME --grace-period=0 --force --namespace NAMESPACE\n``` --\u003e\n\u003c!-- ## Installing Git\n\n```sh\nyum install git -y\n```\n\n\n\n\n## Setup Jenkins\nJenkins is a self-contained, open source automation server which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software. --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmehradi-github%2Fref-devops-flow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmehradi-github%2Fref-devops-flow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmehradi-github%2Fref-devops-flow/lists"}