Skip to content

Commit

Permalink
kubevirt: Set transient hostname from metadata
Browse files Browse the repository at this point in the history
At KubeVirt the hostname is usually set using DHCP on the case of
fcos/rhcos but at some use cases this is not the case and at least the
transient hostname should be set from the metadata. This change runs the
afterburn service that read metadata and dump and env file that can be
used later on with hostnamectl to set the transient hostname.

Signed-off-by: Enrique Llorente <ellorent@redhat.com>
  • Loading branch information
qinqon committed Oct 31, 2023
1 parent c778cd6 commit 05bd19b
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: afterburn-transient-hostname.service
enabled: true
contents: |
[Unit]
Description=Set Transient Hostname from KubeVirt meta_data
# Run afterburn service for collect info from metadata server
# see: https://coreos.github.io/afterburn/usage/attributes/
Wants=afterburn.service
After=afterburn.service
# Before hostname is received from DHCP
Before=network-pre.target
Wants=network-pre.target
# Run before kubelet
Before=kubelet.service
[Service]
# Mark afterburn environment file optional, due to it is possible that afterburn service was not executed
EnvironmentFile=/run/metadata/afterburn
ExecStart=hostnamectl hostname --transient "${AFTERBURN_KUBEVIRT_HOSTNAME}"
Type=oneshot
[Install]
WantedBy=network-online.target

0 comments on commit 05bd19b

Please sign in to comment.