Google.Cloud.Container.V1

Google.Cloud.Container.V1 is a.NET client library for the Google Kubernetes Engine API.

Note: This documentation is for version 3.20.0 of the library. Some samples may not work with other versions.

Installation

Install the Google.Cloud.Container.V1 package from NuGet. Add it to your project in the normal way (for example by right-clicking on the project in Visual Studio and choosing "Manage NuGet Packages...").

Authentication

When running on Google Cloud, no action needs to be taken to authenticate.

Otherwise, the simplest way of authenticating your API calls is to download a service account JSON file then set the GOOGLE_APPLICATION_CREDENTIALS environment variable to refer to it. The credentials will automatically be used to authenticate. See the Authentication use cases guide for more details.

Getting started

All operations are performed through ClusterManagerClient.

Sample code

List clusters

ClusterManagerClient client = ClusterManagerClient.Create();
// You can list clusters in a single zone, or specify "-" for all zones.
LocationName location = new LocationName(projectId, locationId: "-");
ListClustersResponse zones = client.ListClusters(location.ToString());
foreach (Cluster cluster in zones.Clusters)
{
    Console.WriteLine($"Cluster {cluster.Name} in {cluster.Location}");
}