OKD includes a client library for creating applications to interact with OKD and Kubernetes clusters. Using the Go programming language (golang), you write programs to perform actions (such as get, list, watch, create, update, or delete) on OKD and Kubernetes resources (such as pods, services, and replicationcontrollers).
Both the client library and API object definitions are versioned, with separate branches corresponding to major versions of OKD. You need to match the client library version you use to the version of OKD with which you are interacting.
For client-go applications, you use a client library and API object definitions to create applications that interact with the OpenShift REST API. The openshift/client-go library is designed to be compatible with and complementary to the kubernetes/client-go library. To get started, we recommend you follow these general steps:
Read the client-go README: This file explains the components of Kubernetes client-go, as well as which client-go versions you should use with different versions of Kubernetes. You can also see in-cluster and out-of-cluster examples of go client applications. Refer to OpenShift Client in Go for specifics about OpenShift compatibility issues.
Read the client-go INSTALL: This helps you set up your client-go environment by vendoring (downloading) the correct code and helps you understand the tools you need to create applications. Dependency management in particular is addressed.
Review client-go examples: These include examples of cluster authentication and managing resources, as well as more advanced concepts for interfacing with work queues and custom resource definitions.
Review client-go build operations: This example demonstrates basic operations for using build resources. These include
Retrieve details of a build, and
Trigger a build.
Review the client-go source code: Go through the client-go source code, which contains the client-side code to invoke most actions against a cluster. To use the source code in a sample go project, all you need to do is to vendor these artifacts and write the code. When using Glide make sure to use 0.13.
The rest of this guide provides examples of client-go code used to perform specific tasks:
For information on the Kubernetes and OpenShift REST APIs, see the REST API Reference.