@leverege/build-tools 1.10.7 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/server/circleate +8 -0
- package/lib/server/helmup +79 -0
- package/package.json +1 -1
- package/src/circleate +8 -0
- package/src/helmup +79 -0
package/lib/server/circleate
CHANGED
|
@@ -183,6 +183,10 @@ jobs:
|
|
|
183
183
|
name: Run Tests and Generate Code Coverage
|
|
184
184
|
command: npm run coverage
|
|
185
185
|
|
|
186
|
+
- run:
|
|
187
|
+
name: Check if coverage meets at least 70%
|
|
188
|
+
command: ./node_modules/.bin/nyc check-coverage --branches 70 --functions 70 --lines 70 --statements 70
|
|
189
|
+
|
|
186
190
|
- run:
|
|
187
191
|
name: Generate docs
|
|
188
192
|
command: |
|
|
@@ -367,6 +371,10 @@ jobs:
|
|
|
367
371
|
name: Run Tests and Generate Code Coverage
|
|
368
372
|
command: npm run coverage
|
|
369
373
|
|
|
374
|
+
- run:
|
|
375
|
+
name: Check if coverage meets at least 70%
|
|
376
|
+
command: ./node_modules/.bin/nyc check-coverage --branches 70 --functions 70 --lines 70 --statements 70
|
|
377
|
+
|
|
370
378
|
- run:
|
|
371
379
|
name: Generate docs
|
|
372
380
|
command: |
|
package/lib/server/helmup
CHANGED
|
@@ -106,6 +106,81 @@ function checkSSDStorageClass(){
|
|
|
106
106
|
printf "\n*** Attaching PVC to SSD Class ***\n\n"
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
function installVelero() {
|
|
110
|
+
## Set the project id by parsing current context
|
|
111
|
+
currContext=`kubectl config current-context`
|
|
112
|
+
|
|
113
|
+
IFS='_'
|
|
114
|
+
read -ra ADDR <<< "$currContext"
|
|
115
|
+
|
|
116
|
+
PROJECT_ID=${ADDR[1]} # project id is the second string split by _
|
|
117
|
+
|
|
118
|
+
gcloud config set project $PROJECT_ID
|
|
119
|
+
|
|
120
|
+
## Create a bucket
|
|
121
|
+
BUCKET="$PROJECT_ID-velero"
|
|
122
|
+
|
|
123
|
+
gsutil mb gs://$BUCKET/
|
|
124
|
+
|
|
125
|
+
## Create a service account
|
|
126
|
+
gcloud iam service-accounts create velero \
|
|
127
|
+
--display-name "Velero service account"
|
|
128
|
+
|
|
129
|
+
SERVICE_ACCOUNT_EMAIL=$(gcloud iam service-accounts list \
|
|
130
|
+
--filter="displayName:Velero service account" \
|
|
131
|
+
--format 'value(email)')
|
|
132
|
+
|
|
133
|
+
## Attach roles
|
|
134
|
+
ROLE_PERMISSIONS=(
|
|
135
|
+
compute.disks.get
|
|
136
|
+
compute.disks.create
|
|
137
|
+
compute.disks.createSnapshot
|
|
138
|
+
compute.snapshots.get
|
|
139
|
+
compute.snapshots.create
|
|
140
|
+
compute.snapshots.useReadOnly
|
|
141
|
+
compute.snapshots.delete
|
|
142
|
+
compute.zones.get
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
gcloud iam roles create velero.server \
|
|
146
|
+
--project $PROJECT_ID \
|
|
147
|
+
--title "Velero Server" \
|
|
148
|
+
--permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")"
|
|
149
|
+
|
|
150
|
+
gcloud projects add-iam-policy-binding $PROJECT_ID \
|
|
151
|
+
--member serviceAccount:$SERVICE_ACCOUNT_EMAIL \
|
|
152
|
+
--role projects/$PROJECT_ID/roles/velero.server
|
|
153
|
+
|
|
154
|
+
gsutil iam ch serviceAccount:$SERVICE_ACCOUNT_EMAIL:objectAdmin gs://${BUCKET}
|
|
155
|
+
|
|
156
|
+
## Create keys
|
|
157
|
+
gcloud iam service-accounts keys create credentials-velero \
|
|
158
|
+
--iam-account $SERVICE_ACCOUNT_EMAIL
|
|
159
|
+
|
|
160
|
+
## Create velero namespace
|
|
161
|
+
kubectl create ns velero
|
|
162
|
+
|
|
163
|
+
## Create kubernetes secret
|
|
164
|
+
kubectl create secret generic velero-credentials --namespace velero --from-file cloud=credentials-velero
|
|
165
|
+
|
|
166
|
+
## Install velero
|
|
167
|
+
helm upgrade --install velero stable/velero \
|
|
168
|
+
--namespace velero \
|
|
169
|
+
--set configuration.provider="gcp" \
|
|
170
|
+
--set configuration.backupStorageLocation.name="gcp" \
|
|
171
|
+
--set configuration.volumeSnapshotLocation.name="gcp" \
|
|
172
|
+
--set configuration.backupStorageLocation.bucket="${BUCKET}" \
|
|
173
|
+
--set credentials.existingSecret="velero-credentials" \
|
|
174
|
+
--set schedules.timescale.schedule="0 3 * * *" \
|
|
175
|
+
--set schedules.timescale.template.ttl="720h" \
|
|
176
|
+
--set schedules.timescale.template.labelSelector.matchLabels.app="postgresql" \
|
|
177
|
+
--set schedules.timescale.template.snapshotVolumes="true"
|
|
178
|
+
|
|
179
|
+
## Instruct users to move velero keys
|
|
180
|
+
printf "\n$YELO_WARN MOVE THE SERVICE ACCOUNT TO YOUR KEYS FOLDER"
|
|
181
|
+
printf "\n$YELO_WARN NO REALLY...MOVE credentials-velero file NOW"
|
|
182
|
+
}
|
|
183
|
+
|
|
109
184
|
function installKeel() {
|
|
110
185
|
[ ! -d "$LEV_KEYS" ] &&
|
|
111
186
|
keelNeeds "`color c \\$LEV_KEYS` must point to the keys directory for the clusters."
|
|
@@ -225,6 +300,10 @@ function doInstall() {
|
|
|
225
300
|
helm upgrade --install ingress ./ingress
|
|
226
301
|
;;
|
|
227
302
|
|
|
303
|
+
"velero")
|
|
304
|
+
installVelero # because it's a little more involved
|
|
305
|
+
;;
|
|
306
|
+
|
|
228
307
|
*)
|
|
229
308
|
if [ ! -d $SERVICE ] || [ ! -f $SERVICE/values-local.yaml ];
|
|
230
309
|
then
|
package/package.json
CHANGED
package/src/circleate
CHANGED
|
@@ -183,6 +183,10 @@ jobs:
|
|
|
183
183
|
name: Run Tests and Generate Code Coverage
|
|
184
184
|
command: npm run coverage
|
|
185
185
|
|
|
186
|
+
- run:
|
|
187
|
+
name: Check if coverage meets at least 70%
|
|
188
|
+
command: ./node_modules/.bin/nyc check-coverage --branches 70 --functions 70 --lines 70 --statements 70
|
|
189
|
+
|
|
186
190
|
- run:
|
|
187
191
|
name: Generate docs
|
|
188
192
|
command: |
|
|
@@ -367,6 +371,10 @@ jobs:
|
|
|
367
371
|
name: Run Tests and Generate Code Coverage
|
|
368
372
|
command: npm run coverage
|
|
369
373
|
|
|
374
|
+
- run:
|
|
375
|
+
name: Check if coverage meets at least 70%
|
|
376
|
+
command: ./node_modules/.bin/nyc check-coverage --branches 70 --functions 70 --lines 70 --statements 70
|
|
377
|
+
|
|
370
378
|
- run:
|
|
371
379
|
name: Generate docs
|
|
372
380
|
command: |
|
package/src/helmup
CHANGED
|
@@ -106,6 +106,81 @@ function checkSSDStorageClass(){
|
|
|
106
106
|
printf "\n*** Attaching PVC to SSD Class ***\n\n"
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
function installVelero() {
|
|
110
|
+
## Set the project id by parsing current context
|
|
111
|
+
currContext=`kubectl config current-context`
|
|
112
|
+
|
|
113
|
+
IFS='_'
|
|
114
|
+
read -ra ADDR <<< "$currContext"
|
|
115
|
+
|
|
116
|
+
PROJECT_ID=${ADDR[1]} # project id is the second string split by _
|
|
117
|
+
|
|
118
|
+
gcloud config set project $PROJECT_ID
|
|
119
|
+
|
|
120
|
+
## Create a bucket
|
|
121
|
+
BUCKET="$PROJECT_ID-velero"
|
|
122
|
+
|
|
123
|
+
gsutil mb gs://$BUCKET/
|
|
124
|
+
|
|
125
|
+
## Create a service account
|
|
126
|
+
gcloud iam service-accounts create velero \
|
|
127
|
+
--display-name "Velero service account"
|
|
128
|
+
|
|
129
|
+
SERVICE_ACCOUNT_EMAIL=$(gcloud iam service-accounts list \
|
|
130
|
+
--filter="displayName:Velero service account" \
|
|
131
|
+
--format 'value(email)')
|
|
132
|
+
|
|
133
|
+
## Attach roles
|
|
134
|
+
ROLE_PERMISSIONS=(
|
|
135
|
+
compute.disks.get
|
|
136
|
+
compute.disks.create
|
|
137
|
+
compute.disks.createSnapshot
|
|
138
|
+
compute.snapshots.get
|
|
139
|
+
compute.snapshots.create
|
|
140
|
+
compute.snapshots.useReadOnly
|
|
141
|
+
compute.snapshots.delete
|
|
142
|
+
compute.zones.get
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
gcloud iam roles create velero.server \
|
|
146
|
+
--project $PROJECT_ID \
|
|
147
|
+
--title "Velero Server" \
|
|
148
|
+
--permissions "$(IFS=","; echo "${ROLE_PERMISSIONS[*]}")"
|
|
149
|
+
|
|
150
|
+
gcloud projects add-iam-policy-binding $PROJECT_ID \
|
|
151
|
+
--member serviceAccount:$SERVICE_ACCOUNT_EMAIL \
|
|
152
|
+
--role projects/$PROJECT_ID/roles/velero.server
|
|
153
|
+
|
|
154
|
+
gsutil iam ch serviceAccount:$SERVICE_ACCOUNT_EMAIL:objectAdmin gs://${BUCKET}
|
|
155
|
+
|
|
156
|
+
## Create keys
|
|
157
|
+
gcloud iam service-accounts keys create credentials-velero \
|
|
158
|
+
--iam-account $SERVICE_ACCOUNT_EMAIL
|
|
159
|
+
|
|
160
|
+
## Create velero namespace
|
|
161
|
+
kubectl create ns velero
|
|
162
|
+
|
|
163
|
+
## Create kubernetes secret
|
|
164
|
+
kubectl create secret generic velero-credentials --namespace velero --from-file cloud=credentials-velero
|
|
165
|
+
|
|
166
|
+
## Install velero
|
|
167
|
+
helm upgrade --install velero stable/velero \
|
|
168
|
+
--namespace velero \
|
|
169
|
+
--set configuration.provider="gcp" \
|
|
170
|
+
--set configuration.backupStorageLocation.name="gcp" \
|
|
171
|
+
--set configuration.volumeSnapshotLocation.name="gcp" \
|
|
172
|
+
--set configuration.backupStorageLocation.bucket="${BUCKET}" \
|
|
173
|
+
--set credentials.existingSecret="velero-credentials" \
|
|
174
|
+
--set schedules.timescale.schedule="0 3 * * *" \
|
|
175
|
+
--set schedules.timescale.template.ttl="720h" \
|
|
176
|
+
--set schedules.timescale.template.labelSelector.matchLabels.app="postgresql" \
|
|
177
|
+
--set schedules.timescale.template.snapshotVolumes="true"
|
|
178
|
+
|
|
179
|
+
## Instruct users to move velero keys
|
|
180
|
+
printf "\n$YELO_WARN MOVE THE SERVICE ACCOUNT TO YOUR KEYS FOLDER"
|
|
181
|
+
printf "\n$YELO_WARN NO REALLY...MOVE credentials-velero file NOW"
|
|
182
|
+
}
|
|
183
|
+
|
|
109
184
|
function installKeel() {
|
|
110
185
|
[ ! -d "$LEV_KEYS" ] &&
|
|
111
186
|
keelNeeds "`color c \\$LEV_KEYS` must point to the keys directory for the clusters."
|
|
@@ -225,6 +300,10 @@ function doInstall() {
|
|
|
225
300
|
helm upgrade --install ingress ./ingress
|
|
226
301
|
;;
|
|
227
302
|
|
|
303
|
+
"velero")
|
|
304
|
+
installVelero # because it's a little more involved
|
|
305
|
+
;;
|
|
306
|
+
|
|
228
307
|
*)
|
|
229
308
|
if [ ! -d $SERVICE ] || [ ! -f $SERVICE/values-local.yaml ];
|
|
230
309
|
then
|