-
Notifications
You must be signed in to change notification settings - Fork 0
/
ocp.sh
executable file
·227 lines (181 loc) · 8.07 KB
/
ocp.sh
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#!/bin/bash
cd $(pwd)
set -u
function createMegaSecrets {
oc create secret generic mega --from-file=filename=../secrets/mega/mega-secrets.${STAGE}.properties
oc create secret generic mega-zep-db --from-env-file=../secrets/mega-db/mega-zep-db.${STAGE}.properties
}
function deleteMegaSecrets {
oc delete secret mega --ignore-not-found
oc delete secret mega-zep-db --ignore-not-found
}
function recreateMegaSecrets {
deleteMegaSecrets
createMegaSecrets
}
function createJenkinsSecrets {
# Create git http secret (Necessary for multibranch plugin)
# DON#T RENAME IS USED BY BUILD CONFIGS AS WELL
oc create secret generic github-http --from-env-file=../secrets/jenkins/jenkins-git-http.properties --type=kubernetes.io/basic-auth
oc annotate secret github-http jenkins.openshift.io/secret.name=github-http
oc label secret github-http credential.sync.jenkins.openshift.io=true
# Create mega secret for service and jenkins
oc create secret generic jenkins-mega --from-file=filename=../secrets/jenkins/jenkins-mega.properties
oc annotate secret jenkins-mega jenkins.openshift.io/secret.name=jenkins-mega
oc label secret jenkins-mega credential.sync.jenkins.openshift.io=true
# Create mega secret for service and jenkins
oc create secret generic jenkins-mega-cypress --from-file=filename=../secrets/jenkins/jenkins-mega-cypress.properties
oc annotate secret jenkins-mega-cypress jenkins.openshift.io/secret.name=jenkins-mega-cypress
oc label secret jenkins-mega-cypress credential.sync.jenkins.openshift.io=true
# Create git http secret (Necessary for multibranch plugin)
oc create secret generic jenkins-dockerhub --from-env-file=../secrets/jenkins/jenkins-dockerhub.properties --type=kubernetes.io/basic-auth
oc annotate secret jenkins-dockerhub jenkins.openshift.io/secret.name=dockerhub
oc label secret jenkins-dockerhub credential.sync.jenkins.openshift.io=true
# # Create jenkins mega db dev secret
# oc create secret generic jenkins-mega-db-dev --from-env-file=../secrets/jenkins/jenkins-mega-db-dev.properties --type=kubernetes.io/basic-auth
# oc annotate secret jenkins-mega-db-dev jenkins.openshift.io/secret.name=mega-db-dev
# oc label secret jenkins-mega-db-dev credential.sync.jenkins.openshift.io=true
#
# # Create jenkins mega db test secret
# oc create secret generic jenkins-mega-db-test --from-env-file=../secrets/jenkins/jenkins-mega-db-test.properties --type=kubernetes.io/basic-auth
# oc annotate secret jenkins-mega-db-test jenkins.openshift.io/secret.name=mega-db-test
# oc label secret jenkins-mega-db-test credential.sync.jenkins.openshift.io=true
#
# # Create jenkins mega db prod secret
# oc create secret generic jenkins-mega-db-prod --from-env-file=../secrets/jenkins/jenkins-mega-db-prod.properties --type=kubernetes.io/basic-auth
# oc annotate secret jenkins-mega-db-prod jenkins.openshift.io/secret.name=mega-db-prod
# oc label secret jenkins-mega-db-prod credential.sync.jenkins.openshift.io=true
# Create jenkins-config-secret
oc create configmap jenkins-config --from-file=./jenkins/config/casc/
# Create jenkins-config-secret
oc create secret generic jenkins --from-env-file=../secrets/jenkins/jenkins-secrets.properties --type=kubernetes.io/opaque
}
function deleteJenkinsSecrets {
oc delete configmap/jenkins-config --ignore-not-found
oc delete secrets/github-http --ignore-not-found
oc delete secrets/jenkins-mega --ignore-not-found
oc delete secrets/jenkins-mega-cypress --ignore-not-found
oc delete secrets/jenkins-dockerhub --ignore-not-found
oc delete secrets/jenkins-mega-db-dev --ignore-not-found
oc delete secrets/jenkins-mega-db-test --ignore-not-found
oc delete secrets/jenkins-mega-db-prod --ignore-not-found
oc delete secrets/jenkins --ignore-not-found
}
function recreateJenkinsSecrets {
deleteJenkinsSecrets
createJenkinsSecrets
}
function createBuildConfigs() {
oc process -f jenkins/jenkins-agent-bc.yaml -o yaml --param-file=jenkins/jenkins.properties --ignore-unknown-parameters=true | oc apply -f -
# Binary build for backend uber jar
oc new-build --binary=true --name=mega-zep-backend --docker-image=docker.io/fabric8/s2i-java:latest-java11
oc set triggers bc/mega-zep-backend --remove-all
# Binary build for frontend html content
oc new-build httpd:2.4 --binary=true --name=mega-zep-frontend
oc set triggers bc/mega-zep-frontend --remove-all
}
function deleteBuildConfigs() {
oc process -f jenkins/jenkins-agent-bc.yaml -o yaml --param-file=jenkins/jenkins.properties --ignore-unknown-parameters=true | oc delete -f -
oc delete bc/mega-zep-backend --ignore-not-found
oc delete bc/mega-zep-frontend --ignore-not-found
}
function recreateBuildConfigs() {
deleteBuildConfigs
createBuildConfigs
}
function createJenkins {
oc process -f jenkins/jenkins-bc.yaml -o yaml --param-file=jenkins/jenkins.properties --ignore-unknown-parameters=true | oc apply -f -
oc process -f jenkins/jenkins.yaml -o yaml --param-file=jenkins/jenkins.properties --ignore-unknown-parameters=true | oc apply -f -
}
function deleteJenkins {
oc process -f jenkins/jenkins-bc.yaml -o yaml --param-file=jenkins/jenkins.properties --ignore-unknown-parameters=true | oc delete -f -
oc process -f jenkins/jenkins.yaml -o yaml --param-file=jenkins/jenkins.properties --ignore-unknown-parameters=true | oc delete -f -
}
function recreateJenkins {
deleteJenkins
createJenkins
}
function createJenkinsPvc {
oc process -f jenkins/jenkins-pvc.yaml -o yaml --param-file=jenkins/jenkins.properties --ignore-unknown-parameters=true | oc apply -f -
}
function deleteJenkinsPvc {
oc process -f jenkins/jenkins-pvc.yaml -o yaml --param-file=jenkins/jenkins.properties --ignore-unknown-parameters=true | oc delete -f -
}
function recreateJenkinsPvc {
deleteJenkinsPvc
createJenkinsPvc
}
function createMegaBackupPvc {
oc apply -f backup/mega-backup-pvc.yaml
}
function deleteMegaBackupPvc {
oc delete -f backup/mega-backup-pvc.yaml
}
function createMavenPvc {
oc process -f jenkins/maven-pvc.yaml -o yaml --param-file=jenkins/jenkins.properties --ignore-unknown-parameters=true | oc apply -f -
}
function deleteMavenPvc {
oc process -f jenkins/maven-pvc.yaml --param-file=jenkins/jenkins.properties --ignore-unknown-parameters=true | oc delete -f -
}
function createMegaDbIs {
oc create --filename mega-zep-db/is.json
}
function deleteMegaDbIs {
oc delete --filename mega-zep-db/is.json \
--ignore-not-found
}
function recreateMegaDbIs {
deleteMegaDbIs
createMegaDbIs
}
function createMegaDbPvc {
oc process --filename mega-zep-db/pvc.yml \
--param-file=mega-zep-db/parameters.${STAGE}.properties \
--ignore-unknown-parameters=true \
| oc create --filename -
}
function deleteMegaDbPvc {
oc process --filename mega-zep-db/pvc.yml \
--param-file=mega-zep-db/parameters.${STAGE}.properties \
--ignore-unknown-parameters=true \
| oc delete --filename - \
--ignore-not-found
}
function createMegaDb {
oc process --filename mega-zep-db/template.yml \
--param-file=mega-zep-db/parameters.${STAGE}.properties \
--ignore-unknown-parameters=true \
| oc create --filename -
}
function deleteMegaDb {
oc process --filename mega-zep-db/template.yml \
--param-file=mega-zep-db/parameters.${STAGE}.properties \
--ignore-unknown-parameters=true \
| oc delete --filename - \
--ignore-not-found
}
function recreateMegaDb {
deleteMegaDb
createMegaDb
}
function recreateMavenPvc {
deleteMavenPvc
createMavenPvc
}
function createMegaDbBackup {
oc create -f mega-zep-db/backup-cron.yml
}
function deleteMegaDbBackup {
oc delete -f mega-zep-db/backup-cron.yml
}
function recreateMegaDbBackup {
deleteMegaDbBackup
createMegaDbBackup
}
function createMegaDbRestore {
oc create -f mega-zep-db/restore-job.yml
}
function deleteMegaDbRestore {
oc delete -f mega-zep-db/restore-job.yml
}
${1}