• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

nkuba/k8s-admin-helper: Kubernetes manifests templates and cheat sheets.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

nkuba/k8s-admin-helper

开源软件地址(OpenSource Url):

https://github.com/nkuba/k8s-admin-helper

开源编程语言(OpenSource Language):


开源软件介绍(OpenSource Introduction):

Kubernetes Admin Helper

This 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


Autocompletion

source <(kubectl completion bash)

Configuration and Maintenance

kubectl 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 operations

Create

kubectl 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

Read

kubectl 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

Node

kubectl 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

etcd

GitHub:

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

systemd

systemctl list-units | grep kube

systemctl status kube-apiserver

journalctl -u kubelet

Minikube

minikube start
minikube ip
minikube version
minikube ssh

containerd

sudo ctr -n k8s.io containers list



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap