narrow-monitor-83965
11/02/2023, 8:26 AM// Fetch a reference to the existing node. You can obtain the node name using `kubectl get nodes`
const node = pulumi.output(k8s.core.v1.getNode("node-name"));
// Create a new NodePatch to add an annotation
new k8s.core.v1.Node("node-name", {
metadata: {
annotations: {
// Old annotations must be preserved to avoid removing existing annotations
...node.metadata.apply(m => m.annotations || {}),
"new-annotation-key": "new-annotation-value",
}
}
}, {
provider: k8sProvider,
deleteBeforeReplace: false,
});
From that I came up with the following code, but I get the error. k8s.core.v1.getNode is not a function
// patch the worker nodes to add the longhorn labels and annotations
const worker1Node = pulumi.output(k8s.core.v1.getNode("k3s-worker-1"))
const worker2Node = pulumi.output(k8s.core.v1.getNode("k3s-worker-2"))
new k8s.core.v1.NodePatch("k3s-worker-1", {
metadata: {
labels: {
...worker1Node.metadata.apply(m => m.labels || {}),
"node.longhorn.io/create-default-disk": "config",
},
annotations: {
...worker1Node.metadata.apply(m => m.annotations || {}),
"node.longhorn.io/default-disks-config": `[ {
"path":"/data",
"allowScheduling":true
}]`,
}
}
},{
dependsOn: [k3sWorker1Install],
provider: k8sProvider,
deleteBeforeReplace: false
})
new k8s.core.v1.NodePatch("k3s-worker-2", {
metadata: {
labels: {
...worker2Node.metadata.apply(m => m.labels || {}),
"node.longhorn.io/create-default-disk": "config",
},
annotations: {
...worker1Node.metadata.apply(m => m.annotations || {}),
"node.longhorn.io/default-disks-config": `[ {
"path":"/data",
"allowScheduling":true
}]`,
}
}
},{
dependsOn: [k3sWorker2Install],
provider: k8sProvider,
deleteBeforeReplace: false
})
Indeed when I check the the kubernetes provider there is no reference to getNode. Anyone get any ideas how I can achieve what I am trying to do?