Closed th-2021 closed 3 years ago
Hello @th-2021 Could you provide us with the VM/VMI manifest used to create the VM?
apiVersion: kubevirt.io/v1alpha3
kind: VirtualMachine
metadata:
labels:
kubevirt.io/vm: ubuntu-home
name: ubuntu-home
namespace: vm-images
spec:
runStrategy: "RerunOnFailure"
template:
metadata:
labels:
kubevirt.io/vm: ubuntu-home
annotations:
backup.velero.io/backup-volumes: datavolumedisk1
spec:
hostname: "ubuntu-home"
subdomain: "vm"
domain:
devices:
disks:
- disk:
bus: virtio
name: datavolumedisk1
- disk:
bus: virtio
name: cloudinitdisk
interfaces:
- bridge: {}
name: default
- bridge: {}
name: ovs-blue-net
machine:
type: ""
firmware:
# this sets the bootloader type
#bootloader:
# efi: { secureBoot: False}
resources:
requests:
memory: 16Gi
cpu: 4
networks:
- name: default
pod: {}
- multus:
networkName: ovs-blue
name: ovs-blue-net
terminationGracePeriodSeconds: 0
volumes:
- name: datavolumedisk1
persistentVolumeClaim:
claimName: ubuntu-home
- cloudInitNoCloud:
userData: |-
#cloud-config
hostname: ubuntu-home
fqdn: ubuntu-home.lan
manage_etc_hosts: true
users:
- name: thiller
sudo: ALL=(ALL) NOPASSWD:ALL
groups: users, admin
home: /home/thiller
shell: /bin/bash
lock_passwd: false
ssh-authorized-keys:
- ssh-rsa XXXXXXXXX
# only cert auth via ssh (console access can still login)
ssh_pwauth: false
disable_root: false
chpasswd:
list: |
thiller:xxxxx
expire: False
networkData: |
version: 2
ethernets:
enp1s0:
dhcp4: true
dhcp6: true
enp2s0:
dhcp4: true
dhcp6: true
name: cloudinitdisk
The POD IP is assigned, but reverse address resolution as well as name resolution doesn't work.
thiller@tom-ml350:~/Projects/microk8s/kubevirt/ubuntu$ kubectl -n vm-images get vmi NAME AGE PHASE IP NODENAME READY ubuntu-home 2d6h Running 10.1.154.117 tom-ml350 True
$ kubectl -n vm-images exec -ti dnsutils -- nslookup ubuntu-home.vm Server: 10.152.183.10 Address: 10.152.183.10#53
** server can't find ubuntu-home.vm: NXDOMAIN
command terminated with exit code 1
kubectl -n vm-images exec -ti dnsutils -- nslookup 10.1.154.117 ** server can't find 117.154.1.10.in-addr.arpa: NXDOMAIN
command terminated with exit code 1
Hello, As I understand it, setting the hostname via cloud-init doesn't propagate outside of the VM. Please, see this documentation section about DNS: https://kubevirt.io/user-guide/virtual_machines/dns/#dns-records
In a nutshell, you can set hostname and subdomain to the VM spec. I've tried the following scenario based on the documentation and your VM setup with bridge binding on pod network:
apiVersion: kubevirt.io/v1
kind: VirtualMachineInstance
metadata:
labels:
expose: me
name: vmi-masquerade1
spec:
hostname: "myvmi"
subdomain: "mysubdomain"
domain:
devices:
disks:
- disk:
bus: virtio
name: containerdisk
- disk:
bus: virtio
name: cloudinitdisk
interfaces:
- bridge: {}
name: default
rng: {}
resources:
requests:
memory: 1024M
networks:
- name: default
pod: {}
terminationGracePeriodSeconds: 0
volumes:
- containerDisk:
image: registry:5000/kubevirt/fedora-with-test-tooling-container-disk:devel
name: containerdisk
- cloudInitNoCloud:
userData: |-
#!/bin/bash
echo "fedora" |passwd fedora --stdin
name: cloudinitdisk
---
apiVersion: v1
kind: Service
metadata:
name: mysubdomain
spec:
selector:
expose: me
clusterIP: None
ports:
- name: foo # Actually, no port is needed.
port: 1234
targetPort: 1234
$ kubectl get pods -o wide
virt-launcher-vmi-masquerade1-vz8tc 2/2 Running 0 31m 10.244.196.146 node01 <none> <none>
$ virtctl console vmi-masquerade1
ping myvmi.mysubdomain
PING myvmi.mysubdomain.default.svc.cluster.local (10.244.196.146) 56(84) bytes of data.
64 bytes from myvmi.mysubdomain.default.svc.cluster.local (10.244.196.146): icmp_seq=1 ttl=64 time=0.019 ms
64 bytes from myvmi.mysubdomain.default.svc.cluster.local (10.244.196.146): icmp_seq=2 ttl=64 time=0.028 ms
...
From another pod
$ kubectl exec -it dnsutils -- /bin/sh
/ # nslookup myvmi.mysubdomain
Server: 10.96.0.10
Address: 10.96.0.10#53
Name: myvmi.mysubdomain.default.svc.cluster.local
Address: 10.244.196.146
Hope this helps
I have set hostname and subdomain and it's not working. (Only with Debian and Ubuntu)
Am 26.10.2021 um 11:12 schrieb Radim Hrazdil:
Hello, As I understand it, setting the hostname via cloud-init doesn't propagate outside of the VM. Please, see this documentation section about DNS: https://kubevirt.io/user-guide/virtual_machines/dns/#dns-records
In a nutshell, you can set hostname and subdomain to the VM spec. I've tried the following scenario based on the documentation and your VM setup with bridge binding on pod network:
|apiVersion: kubevirt.io/v1 kind: VirtualMachineInstance metadata: labels: expose: me name: vmi-masquerade1 spec: hostname: "myvmi" subdomain: "mysubdomain" domain: devices: disks: - disk: bus: virtio name: containerdisk - disk: bus: virtio name: cloudinitdisk interfaces: - bridge: {} name: default rng: {} resources: requests: memory: 1024M networks: - name: default pod: {} terminationGracePeriodSeconds: 0 volumes: - containerDisk: image: registry:5000/kubevirt/fedora-with-test-tooling-container-disk:devel name: containerdisk - cloudInitNoCloud: userData: |- #!/bin/bash echo "fedora" |passwd fedora --stdin name: cloudinitdisk --- apiVersion: v1 kind: Service metadata: name: mysubdomain spec: selector: expose: me clusterIP: None ports: - name: foo # Actually, no port is needed. port: 1234 targetPort: 1234 |
$ kubectl get pods -o wide virt-launcher-vmi-masquerade1-vz8tc 2/2 Running 0 31m 10.244.196.146 node01
$ virtctl console vmi-masquerade1 ping myvmi.mysubdomain PING myvmi.mysubdomain.default.svc.cluster.local (10.244.196.146) 56(84) bytes of data. 64 bytes from myvmi.mysubdomain.default.svc.cluster.local (10.244.196.146): icmp_seq=1 ttl=64 time=0.019 ms 64 bytes from myvmi.mysubdomain.default.svc.cluster.local (10.244.196.146): icmp_seq=2 ttl=64 time=0.028 ms ...
From another pod $ kubectl exec -it dnsutils -- /bin/sh / # nslookup myvmi.mysubdomain Server: 10.96.0.10 Address: 10.96.0.10#53
Name: myvmi.mysubdomain.default.svc.cluster.local Address: 10.244.196.146
|Hope this helps |
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kubevirt/kubevirt/issues/6675#issuecomment-951740553, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVVFCF3P5AFG35WSUF2PJLDUIZ5IJANCNFSM5GVGUVDQ. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Did you also create the service, that is called the same as the subdomain and is in the same namespace as the VM? The service also needs to have a selector matching the VMIs in the subdomain
Yes, I have the service, but forgot the label in the manifest. It's working now.
/assign @rhrazdil
Is this a BUG REPORT or FEATURE REQUEST?:
What happened: New VMs with Debian 10 (buster)/Ubuntu 20.04 don't get a DNS entry (even if hostname and subdomain is set) What you expected to happen: As with other VMs (SLES/RHEL/Windows) a dns entry How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Environment:
virtctl version
): 0.46.1kubectl version
): 1.22uname -a
):