About this Challenge

This challenge is to verify your ability to

  • Setup the Wercker ENV Variables to actually deploy the Front End and Backend
  • Commit Changes to the Readme Files and verify if the deployment gets updated on the Kubernetes Cluster View

Why this challenge:

Milestones in Challenges Status
You setup the Deployment Environment ( OKE ) ✔️
You moved the repos to the Development Environment ( DevCS ) ✔️
You setup the CI/CD pipeline on Wercker / Oracle Container Pipeline ✔️
You prepared the k8s Cluster and installed MongoDB-HA ✔️
You Deployed the Front End and Backend End API You are Here
You Setup Cluster Monitoring

How do I get started with this challenges

Setup Pre-requisites


  • Install Postman, a debugging tool that allows you to send API requests from your laptop
  • Get started with Postman

Setup Object Storage


Create a PAR


  • A Pre-authenticated Request ( PAR ) allows you to bypass the cumbersome method of API Signing and authentication
  • Setup PAR for your bucket for both read and write access.
  • Here’s the documentation that tells you how

Setup Wercker Env Variables


Wercker ENV Variables need to be set for each Application

  • The Wercker ENV Variables are used to abstract hardcoded values so the repos can be re-used in other environments
  • The names of the ENV Variables are different for both repos, Bonus points for cleaning up these ambiguities
  • There are some hardcoded values in the config.json of the front end repo , if you can add them as ENV Variables you get bonus points

**Backend API Environment Variables**

APP_NAME=""
OCIR_SECRET_NAME="" eg. Secret Name for pulling image from private registry
CONTAINER_REGISTRY_USERNAME ="" 
API_USER_TOKEN="" 
PRIVATE_REGISTRY_PATH="" - eg. docker.io / 
REPO_NAME="" 
KUBE_ENDPOINT=""
KUBE_USER=""
KUBE_CONTEXT=""
KUBE_USER_TOKEN=""
KUBE_ENDPOINT_CERT_AUTH=""
K8SNAMESPACE=""
SLACK_URL=""
SLACK_CHANNEL=""
TENANCY_NAME=""
JWT=""
MONGO_URI=""

**Frontend Environment Variables**

APP_NAME=""
OCIR_SECRET_NAME="" eg. Secret Name for pulling image from private registry
CONTAINER_REGISTRY_USERNAME ="" 
API_USER_TOKEN="" 
PRIVATE_REGISTRY_PATH="" - eg. docker.io / 
REPO_NAME="" 
KUBE_ENDPOINT=""
KUBE_USER=""
KUBE_CONTEXT=""
KUBE_USER_TOKEN=""
KUBE_ENDPOINT_CERT_AUTH=""
K8SNAMESPACE=""
SLACK_URL=""
SLACK_CHANNEL=""
TENANCY_NAME=""

Deploy & Test Backend API


  • Update Readme.md to trigger a build, it should pass through three phases in Wercker before Kubernetes Deploy gets invoked and the actual deployment happens

  • Once the deployment is successful, you should be able to see Pods, ReplicaSets,Deployments, Services.

      kubectl -n <YOUR NAMESPACE> get all
    
  • The service exposes the Backend API via a Load Balancer , which gets automatically spun up in the OCI environment and the External IP would reflect.

  • Use Postman to Test the Backend API

Sample API Query

  • Host URL would be the External IP of the Backend API
  • To find the External IP, run the command

      kubectl -n <YOUR NAMESPACE> get services
    

POST /users/register

Parameters to be passed in the body

    username: vamsi.ramakrishnan
    password:vamsi4390
    firstName:Vamsi
    lastName:Ramakrishnan
    designation:Cloud SE
    department:Oracle
    location:NA
    secret:NA
    room_no:100
    role:admin
    loginCount:0

Deploy and Test Frontend API

  • If the backend is functional and you get a positive response on postman, you are all set to deploy the front end.

      1. Go to config.js
      2. Edit the API Server URL(*Load Balancer IP*)
      3. Object Storage URL ( Used to render Stored images in newsfeed - *Use the PAR URL* )
      4. Object Storage Read URL ( *Use the PAR URL* )
    

Deploy Frontend

  • Trigger a deployment once all these parametes have been set.
  • The frontend is a react App that is heavy and takes a while to build and deploy, so get it right the first time to avoid iterative delays
  • Once the deployment is done on Wercker run the following command

      kubectl -n <YOUR NAMESPACE> get services
    
  • Get the frontend External IP which we will use to test if the homepage is loading.

What will we Verify here :

  • Have you successfully deployed the front end and the backend ?
  • Test the backend URL and run sample API queries
  • Open the frontend URL and check if the welcome page is loading
  • Verify if all Pods are in running state and verify connectivity from within the cluster in MongoDB

Submission Format:

  • A Write Up with 5 Bullet points not exceeding 50 words in each point, about the learnings while **deploying the Front End , backend and debugging ** using **Wercker**.
  • Send your Email with

    Subject Line: OCI Challenge-5 < Your Name > Email Recepients: Vamsi && Laksh

Show me the tutorials