Bug 1712725 - Cannot create vm with a typical hostname in yaml spec.template.spec.hostname
Summary: Cannot create vm with a typical hostname in yaml spec.template.spec.hostname
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Container Native Virtualization (CNV)
Classification: Red Hat
Component: Virtualization
Version: 2.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 2.1.0
Assignee: Francesco Romani
QA Contact: Israel Pinto
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-05-22 07:00 UTC by Guohua Ouyang
Modified: 2019-06-21 23:06 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-06-20 12:08:09 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Guohua Ouyang 2019-05-22 07:00:11 UTC
Description of problem:
Create VM with hostname 'test.example.com' is failed on UI.

Error "spec.template.spec.hostname does not conform to the kubernetes DNS_LABEL rules : a DNS-1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')" for field "spec.template.spec.hostname".

The whole yaml is:
{
 "apiVersion": "kubevirt.io/v1alpha3",
 "kind": "VirtualMachine",
 "metadata": {
  "name": "test1",
  "labels": {
   "flavor.template.kubevirt.io/small": "true",
   "os.template.kubevirt.io/fedora29": "true",
   "workload.template.kubevirt.io/generic": "true",
   "vm.kubevirt.io/template": "fedora-generic",
   "vm.kubevirt.io/template-namespace": "openshift"
  },
  "annotations": {
   "name.os.template.kubevirt.io/fedora29": "Fedora 29"
  },
  "namespace": "default"
 },
 "spec": {
  "running": true,
  "template": {
   "spec": {
    "domain": {
     "cpu": {
      "cores": 2
     },
     "devices": {
      "disks": [
       {
        "bootOrder": 1,
        "disk": {
         "bus": "virtio"
        },
        "name": "rootdisk"
       },
       {
        "bootOrder": 3,
        "disk": {
         "bus": "virtio"
        },
        "name": "cloudinitdisk"
       }
      ],
      "interfaces": [
       {
        "bootOrder": 2,
        "masquerade": {},
        "name": "nic0"
       }
      ],
      "rng": {}
     },
     "resources": {
      "requests": {
       "memory": "2G"
      }
     }
    },
    "hostname": "test.example.com",
    "networks": [
     {
      "name": "nic0",
      "pod": {}
     }
    ],
    "terminationGracePeriodSeconds": 0,
    "volumes": [
     {
      "containerDisk": {
       "image": "kubevirt/cirros-container-disk-demo"
      },
      "name": "rootdisk"
     },
     {
      "cloudInitNoCloud": {
       "userData": "#cloud-config\nusers:\n  - name: default\n    ssh-authorized-keys: >-\n      ssh-rsa\n      AAAAB3NzaC1yc2EAAAADAQABAAABAQCj47ubVnxR16JU7ZfDli3N5QVBAwJBRh2xMryyjk5dtfugo5JIPGB2cyXTqEDdzuRmI+Vkb/A5duJyBRlA+9RndGGmhhMnj8and3wu5/cEb7DkF6ZJ25QV4LQx3K/i57LStUHXRTvruHOZ2nCuVXWqi7wSvz5YcvEv7O8pNF5uGmqHlShBdxQxcjurXACZ1YY0YDJDr3AJai1KF9zehVJODuSbrnOYpThVWGjFuFAnNxbtuZ8EOSougN2aYTf2qr/KFGDHtewIkzZmP6cjzKO5bN3pVbXxmb2Gces/BYHntY4MXBTUqwsmsCRC5SAz14bEP/vsLtrNhjq9vCS+BjMT\nhostname: test.example.com\n"
      },
      "name": "cloudinitdisk"
     }
    ]
   },
   "metadata": {
    "labels": {
     "vm.kubevirt.io/name": "test1"
    }
   }
  }
 }
}

Version-Release number of selected component (if applicable):
hco:v2.0.0-15
kubevirt-web-ui: brew-pulp-docker01.web.prod.ext.phx2.redhat.com:8888/container-native-virtualization/kubevirt-web-ui@sha256:d0b9fb56f92c2d339fa2a5850f89006e475f5ba7641b6f619e5f2715ba0c1314

How reproducible:
100%

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Guohua Ouyang 2019-05-22 11:52:11 UTC
move to virt component.

Comment 2 Francesco Romani 2019-05-23 08:08:33 UTC
This error comes from kubevirt' validation: https://github.com/kubevirt/kubevirt/blob/master/pkg/virt-api/webhooks/validating-webhook/admitters/vmi-create-admitter.go#L113

I'm not even sure it is an actual bug

Comment 3 Fabian Deutsch 2019-06-20 12:08:09 UTC
It's not a bug.

It is explained what value is permitted, the select value does not meet these requirements.

Comment 4 Guohua Ouyang 2019-06-20 23:06:06 UTC
@Fabian, do you think 'test.example.com' is a valid hostname regardless kubevirt validation? If it is, why we cannot use it?

Comment 5 Fabian Deutsch 2019-06-21 07:17:40 UTC
In the context of kubernetes test.example.com is not a valid hostname.

It needs to be understood that in the kubernetes context, the hostname is used to create an FQDN. That's why the hostname needs to match the DNS_LABEL rule mentioned in the description.
The benefit is, that the VM will tie into Kubernete's DNS system, which means that the VM can be resolved with a complete FQDN once the name is set.

Comment 6 Guohua Ouyang 2019-06-21 23:06:33 UTC
thanks for the explannation, I'm okay to close this bug now.


Note You need to log in before you can comment on or make changes to this bug.