import ( "fmt" "k8s.io/kubernetes/pkg/client/unversioned" ) func main() { config := &unversioned.Config{ Host: "https://cluster.api.endpoint.com", Username: "admin", Password: "password", } client, err := unversioned.New(config) if err != nil { fmt.Println("Error creating Kubernetes client:", err) return } nodes, err := client.Nodes().List() if err != nil { fmt.Println("Error getting node list:", err) return } for _, node := range nodes.Items { fmt.Println("Node name:", node.Name) } }
import ( "fmt" "k8s.io/kubernetes/pkg/client/unversioned" ) func main() { config := &unversioned.Config{ Host: "https://cluster.api.endpoint.com", Username: "admin", Password: "password", } client, err := unversioned.New(config) if err != nil { fmt.Println("Error creating Kubernetes client:", err) return } node, err := client.Nodes().Get("node-1") if err != nil { fmt.Println("Error getting node:", err) return } fmt.Println("Node name:", node.Name) fmt.Println("Node IP address:", node.Status.Addresses[0].Address) }This example shows how to retrieve details about a specific node in the cluster, such as its name and IP address. The "Get" function is used to retrieve the node information, which is then printed to the console.