Skip to content

Commit

Permalink
Merge pull request #14 from SmartColumbusOS/placeholder-units
Browse files Browse the repository at this point in the history
limit real units in lower environments
  • Loading branch information
LtChae authored Oct 7, 2020
2 parents b312f1d + 31ad1df commit 0d23d47
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
7 changes: 4 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ properties([
pipelineTriggers([scos.dailyBuildTrigger()]),
parameters([
booleanParam(defaultValue: false, description: 'Deploy to development environment?', name: 'DEV_DEPLOYMENT'),
choice(name: "LOCATION", choices: ['marysville', 'columbus'], description: 'Location to deploy.')
choice(name: "LOCATION", choices: ['marysville', 'columbus'], description: 'Location to deploy.'),
string(name: 'MAX_UNITS', defaultValue: '10', description: 'If not deploying to prod, defines the number of RSUs from the list to deploy.')
])
])

Expand All @@ -23,11 +24,11 @@ node ('infrastructure') {
scos.doCheckoutStage()

doStageIfDeployingToDev('Deploy to Dev') {
deployTo(environment: 'dev')
deployTo(environment: 'dev', extraArgs: "--set commService.maxUnits=${params.MAX_UNITS}")
}

doStageIfMergedToMaster('Deploy to Staging') {
deployTo(environment: 'staging')
deployTo(environment: 'staging', extraArgs: "--set commService.maxUnits=${params.MAX_UNITS}")
scos.applyAndPushGitHubTag('staging')
}

Expand Down
43 changes: 38 additions & 5 deletions chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- $maxUnits := default 99999999 .Values.commService.maxUnits -}}
{{- $rsuLimit := len .Values.commService.rsu | min $maxUnits -}}
{{- $sublist := slice .Values.commService.rsu 0 $rsuLimit -}}
{{- $totalUnits := len .Values.commService.rsu -}}
{{- $maxUnits := default $totalUnits .Values.commService.maxUnits -}}
{{- $sublist := slice .Values.commService.rsu 0 $maxUnits -}}
{{- range $i, $rsu := $sublist }}
{{- $suffix := $rsu | replace "_" "-" | lower -}}
apiVersion: batch/v1beta1
Expand All @@ -17,7 +17,7 @@ spec:
{{ $randomInt := randNumeric 3 | atoi -}}
schedule: "{{ mod $randomInt 59}} * * * *"
concurrencyPolicy: Replace
successfulJobsHistoryLimit: 1
successfulJobsHistoryLimit: 0
failedJobsHistoryLimit: 1
replicas: {{ $.Values.replicaCount }}
selector:
Expand Down Expand Up @@ -72,4 +72,37 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
---
{{- end }}
{{- end }}

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: "{{ $.Values.location }}-unit-placeholder"
spec:
replicas: {{ sub $totalUnits $maxUnits }}
template:
metadata:
labels:
app: "{{ $.Values.location }}-unit-placeholder"
spec:
containers:
- name: "{{ $.Values.location }}-unit-placeholder"
image: "busybox:latest"
imagePullPolicy: IfNotPresent
command: ["tail", "-f", "/dev/null"]
resources:
{{- toYaml $.Values.resources | nindent 10 }}
livenessProbe:
exec:
command:
- cat
- /dev/null
initialDelaySeconds: 5
periodSeconds: 5
readinessProbe:
exec:
command:
- cat
- /dev/null
initialDelaySeconds: 5
periodSeconds: 5

0 comments on commit 0d23d47

Please sign in to comment.