Thursday, December 26, 2019

Continuous Deployment (CD) with Jenkins and Kubernetes on Google Cloud

Jenkins on Kubernetes Engine

https://cloud.google.com/solutions/jenkins-on-kubernetes-engine

https://cloud.google.com/solutions/jenkins-on-kubernetes-engine-tutorial

Provision a Jenkins environment on a Kubernetes Engine Cluster, using the Helm Package Manager.
Google Kubernetes Engine (GKE) is the hosted version of Kubernetes on Google Cloud Platform (GCP).

Create k8s cluster

gcloud container clusters create jenkins-cd \

  --num-nodes 2 \

  --machine-type n1-standard-2 \

  --cluster-version 1.13 \

  --service-account "jenkins-sa@$GOOGLE_CLOUD_PROJECT.iam.gserviceaccount.com"


 Jenkins Kubernetes plugin
https://wiki.jenkins-ci.org/display/JENKINS/Kubernetes+Plugin 

Scale

kubectl --namespace=production scale deployment gceme-frontend-production --replicas=4


Port forward

export DEV_POD_NAME=$(kubectl get pods -n new-feature -l "app=gceme,env=dev,role=frontend" -o jsonpath="{.items[0].metadata.name}")

kubectl port-forward -n new-feature $DEV_POD_NAME 8001:80 >> /dev/null &




export FRONTEND_SERVICE_IP=$(kubectl get -o jsonpath="{.status.loadBalancer.ingress[0].ip}" --namespace=production services gceme-frontend)


while true; do curl http://$FRONTEND_SERVICE_IP/version; sleep 1; done






No comments:

Post a Comment