diff --git a/README.md b/README.md index 046c835..115b578 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,21 @@ Alternatively, you can add `tinycloud=cloud=` (preferred) or `ds=` `/sys/class/dmi/id/product_serial` (QEMU hack) is another way to explicitly choose a cloud provider. +### Custom Metadata Service Endpoint + +For custom or non-standard metadata services, you can +override the default IMDS endpoint by setting `IMDS_ENDPOINT` in +`/etc/tiny-cloud.conf`: + +```sh +# For Tinkerbell or other custom metadata services +IMDS_ENDPOINT=192.0.2.1:50061 +``` + +The default endpoint is `169.254.169.254` for most cloud providers. This +setting allows you to specify a custom IP address and optional port for the +metadata service. + ## Operation The first time an instance boots -- either freshly instantiated from an image, diff --git a/bin/imds b/bin/imds index 6ccce6b..575ac53 100755 --- a/bin/imds +++ b/bin/imds @@ -52,7 +52,8 @@ unset -f \ ### default variables/functions # Common to many clouds -IMDS_ENDPOINT="169.254.169.254" +# Can be overridden in /etc/tiny-cloud.conf +: "${IMDS_ENDPOINT:=169.254.169.254}" # Common to AWS and NoCloud(ish) IMDS_HOSTNAME="meta-data/hostname" diff --git a/docs/tiny-cloud.conf.5.scd b/docs/tiny-cloud.conf.5.scd index e6d0bbc..0bc6e3e 100644 --- a/docs/tiny-cloud.conf.5.scd +++ b/docs/tiny-cloud.conf.5.scd @@ -33,6 +33,10 @@ Blank lines and shell comments are ignored. Default user account for instance SSH keys and default-user setup. The default is *alpine*. +*IMDS_ENDPOINT*= + Provider endpoint IP address to use. Defaults to 169.254.169.254 for many + providers. + *IMDS_TOKEN_TTL*= Metadata token lifetime in seconds for AWS metadata access. This is only used by the AWS provider. The default is *5*. diff --git a/lib/tiny-cloud/tiny-cloud.conf b/lib/tiny-cloud/tiny-cloud.conf index 599c6d5..7100c49 100644 --- a/lib/tiny-cloud/tiny-cloud.conf +++ b/lib/tiny-cloud/tiny-cloud.conf @@ -8,6 +8,11 @@ # User account where instance SSH keys are installed #CLOUD_USER=alpine +# IMDS endpoint override (IP:PORT or IP) +# Defaults to 169.254.169.254 for most clouds +# Useful for custom metadata services +#IMDS_ENDPOINT=169.254.169.254 + # IMDS token validity, in seconds (AWS only) #IMDS_TOKEN_TTL=5