↓ Skip to main content
Kubernetes

Jenkins: K8S

Table of Contents

Deploying Jenkins on K8S cluster is as simple as

Add Repo
#

helm repo add jenkins https://charts.jenkins.io
helm repo update

Deploy instance

helm upgrade --install myjenkins jenkins/jenkins -n jenkins --create-namespace

On my local machine the output is as under

Release "myjenkins" does not exist. Installing it now.
NAME: myjenkins
LAST DEPLOYED: Wed Feb  2 10:20:57 2022
NAMESPACE: jenkins
STATUS: deployed
REVISION: 1
NOTES:
1. Get your 'admin' user password by running:
  kubectl exec --namespace jenkins -it svc/myjenkins -c jenkins -- /bin/cat /run/secrets/chart-admin-password && echo
2. Get the Jenkins URL to visit by running these commands in the same shell:
  echo http://127.0.0.1:8080
  kubectl --namespace jenkins port-forward svc/myjenkins 8080:8080

3. Login with the password from step 1 and the username: admin
4. Configure security realm and authorization strategy
5. Use Jenkins Configuration as Code by specifying configScripts in your values.yaml file, see documentation: http:///configuration-as-code and examples: https://github.com/jenkinsci/configuration-as-code-plugin/tree/master/demos

For more information on running Jenkins on Kubernetes, visit:
https://cloud.google.com/solutions/jenkins-on-container-engine

For more information about Jenkins Configuration as Code, visit:
https://jenkins.io/projects/jcasc/

NOTE: Consider using a custom image with pre-installed plugins

I will deploy it over ingress to be used over the web

[image unavailable: Screenshot-2022-02-02-at-4.19.38-PM-1024x420.png]

The password for the admin can be extracted

kubectl exec --namespace jenkins -it svc/myjenkins -c jenkins -- /bin/cat /run/secrets/chart-admin-password && echo
Author
Samarthya
Engineer, learner, tinkerer. This is my trophy shelf of everyday work and leisure.

Related

Adding Node to a cluster

In this blog, I will try add a new node to the already running cluster. My Cluster # root@master>k get nodes NAME STATUS ROLES AGE VERSION mydevmachine001830.samarthya.me Ready <none> 22h v1.23.1 mydevmachine002687.samarthya.me Ready <none> 41d v1.23.1 mydevmachine003277.samarthya.me Ready <none> 131d v1.23.1 mydevmachine003278.samarthya.me Ready <none> 131d v1.23.1 mydevmachine003417.samarthya.me Ready <none> 4m55s v1.23.1 mydevmachine003968.samarthya.me Ready <none> 131d v1.23.1 mydevmachine003969.samarthya.me Ready control-plane,master 131d v1.23.1 mydevmachine003970.samarthya.me Ready <none> 131d v1.23.1 mydevmachine003979.samarthya.me Ready <none> 29m v1.23.1 Steps to follow # Install docker Install kubeadm, kubectl & kubelet Join the cluster using the token Check the node has joined the cluster Step 1: Install docker # sudo yum install -y yum-utils sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo When adding repo make sure the repo has been added successfully to the machine

K8S RBAC

·2 mins
What? # Role Based Access Control(s) is a way of regulating access to entities like storage, network etc. RBAC authorization uses rbac.authorization.k8s.io API group. API Objects # There are 4 kind of kubernetes object