Files
csharp/README.md

84 lines
2.0 KiB
Markdown
Raw Normal View History

2017-10-13 03:44:59 +08:00
# Kubernetes C# Client
[![Travis](https://img.shields.io/travis/kubernetes-client/csharp.svg)](https://travis-ci.org/kubernetes-client/csharp)
2017-11-14 22:10:47 -08:00
[![Client Capabilities](https://img.shields.io/badge/Kubernetes%20client-Silver-blue.svg?style=flat&colorB=C0C0C0&colorA=306CE8)](http://bit.ly/kubernetes-client-capabilities-badge)
[![Client Support Level](https://img.shields.io/badge/kubernetes%20client-beta-green.svg?style=flat&colorA=306CE8)](http://bit.ly/kubernetes-client-support-badge)
2017-09-13 14:49:35 -07:00
# Usage
2017-10-20 21:20:52 -07:00
[Nuget Package](https://www.nuget.org/packages/KubernetesClient/)
2017-09-13 14:49:35 -07:00
```sh
dotnet add package KubernetesClient
```
# Generating the Client Code
## Prerequisites
Check out the generator project into some other directory
(henceforth `$GEN_DIR`)
```bash
cd $GEN_DIR/..
git clone https://github.com/kubernetes-client/gen
```
Install the [`autorest` tool](https://github.com/azure/autorest):
```bash
npm install autorest
```
## Generating code
```bash
# Where REPO_DIR points to the root of the csharp repository
cd ${REPO_DIR}/csharp/src
${GEN_DIR}/openapi/csharp.sh generated csharp.settings
```
# Usage
## Running the Examples
```bash
git clone git@github.com:kubernetes-client/csharp.git
cd csharp\examples\simple
dotnet run
```
## Known issues
While preferred way of connecting to a remote cluster from local machine is:
```
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
var client = new Kubernetes(config);
```
Not all auth providers are supported at moment [#91](https://github.com/kubernetes-client/csharp/issues/91#issuecomment-362920478), but you still can connect to cluster by starting proxy:
```bash
$ kubectl proxy
Starting to serve on 127.0.0.1:8001
```
and changing config:
```csharp
var config = new KubernetesClientConfiguration { Host = "http://127.0.0.1:8001" };
```
Notice that this is a workaround and is not recommended for production use
## Testing
The project uses [XUnit](https://xunit.github.io) as unit testing framework.
To run the tests
```bash
cd csharp\tests
dotnet restore
2017-10-13 03:44:59 +08:00
dotnet test
2017-09-13 14:33:06 -07:00
```