我已经声明了一个 Kubernetes 部署,例如:
const ledgerDeployment = new k8s.extensions.v1beta1.Deployment("ledger", {
spec: {
template: {
metadata: {
labels: {name: "ledger"},
name: "ledger",
// namespace: namespace,
},
spec: {
containers: [
...
],
volumes: [
{
emptyDir: {},
name: "gunicorn-socket-dir"
}
]
}
}
}
});
稍后index.ts
我想有条件地修改volumes
部署。我认为这是 pulumi 的一个怪癖,我还没有完全理解,但这是我目前的尝试:
if(myCondition) {
ledgerDeployment.spec.template.spec.volumes.apply(volumes =>
volumes.push(
{
name: "certificates",
secret: {
items: [
{key: "tls.key", path: "proxykey"},
{key: "tls.crt", path: "proxycert"}],
secretName: "star.builds.qwil.co"
}
})
)
)
当我这样做时,我收到以下错误:Property 'mode' is missing in type '{ key: string; path: string; }' but required in type 'KeyToPath'
我怀疑我使用apply
不正确。当我尝试直接修改时ledgerDeployment.spec.template.spec.volumes.push()
出现错误Property 'push' does not exist on type 'Output<Volume[]>'
。
Pulumi 中修改资源的模式是什么?如何将新卷添加到我的部署中?