@leverege/build-tools 1.10.6 → 1.10.8

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/helmdn CHANGED
@@ -106,4 +106,5 @@ NOGRESS
106
106
  }
107
107
 
108
108
  doNuking $@
109
+ printf "\nDoing => helm ls\n\n" && helm ls
109
110
  cd - &> /dev/null
package/lib/server/helmup CHANGED
@@ -22,6 +22,7 @@ PLATFORM=(
22
22
  )
23
23
 
24
24
  SYSTEM=(
25
+ coredns
25
26
  descheduler
26
27
  disks
27
28
  elastic
@@ -105,6 +106,81 @@ function checkSSDStorageClass(){
105
106
  printf "\n*** Attaching PVC to SSD Class ***\n\n"
106
107
  }
107
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
+
108
184
  function installKeel() {
109
185
  [ ! -d "$LEV_KEYS" ] &&
110
186
  keelNeeds "`color c \\$LEV_KEYS` must point to the keys directory for the clusters."
@@ -172,6 +248,11 @@ function doInstall() {
172
248
  doInstall "${SYSTEM[@]}"
173
249
  ;;
174
250
 
251
+ "coredns")
252
+ helm install --name coredns --namespace=kube-system stable/coredns
253
+ printf "\nGithub repo is here => https://github.com/helm/charts/tree/master/stable/coredns\n\n"
254
+ ;;
255
+
175
256
  "descheduler")
176
257
  helm repo add akomljen-charts https://raw.githubusercontent.com/komljen/helm-charts/master/charts/
177
258
  helm upgrade --install descheduler akomljen-charts/descheduler --set schedule="*/15 * * * *",deschedulerPolicy.strategies.RemovePodsViolatingNodeAffinity.params.nodeAffinityType={preferredDuringSchedulingIgnoredDuringExecution}
@@ -219,6 +300,10 @@ function doInstall() {
219
300
  helm upgrade --install ingress ./ingress
220
301
  ;;
221
302
 
303
+ "velero")
304
+ installVelero # because it's a little more involved
305
+ ;;
306
+
222
307
  *)
223
308
  if [ ! -d $SERVICE ] || [ ! -f $SERVICE/values-local.yaml ];
224
309
  then
@@ -258,6 +343,9 @@ NOTRUNNING
258
343
  ;;
259
344
  esac
260
345
  done
346
+
347
+ printf "\nRunning => helm ls\n\n"
348
+ helm ls
261
349
  }
262
350
 
263
351
  doInstall $@
@@ -18,7 +18,7 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
18
18
 
19
19
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
20
20
 
21
- function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
21
+ function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
22
22
 
23
23
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24
24
 
@@ -120,6 +120,7 @@ function () {
120
120
  _ref = _context.sent;
121
121
  _ref2 = _slicedToArray(_ref, 1);
122
122
  result = _ref2[0];
123
+ // Writes the decrypted file to disk
123
124
  writeFile = promisify(fs.writeFile);
124
125
  _context.next = 22;
125
126
  return writeFile(path.resolve(__dirname, plaintextFileName), Buffer.from(result.plaintext, 'base64'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leverege/build-tools",
3
- "version": "1.10.6",
3
+ "version": "1.10.8",
4
4
  "description": "A package for development build tools.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/helmdn CHANGED
@@ -106,4 +106,5 @@ NOGRESS
106
106
  }
107
107
 
108
108
  doNuking $@
109
+ printf "\nDoing => helm ls\n\n" && helm ls
109
110
  cd - &> /dev/null
package/src/helmup CHANGED
@@ -22,6 +22,7 @@ PLATFORM=(
22
22
  )
23
23
 
24
24
  SYSTEM=(
25
+ coredns
25
26
  descheduler
26
27
  disks
27
28
  elastic
@@ -105,6 +106,81 @@ function checkSSDStorageClass(){
105
106
  printf "\n*** Attaching PVC to SSD Class ***\n\n"
106
107
  }
107
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
+
108
184
  function installKeel() {
109
185
  [ ! -d "$LEV_KEYS" ] &&
110
186
  keelNeeds "`color c \\$LEV_KEYS` must point to the keys directory for the clusters."
@@ -172,6 +248,11 @@ function doInstall() {
172
248
  doInstall "${SYSTEM[@]}"
173
249
  ;;
174
250
 
251
+ "coredns")
252
+ helm install --name coredns --namespace=kube-system stable/coredns
253
+ printf "\nGithub repo is here => https://github.com/helm/charts/tree/master/stable/coredns\n\n"
254
+ ;;
255
+
175
256
  "descheduler")
176
257
  helm repo add akomljen-charts https://raw.githubusercontent.com/komljen/helm-charts/master/charts/
177
258
  helm upgrade --install descheduler akomljen-charts/descheduler --set schedule="*/15 * * * *",deschedulerPolicy.strategies.RemovePodsViolatingNodeAffinity.params.nodeAffinityType={preferredDuringSchedulingIgnoredDuringExecution}
@@ -219,6 +300,10 @@ function doInstall() {
219
300
  helm upgrade --install ingress ./ingress
220
301
  ;;
221
302
 
303
+ "velero")
304
+ installVelero # because it's a little more involved
305
+ ;;
306
+
222
307
  *)
223
308
  if [ ! -d $SERVICE ] || [ ! -f $SERVICE/values-local.yaml ];
224
309
  then
@@ -258,6 +343,9 @@ NOTRUNNING
258
343
  ;;
259
344
  esac
260
345
  done
346
+
347
+ printf "\nRunning => helm ls\n\n"
348
+ helm ls
261
349
  }
262
350
 
263
351
  doInstall $@