我有一个想法要实现,我需要为 kubernetes 集群中的 Pod IP 创建一个缓存,然后使用 http 请求访问缓存的 IP。我正在使用 Golang,因为我是这个领域的新手,如果有人知道如何实现它,我将不胜感激。我在互联网上搜索了很多,但我没有找到任何简单的例子可以作为开始。
我从一段代码开始获取 podlist 我需要将他的 podlist 放入缓存中,就像每次请求到达时它将使用缓存而不是使用 kubernetes api o 获取 IP。
kubeClient, err := kubernetes.NewForConfig(cfg)
if err != nil {
fmt.Printf("Error building kubernetes clientset: %v\n", err)
os.Exit(2)}
options := metav1.ListOptions{
LabelSelector: "app=hello",}
podList, _ := kubeClient.CoreV1().Pods("namespace").List(options). What i need is to create a cache for the IPs of hello pods for-example and when an http request arrive to my http server, the request will use directly the cached IPs
我感谢您的帮助。
先感谢您,