Class KubeConfig
java.lang.Object
com.google.jenkins.plugins.k8sengine.KubeConfig
Encapsulates KubeConfig data, its construction from Cluster data, and its output to Yaml.
NOTE(craigatgoogle): This is a temporary stop-gap measure which will be replaced once the GKE API
supports a server-side method for this functionality: b/120097899.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic KubeConfigfromCluster(String projectId, com.google.api.services.container.model.Cluster cluster, String accessToken) Creates aKubeConfigfrom the specifiedCluster.com.google.common.collect.ImmutableList<Object>com.google.common.collect.ImmutableList<Object>com.google.common.collect.ImmutableList<Object>getUsers()toYaml()Write a Yaml dump of thisKubeConfig's data to the specifiedWriter.
-
Method Details
-
getContexts
- Returns:
- This config's contexts.
-
getClusters
- Returns:
- This config's clusters.
-
getUsers
- Returns:
- This config's users.
-
getCurrentContext
- Returns:
- This config's current context.
-
toYaml
Write a Yaml dump of thisKubeConfig's data to the specifiedWriter. NOTE(craigatgoogle): The logic here is taken directly from the `gcloud containers clutsers get-credentials` command's implementation: link.- Returns:
- A string containing a Yaml dump of this
KubeConfig. - Throws:
IOException- If an error was encountered while exporting to Yaml.
-
fromCluster
public static KubeConfig fromCluster(String projectId, com.google.api.services.container.model.Cluster cluster, String accessToken) Creates aKubeConfigfrom the specifiedCluster.- Parameters:
projectId- The ID of the project the cluster resides in.cluster- The cluster data will be drawn from.accessToken- Access token for GKE API access.- Returns:
- A
KubeConfigfrom the specifiedCluster.
-