helm
helm copied to clipboard
Example with Port Forwarding
I've attempted to figure out how to get this working with Port Forwarding from the Kubernetes-Client/csharp library but I've yet to have any success. Would you be able to provide an example for connecting over that method?
You should be able to get this to work if you're a bit adventurous.
Can you give this a try:
- Make sure you use the latest version of KubernetsClient (1.0.0 or 1.1.0-gf488d54ce7)
- Use the code in the
TillerLocatorto find the Tiller pod, though you'll need to get the namespace and name of the Tiller pod - Use
KubernetesClient.WebSocketNamespacedPodPortForwardAsyncto connect to the Tiller port on the Tiller pod over port forwarding. This will return aStream - That stream is muxed and you'll need to use the
StreamDemuxerto demux it into a stream which you can pass to the constructor of theTillerClientclass.
I've tried the following with no success:
private static void Main(string[] args) => MainAsync().GetAwaiter().GetResult();
private static async Task MainAsync()
{
var kubeConfig = KubernetesClientConfiguration.BuildConfigFromConfigFile();
kubeConfig.SkipTlsVerify = true;
var kubernetes = new Kubernetes(kubeConfig);
var selector = "app=helm,name=tiller";
var pod = (await kubernetes.ListNamespacedPodAsync("kube-system", labelSelector: selector))?.Items.FirstOrDefault();
if (pod == null)
{
return;
}
using (var webSocket = await kubernetes.WebSocketNamespacedPodPortForwardAsync(
name: pod.Metadata.Name,
@namespace: "kube-system",
ports: new[] {44134}
))
using (var muxer = new StreamDemuxer(webSocket))
{
muxer.Start();
using (var stream = muxer.GetStream(0, 1))
{
TillerClient client = new TillerClient(() => stream);
var version = await client.GetVersion();
Console.WriteLine(version.SemVer);
}
}
}
@stephenwilliams did you end up figuring this out? I'm in the same boat. My workaround right now is shelling out to kubectl port-forward which is suboptimal.
@jpoon I did not, I ended up doing the same in my testing but I've also moved away from using Helm due to a few bugs that concerned me.