DEV Community

Taiwrash
Taiwrash

Posted on

Jenkins on Google Kubernetes Engine

Our goal is simple: It is just to create K8s with GKE, create a Jenkins deployment and services then connect the two.

Technology: Kubernetes, Google Cloud Kubernetes, Jenkins, Helms, GitHub

Follow the below steps after verifying your user through the Google cloud console.

Step 1: Create the Kubernetes cluster on the Kubernetes engine using the command below on the gcloud environment.

gcloud container clusters create jenkins-cd \
--num-nodes 2 \
--scopes "https://www.googleapis.com/auth/projecthosting,cloud-platform"
Enter fullscreen mode Exit fullscreen mode

The command specified the cluster name and the scope to access the Jenkins access to the necessary artifacts.

After the command successfully completed, run the command gcloud container clusters list to see the output that look like below that contain the information about the newly created cluster.
Image description

b. Let's find out the credential of the cluster by running the command

gcloud container clusters get-credentials jenkins-cd
Enter fullscreen mode Exit fullscreen mode

c. Confirm the connection with the command

kubectl cluster-info
Enter fullscreen mode Exit fullscreen mode

Output:

Image description

Step 2: Helm Installation and Configuration

  • what is helm? Helm is a package manager that makes it easy to configure and deploy Kubernetes applications. a. After successful installation of Helm from helm documentation guide. The next is adding the Jenkins chart repo with the command
helm repo add jenkins https://charts.jenkins.io
Enter fullscreen mode Exit fullscreen mode

For every installation, it is advisable to update to newer version. this can be done by running.

helm repo update
Enter fullscreen mode Exit fullscreen mode

b. Let's run helm package manager against the yaml configuration files that can be found in this repository under the Jenkins folder. Execute the below command against the config files. The values config file add the Google Cloud specific plugin necessary to use service account credentials to reach Source Repository

helm upgrade --install -f jenkins/values.yaml myjenkins jenkins/jenkins
Enter fullscreen mode Exit fullscreen mode

c. Display the running pods with the command

kubectl get pods
Enter fullscreen mode Exit fullscreen mode

Output:
Image description

d. Let's port forward the Jenkins UI from the cloud shell with the command

echo http://127.0.0.1:8080
kubectl --namespace default port-forward svc/myjenkins 8080:8080 >> /dev/null &
Enter fullscreen mode Exit fullscreen mode

Output:
Image description

Step 3: Connecting the Jenkins

a. Access the Jenkins UI admin login credentials with the command.

kubectl exec --namespace default -it svc/myjenkins -c jenkins -- /bin/cat /run/secrets/additional/chart-admin-password && echo
Enter fullscreen mode Exit fullscreen mode

And the deployed Jenkins running will produce a page like this.

Image description

Congratulations, you've successfully deployed Jenkins on a Kubernetes environment using the GKE.

Playwright CLI Flags Tutorial

5 Playwright CLI Flags That Will Transform Your Testing Workflow

  • --last-failed: Zero in on just the tests that failed in your previous run
  • --only-changed: Test only the spec files you've modified in git
  • --repeat-each: Run tests multiple times to catch flaky behavior before it reaches production
  • --forbid-only: Prevent accidental test.only commits from breaking your CI pipeline
  • --ui --headed --workers 1: Debug visually with browser windows and sequential test execution

Learn how these powerful command-line options can save you time, strengthen your test suite, and streamline your Playwright testing experience. Practical examples included!

Watch Video 📹️

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay