https://pulumi.com logo
#general
Title
# general
d

damp-book-35965

03/21/2019, 8:39 PM
Are there any examples of using helm chart with pulumi but with quite a complex list of custom values need to be added to the chart ? @microscopic-florist-22719 @white-balloon-205 @gentle-diamond-70147
c

creamy-potato-29402

03/21/2019, 9:05 PM
not really
there are a couple examples of “simple” usages
d

damp-book-35965

03/21/2019, 10:28 PM
I'm looking to add tolerations and pod affinities and mount paths which I'm not sure how it's going to treat it
It would be really nice to have a tool to convert helm values.yaml into values as needed for pulumi as input
c

creamy-potato-29402

03/21/2019, 10:42 PM
@damp-book-35965 Pulumi will do whatever Helm does, right?
I’m not sure I understand the question.
d

damp-book-35965

03/21/2019, 10:43 PM
No I meant converting the yaml formatted values into the pulumi code as a utility
c

creamy-potato-29402

03/21/2019, 10:44 PM
You can use
JSON.parse(fs.readFileSync("values.yml"))
and just pass that into
new helm.v2.Chart
, right?
d

damp-book-35965

03/21/2019, 10:44 PM
So as of now, I'm confused about how to add blocks like this:
Copy code
affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
            - key: key
              operator: NotIn
              values:
              - value
Ohh..
c

creamy-potato-29402

03/21/2019, 10:44 PM
just a normal language, no?
d

damp-book-35965

03/21/2019, 10:45 PM
I see what you are saying but I thought pulumi supports adding values right into the code right ?
c

creamy-potato-29402

03/21/2019, 10:45 PM
yes?
d

damp-book-35965

03/21/2019, 10:46 PM
For example:
Copy code
const prometheusAdapter = new k8s.helm.v2.Chart("prometheus-adapter", {
    version: "0.2.171",
    namespace: "kube-system",
    chart: "prometheus-adapter",
    values: {
        prometheus: {
            url: "<http://prometheus-operator-prometheus.kube-system.svc>"
        },
    },
}, { providers: { kubernetes: cluster.provider } });
c

creamy-potato-29402

03/21/2019, 10:47 PM
Copy code
const prometheusAdapter = new k8s.helm.v2.Chart("prometheus-adapter", {
    version: "0.2.171",
    namespace: "kube-system",
    chart: "prometheus-adapter",
    values: JSON.parse(fs.readFileSync("values.yml")),
}, { providers: { kubernetes: cluster.provider } });
👍 1
right?
d

damp-book-35965

03/21/2019, 10:47 PM
Yes..
I'm going to give this a shot
c

creamy-potato-29402

03/21/2019, 10:47 PM
No need for a special tool, just read the file
that’s all I’m saying.
d

damp-book-35965

03/21/2019, 10:47 PM
Yup makes sense
Thanks @creamy-potato-29402 works well
b

busy-pizza-73563

03/23/2019, 11:25 AM
@creamy-potato-29402 Is that
JSON
a special one that also parses yaml?!
c

creamy-potato-29402

03/23/2019, 5:02 PM
@busy-pizza-73563 it's just a built in JavaScript function
no yaml support though
d

damp-book-35965

03/25/2019, 4:47 PM
@busy-pizza-73563 I had to basically run a yaml to json converter first and then this worked
w

white-balloon-205

03/25/2019, 5:25 PM
Note that you can also use an NPM package to parse YAML - like https://www.npmjs.com/package/js-yaml.
b

busy-pizza-73563

03/27/2019, 11:34 AM
I guess I was a bit confused about that
JSON.parse(fs.readFileSync('values.yml'))
. 🙂
2 Views