Florian Boehmak
Florian Boehmak

Reputation: 521

How to deploy a Helm 3 chart using C#

What is the best way to deploy a Helm chart using C#? Helm 3 is written in go and I could not find a C# wrapper, any advise on that? Thank you.

Upvotes: 2

Views: 2037

Answers (2)

Oliver
Oliver

Reputation: 1

helm is a command-line tool and could be tricky to run from C# code. There is a good Kubernetes C# client which has worked great for me, it seems that you can use it to do everything a Helm chart could do. It might even be easier, since you can use C# variables as values for the placeholders in your YAML files, and don't have to deal with values.yaml files and the --set flag, etc.

For example, here is a snippet from my original YAML file:

apiVersion: v1
kind: Service
metadata:
  name: {{ .Values.appName }}-headless-service
spec:
  ports:
  - port: 80
    name: web
...

and here is how it looks with the C# client:

var service = new V1Service {
    ApiVersion = "v1",
    Kind = "Service",
    Metadata = new V1ObjectMeta {
        Name = $"{appName}-headless-service",
        NamespaceProperty = "default"
    },
    Spec = new V1ServiceSpec {
        Ports = new List<V1ServicePort> {
            new V1ServicePort { Port = 80, Name = "web" }
        },
...

Notice the normal C# variables like appName. Gen AI can be very helpful in converting from the YAML to all the different kinds of objects the C# client has.

Upvotes: 0

coderanger
coderanger

Reputation: 54249

Helm is written in Go so unless you want to get incredibly fancy your best bet is running it as a subprocess like normal. A medium-fancy solution would be using one of the many Helm operators and then using a C# Kubernetes api client library to set the objects.

Upvotes: 3

Related Questions