Add delete preview-env / auto-deploy a staging
This commit is contained in:
parent
1d0313229e
commit
a55693f967
10 changed files with 136 additions and 91 deletions
|
@ -35,44 +35,70 @@ function(vars={})
|
|||
],
|
||||
},
|
||||
|
||||
local appversion = "1.0.0-%s" % vars.images.quayci.tag,
|
||||
local namespace = "ci-quay-%s" % vars.images.quayci.tag,
|
||||
|
||||
QuayDeploy: {
|
||||
local this = self,
|
||||
local _vars = self.localvars,
|
||||
localvars:: {
|
||||
appversion: "1.0.0-%s" % self.image.tag,
|
||||
apprepo: "quay.io/quay/%s" % self.appname,
|
||||
appname: "quay-ci-app",
|
||||
domain: "quay-%s.k8s.devtable.com" % self.image.tag,
|
||||
namespace: "ci-quay-%s" % self.image.tag,
|
||||
image: vars.images.quayci,
|
||||
channels: [],
|
||||
pushargs: ["-f"],
|
||||
|
||||
buildParams(extra_params={}):: (
|
||||
local params = {image: _vars.image.name,
|
||||
tag: _vars.image.tag,
|
||||
domain: "$QUAY_DOMAIN"} + extra_params;
|
||||
[
|
||||
"echo -n %s > VERSION" % _vars.appversion,
|
||||
'echo %s > params.json' % std.escapeStringJson(params),
|
||||
"cat params.json"
|
||||
]),
|
||||
|
||||
pushApp(repo="quay.io/quay", extra_args=['-f'], channels=[]):: (
|
||||
["appr push %s %s" % [repo, std.join(" ", extra_args)]] +
|
||||
["appr push %s -c %s" % [repo, channel] for channel in channels]
|
||||
),
|
||||
},
|
||||
|
||||
variables: {K8S_NAMESPACE: _vars.namespace,
|
||||
QUAY_DOMAIN: _vars.domain},
|
||||
image: "quay.io/appr/appr:kubectl",
|
||||
when: "manual",
|
||||
environment: {
|
||||
name: "review/%s" % vars.images.quayci.tag,
|
||||
url: "https://quay-%s.k8s.devtable.com" % vars.images.quayci.tag,
|
||||
name: "review/%s" % _vars.image.tag,
|
||||
url: "https://%s" % _vars.domain,
|
||||
},
|
||||
tags: [
|
||||
"kubernetes",
|
||||
],
|
||||
stage: "deploy",
|
||||
|
||||
before_script: [
|
||||
"appr login -u $DOCKER_USER -p $DOCKER_PASS quay.io",
|
||||
],
|
||||
script: [
|
||||
"cd deploy/quay-demo-app",
|
||||
"echo -n %s > VERSION" % appversion,
|
||||
'echo "{\\"image\\": \\"%s\\", \\"tag\\": \\"%s\\"}" > params.json' % [vars.images.quayci.name, vars.images.quayci.tag],
|
||||
"cat params.json",
|
||||
"appr push quay.io/quay -f",
|
||||
"appr deploy quay.io/quay/quay-demo-app@%s --namespace %s -x docker_user=$DOCKER_USER -x docker_pass=$DOCKER_PASS" % [appversion, namespace],
|
||||
"kubectl get ingresses -n %s -o wide" % namespace,
|
||||
"appr login -u $DOCKER_USER -p $DOCKER_PASS quay.io",
|
||||
"cd deploy/%s" % _vars.appname,
|
||||
] + _vars.buildParams(),
|
||||
|
||||
script:
|
||||
_vars.pushApp(_vars.apprepo, _vars.pushargs, _vars.channels) +
|
||||
[
|
||||
"appr deploy %s@%s --namespace %s -x docker_user=$DOCKER_USER -x docker_pass=$DOCKER_PASS" % [
|
||||
_vars.apprepo,
|
||||
_vars.appversion,
|
||||
_vars.namespace],
|
||||
"kubectl get ingresses -n %s -o wide" % _vars.namespace,
|
||||
],
|
||||
},
|
||||
|
||||
QuayDeployStop: self.QuayDeploy {
|
||||
variables: {GIT_STRATEGY: "none"},
|
||||
variables+: {GIT_STRATEGY: "none"},
|
||||
environment+: {
|
||||
action: "stop"
|
||||
},
|
||||
script: [
|
||||
'echo "{\\"image\\": \\"%s\\", \\"tag\\": \\"%s\\"}" > params.json' % [vars.images.quayci.name, vars.images.quayci.tag],
|
||||
"cat params.json",
|
||||
"appr remove quay.io/quay/quay-demo-app@%s --namespace %s -x docker_user=$DOCKER_USER -x docker_pass=$DOCKER_PASS -x params.json" % [appversion, namespace],
|
||||
"kubectl get pods -n %s -o wide" % namespace,
|
||||
],
|
||||
before_script: [],
|
||||
script: [],
|
||||
},
|
||||
|
||||
dbTest(scheme, image, env):: self.QuayTest {
|
||||
|
|
|
@ -8,12 +8,11 @@ local utils = import "utils.libsonnet";
|
|||
|
||||
// internal variables
|
||||
images: {
|
||||
// Quay initial image, used in the FROM clause
|
||||
// Quay initial image, used in the Dockerfile FROM clause
|
||||
base: { repo: "quay.io/quay/quay-base", tag: "latest",
|
||||
name: utils.containerName(self.repo, self.tag),
|
||||
},
|
||||
|
||||
// @TODO(ant31) release should use quay/quay
|
||||
// release is a copy of the quayci image to the 'prod' repository
|
||||
release: { repo: "quay.io/quay/quay",
|
||||
tag: "${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA}",
|
||||
|
|
Reference in a new issue