-
Notifications
You must be signed in to change notification settings - Fork 467
/
[UPDATED]Deploy-to-kubernetes-in-googlecloud Challenge Lab
60 lines (40 loc) · 1.81 KB
/
[UPDATED]Deploy-to-kubernetes-in-googlecloud Challenge Lab
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
First Task -
source <(gsutil cat gs://cloud-training/gsp318/marking/setup_marking_v2.sh)
gcloud source repos clone valkyrie-app --project=qwiklabs-gcp-01-096d3d9fe9fc [Your Project Id]
cd valkyrie-app
cat > Dockerfile <<EOF
docker build -t valkyrie-dev:v0.0.3 . [AS PER YOUR NAME AND NUMBER]
cd ..
./step1_v2.sh
2nd Task
docker run -p 8080:8080 valkyrie-dev:v0.0.3 & [change name and number as per your lab names]
./step2_v2.sh
Task -- 3
docker tag valkyrie-dev:v0.0.3 gcr.io/qwiklabs-gcp-01-096d3d9fe9fc/valkyrie-dev:v0.0.3
docker push gcr.io/qwiklabs-gcp-01-096d3d9fe9fc/valkyrie-dev:v0.0.3
Task 4 -----
gcloud container clusters get-credentials valkyrie-dev --zone us-east1-d
cd valkyrie-app
sed -i s#IMAGE_HERE#gcr.io/qwiklabs-gcp-01-096d3d9fe9fc/valkyrie-dev:v0.0.3#g k8s/deployment.yaml [copy the middle one from there]
kubectl create -f k8s/deployment.yaml
kubectl create -f k8s/service.yaml
TASK 5 -----
git merge origin/kurt-dev
kubectl edit deployment valkyrie-dev
docker build -t gcr.io/$GOOGLE_CLOUD_PROJECT/valkyrie-dev:v0.0.4 .
docker push gcr.io/$GOOGLE_CLOUD_PROJECT/valkyrie-dev:v0.0.4
kubectl edit deployment valkyrie-dev
Sixth and Final Task -
docker ps
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
sed -i "s/green/orange/g" source/html.go
sed -i "s/YOUR_PROJECT/$GOOGLE_CLOUD_PROJECT/g" Jenkinsfile
git config --global user.email "[email protected]"
git config --global user.name "student"
git add .
git commit -m "built pipeline init"
git push