}
}
You can then retrieve the full JSON specification
of each API by using a
curl
com‐
mand of this type:
$ curl http://localhost:8080/swaggerapi/api/v1
This might be useful if you want to write your own Kubernetes client. However,
Swagger also exposes a web UI that makes exploring the API straightforward. Assum‐
ing you can reach the API server from a web browser, you can open the UI at a
http://
:8080/swagger-ui/
, and should be presented with the
Swagger UI as shown in
Figure 5-3
.
Figure 5-3. Swagger UI to explore Kubernetes API
Discussion
Exploring the API with Swagger and
curl
is useful to get a better understanding of
Kubernetes, including the schema used for pods, replication controllers, and services.
However, it is more practical to use the
kubectl
client that comes with every release.
The usage is well documented and allows you to perform most API functions:
$ ./kubectl
kubectl controls the Kubernetes cluster manager.
Find more information at https://github.com/GoogleCloudPlatform/kubernetes.
Usage:
kubectl [flags]
kubectl [command]
160 | Chapter 5: Kubernetes
Available Commands:
get Display
one or many resources
describe Show details of a specific resource or group of resources
create Create a resource by filename or stdin
replace Replace a resource by filename or stdin.
patch Update field(s) of a resource by stdin.
delete
Delete a resource by filename, stdin, resource and name, ...
namespace SUPERCEDED: Set and view the current Kubernetes namespace
logs Print the logs for a container in a pod.
rolling-update Perform a rolling update of the given ReplicationController.
scale Set a new size for a Replication Controller.
exec Execute a command in a container.
port-forward Forward one or more local ports to a pod.
proxy Run a proxy
to the Kubernetes API server
run Run a particular image on the cluster.
stop Gracefully shut down a resource by name or filename.
expose Take a replicated application and expose it as Kubernetes
Service
label Update the labels on a resource
config config
modifies kubeconfig files
cluster-info Display cluster info
api-versions Print available API versions.
version Print the client and server version information.
help Help about any command
As you explore the Kubernetes API, you might enjoy a few interest‐
ing routes as well, like
/ping/
and
/validate
:
$ curl http://localhost:8080/ping/
{
"paths": [
"/api",
"/api/v1",
"/healthz",
"/healthz/ping",
"/logs/",
"/metrics",
"/resetMetrics",
"/swagger-ui/",
"/swaggerapi/",
"/ui/",
"/version"
]
}
Do'stlaringiz bilan baham: