Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hostname points to the name of the infra container instead to hostname of the pod itself #11

Open
abalage opened this issue Jan 29, 2020 · 3 comments

Comments

@abalage
Copy link

@abalage abalage commented Jan 29, 2020

Hi,

I am having an issue with name resolution not working with pod names.
I would like to achieve pod-to-pod communication via hostnames / DNS of pods.

I create a pod for each different systems I may use. Each pods contain different number of containers. The plugin dnsname is configured for the default network.

The very basic setup I'd like to achieve can be seen on the picture below.

DSC_0084

As all the pods are attached to the same network (cni-podman0) IP connectivity is not a problem.
Checking the hosts file within containers of the same pod I see that they aware of the hostname of the pod as well its IP address.
However the DNS service running in the same network is only resolving the IP addresses of infra containers. The problem with that is their name is auto generated from the ID of the pod. I cannot rely on them. I would rather like to see the --name or --hostname of the pods bounded to the IP of infra contrainer by dnsname.

Checking the source code I could find this part.

type podname struct {
types.CommonArgs
K8S_POD_NAME types.UnmarshallableString `json:"podname,omitempty"`
}

But I do not know whether 'podname' should point to the name of the pod (sounds reasonable) of to the name of the container?

# podman network inspect podman
[
        {
                "cniVersion": "0.4.0",
                "name": "podman",
                "plugins": [
                        {
                                "bridge": "cni-podman0",
                                "ipMasq": true,
                                "ipam": {
                                        "ranges": [
                                                [
                                                        {
                                                                "gateway": "10.88.0.1",
                                                                "subnet": "10.88.0.0/16"
                                                        }
                                                ]
                                        ],
                                        "routes": [
                                                {
                                                        "dst": "0.0.0.0/0"
                                                }
                                        ],
                                        "type": "host-local"
                                },
                                "isGateway": true,
                                "type": "bridge"
                        },
                        {
                                "domainName": "podman.local",
                                "type": "dnsname"
                        },
                        {
                                "capabilities": {
                                        "portMappings": true
                                },
                                "type": "portmap"
                        },
                        {
                                "backend": "firewalld",
                                "type": "firewall"
                        }
                ]
        }
]

# podman ps -ap
CONTAINER ID  IMAGE                                                COMMAND               CREATED      STATUS          PORTS                                                   NAMES               POD           POD NAME
bc79e85d737f  docker.io/library/nginx:1.16                         nginx -g daemon o...  3 hours ago  Up 3 hours ago  192.168.122.253:80->80/tcp                              proxy               e59ccfa83aa6  reverse_proxy
f89ad7e8e4cd  registry.opensuse.org/kubic/pause:3.1                                      3 hours ago  Up 3 hours ago  192.168.122.253:80->80/tcp                              e59ccfa83aa6-infra  e59ccfa83aa6  reverse_proxy
29b35a360e91  docker.io/library/mariadb:10.4                       mysqld                3 hours ago  Up 3 hours ago  0.0.0.0:3306->3306/tcp                                  mariadb             c7090bdc990d  mysql
32e01f41626a  registry.opensuse.org/kubic/pause:3.1                                      3 hours ago  Up 3 hours ago  0.0.0.0:3306->3306/tcp                                  c7090bdc990d-infra  c7090bdc990d  mysql
048bb0b9fe83  docker.io/library/redis:5                            redis-server          3 hours ago  Up 3 hours ago  0.0.0.0:8080->80/tcp                                    nextcloud-redis     fe69e1d9a88e  nextcloud
70cc7e3d0bb3  docker.io/library/nginx:1.16                         nginx -g daemon o...  3 hours ago  Up 3 hours ago  0.0.0.0:8080->80/tcp                                    nextcloud-www       fe69e1d9a88e  nextcloud
ebc69be64be9  localhost/balage/php72-fpm-opensuse:latest           php-fpm -c /etc/p...  3 hours ago  Up 3 hours ago  0.0.0.0:8080->80/tcp                                    nextcloud-php       fe69e1d9a88e  nextcloud
fbdd9fa5baad  registry.opensuse.org/kubic/pause:3.1                                      3 hours ago  Up 3 hours ago  0.0.0.0:8080->80/tcp                                    fe69e1d9a88e-infra  fe69e1d9a88e  nextcloud
b27d58d62133  docker.elastic.co/kibana/kibana:7.4.2                /usr/local/bin/ki...  3 hours ago  Up 3 hours ago  0.0.0.0:5601->5601/tcp, 192.168.122.253:9200->9200/tcp  kibana              03e5e1a02d0f  elk
db3a7c79d3bf  docker.elastic.co/elasticsearch/elasticsearch:7.4.2  eswrapper             3 hours ago  Up 3 hours ago  0.0.0.0:5601->5601/tcp, 192.168.122.253:9200->9200/tcp  elasticsearch       03e5e1a02d0f  elk
4b9d202aa91e  registry.opensuse.org/kubic/pause:3.1

# cat /run/containers/cni/dnsname/podman/addnhosts
10.88.0.148     03e5e1a02d0f-infra
10.88.0.149     fe69e1d9a88e-infra
10.88.0.150     c7090bdc990d-infra
10.88.0.151     e59ccfa83aa6-infra

# podman exec -ti nextcloud-www cat /etc/hosts
127.0.0.1       localhost
...
10.88.0.149     nextcloud

Here are some details you may find useful.

# podman --version
podman version 1.7.0

# podman info 
host:
  BuildahVersion: 1.12.0
  CgroupVersion: v1
  Conmon:
    package: conmon-2.0.9-lp151.19.1.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.0.9, commit: unknown'
  Distribution:
    distribution: '"opensuse-leap"'
    version: "15.1"
  MemFree: 4509601792
  MemTotal: 8340729856
  OCIRuntime:
    name: runc
    package: runc-1.0.0~rc6-lp151.1.2.x86_64
    path: /usr/sbin/runc
    version: |-
      runc version 1.0.0-rc6
      spec: 1.0.1-dev
  SwapFree: 0
  SwapTotal: 0
  arch: amd64
  cpus: 2
  eventlogger: file
  hostname: linux-thwt
  kernel: 5.4.14-1.gfc4ea7a-default
  os: linux
  rootless: false
  uptime: 3h 45m 32.16s (Approximately 0.12 days)
registries:
  search:
  - docker.io
store:
  ConfigFile: /etc/containers/storage.conf
  ContainerStore:
    number: 11
  GraphDriverName: overlay
  GraphOptions: {}
  GraphRoot: /var/lib/containers/storage
  GraphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  ImageStore:
    number: 9
  RunRoot: /var/run/containers/storage
  VolumePath: /var/lib/containers/storage/volumes
@abalage

This comment has been minimized.

Copy link
Author

@abalage abalage commented Jan 29, 2020

tl;dr.

I would need a 'poor man's' service discovery. Find published ports of pods on the same network by using the name of the pods. And not by the name of the infra container of a pod.

@baude

This comment has been minimized.

Copy link
Collaborator

@baude baude commented Jan 29, 2020

@abalage name resolution does is not supported yet for pods ... BUT I am currently working on it

@abalage

This comment has been minimized.

Copy link
Author

@abalage abalage commented Jan 29, 2020

Great to hear. I am happy to test any release you may have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.