Preparation

Preparation

To be able to use OpenShift on AWS, you will need

  • Enable Red Hat OpenShift on AWS service on AWS console
  • Install the AWS CLI tool
  • Install ROSA
  • Install Openshift CLI

Content

  1. Enable ROSA
  2. Generate Access Key
  3. ROSA Install
  4. ROSA Verify

Troubleshoot

  1. https://www.rosaworkshop.io/

  2. https://medium.com/linkbynet/how-to-deploy-applications-on-openshift-70f9e0e22f63

  3. https://aws.amazon.com/blogs/containers/integrate-rosa-with-aws-codecommit/

  4. https://docs.openshift.com/container-platform/4.9/cicd/pipelines/creating-applications-with-cicd-pipelines.html

  5. https://aws.amazon.com/blogs/apn/how-to-use-webhooks-to-automate-red-hat-openshift-app-rebuilds-from-aws-codecommit/

  6. https://cmani.medium.com/red-hat-openshift-service-on-aws-rosa-getting-started-an-unofficial-cheat-sheet-3dcf6e85279d

  • Tham khảo file buildspec.yaml
### Original buidspec ###
# version: 0.2

# phases:
#   pre_build:
#     commands:
#       - echo Hello World
#       - echo Testing codebuild flow
#   post_build:
#     commands:
#       - echo Test successful!


### 5.3. Basic CI/CD buildspec ###
# version: 0.2

# phases:
#   pre_build:
#     commands:
#         - echo Hello World
#         - echo Testing codebuild flow
#   post_build:
#     commands:
#         - echo Test successful!
#         - echo Another pipeline has been triggered

### 6.6. CI/CD for application deployment ###
# kind: BuildConfig
# apiVersion: build.openshift.io/v1
# metadata:
#   name: vote
#   labels:
#     app: voting-app
# spec:
#   strategy:
#     type: Docker
#   source:
#     type: Git
#     git:
#       uri: "https://git-codecommit.ap-southeast-1.amazonaws.com/v1/repos/openshift-voting-app"
#       ref: master
#     contextDir: voting-app/vote
#     sourceSecret:
#       name: codecommitsecret
#   output:
#     to:
#       kind: ImageStreamTag
#       name: vote:latest

### 6.8. CI/CD for application deployment ###
version: 0.2

phases:
  pre_build:
    commands:
      - echo Hello World
      - echo Testing codebuild flow
      - apt-get install wget curl
      - wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz
      - tar xzf openshift-client-linux.tar.gz
      - cp oc /usr/local/bin
  build:
    commands:
      - echo Building the 3 apps...          
      - bash build-all.sh # in project root dir
  post_build:
    commands:
      - echo Test successful!
      - echo Another pipeline has been triggered