Kubernetes Prow Robot 41e317dd38 Merge pull request #5 from brendandburns/docs
Improve the READMEs for the client.
2020-03-23 22:36:47 -07:00
2020-03-18 17:24:33 +08:00
2020-03-17 07:59:06 -04:00
2020-03-17 07:59:06 -04:00
2020-03-17 07:59:06 -04:00
2020-03-23 21:44:28 -07:00
2020-03-17 07:59:06 -04:00
2020-03-18 17:24:33 +08:00

Kubernetes Client Library for C

This is the official Kubernetes client library for the C programming language. It is a work in progress and should be considered alpha quality software at this time.

Building the library

# Clone the repo
git clone https://github.com/kubernetes-client/c
CLIENT_REPO_ROOT=${PWD}/c

# Install pre-requisites
sudo apt-get install libcurl4-openssl-dev uncrustify

# Move into the Kubernetes directory
cd ${CLIENT_REPO_ROOT}/kubernetes

# Build
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/lib ..
make
sudo make install

Building an example

cd ${CLIENT_REPO_ROOT}/examples/list_pod
make

Running the example

For now, you need to use kubectl proxy to handle authentication.

kubectl proxy
./list_pod_bin

Usage example

    list_t *apiKeys;
    apiKeys = list_create();
    
    keyValuePair_t *keyPairToken = keyValuePair_create(keyToken, valueToken);
    list_addElement(apiKeys, keyPairToken);

    g_k8sAPIConnector = apiClient_create_with_base_path(K8S_APISERVER_BASEPATH, NULL, apiKeys);

    v1_pod_list_t *pod_list = NULL;
    pod_list = CoreV1API_listNamespacedPod(apiClient,
                                          "default",    /*namespace */
                                           NULL,    /* pretty */
                                           0,       /* allowWatchBookmarks */
                                           NULL,    /* continue */
                                           NULL,    /* fieldSelector */
                                           NULL,    /* labelSelector */
                                           0,       /* limit */
                                           NULL,    /* resourceVersion */
                                           0,       /* timeoutSeconds */
                                           0        /* watch */
        );
    printf("return code=%ld\n", apiClient->response_code);
    if (pod_list) {
      ...
    }

Community, discussion, contribution, and support

Learn how to engage with the Kubernetes community on the community page.

You can reach the maintainers of this project at:

Code of conduct

Participation in the Kubernetes community is governed by the Kubernetes Code of Conduct.

Description
No description provided
Readme Apache-2.0 8.7 MiB
Languages
C 99.5%
CMake 0.4%