pulumi関連。
terraformでやれてたremote stateパターンっぽいのをやってみる。
// project名:test-k8s(index.ts)
import * as pulumi from "@pulumi/pulumi";
import * as kubernetes from '@pulumi/kubernetes';
const ns = new kubernetes.core.v1.Namespace("hatano",{
apiVersion: "v1",kind:"Namespace",metadata: {
name: "hatano"
}
})
const deploy = new kubernetes.apps.v1.Deployment("my-deploy", {
apiVersion: "apps/v1",
kind: "Deployment",
metadata: {
labels: {
app: "nginx",
},
namespace: ns.metadata.name
},
spec: {
selector: {
matchLabels: {
app: "nginx"
}
},
template: {
metadata: {
labels: {
app: "nginx"
}
},
spec: {
containers: [{
image: "nginx",
name: "nginx"
}]
}
}
}
})
export let deployLabels = deploy.metadata.labels;
exportしとけば、他プロジェクトから使いまわせるようだ。
// 別プロジェクト(index.ts)
new pulumi.StackReference("test-k8s",{name: "test/test-k8s/dev"}).outputs.apply(t=>console.log(t)