在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):nkuba/k8s-admin-helper开源软件地址(OpenSource Url):https://github.com/nkuba/k8s-admin-helper开源编程语言(OpenSource Language):开源软件介绍(OpenSource Introduction):Kubernetes Admin HelperThis project contains selection of resources helpful for Kubernetes Administrators. Manifests templates are created based on official Kubernetes Documentation and API Reference v1.9 Cheat sheet commands are based on official kubectl Cheat Sheet Autocompletionsource <(kubectl completion bash) Configuration and Maintenancekubectl config view
kubectl config current-context
kubectl config use-context CONTEXT
kubectl cluster-info
kubectl get componentstatuses
kubectl get events
# Logs
kubectl logs --namespace=NAMESPACE POD_NAME --container=CONTAINER_NAME
kubectl logs --previous POD_NAME --container=CONTAINER_NAME
# Namespaces
kubectl get namespace
kubectl create namespace NAMESPACE Resource lifecycle operationsCreatekubectl create -f my-manifest.yaml # create from file
kubectl create -f my1.yaml -f my2.yaml # create from multiple files
kubectl create -f dir # create from files in dir Readkubectl get pods # List all pods in the namespace
kubectl get pods --all-namespaces # List all pods in all namespaces
kubectl get pods -o wide # List all pods in the namespace, with more details
kubectl get pods --include-uninitialized # List all pods in the namespace, including uninitialized ones
kubectl get pods --watch # List all pods and watch changes
kubectl get pod my-pod # List a particular deployment
kubectl describe nodes my-node
kubectl get services --sort-by=.metadata.name # List Services Sorted by Name
# List pods Sorted by Restart Count
kubectl get pods --sort-by='.status.containerStatuses[0].restartCount'
# Get the version label of all pods with label app=cassandra
kubectl get pods --selector=app=cassandra -o jsonpath='{.items[*].metadata.labels.version}'
# Get all running pods in the namespace
kubectl get pods --field-selector=status.phase=Running
# Get ExternalIPs of all nodes
kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="ExternalIP")].address}'
# List Names of Pods that belong to Particular Deployment
# "jq" command useful for transformations that are too complex for jsonpath, it can be found at https://stedolan.github.io/jq/
sel=$(kubectl get deployment nginx-deployment -o=json | jq -j '.spec.selector.matchLabels | to_entries | map([.key,.value] | join("=")) | join(",")')
kubectl get pods -l=$sel -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}' Update# Force replace, delete and then re-create the resource. Will cause a service outage.
kubectl replace --force -f ./pod.json Nodekubectl label node NODE KEY=VALUE
kubectl get nodes --show-labels
kubectl get nodes -o jsonpath="{$.items[*].metadata.labels}"
# Taint
kubectl taint node NODE_NAME LABEL_KEY=LABEL_VALUE:NoSchedule
# Drain and Uncordon
kubectl drain NODE_NAME
kubectl uncordon NODE_NAME etcdGitHub: Global flags# API version
export ETCDCTL_API=3
# Certificates
export ETCDCTL_CACERT=/tmp/ca.pem
export ETCDCTL_CERT=/tmp/cert.pem
export ETCDCTL_KEY=/tmp/key.pem Commands# List etcd cluster members
etcdctl member list
# List resources
etcdctl ls
etcdctl ls /registry
# Backup
etcdctl --endpoints <ENDPOINT> snapshot save snapshotdb
etcdctl --write-out=table snapshot status snapshotdb systemdsystemctl list-units | grep kube
systemctl status kube-apiserver
journalctl -u kubelet Minikubeminikube start
minikube ip
minikube version
minikube ssh containerdsudo ctr -n k8s.io containers list |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论