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

推荐订阅源

V
Visual Studio Blog
The Last Watchdog
The Last Watchdog
Cisco Talos Blog
Cisco Talos Blog
A
Arctic Wolf
WordPress大学
WordPress大学
The Hacker News
The Hacker News
C
Cybersecurity and Infrastructure Security Agency CISA
H
Help Net Security
GbyAI
GbyAI
V
V2EX
Security Latest
Security Latest
Cyberwarzone
Cyberwarzone
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
P
Privacy International News Feed
I
InfoQ
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tor Project blog
P
Privacy & Cybersecurity Law Blog
C
Cisco Blogs
月光博客
月光博客
B
Blog
T
Threat Research - Cisco Blogs
I
Intezer
Recent Announcements
Recent Announcements
Latest news
Latest news
S
Schneier on Security
美团技术团队
量子位
H
Hacker News: Front Page
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Webroot Blog
Webroot Blog
N
News | PayPal Newsroom
Martin Fowler
Martin Fowler
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
爱范儿
爱范儿
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 聂微东
Cloudbric
Cloudbric
MyScale Blog
MyScale Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Microsoft Security Blog
Microsoft Security Blog
人人都是产品经理
人人都是产品经理
S
Securelist
Hacker News: Ask HN
Hacker News: Ask HN
Y
Y Combinator Blog
Attack and Defense Labs
Attack and Defense Labs
TaoSecurity Blog
TaoSecurity Blog

Learn Cloud Native

Agentgateway rate limiting for agents | Learn Cloud Native Local development with coding agents on Kubernetes using Signadot | Learn Cloud Native cuenv: one typed file for your whole project | Learn Cloud Native Preflight: AI Code Review Before You Push Anatomy of AI Agents Accessing Google Drive from Next.js Deploying to Fly.io using Dagger and Github Top Cloud-Native & Kubernetes Certifications [2026 Guide] Rapid microservices development with Signadot How to prepare for Istio certified associate exam (ICA) Global Rate Limiting in Istio with Envoy Rate Limit Service My Journey with Istio: From Incubation to Graduation Cilium Network Policy Tutorial: Secure Kubernetes Step by Step Kubernetes Networking: How kube-proxy and iptables Work Istio ServiceEntry: DNS vs. STATIC Resolution & Endpoints Explained Apply an Istio DestinationRule Globally (Mesh-Wide) Istio Rate Limiting: Configure a Local Rate Limiter in Envoy How to expose custom ports on Istio ingress gateway Portainer Tutorial: A Web UI for Kubernetes & Containers Traefik Proxy 2.x and TLS 101 Setting up SSL certificates with Istio Gateway ArgoCD Best Practices You Should Know 在 OCI Ampere A1 计算实例上运行 AI Running AI On OCI Ampere A1 Instance How to Deploy Traefik Proxy Using Flux and GitOps Principles Firebase Emulators with Next.js: Local Setup Guide Running Hugo on free Ampere VM (Oracle Cloud Infrastructure) How to use kwatch to detect crashes in Kubernetes clusters Continuous profiling in Kubernetes using Pyroscope Monitoring containers with cAdvisor Creating a Kubernetes cluster in Google Cloud (LAB) Your first Kubernetes Pod and ReplicaSet (LABS) Container Lifecycle Hooks Maybe Convert Wasm Extension Config? GetIstio - CLI, training, and community Attach multiple VirtualServices to Istio Gateway Kubernetes Volumes Explained: Keep Data Beyond the Pod Send a Slack message when Docker images are updated Kubernetes Network Policy Ambassador Container Pattern Start Kubernetes Release Sidecar Container Pattern Kubernetes Init Containers Deploying multiple Istio Ingress Gateways Branch by Abstraction Pattern The Strangler Pattern Kubernetes Development Environment with Skaffold Securing Kubernetes Ingress with Ambassador and Let's Encrypt All About the Ingress Resource How to quarantine Kubernetes pods? Getting started with Kubernetes Horizontal partitioning in MongoDB Docker image tagging scheme Six things to keep in mind when working with Dockerfiles Beginners guide to Docker Beginners guide to gateways and proxies Deploy and Operate Multiple Istio Meshes in one Kubernetes Cluster Managing service meshes with Meshery Circuit Breaking in Istio Explained Build and push your Docker images using Github Actions Kubernetes and Istio service mesh workshop materials Build Netlify-like deployment for React app using Kubernetes pods Six exciting enhancements in Istio 1.4.0 Fallacies of Distributed Systems CAP Theorem Explained Master the Kubernetes CLI (kubectl) - Cheatsheet Minikube Basics and How to Get Started with Kubernetes 5 Tips to Be More Productive with Kubernetes What are sticky sessions and how to configure them with Istio? Debugging Kubernetes applications using Istio Kubernetes Ingress and Istio Gateway Resource Zero Downtime Releases using Kubernetes and Istio Traffic Mirroring with Istio Service Mesh Expose a Kubernetes service on your own custom domain
Kubernetes CLI (kubectl) tips you didn't know about
Peter Jausovec · 2022-05-10 · via Learn Cloud Native

