惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
Help Net Security
Help Net Security
P
Privacy International News Feed
T
Threat Research - Cisco Blogs
C
Cisco Blogs
C
CERT Recently Published Vulnerability Notes
NISL@THU
NISL@THU
L
LINUX DO - 热门话题
Security Latest
Security Latest
A
Arctic Wolf
G
GRAHAM CLULEY
月光博客
月光博客
S
Securelist
D
Docker
J
Java Code Geeks
T
Troy Hunt's Blog
T
Tenable Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
SecWiki News
SecWiki News
S
Security @ Cisco Blogs
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
LINUX DO - 最新话题
Recent Commits to openclaw:main
Recent Commits to openclaw:main
aimingoo的专栏
aimingoo的专栏
博客园 - 【当耐特】
H
Heimdal Security Blog
The Hacker News
The Hacker News
博客园 - 三生石上(FineUI控件)
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
Netflix TechBlog - Medium
Vercel News
Vercel News
Forbes - Security
Forbes - Security
B
Blog RSS Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
IT之家
IT之家
B
Blog
MongoDB | Blog
MongoDB | Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
S
Secure Thoughts
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Check Point Blog
云风的 BLOG
云风的 BLOG
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
L
Lohrmann on Cybersecurity
F
Full Disclosure
D
Darknet – Hacking Tools, Hacker News & Cyber Security
P
Proofpoint News Feed

卫星实验室 on XLabs

Spring Boot 4 迁移指南:从 3.x 升级到 4.0 完整教程与踩坑实战 Awesome Alternatives Bitnami:寻找 Bitnami Charts 的替代方案 Javax 和 Jakarta 过渡期兼容方案 - 企业级迁移指南 预防和消灭技术债:Maven CI 如何在编译时禁止调用某些特定 API Keycloak 自定义 User Federation SPI 实现:对接企业已有用户系统 Spring Security 集成 Keycloak:RBAC/ABAC 授权与 JWT Token 解析实战 Backstage 集成 Keycloak 和 oauth2-proxy:K8S 部署与 RBAC/ABAC 授权实战 统一身份认证 总体架构 Introduction Introduction
Kubernetes
2023-09-07 · via 卫星实验室 on XLabs

常用 Kubernetes 命令,复制,粘贴,这就是生活。


  • 复制 secret 到另一个 namespace。
kubectl get secret mys --namespace=na -oyaml | grep -v '^\s*namespace:\s' | kubectl apply --namespace=nb -f -
  • 批量删除 pod。
kubectl get pods --all-namespaces | grep Evicted | awk '{print $2 " --namespace=" $1}' | xargs kubectl delete pod
# Delete by label
kubectl delete pod -n idaas-book -l app.kubernetes.io/name=idaas-book
  • 原地重启 Pod。
kubectl rollout restart deploy/xxx -n your-namespace
  • 命令行快速扩缩容。
# kubectl scale -h
kubectl scale --replicas=1 deploy/xxx -n your-namespace
  • 密钥解密。
 kubectl get secret my-creds -n mysql -o jsonpath="{.data.ADMIN_PASSWORD}" | base64 --decode
  • 合并多个 kube config 文件。
export KUBECONFIG=~/.kube/config:~/.kube/anotherconfig
kubectl config view --flatten > ~/.kube/config-all

cp ~/.kube/config-all ~/.kube/config
# 顺手把权限改了,避免 helm 或 kubectl 客户端 warning
chmod 600 ~/.kube/config
  • 获取某个 namespace 下的全部资源,找出你看不见的资源,常用于 webhook/CR/CRD 等资源清理,解决强制删除失败。

ns=your-namespace

for resource in `kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get -o name -n $ns`; do
    kubectl get $resource  -n $ns;
    # kubectl patch $resource -p '{"metadata": {"finalizers": []}}' --type='merge' -n $ns;
done
  • 根据特定字段排序 Pod 列表。
# 根据重启次数排序
kubectl get pods --sort-by='.status.containerStatuses[0].restartCount' -A