Class KubeConfig

  • public class KubeConfig
    extends Object
    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.
    • Method Detail

      • getContexts

        public<Object> getContexts()
        This config's contexts.
      • getClusters

        public<Object> getClusters()
        This config's clusters.
      • getUsers

        public<Object> getUsers()
        This config's users.
      • getCurrentContext

        public String getCurrentContext()
        This config's current context.
      • toYaml

        public String toYaml()
                      throws IOException
        Write a Yaml dump of this KubeConfig's data to the specified Writer. NOTE(craigatgoogle): The logic here is taken directly from the `gcloud containers clutsers get-credentials` command's implementation: link.
        A string containing a Yaml dump of this KubeConfig.
        IOException - If an error was encountered while exporting to Yaml.
      • fromCluster

        public static KubeConfig fromCluster​(String projectId,
                                             String accessToken)
        Creates a KubeConfig from the specified Cluster.
        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.
        A KubeConfig from the specified Cluster.