"List of functions that `kubed-update-all' runs."
:type 'hook)
-(defcustom kubed-kubectl-executable "kubectl"
+(defcustom kubed-kubectl-program "kubectl"
"Name of `kubectl' executable to use for interacting with Kubernetes."
:type 'string)
:buffer ,out-name
:stderr ,err-name
:command (list
- kubed-kubectl-executable
+ kubed-kubectl-program
"get" ,(format "%Ss" resource)
,@(when namespaced
`((concat "--all-namespaces="
(erase-buffer)
(unless (zerop
(call-process
- kubed-kubectl-executable nil ,buf-name t "get"
+ kubed-kubectl-program nil ,buf-name t "get"
(if k8sns
(concat "--namespace=" k8sns)
"--all-namespaces=false")
(erase-buffer)
(unless (zerop
(call-process
- kubed-kubectl-executable nil ,buf-name t "get"
+ kubed-kubectl-program nil ,buf-name t "get"
,(symbol-name resource) "--output=yaml" ,resource))
(error ,(format "`kubectl get %S' failed" resource))))
(goto-char (point-min))
(cons (concat "KUBE_EDITOR=" emacsclient-program-name)
process-environment)))
(start-process ,(format "*kubed-%S-edit*" plrl-var) nil
- kubed-kubectl-executable "edit"
+ kubed-kubectl-program "edit"
(if k8sns
(concat "--namespace=" k8sns)
"-o=yaml")
(cons (concat "KUBE_EDITOR=" emacsclient-program-name)
process-environment)))
(start-process ,(format "*kubed-%S-edit*" plrl-var) nil
- kubed-kubectl-executable "edit"
+ kubed-kubectl-program "edit"
,(symbol-name resource) ,resource))))
,(if namespaced
" `%s' in namespace `%s'...")
name space)
(if (zerop (call-process
- kubed-kubectl-executable nil nil nil
+ kubed-kubectl-program nil nil nil
"delete" "--namespace" space
,(symbol-name plrl-var) name))
(message ,(concat "Deleting Kubernetes "
" `%s'...")
(string-join ,plrl-var "', `"))
(if (zerop (apply #'call-process
- kubed-kubectl-executable nil nil nil
+ kubed-kubectl-program nil nil nil
"delete" ,(symbol-name plrl-var) ,plrl-var))
(message ,(concat "Deleting Kubernetes "
(symbol-name plrl-var)
" `%s'...")
(string-join ,plrl-var "', `"))
(if (zerop (apply #'call-process
- kubed-kubectl-executable nil nil nil
+ kubed-kubectl-program nil nil nil
"delete" ,(symbol-name plrl-var) ,plrl-var))
(message ,(concat "Deleting Kubernetes "
(symbol-name plrl-var)
(make-process
:name ,(format "*kubed-%Ss-execute*" resource)
:stderr ,dlt-errb
- :command (list kubed-kubectl-executable
+ :command (list kubed-kubectl-program
"delete"
"--namespace" space
,(symbol-name plrl-var)
:name ,(format "*kubed-%Ss-execute*" resource)
:stderr ,dlt-errb
:command (append
- (list kubed-kubectl-executable
+ (list kubed-kubectl-program
"delete" ,(symbol-name plrl-var))
delete-list)
:sentinel (lambda (_proc status)
:name ,(format "*kubed-%Ss-execute*" resource)
:stderr ,dlt-errb
:command (append
- (list kubed-kubectl-executable
+ (list kubed-kubectl-program
"delete" ,(symbol-name plrl-var))
delete-list)
:sentinel (lambda (_proc status)
(interactive (list (read-string "Create namespace with name: ")))
(unless (zerop
(call-process
- kubed-kubectl-executable nil nil nil
+ kubed-kubectl-program nil nil nil
"create" "namespace" name))
(user-error "Failed to create Kubernetes namespace with name `%s'" name))
(message "Created Kubernetes namespace with name `%s'." name)
(list name images namespace replicas port command)))
(unless (zerop
(apply #'call-process
- kubed-kubectl-executable nil nil nil
+ kubed-kubectl-program nil nil nil
"create" "deployment" name
(append
(mapcar (lambda (image) (concat "--image=" image)) images)
(defun kubed-contexts ()
"Return list of Kubernetes contexts."
- (process-lines kubed-kubectl-executable "config" "get-contexts" "-o" "name"))
+ (process-lines kubed-kubectl-program "config" "get-contexts" "-o" "name"))
(defun kubed-current-context ()
"Return current Kubernetes context."
- (car (process-lines kubed-kubectl-executable "config" "current-context")))
+ (car (process-lines kubed-kubectl-program "config" "current-context")))
(defvar kubed-context-history nil
"History list for `kubed-read-context'.")
(list (kubed-read-context "Use context" (kubed-current-context))))
(unless (zerop
(call-process
- kubed-kubectl-executable nil nil nil
+ kubed-kubectl-program nil nil nil
"config" "use-context" context))
(user-error "Failed to use Kubernetes context `%s'" context))
(message "Now using Kubernetes context `%s'." context)
(defun kubed-current-namespace (&optional context)
"Return current Kubernetes namespace for context CONTEXT."
(car (process-lines
- kubed-kubectl-executable
+ kubed-kubectl-program
"config" "view" "-o"
(format "jsonpath={.contexts[?(.name==\"%s\")].context.namespace}"
(or context (kubed-current-context))))))
(list (kubed-read-namespace "Set namespace" (kubed-current-namespace))))
(unless (zerop
(call-process
- kubed-kubectl-executable nil nil nil
+ kubed-kubectl-program nil nil nil
"config" "set-context" "--current" "--namespace" ns))
(user-error "Failed to set Kubernetes namespace to `%s'" ns))
(message "Kubernetes namespace is now `%s'." ns)
(message "Creating Kubernetes %s with definition `%s'..." kind definition)
(message "Creating Kubernetes %s with definition `%s'... Done. New %s name is `%s'."
kind definition kind
- (car (process-lines kubed-kubectl-executable
+ (car (process-lines kubed-kubectl-program
"create" "-f" (expand-file-name definition)
"-o" "jsonpath={.metadata.name}")))))
"Return list of containers in Kubernetes pod POD in namespace K8SNS."
(string-split
(car (process-lines
- kubed-kubectl-executable "get"
+ kubed-kubectl-program "get"
(if k8sns (concat "--namespace=" k8sns) "--all-namespaces=false")
"pod" pod "-o" "jsonpath={.spec.containers[*].name}"))
" "))
(defun kubed-pod-default-container (pod &optional k8sns)
"Return default container of Kubernetes pod POD in namespace K8SNS, or nil."
(car (process-lines
- kubed-kubectl-executable
+ kubed-kubectl-program
"get"
(if k8sns (concat "--namespace=" k8sns) "--all-namespaces=false")
"pod" pod "-o"
(message "Getting logs for container `%s' in pod `%s' in namespace `%s'..." container pod k8sns)
(message "Getting logs for container `%s' in pod `%s'..." container pod))
(start-process "*kubed-logs*" buf
- kubed-kubectl-executable "logs"
+ kubed-kubectl-program "logs"
(if k8sns (concat "--namespace=" k8sns) "--tail=-1")
"-f" "-c" container pod)
(display-buffer buf)))
pod local-port remote-port
(if k8sns (concat " in " k8sns) ""))
(start-process "*kubed-port-forward*" nil
- kubed-kubectl-executable "port-forward"
+ kubed-kubectl-program "port-forward"
(if k8sns (concat "--namespace=" k8sns) "--address=localhost")
pod (format "%d:%d" local-port remote-port)))
kubed-port-forward-process-alist))