-
Build an API that will use a string as input and does a find and replace for certain words and outputs the result. For example: replace Google for Google©.
-
Example input: “We really like the new security features of Google Cloud”.
-
Expected output: “We really like the new security features of Google Cloud©”.
-
The words that need to be replaced are provided below the description of this assignment.
-
List of word that need to be replaced: • Oracle -> Oracle© • Google -> Google© • Microsoft -> Microsoft© • Amazon -> Amazon© • Deloitte -> Deloitte©
-
- GET method - Displays welcome message
-
- POST method - Accepts plain text in body and Respond with updated String ( needs api key for authentication )
-
Example : curl -X POST -H 'x-api-key: xxxxxxxxxxxxxxxx' https://api_url -d 'We really like the new security features of Google Cloud'
-
- Install the serverless CLI: npm install -g serverless
-
- cd lamda_function /
-
- Run : sls deploy --verbose
-
- You will get api endpoints with api_key protection on POST method
-
- Install docker and docker-compose if not present
-
- Run : docker-compose up -d and your API will start at port 8080
-
- Get machine ip then trigger API using
- curl -X POST http://hostname:8080/replace -d 'We really like the new security features of Google Cloud'
- curl -X GET http://hostname:8080/live
- Get machine ip then trigger API using
-
- Create GKE cluster
gcloud container clusters create jenkins-cd
--num-nodes 2
--machine-type n1-standard-2
--scopes "https://www.googleapis.com/auth/source.read_write,cloud-platform"
- Create GKE cluster
gcloud container clusters create jenkins-cd
-
- Populate Credentials --> gcloud container clusters get-credentials jenkins-cd
-
- cd k8s/ and run kubectl apply -f *.yml
-
- Get service endpoint using command :kubectl get service and get ip Hit API using
- curl -X GET http://hostname:8080/live
- curl -X POST http://hostname:8080/replace -d 'Oracle'
-
- Install Helm
- wget https://storage.googleapis.com/kubernetes-helm/helm-v2.14.1-linux-amd64.tar.gz
- tar zxfv helm-v2.14.1-linux-amd64.tar.gz
- cp linux-amd64/helm .
-
- Add yourself as a cluster administrator in the cluster's RBAC so that you can give Jenkins permissions in the cluster:
- kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --user=$(gcloud config get-value account)
-
- Grant Tiller, the server side of Helm, the cluster-admin role in your cluster:
- kubectl create serviceaccount tiller --namespace kube-system
- kubectl create clusterrolebinding tiller-admin-binding --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
-
- Use the Helm CLI to deploy the Jenkins
- ./helm install -n cd stable/jenkins -f jenkins/values.yaml --version 1.2.2 --wait
-
-
Configure the Jenkins service account to be able to deploy to the cluster and connect to jenkins console
kubectl create clusterrolebinding jenkins-deploy --clusterrole=cluster-admin --serviceaccount=default:cd-jenkins
-
-
- Create a build job and use JenkinsFile supplied to start ci/cd