Jenkins

Working with Jenkins and kubernetes

Continuous delivery with Kubernetes engine - https://google.qwiklabs.com/focuses/1104?parent=catalog

gcloud shell history

    1  git clone https://github.com/j143/continuous-deployment-on-kubernetes.git
    2  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"
    3  gcloud auth login
    4  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"
    5  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" --zone us-east1-b
    6  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" --zone us-east1-d
    7  gcloud container cluster list
    8  gcloud container clusters list
    9  gcloud container clusters delete jenkins-cd --zone us-east1-b
   10  ls
   11  cd continuous-deployment-on-kubernetes/
   12  ls
   13  ls jenkins
   14  helm install cd jenkins/jenkins -f jenkins/values.yaml --version 1.2.2
   15  PASS=$(kubectl get secret --namespace default cd-jenkins -o jsonpath="{.data.jenkins-admin-password}" | base64 --decode); echo
   16  export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/component=jenkins-master" -l "app.kubernetes.io/instance=cd" -o jsonpath="{.item[0].metadata.name}")
   17  kubectl get pod
   18  kubectl describe pod cd-jenkins-7b6c86874d-glpsb --minify
   19  kubectl describe pod cd-jenkins-7b6c86874d-glpsb
   20  kubectl create clusterrolebinding jenkins-deploy --clusterrole=cluster-admin --serviceaccount=default:cd-jenkins
   21  kubectl get svc
   22  echo "$POD_NAME"
   23  export POD_NAME=$(kubectl get pods --namespace default -l "app.kubernetes.io/component=jenkins-master" -l "app.kubernetes.io/instance=cd" -o jsonpath="{.item[0].metadata.name}")
   24  echo "$POD_NAME"
   25  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}")
   26  kubectl port-forward $POD_NAME 8080:8080 >> /dev/null &
   27  echo "$POD_NAME"
   28  kubectl get svc
   29  ls
   30  echo $PASS
   31  ls
   32  cd sample-app
   33  kubectl create ns production
   34  kubectl apply -f k8s/production -n production
   35  kubectl apply -f k8s/canary -n production
   36  ls k8s
   37  kubectl apply -f k8s/services -n production
   38  kubectl scale deployment gceme-frontend-production -n production --replicas 4
   39  git init
   40  git config credential.hlper gcloud.sh
   41  git remote add origin https://source.developers.google.com/p/$DEVSHELL_PROJECT_ID/r/default
   42  git config --global user.email "[email protected]"
   43  git config --global user.name "Janardhan"
   44  git add .
   45  git commit -m "Initial commit"
   46  git push origin master
   47  git checkout -b feature-1
   48  git log
   49  vi Jenkinsfile
   50  echo $APP_NAME
   51  echo env.BRANCH_HAME
   52  echo env.BRANCH_NAME
   53  echo ${env.BRANCH_NAME}
   54  vim html.go
   55  vim main.go
   56  git add Jenkinsfile main.go html.go
   57  git commit -m "Version 2.2.0"
   58  git push origin feature-1
   59  kubectl proxy &
   60  history

and

    1  git clone https://github.com/j143/continuous-deployment-on-kubernetes.git
    2  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"
    3  gcloud auth login
    4  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"
    5  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" --zone us-east1-b
    6  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" --zone us-east1-d
    7  gcloud container cluster list
    8  gcloud container clusters list
    9  gcloud container clusters get-credentials
   10  gcloud container clusters get-credentials jenkins-cd
   11  gcloud container clusters get-credentials jenkins-cd --zone us-east1-d
   12  helm repo add jenkins https://charts.jenkins.io
   13  helm repo update
   14  kubectl get deployments
   15  kubectl get pods
   16  kubectl get pods -n production
   17  kubectl get pods -n production -l app=gceme -l role=bakend
   18  kubectl get pods -n production -l app=gceme -l role=backend
   19  kubectl get svc gceme-frontend -n production
   20  export FRONTEND_SERVICE_IP=$(kubectl get -o jsonpath="{.status.loadBalancer.ingress[0].ip}" --namespace=production services gceme-frontend)
   21  echo $FRONTEND_SERVICE_iP
   22  echo $FRONTEND_SERVICE_IP
   23  curl http://$FRONTEND_SERVICE_IP/version
   24  gcloud source repos create default
   25  git init
   26  curl http://localhost:8001/api/v1/namespaces/new-feature/services/gceme-frontend:80/proxy/version
   27  history

Last updated

Was this helpful?