-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
50 lines (42 loc) · 1.54 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import * as pulumi from '@pulumi/pulumi';
import * as k8s from "@pulumi/kubernetes";
import * as kx from "@pulumi/kubernetesx";
import { ProviderResource } from "@pulumi/pulumi";
import * as lib from './lib';
import { Istio } from './components';
interface Config {
namespace: string,
ingress?: {
name: string,
port: number,
}[]
};
const main = async (): Promise<lib.Root> => {
const config = new pulumi.Config().requireObject<Config>('data');
const stack = pulumi.getStack();
const kubernetes_provider = new k8s.Provider('k8s');
await pulumi.ProviderResource.register(kubernetes_provider);
const opts = {
provider: kubernetes_provider,
};
const istiod = new Istio.Control('istio-control', {}, opts);
const namespace = new k8s.core.v1.Namespace(config.namespace, {
metadata: {
name: config.namespace,
labels: { 'istio-injection': 'enabled' },
},
}, opts);
const ingress_name = `${stack}-istio-ingressgateway`;
/* output<ingress> だと lib.Root 型へうまく代入できないなぁ。
const ingress = pulumi.all([namespace]).apply(([ns]) => new Istio.Ingress(ingress_name, {
namespace: ns.metadata.name,
ports: config.ingress,
}, { ...opts, dependsOn: [istiod, namespace] }));
*/
const ingress = new Istio.Ingress(ingress_name, {
namespace: config.namespace,
ports: config.ingress,
}, { ...opts, dependsOn: [istiod, namespace] });
return { namespace, ingress, };
}
export const output = main();