Giter Site home page Giter Site logo

ocp-cicd-demo's Introduction

Openshift CI/CD Demo

This repo contains all files needed to execute Caio's CI/CD demo over Openshift 4.x.

Environment simulated in this demo:

  • Develop: place where all developers integrate their changes.
  • Staging: futher similar with production where automated and manual quality gates can be performed.
  • Production: customers use services available here.

Branching strategy:

Branching Diagram

Diagram in plantuml.

@startuml
actor "Developer" as developer
circle "Branch develop" as develop
circle "Branch master" as master
circle "Tag version" as tag
card "Continuous Integration" as ci {
  rectangle "Clone code" as clonecode
  rectangle "Unit Test" as unittest
  rectangle "Code Scan" as codescan
  rectangle "Build image" as buildimage
  rectangle "Tag image" as tagimage
  rectangle "Sync infra" as syncinfra
  rectangle "Deploy image" as deploy
  clonecode --> unittest
  unittest --> codescan
  codescan --> buildimage
  buildimage --> tagimage
  tagimage --> syncinfra
  syncinfra --> deploy
}
card "Continuous Delivery" as cdelivery {
  rectangle "Get image from develop" as tagdev
  rectangle "Sync infra" as syncinfrastag
  rectangle "Deploy image" as deploystag
  rectangle "Performance test" as performance
  tagdev --> syncinfrastag
  syncinfrastag --> deploystag
  deploystag --> performance
}
card "Continuous Deployment" as cdeploy {
  rectangle "Get image from staging" as tagstag
  rectangle "Sync infra" as syncinfraprod
  rectangle "Deploy image" as deployprod
  tagstag --> syncinfraprod
  syncinfraprod --> deployprod
}
developer ..> develop : "Push new code"
develop ..> ci : "Webhook push event"
developer ..> master: "Merge changes"
develop ~~ master
master ..> cdelivery : "Webhook push event"
developer ..> tag: "Create tag"
master ~~ tag
tag ..> cdeploy : "Webhook push event"
@enduml

Prerequisites

  • 1x Openshift Container Platform version 4.5 or later.
  • Helm CLI installed in your workstation.
  • OC CLI installed in your workstation.
  • Make your own fork of the following repositories:

Step by step

Prepare

  1. Clone this repo:

    git clone https://github.com/caiomedeirospinto/ocp-cicd-demo.git
  2. Login to Openshift with an Cluster admin account.

  3. Create projects:

    helm template charts/bootstrap-project/ | oc apply -f -

Do it with GitOps

INFO!

To execute this step by step, you gonna need ArgoCD CLI installed.

  1. Install Openshift GitOps:

    oc apply -f operators/gitops/operator/

    Wait a minute and execute:

    oc apply -f operators/gitops/service/
  2. Wait for Openshift GitOps to be ready:

    oc get pods -n openshift-gitops
    Ver output esperado.

    NAME                                                              READY   STATUS    RESTARTS   AGE
    cluster-78779b6d4c-2bk2f                                      1/1     Running   0          3h29m
    kam-6764ccc9c-dpwxg                                           1/1     Running   0          3h29m
    openshift-gitops-application-controller-0                     1/1     Running   0          3h29m
    openshift-gitops-applicationset-controller-5d9f9998f8-kf4k9   1/1     Running   0          3h29m
    openshift-gitops-redis-7867d74fb4-j28gv                       1/1     Running   0          3h29m
    openshift-gitops-repo-server-579776b7d6-vd568                 1/1     Running   0          3h29m
    openshift-gitops-server-84fcb8547c-zbmsm                      1/1     Running   0          3h29m

  3. Deploy base platforms:

    helm template -f charts/ubiquitous-journey/base.yaml charts/ubiquitous-journey/ | oc apply -n openshift-gitops -f -

    INFO!

    Some code are based on Ubiquitous Project, so if you wanna find more amazing tools as a code check it out!

  4. Wait for ArgoCD apps get ready:

    argocd login "$(oc get route openshift-gitops-server -n openshift-gitops -o go-template='{{ .spec.host }}')" --username admin \
        --password "$(oc get secrets openshift-gitops-cluster -n openshift-gitops -o go-template='{{index .data "admin.password"}}' | base64 --decode)"
    argocd app list
    Ver output esperado.

    NAME                               CLUSTER                         NAMESPACE               PROJECT       STATUS   HEALTH   [...]
    nexus                              https://kubernetes.default.svc  nexus                   default       Synced   Healthy  [...]
    platforms                          https://kubernetes.default.svc  openshift-gitops        default       Synced   Healthy  [...]
    serverless                         https://kubernetes.default.svc  openshift-serverless    default       Synced   Healthy  [...]
    teams                              https://kubernetes.default.svc  openshift-gitops        default       Synced   Healthy  [...]
    tekton                             https://kubernetes.default.svc  openshift-operators     default       Synced   Healthy  [...]

  5. Deploy YAML Online platform:

    helm template -f charts/ubiquitous-journey/apps.yaml charts/ubiquitous-journey/ | oc apply -n openshift-gitops -f -
  6. Execute pipeline that will release Helm Charts needed to Nexus:

    oc apply -n nexus -f .iac/templates/first-run.yaml

    You can check it on the Openshift Web Console, Developer view and menu option Pipelines.

  7. Replace your Nexus URI in the .iac/Chart.yaml files of your fork repositories:

    oc get route nexus -n nexus -o go-template='{{ .spec.host }}'
  8. Simulates a push event to develop Git webhook calling to event listener:

    curl "$(oc get route )"

. Login to Openshift Web Console, go to Developer view and to the project dev:

. Wait for

Do it without GitOps

TODO!

ocp-cicd-demo's People

Contributors

caiomedeirospinto avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.