I have a state with three members. They are accessible from within the cluster with something like:
podname-{0..n}.service.default.svc.cluster.local
I am using the Kubernetes API from the controller. I just created a Statefulset with:
import (
"k8s.io/client-go/kubernetes"
appsv1 "k8s.io/api/apps/v1"
)
...
s := appsv1.StatefulSet{ /* some data */ }
kubernetes.AppsV1().StatefulSets(nameSpace).Create(s)
Suppose everything works correctly, and after a few minutes I have 3 sub-sets. How can I get Pod DNS records for newly created Pods?
I know that I can create DNS using:
fmt.Sprintf("%s-%d.%s.%s.svc.cluster.local", s.Name, idx, service, S.Namespace)
But I find some problems:
- I will have to calculate the index based on the number of replicas
- I need to know the service name used for this
StatefulSet - I assume the cluster domain
cluster.local, which is not necessarily true
, ( , ), API, , StatefulSet, DNS Replicas. API?