[sr-dev] [kamailio/kamailio] hostname in kubernetes (#2119)

sergey-safarov notifications at github.com
Thu Nov 7 04:33:48 CET 2019


Here output of strace command
```
/ # strace hostname -f
execve("/bin/hostname", ["hostname", "-f"], 0x7ffd0fb7df78 /* 84 vars */) = 0
arch_prctl(ARCH_SET_FS, 0x7f36d29e7d48) = 0
set_tid_address(0x7f36d29e831c)         = 34
mprotect(0x7f36d29e4000, 4096, PROT_READ) = 0
mprotect(0x564ae99b0000, 16384, PROT_READ) = 0
getuid()                                = 0
uname({sysname="Linux", nodename="test-st-0", ...}) = 0
open("/etc/hosts", O_RDONLY|O_CLOEXEC)  = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
read(3, "# Kubernetes-managed hosts file."..., 1024) = 248
read(3, "", 1024)                       = 0
close(3)                                = 0
open("/etc/hosts", O_RDONLY|O_CLOEXEC)  = 3
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
read(3, "# Kubernetes-managed hosts file."..., 1024) = 248
read(3, "", 1024)                       = 0
close(3)                                = 0
ioctl(1, TIOCGWINSZ, {ws_row=41, ws_col=173, ws_xpixel=0, ws_ypixel=0}) = 0
writev(1, [{iov_base="test-st-0.test-st.ippbx.svc.clus"..., iov_len=41}, {iov_base="\n", iov_len=1}], 2test-st-0.test-st.ippbx.svc.cluster.local
) = 42
exit_group(0)                           = ?
+++ exited with 0 +++
```
Looks as `hostname -f` take value from `/etc/hosts` file
```
/ # cat /etc/hosts
# Kubernetes-managed hosts file.
127.0.0.1	localhost
::1	localhost ip6-localhost ip6-loopback
fe00::0	ip6-localnet
fe00::0	ip6-mcastprefix
fe00::1	ip6-allnodes
fe00::2	ip6-allrouters
172.21.0.141	test-st-0.test-st.ippbx.svc.cluster.local	test-st-0
```
Test made using this statefulset.
```yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: test-st
spec:
  podManagementPolicy: Parallel
  serviceName: test-st
  replicas: 1
  selector:
    matchLabels:
      app: test-st
  template:
    metadata:
      labels:
        app: test-st
    spec:
      containers:
      - name: proxy
        securityContext:
          privileged: true
        image: kamailio/kamailio-ci:master-alpine.debug
        imagePullPolicy: IfNotPresent
        command:
          - /bin/sh
        args:
          - "-c"
          - "sleep 360000000000"
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2119#issuecomment-550643475
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20191106/8effbaee/attachment.html>


More information about the sr-dev mailing list