такой скрипт юзать (я для монги юзаю)
##
## Generate statefulset peer hostnames in the form $(statefulset name)-$(ordinal)
## and from host names and knowing service name generate pod dns names.
## I.e. for replicas=3 pod hostnames will be:
## $(statefulset name)-0
## $(statefulset name)-1
## $(statefulset name)-2
## and pod dns names will be:
## $(statefulset name)-0.$(service name).$(namespace name).svc.cluster.local
## $(statefulset name)-1.$(service name).$(namespace name).svc.cluster.local
## $(statefulset name)-2.$(service name).$(namespace name).svc.cluster.local
##
## Links:
## https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#pod-identity
## https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#deployment-and-scaling-guarantee
## https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#srv-records
##
function get_peers() {
local stateful_set_name=${1:?}
local service_name=${2:?}
local replicas=${3:?}
local my_dns_name=${4:?}
local namespace_name=${5:?}
local peers_dns_names=""
for i in $(seq 0 $(($replicas - 1))); do
local peers_dns_name="$stateful_set_name-$i.$service_name.$namespace_name.svc.cluster.local"
if [[ "$peers_dns_name" != "$my_dns_name" ]]; then
peers_dns_names="$peers_dns_names $peers_dns_name"
fi
done
echo "$peers_dns_names"
}
вот нашел в хистори какие имена у подов стейтфулсета
Обсуждают сегодня