You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I use statefulset and headless serivce inside vcluster and access the pod using <pod.hostname>.<pod.subdomain>.<namespace>.svc.cluster.local, it works as expected.
However, in the physical cluster using the synced pod and serivce, it does not work, the ip is not resolved. I noticed that the subdomain is set to "" in the physical cluster pod, and by reading I found the following logic:
// if spec.subdomain is set we have to translate the /etc/hosts// because otherwise we could get a different hostname as if the pod// would be deployed in a non virtual kubernetes clusterifpPod.Spec.Subdomain!="" {
ift.overrideHosts {
rewritePodHostnameFQDN(pPod, t.defaultImageRegistry, t.overrideHostsImage, pPod.Spec.Hostname, pPod.Spec.Hostname, pPod.Spec.Hostname+"."+pPod.Spec.Subdomain+"."+vPod.Namespace+".svc."+t.clusterDomain)
}
pPod.Spec.Subdomain=""
}
I changed the code to this, and it works fine, and I was able to access the vcluster's pods on the phsyical cluster via dns.
// truncate hostname if neededifpPod.Spec.Hostname=="" {
iflen(vPod.Name) >63 {
pPod.Spec.Hostname=vPod.Name[0:63]
} else {
pPod.Spec.Hostname=vPod.Name
}
// Kubernetes does not support setting the hostname to a value that// includes a '.', therefore we need to rewrite the hostname. This is really bad// and wrong, but unfortunately there is currently no other solution as there is// no other way to change the container's hostname.// EDIT!pPod.Spec.Hostname=translate.Default.PhysicalName(strings.TrimSuffix(strings.Replace(pPod.Spec.Hostname, ".", "-", -1), "-"), vPod.Namespace)
}
....
// if spec.subdomain is set we have to translate the /etc/hosts// because otherwise we could get a different hostname as if the pod// would be deployed in a non virtual kubernetes clusterifpPod.Spec.Subdomain!="" {
ift.overrideHosts {
rewritePodHostnameFQDN(pPod, t.defaultImageRegistry, t.overrideHostsImage, pPod.Spec.Hostname, pPod.Spec.Hostname, pPod.Spec.Hostname+"."+pPod.Spec.Subdomain+"."+vPod.Namespace+".svc."+t.clusterDomain)
}
// Translate the subdomain using the same method as other resources// EDIT!pPod.Spec.Subdomain=translate.Default.PhysicalName(pPod.Spec.Subdomain, vPod.Namespace)
}
I can't understand why I can't sync out the subdomain and if there is another way for me to access the pods inside StatefuSet via dns in the physical cluster.
Which solution do you suggest?
Set the subdomain and hostname for the synced pods.
Which alternative solutions exist?
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem?
When I use statefulset and headless serivce inside vcluster and access the pod using
<pod.hostname>.<pod.subdomain>.<namespace>.svc.cluster.local
, it works as expected.However, in the physical cluster using the synced pod and serivce, it does not work, the ip is not resolved. I noticed that the subdomain is set to
""
in the physical cluster pod, and by reading I found the following logic:I changed the code to this, and it works fine, and I was able to access the vcluster's pods on the phsyical cluster via dns.
I can't understand why I can't sync out the subdomain and if there is another way for me to access the pods inside StatefuSet via dns in the physical cluster.
Which solution do you suggest?
Set the subdomain and hostname for the synced pods.
Which alternative solutions exist?
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: