kubernetes-client / c

Licence: Apache-2.0 license
Official C client library for Kubernetes

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to c

Google Maps Services Js
Node.js client library for Google Maps API Web Services
Stars: ✭ 2,432 (+2830.12%)
Mutual labels:  client-library
ably-cocoa
iOS, tvOS and macOS Objective-C and Swift client library SDK for Ably realtime messaging service
Stars: ✭ 33 (-60.24%)
Mutual labels:  client-library
node-meraki-dashboard
A modern node.js client library for using the Meraki Dashboard API.
Stars: ✭ 20 (-75.9%)
Mutual labels:  client-library
Alpaca
Given a web API, Generate client libraries in node, php, python, ruby
Stars: ✭ 2,447 (+2848.19%)
Mutual labels:  client-library
kubernetes-client-lambda
one-line kubernetes client: light-weight, lambda-styled, easy-testing. For a simplified kubernetes programming.
Stars: ✭ 47 (-43.37%)
Mutual labels:  client-library
js-client-library
TimeTac Client Library is a thin wrapper for client to make api request.
Stars: ✭ 11 (-86.75%)
Mutual labels:  client-library
Node Sparkpost
SparkPost client library for Node.js
Stars: ✭ 177 (+113.25%)
Mutual labels:  client-library
agollo
🚀Go client for ctrip/apollo (https://github.com/apolloconfig/apollo)
Stars: ✭ 563 (+578.31%)
Mutual labels:  client-library
streamr-client-javascript
JS library for interacting with Streamr APIs: publishing and subscribing to data, creating streams, etc.
Stars: ✭ 35 (-57.83%)
Mutual labels:  client-library
goql
A GraphQL client package written in Go.
Stars: ✭ 17 (-79.52%)
Mutual labels:  client-library
Jreactive 8583
Java Client & Server for ISO8583 & Netty
Stars: ✭ 248 (+198.8%)
Mutual labels:  client-library
iyzipay-dotnet-client
iyzipay api .net framework and .net core client
Stars: ✭ 30 (-63.86%)
Mutual labels:  client-library
iyzipay-ruby
iyzipay api ruby client
Stars: ✭ 37 (-55.42%)
Mutual labels:  client-library
Iyzipay Php
iyzipay api php client
Stars: ✭ 205 (+146.99%)
Mutual labels:  client-library
braze-php-sdk
A PHP client to interact with Braze API
Stars: ✭ 15 (-81.93%)
Mutual labels:  client-library
Php Sparkpost
SparkPost client library for PHP
Stars: ✭ 190 (+128.92%)
Mutual labels:  client-library
ably-php
PHP client library SDK for Ably realtime messaging service
Stars: ✭ 41 (-50.6%)
Mutual labels:  client-library
circles-core
Common methods to interact with the Circles ecosystem
Stars: ✭ 22 (-73.49%)
Mutual labels:  client-library
Milvasoft.Iyzipay
Iyzico client for .Net 6
Stars: ✭ 15 (-81.93%)
Mutual labels:  client-library
govpp
Go toolset for the VPP.
Stars: ✭ 119 (+43.37%)
Mutual labels:  client-library

Kubernetes Client Library for C

Client Capabilities Client Support Level Code Check Build

This is the official Kubernetes client library for the C programming language.

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 libssl-dev libcurl4-openssl-dev uncrustify

# Build pre-requisite: libwebsockets
git clone https://libwebsockets.org/repo/libwebsockets --depth 1 --branch v4.2-stable
cd libwebsockets
mkdir build
cd build
cmake -DLWS_WITHOUT_TESTAPPS=ON -DLWS_WITHOUT_TEST_SERVER=ON-DLWS_WITHOUT_TEST_SERVER_EXTPOLL=ON \
      -DLWS_WITHOUT_TEST_PING=ON -DLWS_WITHOUT_TEST_CLIENT=ON -DCMAKE_C_FLAGS="-fpic" -DCMAKE_INSTALL_PREFIX=/usr/local ..
make
sudo make install

# Build pre-requisite: libyaml
git clone https://github.com/yaml/libyaml --depth 1 --branch release/0.2.5
cd libyaml
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_TESTING=OFF  -DBUILD_SHARED_LIBS=ON ..
make
sudo make install

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

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

(Optional) Installing using vcpkg on Windows

If you want to install the C client using vcpkg, please refer to vcpkg.md

Building an example

cd ${CLIENT_REPO_ROOT}/examples/list_pod
make

Running the example

./list_pod_bin

Usage example

list all pods:

    char *basePath = NULL;
    sslConfig_t *sslConfig = NULL;
    list_t *apiKeys = NULL;
    int rc = load_kube_config(&basePath, &sslConfig, &apiKeys, NULL);/* NULL means loading configuration from $HOME/.kube/config */
    if (rc != 0) {
        printf("Cannot load kubernetes configuration.\n");
        return -1;
    }
    apiClient_t *apiClient = apiClient_create_with_base_path(basePath, sslConfig, apiKeys);
    if (!apiClient) {
        printf("Cannot create a kubernetes client.\n");
        return -1;
    }

    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 */
                                           NULL,    /* resourceVersionMatch */
                                           0,       /* timeoutSeconds */
                                           0        /* watch */
        );
    printf("return code=%ld\n", apiClient->response_code);
    if (pod_list) {
      ...
    }

    apiClient_free(apiClient);
    apiClient = NULL;
    free_client_config(basePath, sslConfig, apiKeys);
    basePath = NULL;
    sslConfig = NULL;
    apiKeys = NULL;
    apiClient_unsetupGlobalEnv();

list all pods in cluster:

    char *basePath = NULL;
    sslConfig_t *sslConfig = NULL;
    list_t *apiKeys = NULL;
    int rc = load_incluster_config(&basePath, &sslConfig, &apiKeys);
    if (rc != 0) {
        printf("Cannot load kubernetes configuration in cluster.\n");
        return -1;
    }
    apiClient_t *apiClient = apiClient_create_with_base_path(basePath, sslConfig, apiKeys);
    if (!apiClient) {
        printf("Cannot create a kubernetes client.\n");
        return -1;
    }

    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 */
                                           NULL,    /* resourceVersionMatch */
                                           0,       /* timeoutSeconds */
                                           0        /* watch */
        );
    printf("return code=%ld\n", apiClient->response_code);
    if (pod_list) {
      ...
    }

    apiClient_free(apiClient);
    apiClient = NULL;
    free_client_config(basePath, sslConfig, apiKeys);
    basePath = NULL;
    sslConfig = NULL;
    apiKeys = NULL;
    apiClient_unsetupGlobalEnv();

Aggregated APIs and CRD-based APIs

If you want to implement a client for aggregated APIs (such as the metrics server API apis/metrics.k8s.io ) or CRD-based APIs, use the generic client. See example.

Multi-threaded Usage

If the C client library is used in multi-threaded program, the following 2 actions are required:

  1. After the program starts up, main thread must call the function apiClient_setupGlobalEnv() before any worker thread is created.

  2. If the C client is no longer used, main thread must call the function apiClient_unsetupGlobalEnv() after all worker threads end.

Refer to the example for detail.

Documentation

All APIs and Models' documentation can be found at the Generated client's README file

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].