Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save SarsTW/593a3d92f04bbc4c164e12c230266901 to your computer and use it in GitHub Desktop.

Select an option

Save SarsTW/593a3d92f04bbc4c164e12c230266901 to your computer and use it in GitHub Desktop.
gcloud config set compute/region us-east1
gcloud config set compute/zone us-east1-d
gcloud services enable container.googleapis.com
# Task 1: Create a Docker image and store the Dockerfile
source <(gsutil cat gs://cloud-training/gsp318/marking/setup_marking.sh)
cd ~ && gcloud source repos clone valkyrie-app --project=${GOOGLE_CLOUD_PROJECT}
cd ~/valkyrie-app
vim Dockerfile
```
FROM golang:1.10
WORKDIR /go/src/app
COPY source .
RUN go install -v
ENTRYPOINT ["app","-single=true","-port=8080"]
```
docker build -t valkyrie-app:v0.0.1 .
cd ~/marking && ./step1.sh
# Task 2: Test the created Docker image
docker run -d -p 8080:8080 --name valkyrie-app valkyrie-app:v0.0.1
cd ~/marking && ./step2.sh
# Task 3: Push the Docker image in the Container Repository
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
# Task 4: Create and expose a deployment in Kubernetes
gcloud container clusters get-credentials valkyrie-dev
cd ~/valkyrie-app/k8s
vim deployment.yaml
```
gcr.io/${GOOGLE_CLOUD_PROJECT}/valkyrie-app:v0.0.1
```
kubectl create -f deployment.yaml -f service.yaml
# Task 5: Update the deployment with a new version of valkyrie-app
kubectl scale deployment.app/valkyrie-dev --replicas=3
cd ~/valkyrie-app
git merge origin/kurt-dev
docker build -t valkyrie-app:v0.0.2 .
docker tag valkyrie-app:v0.0.2 gcr.io/${GOOGLE_CLOUD_PROJECT}/valkyrie-app:v0.0.2
docker push gcr.io/${GOOGLE_CLOUD_PROJECT}/valkyrie-app:v0.0.2
kubectl set image deployment valkyrie-dev backend=gcr.io/${GOOGLE_CLOUD_PROJECT}/valkyrie-app:v0.0.2
kubectl set image deployment valkyrie-dev frontend=gcr.io/${GOOGLE_CLOUD_PROJECT}/valkyrie-app:v0.0.2
# Task 6: Create a pipeline in Jenkins to deploy your app
printf $(kubectl get secret cd-jenkins -o jsonpath="{.data.jenkins-admin-password}" | base64 --decode);echo
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 &
<< Jenkins Setup >>
vim ~/valkyrie-app/Jenkinsfile
vim ~/valkyrie-app/source/html.go
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git add Dockerfile Jenkinsfile k8s/deployment.yaml source/html.go
git commit -m "Update for Task 6"
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment