Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRAMP + Emacs 30 #109

Open
johnhamelink opened this issue Nov 30, 2022 · 4 comments
Open

TRAMP + Emacs 30 #109

johnhamelink opened this issue Nov 30, 2022 · 4 comments
Labels
enhancement New feature or request

Comments

@johnhamelink
Copy link
Contributor

johnhamelink commented Nov 30, 2022

Hi there,

I'm running Emacs from master branch. Emacs 29 comes with support for Kubernetes, Podman and Docker as TRAMP "inline methods" (see here).

@abrochard
Copy link
Owner

abrochard commented Dec 5, 2022

Hi @johnhamelink ,
Thank you for sharing this! I was not aware of these changes at all.
This is actually a trickier change than first anticipated because we also have to keep things working for people running versions anterior to 29:

  • we can probably do some smart logic and try to default/fallback to tramp-kubernetes-program if defined
  • similarly we should keep the old TRAMP method if tramp-kubernetes-method isn't defined
  • I think that <kubectl> config use/set-context <context> is global? as in it will change the context for the whole machine, which is something that kubel doesn't do at all today and could have un-intended consequences

I'm also still on 28 and not sure when I will upgrade/find time to work on this.

@abrochard abrochard added the enhancement New feature or request label Dec 5, 2022
@johnhamelink
Copy link
Contributor Author

johnhamelink commented Dec 6, 2022

We can probably do some smart logic and try to default/fallback to tramp-kubernetes-program if defined
similarly we should keep the old TRAMP method if tramp-kubernetes-method isn't defined

Sounds good!

I think that config use/set-context is global?

That's right. I wonder if instead we could supply environment variables to the underlying kubectl process?

Another issue is that according to the docs, "The first container in a pod is used", which is rather limiting for Kubel's use-case. Similar tools like k9s allow you to select the pod - often the first pod is actually istio-proxy or a similar "sidecar" pod which is less interesting.

@linktohack
Copy link

This works for me

  (with-eval-after-load 'tramp
    (require 'tramp-container)
    (when-let* ((method (thread-last tramp-methods
				     (seq-find #'(lambda (it) (pcase it (`("kubernetes" . ,_) t))))))
		(updated (pcase method (`(,_ . ,rest) `("kubectl" . ,rest)))))
      (add-to-list 'tramp-methods updated)))

It inserts kubectl method with the same config of kubernetes method defined in tramp-container

Hope it helps.

@johnhamelink
Copy link
Contributor Author

johnhamelink commented Aug 16, 2023

FYI it's now possible to define a container ID along with a pod in Emacs master: https://github.com/emacs-mirror/emacs/blob/master/lisp/net/tramp-container.el#L47

It seems that the namespace and context can be defined now too:
https://github.com/emacs-mirror/emacs/blob/master/etc/NEWS#L439

@johnhamelink johnhamelink changed the title TRAMP + Emacs 29 TRAMP + Emacs 30 Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants