* generated based on 1.33 * Update version to 17.0 in version.json * Remove extra API endpoint from swagger.json * Remove ModelConverter and related AutoMapper components * Update package versions * Refactor code to use ConfigureAwait(false) for asynchronous calls and update target framework to net9.0 * Remove ConfigureAwait(false) from OidcAuthTests for consistency in async calls * Update SDK version in README to reflect support for net8.0 and net9.0 * Update dotnet SDK version to 9.0.x in build workflow * Revert Fractions package version to 7.3.0 in Directory.Packages.props * Update target framework to netstandard2.1 for improved compatibility * Update package references for Microsoft.CodeAnalysis in Directory.Packages.props and LibKubernetesGenerator.target * Refactor Worker class constructor documentation and standardize Dictionary type declaration in Program.cs
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using k8s;
|
|
using OpenTelemetry;
|
|
using OpenTelemetry.Resources;
|
|
using OpenTelemetry.Trace;
|
|
|
|
var serviceName = "MyCompany.MyProduct.MyService";
|
|
var serviceVersion = "1.0.0";
|
|
|
|
// Create the OpenTelemetry TraceProvide with HttpClient instrumentation enabled
|
|
// NOTE: for this example telemetry will be exported to console
|
|
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
|
|
.AddSource(serviceName)
|
|
.SetResourceBuilder(ResourceBuilder.CreateDefault().AddService(serviceName: serviceName, serviceVersion: serviceVersion))
|
|
.AddHttpClientInstrumentation()
|
|
.AddConsoleExporter()
|
|
.Build();
|
|
|
|
// Load kubernetes configuration
|
|
var config = KubernetesClientConfiguration.BuildDefaultConfig();
|
|
|
|
// Create an istance of Kubernetes client
|
|
IKubernetes client = new Kubernetes(config);
|
|
|
|
// Read the list of pods contained in default namespace
|
|
var list = client.CoreV1.ListNamespacedPod("default");
|
|
|
|
// Print the name of pods
|
|
foreach (var item in list.Items)
|
|
{
|
|
Console.WriteLine(item.Metadata.Name);
|
|
}
|
|
|
|
// Or empty if there are no pods
|
|
if (list.Items.Count == 0)
|
|
{
|
|
Console.WriteLine("Empty!");
|
|
}
|