There are plenty of reasons to call the Kubernetes API using a CLI (like curl) or GUI (like postman) HTTP client. For instance, you may need finer-grained control over Kubernetes Objects than kubectl provides or just want to explore the API before trying to access it from code.
This article is not a mere list of handy commands but a thoughtful walk-through revealing some interesting problems you may stumble upon while calling the Kubernetes API from the command line. It covers the following topics:
- How to get the Kubernetes API server address
- How to authenticate the API server to clients
- How to authenticate clients to the API server using certificates
- How to authenticate clients to the API server using tokens
- Bonus: How to call the Kubernetes API from inside a Pod
- How to perform the basic CRUD operations on Kubernetes Objects with curl
- How to access the Kubernetes API directly using the kubectl's raw mode
- Bonus: How to see what API requests a kubectl command like apply sends.