Code Monkey home page Code Monkey logo

fubectl's Introduction

fubectl

Because it's fancy-kubectl !

Prerequisites?

Installation

You can directly download the fubectl.source and save it in some directory.

Download:

curl -LO https://rawgit.com/kubermatic/fubectl/master/fubectl.source

then add to your .bashrc/.zshrc file:

[ -f <path-to>/fubectl.source ] && source <path-to>/fubectl.source

Alternatively you can install fubectl using the ZSH plugin manager of your choice.

What can it do?

k - alias for kubectl

Like g for git but 133% more effective!

Examples:

  • k get nodes
  • k get pods
  • k version --short

Usage: kGif


kw - alias for 'watch kubectl'

Examples:

  • kw nodes
  • kw pods
  • kw nodes,pods,services

kall - All pods in all namespaces

Get all pods

Usage: kGif


kwall - Watch all pods in all namespaces

Watch all pods in all namespaces every 2 seconds.

Usage: kGif


kdes - Describe a resource

Examples:

  • kdes pod
  • kdes service
  • kdes nodes

Usage: kGif


kdel - Delete a resource

Examples:

  • kdel pod
  • kdel secret
  • kdel pvc

Usage: kGif


klog - Print the logs for a container in a pod

Examples:

  • klog - Print the last 10 lines
  • klog 100 - Print the last 100 lines
  • klog 250 -f - Print the last 250 lines and follow the output, like tail -f
  • klog 50 -p - Print the last 50 lines of the previous container

Usage: kGif


kex - Execute a command in a container

Examples:

  • kex bash - Start a bash in a container
  • kex date - Print the date in a container

Usage: kGif


kfor - Forward one or more local ports to a pod

Examples:

  • kfor 8000 - Forwards port 8000 to a pod
  • kfor 8000:80 Fowards local port 8000 to a pod's port 80

Usage: kGif


ksearch - Search for string in resources

Examples:

  • // TODO

Usage: kGif


kcl - Displays one or many contexts from the kubeconfig file

Context list

Usage: kGif

kcs - Sets the current context

Usage: kGif


kcns - Switch the default namespace

kcns - Set the current default namespace from list kcns kube-system - Set kube-system as default namespace immediately

Usage: kGif

kdebug - Start a debugging Pod in a Cluster

Usage: kGif


kp - Open the Kubernetes dashboard

Opens localhost:8001/ui in your browser and runs kubectl proxy


Extra!

Do you want to have the current kubecontext in your prompt?:

export PS1="\[$(kube_ctx_name)\] $PS1"

for the current namespace (this is currently slow, because it calls kubectl every time):

export PS1="\[$(kube_ctx_namespace)\] $PS1"

Customization

fubectl can be customized via following environment variables

  • FUBECTL_WATCH_CMD - alterative watch command, e.g. viddy
  • FUBECTL_NO_KCL - disable kcl alias, since it may conflict with KCL language CLI

Troubleshooting

If you encounter issues file an issue or talk to us on the #fubectl channel on the Kubermatic Slack.

Contributing

Thanks for taking the time to join our community and start contributing!

Feedback and discussion are available on Kubermatic Slack.

Before you start

  • Please familiarize yourself with the Code of Conduct before contributing.
  • See CONTRIBUTING.md for instructions on the developer certificate of origin that we require.

Pull requests

  • We welcome pull requests. Feel free to dig through the issues and jump in.

fubectl's People

Contributors

aborilov avatar az82 avatar dharapvj avatar erdii avatar eshepelyuk avatar hc2p avatar kdomanski avatar krbcmt avatar kron4eg avatar lbb avatar luisdavim avatar metalmatze avatar osela avatar realfake avatar scheeles avatar thz avatar toschneck avatar ulrichschreiner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fubectl's Issues

implement kinstall for dependencies

To prevent errors with dependencies like e.g.

# [ktree] prints a tree of k8s objects (kubectl tree plugin needs to be installed)

we should implement:

  • check if the dependencies are there
  • kinstall command what installs the needed dependencies

Vim issues with ked

Discovered the ked command introduced in fubectl but I currently cannot use it. Two (related) issues I have:

I run ked deploy and select one of my deployments to edit

[proposal] adopt kubectx/kubens

Hello,

To manage context and namespace switching functionality - kubectx/kubens toolset could be used.
They could be installed via krew as other plugins used by fubectl.
fubectl could provide useful aliases like kctx / kns, current context / namespace functions would be deprecated.

Tools homepage: https://github.com/ahmetb/kubectx

Installation on macOS Catalina with oh-my-zsh

All prerequsite installed but during the installation I see the following output:

[ -f /Users/1/apps/fubectl/fubectl.source ] && source /Users/1/apps/fubectl/fubectl.source
/Users/1/apps/fubectl/fubectl.source:90: defining function based on alias `ked'
/Users/1/apps/fubectl/fubectl.source:90: parse error near `()'

MicroK8s support

MicroK8S is Kubernetes Distribution from Canonical packaged as snap

Since MicroK8s uses proxy command (microk8s.kubectl get pods instead of kubectl get pods) this would require extracting kubectl command to own variable and maybe some logic like if kubectl bin isn't in $PATH then try microk8s.kubectl

I'm willing to submit pull request if this is found useful

Consider separate aliases for current NS and all NS

Hello

Currently many aliases are querying resources from all namespaces. In case of big cluster with dozens NS and dozens of pods in evey NS such frequent querying could affect cluster performance and also provide slow response time to end users.

I propose to introduce one of the following

  • config parameter (env var, file) that changes namespace filtering behaviour of all declared aliases
  • duplicate aliases to have 2 commands
    • klog for current namespace
    • kloga for all namespaces
    • For backward compatibility it could be klog for current behaviour (all NS) and klg for current NS

