最新文章

常用的几款工具让 Kubernetes 集群上的工作更容易

常用的几款工具让 Kubernetes 集群上的工作更容易

之前写过一篇 介绍了工具加速云原生 Java 开发。

其实日常工作中在集群上的操作也非常多,今天就来介绍我所使用的工具。

kubectl-alias

使用频率最高的工具,我自己稍微修改了一下,加入了 StatefulSet 的支持。

这个是我的 https://github.com/addozhang/kubectl-aliases,基于 https://github.com/ahmetb/kubectl-aliases。

比如输出某个 pod 的 json,kgpoojson xxx 等同于 kubectl get pod xxx -o json。

结合 jq 使用效果更好 😂。

语法解读

  • k=kubectl
    • sys=--namespace kube-system
  • commands:
    • g=get
    • d=describe
    • rm=delete
    • a:apply -f
    • ak:apply -k
    • k:kustomize
    • ex: exec -i -t
    • lo: logs -f
  • resources:
    • po=pod, dep=deployment, ing=ingress, svc=service, cm=configmap, sec=secret,ns=namespace, no=node
  • flags:
    • output format: oyaml, ojson, owide
    • all: --all or --all-namespaces depending on the command
    • sl: --show-labels
    • w=-w/--watch
  • value flags (should be at the end):
    • n=-n/--namespace
    • f=-f/--filename
    • l=-l/--selector

kubectx + kubens

安装看这里