Back to articles
Uniform API server access using clientcmd
How-ToDevOps

Uniform API server access using clientcmd

via Kubernetes Blog

If you've ever wanted to develop a command line client for a Kubernetes API, especially if you've considered making your client usable as a kubectl plugin, you might have wondered how to make your client feel familiar to users of kubectl . A quick glance at the output of kubectl options might put a damper on that: "Am I really supposed to implement all those options?" Fear not, others have done a lot of the work involved for you. In fact, the Kubernetes project provides two libraries to help you handle kubectl -style command line arguments in Go programs: clientcmd and cli-runtime (which uses clientcmd ). This article will show how to use the former. General philosophy As might be expected since it's part of client-go , clientcmd 's ultimate purpose is to provide an instance of restclient.Config that can issue requests to an API server. It follows kubectl semantics: defaults are taken from ~/.kube or equivalent; files can be specified using the KUBECONFIG environment variable; all of t

Continue reading on Kubernetes Blog

Opens in a new tab

Read Full Article
4 views

Related Articles