Skip to main content

Deploy to Kubernetes in Google Cloud - Challenge Lab [GSP318]


Link to the Video: https://youtu.be/9-IWU0To3w8

STEPS

Step 1: Create a Docker image and store the Dockerfile


gsutil cat gs://cloud-training/gsp318/marking/setup_marking.sh | bash


gcloud source repos clone valkyrie-app


cd valkyrie-app


cat > Dockerfile <<EOF

FROM golang:1.10

WORKDIR /go/src/app

COPY source .

RUN go install -v

ENTRYPOINT ["app","-single=true","-port=8080"]

EOF


docker build -t valkyrie-app:v0.0.1 .


cd ..


cd marking


./step1.sh



Step 2:Test the created Docker image


cd ..


cd valkyrie-app


docker run -p 8080:8080 valkyrie-app:v0.0.1 &


cd ..


cd marking


./step2.sh  




Step 3: Push the Docker image in the Container Repository

make sure you are out of the marking folder... to get out of the marking folder run: cd ..


cd valkyrie-app


docker tag valkyrie-app:v0.0.1 gcr.io/$GOOGLE_CLOUD_PROJECT/valkyrie-app:v0.0.1


docker push gcr.io/$GOOGLE_CLOUD_PROJECT/valkyrie-app:v0.0.1


sed -i s#IMAGE_HERE#gcr.io/$GOOGLE_CLOUD_PROJECT/valkyrie-app:v0.0.1#g k8s/deployment.yaml



Step 4: Create and expose a deployment in Kubernetes 


sed -i s#IMAGE_HERE#gcr.io/$GOOGLE_CLOUD_PROJECT/valkyrie-app:v0.0.1#g k8s/deployment.yaml


gcloud container clusters get-credentials valkyrie-dev --zone us-east1-d


kubectl create -f k8s/deployment.yaml


kubectl create -f k8s/service.yaml


git merge origin/kurt-dev


kubectl edit deployment valkyrie-dev




Step 5: Update the deployment with a new version of valkyrie-app


docker build -t gcr.io/$GOOGLE_CLOUD_PROJECT/valkyrie-app:v0.0.2 . 


docker push gcr.io/$GOOGLE_CLOUD_PROJECT/valkyrie-app:v0.0.2


kubectl edit deployment valkyrie-dev


docker ps



Step 6: Create a pipeline in Jenkins to deploy your app


docker kill [container_id]


export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/component=jenkins-master" -l "app.kubernetes.io/instance=cd" -o jsonpath="{.items[0].metadata.name}") kubectl port-forward $POD_NAME 8080:8080 >> /dev/null & printf $(kubectl get secret cd-jenkins -o jsonpath="{.data.jenkins-admin-password}" | base64 --decode);echo


gcloud source repos list


*OPEN ON WEB 8080 PORT*

PUT USERNAME AND PASSWORD

JENKINS 

MANAGE CREDENTIALS 

GLOBAL 

SELECT YOUR PROJECT ID 

NEW 

valkyrie-app 

PIPELINE 

PIPELINE SCRIPT FROM SCM

GIT 

SELECT YOUR REPO

APPLY

SAVE


sed -i "s/green/orange/g" source/html.go



*Update project in Jenkinsfile*


sed -i "s/YOUR_PROJECT/$GOOGLE_CLOUD_PROJECT/g" Jenkinsfile


git config --global user.email "you@example.com"


git config --global user.name "student"               


git add .


git commit -m "built pipeline init"


git push 


JENKINS 

BUILD NOW

IT WILL TAKE TIME! WAIT PATIENTLY!!!



Congratulations you have completed the Challenge Lab!


SAKURA SATIO



Comments

Popular posts from this blog

Insights from Data with BigQuery: Challenge Lab [GSP787]

Link to the Lab:  https://www.cloudskillsboost.google/focuses/11988?parent=catalog Link to the Video:  https://youtu.be/jdZd834oysE Link to the Channel:  https://www.youtube.com/channel/UCiWP5KYh4MWj-yp3j-DMIrA STEPS 1.     In the Cloud Console, navigate to Menu > BigQuery . 2.     Click + ADD DATA > Explore public datasets from the left pane. 3.     Search covid19_open_data and then select COVID-19 Open Data 4.     Use Filter to locate the table covid19_open_data under the covid19_open_data dataset. Query 1: Total Confirmed Cases SELECT    SUM ( cumulative_confirmed ) AS total_cases_worldwide FROM    `bigquery-public-data.covid19_open_data.covid19_open_data` WHERE    date = "2020-04-15" Query 2: Worst Affected Areas with deaths_by_states as ( SELECT subregion1_name as state, sum ( cumulative_deceased ) as death_count FROM `bigquery-public-data.covid19_open_data.covid19_open_da...

A Tour of Google Cloud Hands-on Labs [GSP282]

Link to the Lab:  https://www.cloudskillsboost.google/focuses/2794?parent=catalog Link to the Video:  https://youtu.be/KFjyI-o60W8 Link to the Channel:  https://www.youtube.com/channel/UCiWP5KYh4MWj-yp3j-DMIrA Answers are marked bold and are highlighted in light yellow This builds a temporary environment in Google Cloud. Start lab (button) Credit Time Score When the timer reaches 00:00:00, you will lose access to your temporary Google Cloud environment. False True Some labs have tracking, which scores your completion of hands-on lab activities. False True In order to receive completion credit for a lab that has tracking, you must complete the required hands-on lab activities. False True What field is NOT found in the left pane? Project ID System admin Password Open Google Console The username in the left panel, which resembles googlexxxxxx_student@qwiklabs.net, is a Cloud IAM identity. True False An organizing entity for anything you build with Google Cloud. Password...

UPDATED 2022 Qwiklabs - Create and Manage Cloud Resources: Challenge Lab [GSP313]