AhmetB started an excellent thread yesterday where he asked people to share a Kubernetes CLI (kubectl) tip that they think a lot of users don't know about.

There are so many excellent tips I decided to collect the most interesting ones in a single post. The first thing that I typically do when I am on a new machine is to set the alias for kubectl:

If you're working with Kubernetes, you'll be typing kubectl a lot, so why not make it shorter.

Enjoy the tips below and let us know if you have any other tips you want to share. Here are all the tips in no particular order.

1. Set up load-based horizontal pod autoscaling on your Kubernetes resources

kubectl autoscale deployment foo --min=2 --max=10

2. Create a new job from a cronjob

kubectl create job --from=cronjob/<name of cronjob> <name of this run>

3. Enumerate permissions for a given service account

kubectl -n <namespace> auth can-i --list --as system:serviceaccount:<namespace>:<service account name>

4. Annotate resources

# To add annotation
kubectl annotate <resource-type>/<resource-name> foo=bar
# To remove annotation
kubectl annotate <resource-type>/<resource-name> foo-

5. Get a list of endpoints across all namespaces

6. Get a list of events sorted by lastTimestamp

kubectl get events --sort-by=".lastTimestamp"

7. Watch all warnings across the namespaces

kubectl get events -w --field-selector=type=Warning -A

8. Add the EVENT column to the list of watched pods

kubectl get pods --watch --output-watch-events

9. Get raw JSON for the various APIs

kubectl get --raw /apis/apps/v1

# Get metrics
kubectl get --raw /metrics

10. Wait for specific pods to be ready

kubectl wait --for=condition=ready pod -l foo=bar

11. Explain the various resources

12. Get all resources that match a selector

kubectl get deployments,replicasets,pods,services --selector=hello=yourecute

13. Forward a port from a service to a local port

kubectl port-forward svc/<service-name> <local-port>:<remote-port>

14. List the environment variables for a resource

kubectl set env <resource>/<resource-name> --list

15. Get a list of pods and the node they run on

kubectl get po -o=custom-columns=NODE:.spec.nodeName,NAME:.metadata.name

16. Create a starter YAML manifest for deployment (also works for other resources)

kubectl create deploy nginx-deployment --image=nginx --dry-run=client -o yaml

17. Get a list of pods sorted by memory usage

kubectl top pods -A --sort-by='memory'

18. Get a list of pods that have a specific label value set

kubectl get pods -l 'app in (foo,bar)'

19. Get the pod logs before the last restart

kubectl logs <pod-name> --previous

20. Copy a file from a pod to a local file

kubectl cp <namespace>/<pod>:<file_path> <local_file_path>
kubectl delete pod <pod-name> --now

22. Show the logs from pods with specific labels

23. Get more information about the resources (aka wide-view)

kubectl get <resource> -o wide

24. Output and apply the patch

# Edit a resource and get the patch
kubectl edit <resource>/<name> --output-patch

# Use the output from the command above to apply the patch
kubectl patch --patch=<output_from_previous_command>