Improve the READMEs for the client.
This commit is contained in:
78
README.md
78
README.md
@@ -1,16 +1,72 @@
|
|||||||
# Kubernetes Template Project
|
# Kubernetes Client Library for C
|
||||||
|
|
||||||
The Kubernetes Template Project is a template for starting new projects in the GitHub organizations owned by Kubernetes. All Kubernetes projects, at minimum, must have the following files:
|
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.
|
||||||
|
|
||||||
- a `README.md` outlining the project goals, sponsoring sig, and community contact information
|
## Building the library
|
||||||
- an `OWNERS` with the project leads listed as approvers ([docs on `OWNERS` files][owners])
|
```bash
|
||||||
- a `CONTRIBUTING.md` outlining how to contribute to the project
|
# Clone the repo
|
||||||
- an unmodified copy of `code-of-conduct.md` from this repo, which outlines community behavior and the consequences of breaking the code
|
git clone https://github.com/kubernetes-client/c
|
||||||
- a `LICENSE` which must be Apache 2.0 for code projects, or [Creative Commons 4.0] for documentation repositories, without any custom content
|
CLIENT_REPO_ROOT=${PWD}/c
|
||||||
- a `SECURITY_CONTACTS` with the contact points for the Product Security Team
|
|
||||||
to reach out to for triaging and handling of incoming issues. They must agree to abide by the
|
# Install pre-requisites
|
||||||
[Embargo Policy](https://git.k8s.io/security/private-distributors-list.md#embargo-policy)
|
sudo apt-get install libcurl4-openssl-dev uncrustify
|
||||||
and will be removed and replaced if they violate that agreement.
|
|
||||||
|
# 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
|
||||||
|
```bash
|
||||||
|
cd ${CLIENT_REPO_ROOT}/examples/list_pod
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running the example
|
||||||
|
For now, you need to use `kubectl proxy` to handle authentication.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
kubectl proxy
|
||||||
|
./list_pod_bin
|
||||||
|
```
|
||||||
|
|
||||||
|
## Usage example
|
||||||
|
|
||||||
|
```c
|
||||||
|
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
|
## Community, discussion, contribution, and support
|
||||||
|
|
||||||
|
|||||||
1
examples/create_pod/.gitignore
vendored
Normal file
1
examples/create_pod/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
create_pod_bin
|
||||||
@@ -4,7 +4,12 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#define K8S_APISERVER_BASEPATH "https://your.server.here"
|
// kubectl proxy server
|
||||||
|
#define K8S_APISERVER_BASEPATH "http://localhost:8001"
|
||||||
|
|
||||||
|
// Alternately from within a Kubernetes cluster:
|
||||||
|
// #define K8S_APISERVER_BASEPATH https://your.server.here
|
||||||
|
|
||||||
#define K8S_TOKEN_FILE_IN_CLUSTER "/var/run/secrets/kubernetes.io/serviceaccount/token"
|
#define K8S_TOKEN_FILE_IN_CLUSTER "/var/run/secrets/kubernetes.io/serviceaccount/token"
|
||||||
#define K8S_TOKEN_BUF_SIZE 1024
|
#define K8S_TOKEN_BUF_SIZE 1024
|
||||||
#define K8S_AUTH_KEY "Authorization"
|
#define K8S_AUTH_KEY "Authorization"
|
||||||
|
|||||||
1
examples/list_pod/.gitignore
vendored
Normal file
1
examples/list_pod/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
list_pod_bin
|
||||||
@@ -4,7 +4,12 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#define K8S_APISERVER_BASEPATH "https://your.server.here"
|
// kubectl proxy server
|
||||||
|
#define K8S_APISERVER_BASEPATH "http://localhost:8001"
|
||||||
|
|
||||||
|
// Alternately from within a Kubernetes cluster:
|
||||||
|
// #define K8S_APISERVER_BASEPATH https://your.server.here
|
||||||
|
|
||||||
#define K8S_TOKEN_FILE_IN_CLUSTER "/var/run/secrets/kubernetes.io/serviceaccount/token"
|
#define K8S_TOKEN_FILE_IN_CLUSTER "/var/run/secrets/kubernetes.io/serviceaccount/token"
|
||||||
#define K8S_TOKEN_BUF_SIZE 1024
|
#define K8S_TOKEN_BUF_SIZE 1024
|
||||||
#define K8S_AUTH_KEY "Authorization"
|
#define K8S_AUTH_KEY "Authorization"
|
||||||
|
|||||||
@@ -12,7 +12,14 @@ You'll need the `curl 7.58.0` package in order to build the API. To have code fo
|
|||||||
|
|
||||||
# Prerequisites
|
# Prerequisites
|
||||||
|
|
||||||
## Install the `curl 7.58.0` package with the following command on Linux.
|
## Install the `curl 7.58.0`
|
||||||
|
|
||||||
|
### Install from package
|
||||||
|
```bash
|
||||||
|
sudo apt-get install libcurl4-openssl-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Command line instructions
|
||||||
```bash
|
```bash
|
||||||
sudo apt remove curl
|
sudo apt remove curl
|
||||||
wget http://curl.haxx.se/download/curl-7.58.0.tar.gz
|
wget http://curl.haxx.se/download/curl-7.58.0.tar.gz
|
||||||
@@ -22,7 +29,14 @@ cd curl-7.58.0/
|
|||||||
make
|
make
|
||||||
sudo make install
|
sudo make install
|
||||||
```
|
```
|
||||||
## Install the `uncrustify 0.67` package with the following command on Linux.
|
## Install the `uncrustify 0.67`
|
||||||
|
|
||||||
|
### Install using a package manager
|
||||||
|
```bash
|
||||||
|
sudo apt-get install uncrustify
|
||||||
|
```
|
||||||
|
|
||||||
|
### Command line instructions
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/uncrustify/uncrustify.git
|
git clone https://github.com/uncrustify/uncrustify.git
|
||||||
cd uncrustify
|
cd uncrustify
|
||||||
|
|||||||
Reference in New Issue
Block a user