Improve the READMEs for the client.

This commit is contained in:
Brendan Burns
2020-03-22 21:56:55 -07:00
parent ea2fb243e1
commit a66596b0c2
6 changed files with 97 additions and 15 deletions

View File

@@ -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
- an `OWNERS` with the project leads listed as approvers ([docs on `OWNERS` files][owners])
- a `CONTRIBUTING.md` outlining how to contribute to the project
- an unmodified copy of `code-of-conduct.md` from this repo, which outlines community behavior and the consequences of breaking the code
- a `LICENSE` which must be Apache 2.0 for code projects, or [Creative Commons 4.0] for documentation repositories, without any custom content
- 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
[Embargo Policy](https://git.k8s.io/security/private-distributors-list.md#embargo-policy)
and will be removed and replaced if they violate that agreement.
## Building the library
```bash
# 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
```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

1
examples/create_pod/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
create_pod_bin

View File

@@ -4,7 +4,12 @@
#include <stdio.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_BUF_SIZE 1024
#define K8S_AUTH_KEY "Authorization"

1
examples/list_pod/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
list_pod_bin

View File

@@ -4,7 +4,12 @@
#include <stdio.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_BUF_SIZE 1024
#define K8S_AUTH_KEY "Authorization"

View File

@@ -12,7 +12,14 @@ You'll need the `curl 7.58.0` package in order to build the API. To have code fo
# 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
sudo apt remove curl
wget http://curl.haxx.se/download/curl-7.58.0.tar.gz
@@ -22,7 +29,14 @@ cd curl-7.58.0/
make
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
git clone https://github.com/uncrustify/uncrustify.git
cd uncrustify