I'm using podman 4.5-dev I have two pods deployed using: podman kube play foo.yaml podman kube play bar.yaml
I specified the pods' hostnames in the files, but they won't get resolved inside the containers. I verified that the pods are in the same network.
Is there some DNS configuration missing? Should I use a Services? The official docs lack of a precise indication about this topic
Here's one of the two pods's YAML (the other one has the same keys with different values):
apiVersion: v1
kind: Pod
metadata:
labels:
app: postgres
name: postgres
spec:
hostname: postgres
containers:
- name: pgadmin-container
image: docker.io/dpage/pgadmin4:latest
ports:
- containerPort: 80
hostPort: 9876
Here's some terminal output that could be useful:
[daniele@localhost]$ podman pod inspect xptssrv |grep -ni network
25: "HostNetwork": false,
34: "Networks": [
35: "podman-default-kube-network"
37: "NetworkOptions": null,
[daniele@localhost]$ podman pod inspect postgres |grep -ni network
25: "HostNetwork": false,
34: "Networks": [
35: "podman-default-kube-network"
37: "NetworkOptions": null,
[daniele@localhost]$ podman network inspect podman-default-kube-network |grep "" -n
1:[
2: {
3: "name": "podman-default-kube-network",
4: "id": "a4dcf21f020ee4e36651c11256cbe884182552e835eaaafd409153cd21dca4cc",
5: "driver": "bridge",
6: "network_interface": "cni-podman1",
7: "created": "2023-02-21T23:03:25.800256942+01:00",
8: "subnets": [
9: {
10: "subnet": "10.89.0.0/24",
11: "gateway": "10.89.0.1"
12: }
13: ],
14: "ipv6_enabled": false,
15: "internal": false,
16: "dns_enabled": false,
17: "ipam_options": {
18: "driver": "host-local"
19: }
20: }
21:]
[daniele@localhost pods]$ podman exec xptssrv-xptssrv-container cat /etc/resolv.conf
nameserver 192.168.1.6
nameserver 8.8.8.8
Edit your network settings in /etc/containers/net.d/podman-default-kube-network.conflist
Change this line
"dns_enabled": false,
To this:
"dns_enabled": true,
Then reboot and up your yaml and try to resolve this:
postgres_pgadmin-container_1
Or maybe this:
postgres_postgres_1
Just copy the config file:
sudo cp /usr/share/containers/containers.conf /etc/containers/containers.conf
Then in the file change the network backend to netavark using the following command:
sed -i "/^\s*\#*\s*network_backend\s*=.*$/ s/^.*$/network_backend = \"netavark\"/" /etc/containers/containers.conf
Notice: I think it's better to restart you system in order to apply changes.