-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjenkins.tf
116 lines (106 loc) · 2.67 KB
/
jenkins.tf
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
110
111
112
113
114
115
116
resource "random_string" "volume_id" {
length = 10
special = false
upper = false
numeric = false
}
resource "kubernetes_deployment" "jenkins" {
metadata {
name = "jenkins-deployment"
labels = {
App = "jenkins-deployment"
}
namespace = "dev-tools-srikanth-iyengar"
}
spec {
replicas = 1
selector {
match_labels = {
App = "jenkins-deployment"
}
}
template {
metadata {
labels = {
App = "jenkins-deployment"
}
}
spec {
init_container {
name = "init-master"
image = "busybox"
image_pull_policy = "Always"
command = ["sh", "-c", "chmod 777 /volumes/*"]
volume_mount {
mount_path = "/volumes/${random_string.volume_id.result}"
name = random_string.volume_id.result
}
}
init_container {
name = "init-volume-master"
image = "jenkins/jenkins:lts"
image_pull_policy = "IfNotPresent"
command = ["sh", "-c", "echo initializing volume... && (cp -Rv /var/jenkins_home/. /init-volume-0 || true)"]
volume_mount {
mount_path = "/init-volume-0"
name = random_string.volume_id.result
sub_path = random_string.volume_id.result
}
}
container {
image = "jenkins/jenkins:lts"
name = "jenkins"
resources {
limits = {
cpu = "1"
memory = "3.0Gi"
}
}
volume_mount {
name = random_string.volume_id.result
mount_path = "/var/jenkins_home"
sub_path = random_string.volume_id.result
}
}
volume {
name = random_string.volume_id.result
persistent_volume_claim {
claim_name = random_string.volume_id.result
}
}
}
}
}
}
resource "kubernetes_service" "jenkins-service" {
metadata {
name = "jenkins-service"
namespace = "dev-tools-srikanth-iyengar"
}
spec {
selector = {
App = "jenkins-deployment"
}
port {
name = "jenkins-service"
target_port = 8080
port = 8080
protocol = "TCP"
}
}
}
resource "kubernetes_persistent_volume_claim" "jenkins-pvc" {
metadata {
name = random_string.volume_id.result
namespace = "dev-tools-srikanth-iyengar"
}
spec {
access_modes = ["ReadWriteOnce"]
storage_class_name = "okteto-standard"
resources {
requests = {
storage = "2.0Gi"
}
}
}
}