Subject: bug#59797: 30.0.50; [wishlist] Using namespaces in Tramp's kubernetes integration

From: Michael Albinus <[email-masked]>
Date: Tue, 23 Jul 2024 14:29:34 +0200

Eshel Yaron <[email-masked]> writes:

> Hi Michael,

Hi Eshel,

> Michael Albinus <[email-masked]> writes:
>
>> Now we have kubernetes integrated in Tramp. We can access pods like
>> "/kubernetes:POD:/path/to/file".
>>
>> However, kubernetes can much more. For all services (like pods) it
>> creates DNS entries "<service-name>.<namespace-name>.svc.cluster.local".
>> Should'nt we support this? It means should we allow to access kubernetes
>> pods like "/kubernetes:POD.NAMESPACE:/path/to/file", including
>> completion for namespace names?
>
> [...]
>
>> Finally, I've taken the stab and implemented something along these
>> lines. It is a little bit different from earlier proposals.
>>
>> - You can now specify a container in the host name, dotted notation.
>>   "/kubernetes:container.pod:" accesses the given container. If it is
>>   not specified, as in "/kubernetes:pod:", the first container is taken.
>>
>> - You can now specify different context and namespace. Change the new
>>   user options tramp-kubernetes-context or tramp-kubernetes-namespace
>>   for this effect.
>>
>> Everything pushed to the Emacs and Tramp master repositories. The target
>> is now Tramp 2.7 / Emacs 30. Comments welcome :-)
>
> Sorry for not chiming in when this discussion was still ongoing, and
> thank you for your work on the Kubernetes integration.  I use it a lot.
>
> Would it be possible the reconsider adding an optional namespace to
> Tramp's Kubernetes file name syntax?  I'm thinking of something like
> "/kubernetes:[CONTAINER.]POD[.NAMESPACE]:/...".

Possible. However, the syntax is ambiguous. If we have "/kubernetes:name1.name2:/..."
it isn't clear what they are. name1 could be a container, and name2 a pod. Or
name1 is a pod, and name2 is a namespace. Could we agree on another
delimiter between POD and NAMESPACE?

> My use case is that I want to start Dired for a (container in a) pod in
> another namespace.  I can almost get there if I temporarily bind
> tramp-kubernetes-namespace around the call to dired, but the binding
> doesn't carry on to subsequent operations in the Dired buffer.  So an
> explicit namespace in default-directory could help, I think.

I see, it makes sense. My practical kubernetes experience is sparse; I
would exploit you while implementing. At least for tests.

Note also, that Emacs 30 is in pretest. Any such feature change will be
targeted to Emacs 31 / Tramp 2.8.

> Best,
> Eshel

Best regards, Michael.