Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a358cb9
Remove hacky WebSocket connection factory. (#171)
tintoy Jun 7, 2018
f488d54
Fix incorrect exception message in CertUtils (#172)
davidorbelian Jun 11, 2018
6eb5555
Fix issue with X509VerificationFlags.AllowUnknownCertificateAuthority…
davidorbelian Jun 13, 2018
7723604
fix test case fail on windows (#177)
tg123 Jun 25, 2018
de916f6
Additional watcher tests (#178)
qmfrederik Jun 25, 2018
c1543b5
add SECURITY_CONTACTS (#180)
tg123 Jun 25, 2018
bc1cb62
Watcher: notify the caller when the server closes the connection (#184)
qmfrederik Jun 27, 2018
49bb82b
generate v1.11.0 (#182)
tg123 Jul 2, 2018
bb11e5f
Remove last version digit (#185)
qmfrederik Jul 2, 2018
3f69820
Always add client certificates if present. (#188)
brendandburns Jul 2, 2018
d014467
add patch example (#189)
tg123 Jul 9, 2018
8c3152a
Update WatcherDelegatingHandler to stop eating first line (#183) (#190)
hossambarakat Jul 9, 2018
dae6d62
Update tests namespaces for consistency (#191)
hossambarakat Jul 9, 2018
aec5c99
Rev to 1.2.0 (#192)
brendandburns Jul 14, 2018
ac99f43
Move Fractions library inside project (#194)
RohanNagar Jul 17, 2018
3551f03
Add support for Azure AAD based authentication. (#193)
brendandburns Jul 19, 2018
722d4e0
Regenerate code. (#197)
brendandburns Aug 7, 2018
397a582
Add CONTRIBUTING.md (#199)
nikhita Aug 19, 2018
3cee7fb
Changes to support xamarin. (#200)
JonJam Sep 10, 2018
09a8c87
Update install-linux.sh (#201)
DWSR Sep 13, 2018
9372e32
align files to .editorconfig (#203)
tg123 Sep 27, 2018
df33816
run generate script for k8s 1.12 (#205)
tg123 Oct 3, 2018
043a342
Create KubernetesClientConfiguration from pre-loaded K8SConfiguration
ThatRendle Jun 6, 2018
3ae0ac6
Tweaked a couple more doc strings
itowlson Oct 22, 2018
481c5e2
Fix duplicated tests
itowlson Oct 22, 2018
615a238
Give the new method a more informative name
itowlson Oct 23, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Contributing

Thanks for taking the time to join our community and start contributing!

Please remember to read and observe the [Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md).

This project accepts contribution via github [pull requests](https://help.github.com/articles/about-pull-requests/). This document outlines the process to help get your contribution accepted. Please also read the [Kubernetes contributor guide](https://github.com/kubernetes/community/blob/master/contributors/guide/README.md) which provides detailed instructions on how to get your ideas and bug fixes seen and accepted.

## Sign the Contributor License Agreement
We'd love to accept your patches! Before we can accept them you need to sign Cloud Native Computing Foundation (CNCF) [CLA](https://github.com/kubernetes/community/blob/master/CLA.md).

## Reporting an issue
If you have any problem with the package or any suggestions, please file an [issue](https://github.com/kubernetes-client/csharp/issues).

## Contributing a Patch
1. Submit an issue describing your proposed change to the repo.
2. Fork this repo, develop and test your code changes.
3. Submit a pull request.
4. The bot will automatically assigns someone to review your PR. Check the full list of bot commands [here](https://prow.k8s.io/command-help).

### Contact
You can reach the maintainers of this project at [SIG API Machinery](https://github.com/kubernetes/community/tree/master/sig-api-machinery) or on the [#kubernetes-client](https://kubernetes.slack.com/messages/kubernetes-client) channel on the Kubernetes slack.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,7 @@ cd csharp\tests
dotnet restore
dotnet test
```

## Contributing

Please see [CONTRIBUTING.md](CONTRIBUTING.md) for instructions on how to contribute.
13 changes: 13 additions & 0 deletions SECURITY_CONTACTS
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Defined below are the security contacts for this repo.
#
# They are the contact point for the Product Security Team to reach out
# to for triaging and handling of incoming issues.
#
# The below names agree to abide by the
# [Embargo Policy](https://github.com/kubernetes/sig-release/blob/master/security-release-process-documentation/security-release-process.md#embargo-policy)
# and will be removed and replaced if they violate that agreement.
#
# DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE
# INSTRUCTIONS AT https://kubernetes.io/security/

brendandburns
2 changes: 1 addition & 1 deletion csharp.settings
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export KUBERNETES_BRANCH=v1.10.0
export KUBERNETES_BRANCH=v1.12.0
export CLIENT_VERSION=0.0.1
export PACKAGE_NAME=k8s
2 changes: 1 addition & 1 deletion examples/attach/Attach.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private static async Task Main(string[] args)

private async static Task AttachToPod(IKubernetes client, V1Pod pod) {
var webSocket = await client.WebSocketNamespacedPodAttachAsync(pod.Metadata.Name, "default", pod.Spec.Containers[0].Name);

var demux = new StreamDemuxer(webSocket);
demux.Start();

Expand Down
88 changes: 44 additions & 44 deletions examples/labels/PodList.cs
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
using System;
using System.Collections.Generic;
using k8s;
namespace simple
{
internal class PodList
{
private static void Main(string[] args)
{
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
IKubernetes client = new Kubernetes(config);
Console.WriteLine("Starting Request!");
var list = client.ListNamespacedService("default");
foreach (var item in list.Items)
{
Console.WriteLine("Pods for service: " + item.Metadata.Name);
Console.WriteLine("=-=-=-=-=-=-=-=-=-=-=");
if (item.Spec == null || item.Spec.Selector == null)
{
continue;
}
var labels = new List<string>();
foreach (var key in item.Spec.Selector)
{
labels.Add(key.Key + "=" + key.Value);
}
var labelStr = string.Join(",", labels.ToArray());
Console.WriteLine(labelStr);
var podList = client.ListNamespacedPod("default", labelSelector: labelStr);
foreach (var pod in podList.Items)
{
Console.WriteLine(pod.Metadata.Name);
}
if (podList.Items.Count == 0)
{
Console.WriteLine("Empty!");
}
Console.WriteLine();
}
}
}
}
using System;
using System.Collections.Generic;
using k8s;

namespace simple
{
internal class PodList
{
private static void Main(string[] args)
{
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
IKubernetes client = new Kubernetes(config);
Console.WriteLine("Starting Request!");

var list = client.ListNamespacedService("default");
foreach (var item in list.Items)
{
Console.WriteLine("Pods for service: " + item.Metadata.Name);
Console.WriteLine("=-=-=-=-=-=-=-=-=-=-=");
if (item.Spec == null || item.Spec.Selector == null)
{
continue;
}
var labels = new List<string>();
foreach (var key in item.Spec.Selector)
{
labels.Add(key.Key + "=" + key.Value);
}
var labelStr = string.Join(",", labels.ToArray());
Console.WriteLine(labelStr);
var podList = client.ListNamespacedPod("default", labelSelector: labelStr);
foreach (var pod in podList.Items)
{
Console.WriteLine(pod.Metadata.Name);
}
if (podList.Items.Count == 0)
{
Console.WriteLine("Empty!");
}
Console.WriteLine();
}
}
}
}
160 changes: 80 additions & 80 deletions examples/namespace/Namespace.cs
Original file line number Diff line number Diff line change
@@ -1,87 +1,87 @@
using System;
using System.Net;
using System.Threading.Tasks;
using k8s;
using k8s.Models;
namespace @namespace
{
class NamespaceExample
{
static void ListNamespaces(IKubernetes client) {
var list = client.ListNamespace();
foreach (var item in list.Items) {
Console.WriteLine(item.Metadata.Name);
}
if (list.Items.Count == 0) {
Console.WriteLine("Empty!");
}
}
static async Task DeleteAsync(IKubernetes client, string name, int delayMillis) {
while (true) {
await Task.Delay(delayMillis);
try
{
using System;
using System.Net;
using System.Threading.Tasks;
using k8s;
using k8s.Models;

namespace @namespace
{
class NamespaceExample
{
static void ListNamespaces(IKubernetes client) {
var list = client.ListNamespace();
foreach (var item in list.Items) {
Console.WriteLine(item.Metadata.Name);
}
if (list.Items.Count == 0) {
Console.WriteLine("Empty!");
}
}

static async Task DeleteAsync(IKubernetes client, string name, int delayMillis) {
while (true) {
await Task.Delay(delayMillis);
try
{
await client.ReadNamespaceAsync(name);
} catch (AggregateException ex) {
foreach (var innerEx in ex.InnerExceptions) {
if (innerEx is Microsoft.Rest.HttpOperationException) {
var code = ((Microsoft.Rest.HttpOperationException)innerEx).Response.StatusCode;
if (code == HttpStatusCode.NotFound) {
return;
}
throw ex;
}
}
} catch (Microsoft.Rest.HttpOperationException ex) {
if (ex.Response.StatusCode == HttpStatusCode.NotFound) {
return;
}
throw ex;
}
}
}
static void Delete(IKubernetes client, string name, int delayMillis) {
DeleteAsync(client, name, delayMillis).Wait();
}
private static void Main(string[] args)
{
var k8SClientConfig = KubernetesClientConfiguration.BuildConfigFromConfigFile();
IKubernetes client = new Kubernetes(k8SClientConfig);
ListNamespaces(client);
var ns = new V1Namespace
{
Metadata = new V1ObjectMeta
{
Name = "test"
}
};
var result = client.CreateNamespace(ns);
Console.WriteLine(result);
ListNamespaces(client);
var status = client.DeleteNamespace(new V1DeleteOptions(), ns.Metadata.Name);
if (status.HasObject)
{
} catch (AggregateException ex) {
foreach (var innerEx in ex.InnerExceptions) {
if (innerEx is Microsoft.Rest.HttpOperationException) {
var code = ((Microsoft.Rest.HttpOperationException)innerEx).Response.StatusCode;
if (code == HttpStatusCode.NotFound) {
return;
}
throw ex;
}
}
} catch (Microsoft.Rest.HttpOperationException ex) {
if (ex.Response.StatusCode == HttpStatusCode.NotFound) {
return;
}
throw ex;
}
}
}

static void Delete(IKubernetes client, string name, int delayMillis) {
DeleteAsync(client, name, delayMillis).Wait();
}

private static void Main(string[] args)
{
var k8SClientConfig = KubernetesClientConfiguration.BuildConfigFromConfigFile();
IKubernetes client = new Kubernetes(k8SClientConfig);

ListNamespaces(client);

var ns = new V1Namespace
{
Metadata = new V1ObjectMeta
{
Name = "test"
}
};

var result = client.CreateNamespace(ns);
Console.WriteLine(result);

ListNamespaces(client);

var status = client.DeleteNamespace(new V1DeleteOptions(), ns.Metadata.Name);

if (status.HasObject)
{
var obj = status.ObjectView<V1Namespace>();
Console.WriteLine(obj.Status.Phase);

Delete(client, ns.Metadata.Name, 3 * 1000);
}
else
{
Console.WriteLine(status.Message);
}
else
{
Console.WriteLine(status.Message);
}

ListNamespaces(client);
}
}
}
ListNamespaces(client);
}
}
}
44 changes: 44 additions & 0 deletions examples/patch/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using k8s;
using k8s.Models;
using Microsoft.AspNetCore.JsonPatch;

namespace patch
{
internal class Program
{
private static void Main(string[] args)
{
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
IKubernetes client = new Kubernetes(config);
Console.WriteLine("Starting Request!");

var pod = client.ListNamespacedPod("default").Items.First();

var name = pod.Metadata.Name;
PrintLabels(pod);

var newlables = new Dictionary<string, string>(pod.Metadata.Labels)
{
["test"] = "test"
};
var patch = new JsonPatchDocument<V1Pod>();
patch.Replace(e => e.Metadata.Labels, newlables);
client.PatchNamespacedPod(new V1Patch(patch), name, "default");

PrintLabels(client.ReadNamespacedPod(name, "default"));
}

private static void PrintLabels(V1Pod pod)
{
Console.WriteLine($"Lables: for {pod.Metadata.Name}");
foreach (var (k, v) in pod.Metadata.Labels)
{
Console.WriteLine($"{k} : {v}");
}
Console.WriteLine("=-=-=-=-=-=-=-=-=-=-=");
}
}
}
12 changes: 12 additions & 0 deletions examples/patch/patch.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\KubernetesClient\KubernetesClient.csproj" />
</ItemGroup>

</Project>
Loading