Information about existing Managed Service for Kubernetes clusters
To find out the Kubernetes cluster ID or NAME, get a list of Kubernetes clusters in the folder or detailed information about the Kubernetes cluster.
Getting a list of Kubernetes clusters in a folder
Get a list of Kubernetes clusters in the default folder.
To get a list of Kubernetes clusters, in the management console
Run this command:
yc managed-kubernetes cluster list
Result:
+----------------------+------------------+---------------------+---------+---------+-------------------------+-------------------+
| ID | NAME | CREATED AT | HEALTH | STATUS | EXTERNAL ENDPOINT | INTERNAL ENDPOINT |
+----------------------+------------------+---------------------+---------+---------+-------------------------+-------------------+
| cata9ertn6tc******** | test-k8s-cluster | 2019-04-12 10:00:27 | HEALTHY | RUNNING | https://84.201.150.176/ | https://10.0.0.3/ |
+----------------------+------------------+---------------------+---------+---------+-------------------------+-------------------+
Use either the list REST API method for the Cluster resource or the ClusterService/List gRPC API call.
Getting detailed information about a Kubernetes cluster
To access a Kubernetes cluster, use the ID or NAME parameters from the previous section.
- In the management console
, select a folder. - Go to Managed Service for Kubernetes.
- Click the name of the Kubernetes cluster.
Get detailed information about a Kubernetes cluster:
yc managed-kubernetes cluster get test-k8s-cluster
Result:
id: cata9ertn6tc********
folder_id: b1g88tflru0e********
created_at: "2019-04-12T10:00:27Z"
...
ip_allocation_policy:
cluster_ipv4_cidr_block: 10.13.0.0/16
service_ipv4_cidr_block: 10.14.0.0/16
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
To get information about a Managed Service for Kubernetes cluster:
-
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
Create a Terraform configuration file with a description of the
yandex_kubernetes_clusterdata source in thedatasection and the requested parameters in theoutputsections (one per section). For example:data "yandex_kubernetes_cluster" "my_cluster" { cluster_id = "<cluster_ID>" } output "external_v4_endpoint" { value = data.yandex_kubernetes_cluster.my_cluster.master.0.external_v4_endpoint }Where:
external_v4_endpoint: Name of the variable whose value will appear in the result.data.yandex_kubernetes_cluster.my_cluster.master.0.external_v4_endpoint: Requested parameter. In our case, it is the cluster’s public IP address.
For the list of cluster parameters you can request this way, see this Terraform provider guide.
Tip
To request all available information about a cluster, add the following
outputsection to the file:output "kubernetes_cluster" { value = data.yandex_kubernetes_cluster.my_cluster } -
Make sure the configuration files are correct:
-
In the command line, navigate to the folder containing the current Terraform configuration files.
-
Run this command:
terraform validateTerraform will display any configuration errors detected in your files.
-
-
Run this command:
terraform applyTerraform will display output variables in the terminal.
-
To check the result, run the following command by specifying the required variable, e.g.:
terraform output external_v4_endpointResult:
"https://158.1**.***.***"
To get detailed information about a Kubernetes cluster, use the get REST API method for the Cluster resource or the ClusterService/Get gRPC API call.