diff --git a/Jenkinsfile b/Jenkinsfile index dd2f27b..6c4ec37 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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.') ]) ]) @@ -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') } diff --git a/chart/templates/deployment.yaml b/chart/templates/deployment.yaml index 9cab99b..2e84aa7 100644 --- a/chart/templates/deployment.yaml +++ b/chart/templates/deployment.yaml @@ -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 @@ -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: @@ -72,4 +72,37 @@ spec: {{- toYaml . | nindent 8 }} {{- end }} --- -{{- end }} \ No newline at end of file +{{- 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