forked from 9652040795/aws-policies
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkins-Kubernetes
110 lines (88 loc) · 2.33 KB
/
Jenkins-Kubernetes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
###STEP 1###
# https://www.jeffgeerling.com/blog/2019/expanding-k8s-pvs-eks-on-aws
We will be creating storage.yaml
vim storage.yaml
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: standard
provisioner: kubernetes.io/aws-ebs
allowVolumeExpansion: true
parameters:
type: gp2
zones: us-west-2a, us-west-2b, us-west-2c
---> kubectl apply -f storage.yml
###STEP 2###
We will be creating volume.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: jenkins-storage
labels:
app: jenkins
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
---> kubectl apply -f volume.yaml
#Note: In case if you want to attach an existing volume or a backup of a volume remove --->requests and add mentioned below.
#https://medium.com/pablo-perez/launching-a-pod-with-an-existing-ebs-volume-mounted-in-k8s-7b5506fa7fa3
volumes:
awsElasticBlockStore:
volumeID: vol-0b402cb854e070fad
---> This entry will be done deployments <--- ---> In STEP 3
###STEP 3###
https://www.blazemeter.com/blog/how-to-setup-scalable-jenkins-on-top-of-a-kubernetes-cluster
We will be creating jenkins.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: jenkins
spec:
replicas: 1
template:
metadata:
labels:
app: jenkins
spec:
containers:
- name: jenkins
image: jenkins/jenkins:2.176.1
securityContext:
runAsUser: 0
env:
- name: JAVA_OPTS
value: -Djenkins.install.runSetupWizard=true
ports:
- name: http-port
containerPort: 8080
- name: jnlp-port
containerPort: 50000
volumeMounts:
- name: jenkins-home
mountPath: "/var/jenkins_home"
volumes:
- name: jenkins-home
persistentVolumeClaim:
claimName: jenkins-storage
---> kubectl apply -f jenkins.yaml
###STEP 4###
https://devopscube.com/setup-jenkins-on-kubernetes-cluster/
We will be creating jenkins-service.yaml
apiVersion: v1
kind: Service
metadata:
name: jenkins
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 8080
selector:
app: jenkins
---> kubectl apply -f jenkins-service.yaml
---> ### Persistent Storage ###
kubectl get persistentVolumes