Wdyt ?

kdes is not working

On Mac with zsh kdes is not working and giving below error. Which script mac user have to -- to -I or something like that ?

(⎈ |minikube:default)➜ hack git:(master) kdes po
xargs: illegal option -- r
usage: xargs [-0opt] [-E eofstr] [-I replstr [-R replacements]] [-J replstr]
[-L number] [-n number [-x]] [-P maxprocs] [-s size]
[utility [argument ...]]
(⎈ |minikube:default)➜ hack git:(master)

Regex parse Error

Hi,

I've done a fresh setup of fubectl. Everything is working fine, but when I do almost any command I get an regex parse error.

image

I suppose its a problem with my setup, but I don't know there exactly the error is coming from.

Any Ideas?

Thanks in advance for any help :)

Watch a specific namespace

kwall is really not helpful when trying to monitor a specific namespace, because there's too much information being displayed at once.

The objective here would be to focus on a namespace.

It's an enhancement, is it viable?

kex not working as intented

kex sh error: expected 'exec POD_NAME COMMAND [ARG1] [ARG2] ... [ARGN]'. POD_NAME and COMMAND are required arguments for the exec command See 'kubectl exec -h' for help and examples.

kadd / kdel zsh

There seems to be parsing issues on zsh with kadd and kdel functions:

fubectl.source:69: defining function based on alias `ked'
fubectl.source:69: parse error near `()'

when commented out those functions all is fine

Inclusion of stern/kail for multi pod logs?

Can we make use of stern / kail to monitor multiple logs at the same time?

We might need to build a thin wrapper to ask questions to user about how they want to tail logs - deployment or service or label etc... then logs can appear.

default line number for klog -f

I would like to have default line number for klog -f so that I don't have to type in how many lines should be in the returned klog 200 -f

it would mirror the behaviour from tail and head as it says in the man page The default starting location is "-n 10", or the last 10 lines of the input

ksearch error: unknown flag: --export

ksearch <smth>
error: unknown flag: --export
See 'kubectl get --help' for usage.

kubectl version --client
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.3", GitCommit:"816c97ab8cff8a1c72eccca1026f7820e93e0d25", GitTreeState:"clean", BuildDate:"2022-01-25T21:25:17Z", GoVersion:"go1.17.6", Compiler:"gc", Platform:"linux/amd64"}

First release? Tag?

Could you create a first release or tag? I am looking into packaging this for openSUSE, so having tags/releases would be nice...

zsh : kex bash command promote not valid in this context

zsh version 5.0.2
kex klog func not working

local command in zsh not identify string include space
for example: local val=$(echo "hello world"|awk '{print $1, $2}')
val equal to hello not hello world
i resolve it by double quote like this: "$(echo "hello world"|awk '{print $1, $2}') "

Some commands from README seem to be outdated

For example, kdebug is described in the project's README, however I can't see any mentions of this function in the current fubectl.source. (I haven't made a PR for this as I am not sure whether kdebug should actually exist for fubectl.)

At the same time, quite interesting commands including ked, ksec, and konsole are defined in the source file, however they are missing in the README.

pod name not recognised by kubectl

Hi there, thanks for the great tool.

I have used it for the past year and recently started using it again on a new computer.

Now, whenever I use klog or kfor, it fails with the following error message:

error: expected 'logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]'.
POD or TYPE/NAME is a required argument for the logs command
See 'kubectl logs -h' for help and examples

Any idea why this could be?

Separating the namespace and pod name solves the issue:
kiwiidb@282bc63

Missing documentation for many amazing commands

By grepping the source and comparing the README.md content.. I identified that below functions are not mentioned and documented in the README currently.

ka
kwa
kwatch
kcmd
kube_ctx_name
kube_ctx_namespace
kget
kexp
kget-exp
ked
kkonfig

Also we need to remove kdebug from the readme.md since it does not exist anymore in source.

kcs uses cluster name and not context name

hi,

when using kcs the code uses the name of the cluster as the context-name:

kcs() {
  context="$(kubectl config get-contexts | _inline_fzf | awk '{print $2}')"
  eval kubectl config set current-context "${context}"
}

$ kubectl config get-contexts
CURRENT   NAME           CLUSTER    AUTHINFO      NAMESPACE
          asterix-ns1    asterix    user1         ns1
*         obelix-ns1     obelix     user2         ns1
          obelix-ns2     obelix     user3         ns2
          minikube       minikube   minikube      

this only works, when the clustername and contextname are identical. if they are different, the configuration is corrupted. i think you should use print $1 for awk:

 context="$(kubectl config get-contexts | _inline_fzf | awk '{print $1}')"

One improvement to kube_ctx_namespace

Hi all!

Looking for new ideas I found your project. It gave me some ones and I'd like to share my visions with you. Hope it will help you further.

fubectl/fubectl.source

Lines 80 to 85 in 3950b1e

# [kube_ctx_namespace] get current namespace
function kube_ctx_namespace() {
local default_ns="$(kubectl config view --minify|grep namespace: |sed 's/namespace: //g'|tr -d ' ')"
default_ns="${default_ns:-default}"
echo "$default_ns"
}

I think the snippet above can be improved a little bit in the way as below. It requires kubectl itself and its jsonpath features that have already been embedded.

kubectl config view --minify \
-o jsonpath="{range .contexts[*].context}{@.user}{\"@\"}{@.cluster}{\":\"}{@.namespace}{\"\n\"}"

It displays the current context in the form similar to the unix prompt like user@cluster:namespace. It's constructed to be used directly or as an alias. You can take it as is or modify on your wants or drop as a bad idea for your project :).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.