Commit ddce41f1 authored by Erin Krengel's avatar Erin Krengel
Browse files

Use kx

parent 6d759012
import * as k8s from "@pulumi/kubernetes";
import * as kx from "@pulumi/kubernetesx";
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
import * as svcKey from "./svcKey";
......@@ -16,7 +17,7 @@ interface AcceptanceConfig {
clusterProvider: k8s.Provider;
}
export function SetupAcceptanceTests(config: AcceptanceConfig): k8s.batch.v1.Job {
export function setupAcceptanceTests(config: AcceptanceConfig): k8s.batch.v1.Job {
const name = `${config.env}-demo-app-acc-test`;
// Create subscription on the app's topic.
......@@ -44,56 +45,44 @@ export function SetupAcceptanceTests(config: AcceptanceConfig): k8s.batch.v1.Job
const serviceAccountKey = svcKey.getSvcKey(name, config.accSvcAccountId);
// Create a K8s secret from the service account key to mount to our K8s job.
const secret = new k8s.core.v1.Secret(name, {
const secret = new kx.Secret(name, {
metadata: {
name: `${config.env}-google-cloud-key-acc-test`,
},
stringData: { "key.json": serviceAccountKey },
}, { provider: config.clusterProvider });
// Define the pod for our acceptance tests.
const secretDestPath = "/var/secrets/google";
const podBuilder = new kx.PodBuilder({
containers: [{
name: name,
image: `rocore/demo-app-acceptance:${config.dockerTag}`,
imagePullPolicy: "Always",
env: {
"SUBSCRIPTION": subscription.name,
"BUCKET": config.bucket.name,
"PROJECT": config.project,
"SERVICE_NAME": config.appService.metadata.name,
"GOOGLE_APPLICATION_CREDENTIALS": `${secretDestPath}/key.json`,
},
volumeMounts: [secret.mount(secretDestPath)],
}],
restartPolicy: "Never",
});
// Create the job for our acceptance tests. The job will only run one time.
// By default, `pulumi up` will wait for the job to complete and only succeed
// if the container (aka our acceptance tests) exit successfully. The means we
// can simply run `pulumi up` to run our acceptance tests and determine if they
// succeeded or not.
const appLabels = { appClass: name };
return new k8s.batch.v1.Job(name,
{
metadata: { labels: appLabels },
spec: {
template: {
spec: {
containers: [{
name: name,
image: `rocore/demo-app-acceptance:${config.dockerTag}`,
imagePullPolicy: "Always",
env: [
{ name: "SUBSCRIPTION", value: subscription.name },
{ name: "BUCKET", value: config.bucket.name },
{ name: "PROJECT", value: config.project },
{ name: "SERVICE_NAME", value: pulumi.interpolate`${config.appService.metadata.name}` },
{ name: "GOOGLE_APPLICATION_CREDENTIALS", value: "/var/secrets/google/key.json" },
],
volumeMounts: [
{ name: "google-cloud-key", mountPath: "/var/secrets/google" }
]
}],
volumes: [
{
name: "google-cloud-key",
secret: { secretName: secret.metadata.name }
}
],
restartPolicy: "Never",
},
},
backoffLimit: 0,
},
},
{
provider: config.clusterProvider,
customTimeouts: { create: "5m" },
dependsOn: [config.appDeployment]
},
);
return new kx.Job(name, {
metadata: { labels: appLabels },
spec: podBuilder.asJobSpec({ backoffLimit: 0 }),
}, {
provider: config.clusterProvider,
customTimeouts: { create: "5m" },
dependsOn: [config.appDeployment]
});
}
......@@ -135,7 +135,7 @@ const service = new k8s.core.v1.Service(name, {
// If it's a test environment, set up acceptance tests.
let job: k8s.batch.v1.Job | undefined;
if (ENV.startsWith("test")) {
job = acceptance.SetupAcceptanceTests({
job = acceptance.setupAcceptanceTests({
env: ENV,
project: project,
topic: topic,
......
......@@ -102,9 +102,9 @@
}
},
"@pulumi/gcp": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@pulumi/gcp/-/gcp-1.2.0.tgz",
"integrity": "sha512-XjmHZJMaxHXOpvBILLmtPrN1l6UzUYnihkGQycIKoYkaqIaCBDvPBEx3Vdwrf/axSnG73WkP0hkcPO/ufZQ5/A==",
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/@pulumi/gcp/-/gcp-1.5.0.tgz",
"integrity": "sha512-krHtZpMwwTrlraKRyQraAl8hicG+OgHi+bp6KX2YywA1d9gEcpSnHnkXr2t20Xaqu2ZmP23PsTcG/dcesj1PRg==",
"requires": {
"@pulumi/pulumi": "^1.0.0",
"@types/express": "^4.16.0",
......@@ -112,11 +112,11 @@
}
},
"@pulumi/kubernetes": {
"version": "0.25.1",
"resolved": "https://registry.npmjs.org/@pulumi/kubernetes/-/kubernetes-0.25.1.tgz",
"integrity": "sha512-QFMpvmjMNTd/MP1WJJ2gU7Y5hWX9rDHPKRYC3e0fE9E6btUJShhju9vWgChQPJbc8tE64QOJ8fqJU8gHmgoMjA==",
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/@pulumi/kubernetes/-/kubernetes-1.2.2.tgz",
"integrity": "sha512-xz9/E0X0tlxl4nvFTA1OlbskaKWSSZy+hjIZdH+uOvsq5bDT0twM/0OG512PUk7RhHKBWpyJEVxngDKucpxuJg==",
"requires": {
"@pulumi/pulumi": "^0.17.18",
"@pulumi/pulumi": "^1.0.0",
"@types/glob": "^5.0.35",
"@types/js-yaml": "^3.11.2",
"@types/node-fetch": "^2.1.4",
......@@ -126,42 +126,43 @@
"node-fetch": "^2.3.0",
"shell-quote": "^1.6.1",
"tmp": "^0.0.33"
}
},
"@pulumi/kubernetesx": {
"version": "0.1.1-dev.1573594718",
"resolved": "https://registry.npmjs.org/@pulumi/kubernetesx/-/kubernetesx-0.1.1-dev.1573594718.tgz",
"integrity": "sha512-lS5P/I2HSuXhnpTtGtDc/Hhl3h5Fj/LCrsRthpqlwnkCBHBLGuRpiNKsjbvqzHl7U4VmmwnhDKhZA7nFvrTPuw==",
"requires": {
"@pulumi/kubernetes": "^1.2.3",
"@pulumi/pulumi": "^1.5.1"
},
"dependencies": {
"@pulumi/pulumi": {
"version": "0.17.28",
"resolved": "https://registry.npmjs.org/@pulumi/pulumi/-/pulumi-0.17.28.tgz",
"integrity": "sha512-pVKahH9Ryl6wIpzdOKjsu2gEshDCA7elB34paJpPXw+3ARViSPri7y/2uTdmMRg36jsbrOdNGEohKJEqIZLioA==",
"@pulumi/kubernetes": {
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/@pulumi/kubernetes/-/kubernetes-1.2.3.tgz",
"integrity": "sha512-IuGvUeIJuQzVhyzq/sYXdw9p11qBvUW0xsrz4S/SkW1YRljEkgobZgFdiYRolu+HHHmjcs3ek3aocxPOAHGf5w==",
"requires": {
"@pulumi/query": "^0.3.0",
"deasync": "^0.1.15",
"google-protobuf": "^3.5.0",
"grpc": "1.21.1",
"minimist": "^1.2.0",
"normalize-package-data": "^2.4.0",
"protobufjs": "^6.8.6",
"read-package-tree": "^5.3.1",
"require-from-string": "^2.0.1",
"semver": "^6.1.0",
"source-map-support": "^0.4.16",
"ts-node": "^7.0.0",
"typescript": "^3.0.0",
"upath": "^1.1.0"
"@pulumi/pulumi": "^1.0.0",
"@types/glob": "^5.0.35",
"@types/js-yaml": "^3.11.2",
"@types/node-fetch": "^2.1.4",
"@types/tmp": "^0.0.33",
"glob": "^7.1.2",
"js-yaml": "^3.12.0",
"node-fetch": "^2.3.0",
"shell-quote": "^1.6.1",
"tmp": "^0.0.33"
}
},
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw=="
}
}
},
"@pulumi/pulumi": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@pulumi/pulumi/-/pulumi-1.2.0.tgz",
"integrity": "sha512-KowEnuaCzDaze5KNTAc5P1AjZNQdhagZZpz3nGV/Nz0u9cRVcTjlPmGBPMEUkc0AnRyi3kRKCdsqJGHguesVKQ==",
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/@pulumi/pulumi/-/pulumi-1.5.1.tgz",
"integrity": "sha512-8/X83ouslBuha36ZfxJFtv3VolIMYO/KM0ZLP1JRFDcDrUfGFRdLhiYmnIOYvu9NhmsxplJ5meP6wFvTQ/GygQ==",
"requires": {
"@pulumi/query": "^0.3.0",
"callback-to-async-iterator": "^1.1.1",
"deasync": "^0.1.15",
"google-protobuf": "^3.5.0",
"grpc": "1.21.1",
......@@ -173,7 +174,7 @@
"semver": "^6.1.0",
"source-map-support": "^0.4.16",
"ts-node": "^7.0.0",
"typescript": "^3.0.0",
"typescript": "=3.6.3",
"upath": "^1.1.0"
},
"dependencies": {
......@@ -196,6 +197,13 @@
"requires": {
"@types/connect": "*",
"@types/node": "*"
},
"dependencies": {
"@types/node": {
"version": "12.12.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz",
"integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w=="
}
}
},
"@types/connect": {
......@@ -204,6 +212,13 @@
"integrity": "sha512-4r8qa0quOvh7lGD0pre62CAb1oni1OO6ecJLGCezTmhQ8Fz50Arx9RUszryR8KlgK6avuSXvviL6yWyViQABOg==",
"requires": {
"@types/node": "*"
},
"dependencies": {
"@types/node": {
"version": "12.12.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz",
"integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w=="
}
}
},
"@types/events": {
......@@ -212,9 +227,9 @@
"integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g=="
},
"@types/express": {
"version": "4.17.1",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.1.tgz",
"integrity": "sha512-VfH/XCP0QbQk5B5puLqTLEeFgR8lfCJHZJKkInZ9mkYd+u8byX0kztXEQxEk4wZXJs8HI+7km2ALXjn4YKcX9w==",
"version": "4.17.2",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.2.tgz",
"integrity": "sha512-5mHFNyavtLoJmnusB8OKJ5bshSzw+qkMIBAobLrIM48HJvunFva9mOa6aBwh64lBFyNwBbs0xiEFuj4eU/NjCA==",
"requires": {
"@types/body-parser": "*",
"@types/express-serve-static-core": "*",
......@@ -222,12 +237,19 @@
}
},
"@types/express-serve-static-core": {
"version": "4.16.9",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.16.9.tgz",
"integrity": "sha512-GqpaVWR0DM8FnRUJYKlWgyARoBUAVfRIeVDZQKOttLFp5SmhhF9YFIYeTPwMd/AXfxlP7xVO2dj1fGu0Q+krKQ==",
"version": "4.16.11",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.16.11.tgz",
"integrity": "sha512-K8d2M5t3tBQimkyaYTXxtHYyoJPUEhy2/omVRnTAKw5FEdT+Ft6lTaTOpoJdHeG+mIwQXXtqiTcYZ6IR8LTzjQ==",
"requires": {
"@types/node": "*",
"@types/range-parser": "*"
},
"dependencies": {
"@types/node": {
"version": "12.12.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz",
"integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w=="
}
}
},
"@types/glob": {
......@@ -238,6 +260,13 @@
"@types/events": "*",
"@types/minimatch": "*",
"@types/node": "*"
},
"dependencies": {
"@types/node": {
"version": "12.12.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz",
"integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w=="
}
}
},
"@types/js-yaml": {
......@@ -261,16 +290,24 @@
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
},
"@types/node": {
"version": "12.7.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.11.tgz",
"integrity": "sha512-Otxmr2rrZLKRYIybtdG/sgeO+tHY20GxeDjcGmUnmmlCWyEnv2a2x1ZXBo3BTec4OiTXMQCiazB8NMBf0iRlFw=="
"version": "12.12.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz",
"integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w==",
"dev": true
},
"@types/node-fetch": {
"version": "2.3.7",
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.3.7.tgz",
"integrity": "sha512-+bKtuxhj/TYSSP1r4CZhfmyA0vm/aDRQNo7vbAgf6/cZajn0SAniGGST07yvI4Q+q169WTa2/x9gEHfJrkcALw==",
"version": "2.5.3",
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.5.3.tgz",
"integrity": "sha512-X3TNlzZ7SuSwZsMkb5fV7GrPbVKvHc2iwHmslb8bIxRKWg2iqkfm3F/Wd79RhDpOXR7wCtKAwc5Y2JE6n/ibyw==",
"requires": {
"@types/node": "*"
},
"dependencies": {
"@types/node": {
"version": "12.12.7",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz",
"integrity": "sha512-E6Zn0rffhgd130zbCbAr/JdXfXkoOUFAKNs/rF8qnafSJ8KYaA/j3oz7dcwal+lYjLA7xvdd5J4wdYpCTlP8+w=="
}
}
},
"@types/range-parser": {
......@@ -305,21 +342,6 @@
"sprintf-js": "~1.0.2"
}
},
"array-filter": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/array-filter/-/array-filter-0.0.1.tgz",
"integrity": "sha1-fajPLiZijtcygDWB/SH2fKzS7uw="
},
"array-map": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/array-map/-/array-map-0.0.0.tgz",
"integrity": "sha1-iKK6tz0c97zVwbEYoAP2b2ZfpmI="
},
"array-reduce": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/array-reduce/-/array-reduce-0.0.0.tgz",
"integrity": "sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys="
},
"arrify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz",
......@@ -376,6 +398,14 @@
"long": "~3"
}
},
"callback-to-async-iterator": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/callback-to-async-iterator/-/callback-to-async-iterator-1.1.1.tgz",
"integrity": "sha512-w5uOapjkp/CEizuvBkLl7JyHlQNlxAT7LSr9g4vFjg5AEM5TJvaajjKkgs4kcFFm0fNqFX9D0zEIotllXvNC1Q==",
"requires": {
"iterall": "^1.0.0"
}
},
"camelcase": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-2.1.1.tgz",
......@@ -1015,6 +1045,11 @@
"has-symbols": "^1.0.0"
}
},
"iterall": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/iterall/-/iterall-1.2.2.tgz",
"integrity": "sha512-yynBb1g+RFUPY64fTrFv7nsjRrENBQJaX2UL+2Szc9REFrSNm1rpSXHGzhmAy7a9uv3vlvgBlXnf9RqmPH1/DA=="
},
"js-yaml": {
"version": "3.13.1",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
......@@ -1029,11 +1064,6 @@
"resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",
"integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw=="
},
"jsonify": {
"version": "0.0.0",
"resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
"integrity": "sha1-LHS27kHZPKUbe1qu6PUDYx0lKnM="
},
"lcid": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz",
......@@ -1260,15 +1290,9 @@
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ=="
},
"shell-quote": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.6.1.tgz",
"integrity": "sha1-9HgZSczkAmlxJ0MOo7PFR29IF2c=",
"requires": {
"array-filter": "~0.0.0",
"array-map": "~0.0.0",
"array-reduce": "~0.0.0",
"jsonify": "~0.0.0"
}
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.7.2.tgz",
"integrity": "sha512-mRz/m/JVscCrkMyPqHc/bczi3OQHkLTqXHEFu0zDhK/qfv3UcOA4SVmRCLmos4bhjr9ekVQubj/R7waKapmiQg=="
},
"slash": {
"version": "1.0.0",
......
......@@ -7,7 +7,8 @@
"@pulumi/docker": "^0.17.0",
"@pulumi/gcp": "latest",
"@pulumi/kubernetes": "1.2.2",
"@pulumi/kubernetesx": "0.1.1-dev.1573594718",
"@pulumi/pulumi": "latest",
"atob": "^2.1.2"
}
}
\ No newline at end of file
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment