sparse-intern-71089
03/18/2020, 3:53 PMbillowy-army-68599
LocalChartsOpts
to point to a Chart.yaml
https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/kubernetes/helm/v2/#LocalChartOpts
You'll need to unpack the tgz
file first thoughbillowy-army-68599
Chart("local-volume-provisioner", LocalChartOpts(
path="charts/provisioner",
namespace="kube-system",
values={
"classes": [
{
"name": 'local',
"hostDir": "/mnt/",
"volumeMode": "Filesystem",
"fsType": "ext4",
}
]
}
))
acoustic-leather-88378
03/18/2020, 6:16 PMacoustic-leather-88378
03/18/2020, 9:14 PMimport * as k8s from "@pulumi/kubernetes";
import * as kx from "@pulumi/kubernetesx";
import * as fs from "fs";
import * as path from "path";
import * as nodepath from "path";
const chartDir = path.resolve( "/tmp" );
// Fetch the Zalando Postgres Operator chart if it hasn't been fetched
if (!fs.existsSync(nodepath.join(chartDir, "postgres-operator"))) {
k8s.helm.v3.fetch("<https://opensource.zalando.com/postgres-operator/charts/postgres-operator/postgres-operator-1.4.0.tgz>",
{
destination: chartDir,
untar: true,
});
}
// Install the CRD's manually
new k8s.yaml.ConfigGroup("postgres-operator-crds", {
files: [ path.join(nodepath.join(chartDir, "postgres-operator/crds", "*.yaml")) ],
});
// Apply the templated Helm chart
const postgresOperator = new k8s.helm.v3.Chart("postgres-operator", {
path: nodepath.join(chartDir, "postgres-operator"),
values: crdValues(),
});
function crdValues(): any {
let fileContents = fs.readFileSync(nodepath.join(chartDir,
"postgres-operator/values-crd.yaml"));
return require("js-yaml").safeLoad(fileContents);
}
Some annoying things:
• I had to check if the .tgz
had already been downloaded and untarred as it tried to do it again after preview or next run and would fail because it already existed
• Using k8s.yaml.ConfigGroup
it seems that the state is tied to the directory location of the files
. If the location of the files
changes it's seen as a state update. Is this by design or am I missing something? Doesn't that force a consistent location for the manifests?
• As above, I had to install the CRD's separately as helm template
obviously doesn't install CRD's. Is there support for a more elegant way of achieving this? Perhaps as part of k8s.helm.v3.Chart
?
• I had to use a pre-existing values file (see original Helm install ... -f <https://opensource.zalando.com/postgres-operator/charts/postgres-operator/values-crd.yaml>
) so I had to read it and parse it as yaml (thanks to hint from https://github.com/pulumi/pulumi-kubernetes/issues/659#issuecomment-515701898) but built in support as described in that issue would have been welcome