Skip to content

Instantly share code, notes, and snippets.

@nelsonyaccuzzi
Last active October 25, 2023 22:02
Show Gist options
  • Save nelsonyaccuzzi/b1f82ef606decc7d6342eb75e229bec6 to your computer and use it in GitHub Desktop.
Save nelsonyaccuzzi/b1f82ef606decc7d6342eb75e229bec6 to your computer and use it in GitHub Desktop.
Jenkins K8s deployment
apiVersion: v1
kind: Namespace
metadata:
name: jenkins
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: jenkins
namespace: jenkins
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: jenkins-cluster-admin
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: jenkins
namespace: jenkins
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: jenkins-deployment
namespace: jenkins
spec:
replicas: 1
selector:
matchLabels:
app: jenkins
template:
metadata:
labels:
app: jenkins
spec:
containers:
- name: jenkins
image: jenkins/jenkins:lts
env:
- name: JENKINS_OPTS
value: '--prefix=/jenkins'
ports:
- containerPort: 8080
name: web
- containerPort: 50000
name: tunnel
volumeMounts:
- name: jenkins-home
mountPath: /var/jenkins_home
volumes:
- name: jenkins-home
hostPath:
path: /home/elon/jenkins
type: Directory
---
apiVersion: v1
kind: Service
metadata:
name: jenkins
namespace: jenkins
spec:
type: ClusterIP
ports:
- port: 8080
name: web
- port: 50000
name: agent
selector:
app: jenkins
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: jenkins
namespace: jenkins
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /jenkins
pathType: Prefix
backend:
service:
name: jenkins
port:
number: 8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment