Preserver the number of replicas
This commit is contained in:
parent
8150f3e5b0
commit
346402e131
1 changed files with 9 additions and 2 deletions
|
@ -1,6 +1,11 @@
|
||||||
node() {
|
node() {
|
||||||
def ocCmd = "oc --token=`cat /var/run/secrets/kubernetes.io/serviceaccount/token` --server=https://openshift.default.svc.cluster.local --certificate-authority=/run/secrets/kubernetes.io/serviceaccount/ca.crt"
|
def ocCmd = "oc --token=`cat /var/run/secrets/kubernetes.io/serviceaccount/token` --server=https://openshift.default.svc.cluster.local --certificate-authority=/run/secrets/kubernetes.io/serviceaccount/ca.crt"
|
||||||
|
|
||||||
|
def getReplicasOpt(deploymentConfig, project) {
|
||||||
|
def replicas = sh(script: "${ocCmd} get dc ${deploymentConfig} --template='{{ .spec.replicas }}' -n ${project}", returnStdout: true).trim()
|
||||||
|
return replicas ? "-v REPLICAS=${replicas}" : ""
|
||||||
|
}
|
||||||
|
|
||||||
def buildConfigFile = "deployment/config/build.yaml"
|
def buildConfigFile = "deployment/config/build.yaml"
|
||||||
def appConfigFile = "deployment/config/app.yaml"
|
def appConfigFile = "deployment/config/app.yaml"
|
||||||
|
|
||||||
|
@ -11,7 +16,8 @@ node() {
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Deploy to DEV') {
|
stage('Deploy to DEV') {
|
||||||
sh "${ocCmd} process -f ${appConfigFile} -v ENV=dev -n rubex-dev | ${ocCmd} apply -f - -n rubex-dev"
|
def replicasOpt = getReplicasOpt("frontend", "rubex-dev")
|
||||||
|
sh "${ocCmd} process -f ${appConfigFile} -v ENV=dev ${replicasOpt} -n rubex-dev | ${ocCmd} apply -f - -n rubex-dev"
|
||||||
sh "${ocCmd} tag rubex-dev/frontend:latest rubex-dev/frontend:dev"
|
sh "${ocCmd} tag rubex-dev/frontend:latest rubex-dev/frontend:dev"
|
||||||
sh "${ocCmd} rollout latest dc/frontend -n rubex-dev"
|
sh "${ocCmd} rollout latest dc/frontend -n rubex-dev"
|
||||||
sh "${ocCmd} rollout status dc/frontend -n rubex-dev"
|
sh "${ocCmd} rollout status dc/frontend -n rubex-dev"
|
||||||
|
@ -24,7 +30,8 @@ node() {
|
||||||
|
|
||||||
if (isPromoteToTest) {
|
if (isPromoteToTest) {
|
||||||
stage('Deploy to TEST') {
|
stage('Deploy to TEST') {
|
||||||
sh "${ocCmd} process -f ${appConfigFile} -v ENV=test -n rubex-test | ${ocCmd} apply -f - -n rubex-test"
|
def replicasOpt = getReplicasOpt("frontend", "rubex-test")
|
||||||
|
sh "${ocCmd} process -f ${appConfigFile} -v ENV=test ${replicasOpt} -n rubex-test | ${ocCmd} apply -f - -n rubex-test"
|
||||||
sh "${ocCmd} tag rubex-dev/frontend:dev rubex-dev/frontend:test"
|
sh "${ocCmd} tag rubex-dev/frontend:dev rubex-dev/frontend:test"
|
||||||
sh "${ocCmd} rollout latest dc/frontend -n rubex-test"
|
sh "${ocCmd} rollout latest dc/frontend -n rubex-test"
|
||||||
sh "${ocCmd} rollout status dc/frontend -n rubex-test"
|
sh "${ocCmd} rollout status dc/frontend -n rubex-test"
|
||||||
|
|
Loading…
Reference in a new issue