mirror of
https://github.com/nubenetes/awesome-kubernetes.git
synced 2026-05-17 06:36:46 +00:00
7.1 KiB
7.1 KiB
Kubectl commands
- Introduction
- Kubectl Cheat Sheets
- Kubectl explain
- Kubectl Autocomplete
- List all resources and sub resources that you can constrain with RBAC
- Copy a configMap in kubernetes between namespaces
- Copy secrets in kubernetes between namespaces
- Export resources with kubectl and python
- Buildkit CLI for kubectl a drop in replacement for docker build
- Kubectl Alternatives
Introduction
- itnext.io: Boosting your kubectl productivity
- medium: 4 Simple Kubernetes Terminal Customizations to Boost Your Productivity
- medium: Ready-to-use commands and tips for kubectl
- medium: Be fast with Kubectl 1.19 CKAD/CKA 🌟 Collection of the fastest ways to create k8s resources using kubectl ≥ 1.18
- developers.redhat.com: Kubectl: Developer tips for the Kubernetes command line 🌟
- ibm.com: 8 Kubernetes Tips and Tricks 🌟 Most of the tips given below are using kubectl, a powerful command-line tool that allows you to execute commands against Kubernetes clusters.
- Set default namespaces
- Helpful aliases to save time
- YAML editing with vi
- Create YAML from kubectl commands
- Switching between Kubernetes namespaces
- Shell auto-completion
- Viewing resource utilization
- Extend kubectl and create your own commands using raw outputs
- pixelstech.net: Update & Delete Kubernetes resources in one-line command
- opensource.com: 5 useful ways to manage Kubernetes with kubectl Learn kubectl to enhance how you interact with Kubernetes.
- hackerxone.com: How to Manage Single & Multiple Kubernetes Clusters using kubectl & kubectx in Linux
Kubectl Cheat Sheets
Kubectl explain
- kubectl explain
- itnext.io: Using ‘kubectl explain’ for Custom Resources Goal: Explore if ‘kubectl explain’ can be used to discover static information about Custom Resources
for r in $(kubectl api-resources|grep -v ^N|awk '{print $1}');do kubectl explain $r --recursive;done
Kubectl Autocomplete
- Kubectl Autocomplete
- kubectl Shell Autocomplete
- Kubernetes productivity tips and tricks 🌟
- complete-alias Automagical shell alias completion.
source <(kubectl completion bash) # setup autocomplete in bash into the current shell, bash-completion package should be installed first.
echo "source <(kubectl completion bash)" >> ~/.bashrc # add autocomplete permanently to your bash shell.
You can also use a shorthand alias for kubectl that also works with completion:
alias k=kubectl
complete -F __start_kubectl k
List all resources and sub resources that you can constrain with RBAC
- kind of a handy way to see all thing things you can affect with Kubernetes RBAC. This will list all resources and sub resources that you can constrain with RBAC. If you want to see just subresources append "| grep {name}/":
kubectl get --raw /openapi/v2 | jq '.paths | keys[]'
Copy a configMap in kubernetes between namespaces
- Copy a configMap in kubernetes between namespaces with deprecated "--export" flag:
kubectl get configmap --namespace=<source> <configmap> --export -o yaml | sed "s/<source>/<dest>/" | kubectl apply --namespace=<dest> -f -
- Flag export deprecated in kubernetes 1.14. Instead following command can be used:
kubectl get configmap <configmap-name> --namespace=<source-namespace> -o yaml | sed ‘s/namespace: <from-namespace>/namespace: <to-namespace>/’ | kubectl create -f
Copy secrets in kubernetes between namespaces
kubectl get secret <secret-name> --namespace=<source> -o yaml | sed ‘s/namespace: <from-namespace>/namespace: <to-namespace>/’ | kubectl create -f
Export resources with kubectl and python
- Export resources with zoidbergwill/export.sh, by zoidbergwill
Buildkit CLI for kubectl a drop in replacement for docker build
- container-registry.com: Lifting Developers’ Productivity 🌟 With BuildKit CLI for kubectl a drop in replacement for docker build. In this post, you will learn how to build container images with BuildKit CLI for kubectl (a replacement for the
docker buildcommand) - vmware-tanzu/buildkit-cli-for-kubectl (kubectl plugin) BuildKit CLI for kubectl is a tool for building container images with your Kubernetes cluster.