Skip to content

Commit ef142f3

Browse files
committed
providers/hetzner: add support for Hetzner Cloud
* Add Hetzner Cloud as a provider * Userdata endpoint is http://169.254.169.254/hetzner/v1/userdata Signed-off-by: Manuel Hutter <manuel@hutter.io>
1 parent 3a20339 commit ef142f3

4 files changed

Lines changed: 58 additions & 0 deletions

File tree

docs/release-notes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ nav_order: 9
1111

1212
### Features
1313

14+
- Support Hetzner Cloud
1415

1516
### Changes
1617

docs/supported-platforms.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Ignition is currently only supported for the following platforms:
1515
* [DigitalOcean] (`digitalocean`) - Ignition will read its configuration from the droplet userdata. Cloud SSH keys and network configuration are handled separately.
1616
* [Exoscale] (`exoscale`) - Ignition will read its configuration from the instance userdata. Cloud SSH keys are handled separately.
1717
* [Google Cloud] (`gcp`) - Ignition will read its configuration from the instance metadata entry named "user-data". Cloud SSH keys are handled separately.
18+
* [Hetzner Cloud] (`hetzner`) - Ignition will read its configuration from the instance userdata. Cloud SSH keys are handled separately.
1819
* [Microsoft Hyper-V] (`hyperv`) - Ignition will read its configuration from the `ignition.config` key in pool 0 of the Hyper-V Data Exchange Service (KVP). Values are limited to approximately 1 KiB of text, so Ignition can also read and concatenate multiple keys named `ignition.config.0`, `ignition.config.1`, and so on.
1920
* [IBM Cloud] (`ibmcloud`) - Ignition will read its configuration from the instance userdata. Cloud SSH keys are handled separately.
2021
* [KubeVirt] (`kubevirt`) - Ignition will read its configuration from the instance userdata via config drive. Cloud SSH keys are handled separately.
@@ -42,6 +43,7 @@ For most cloud providers, cloud SSH keys and custom network configuration are ha
4243
[DigitalOcean]: https://www.digitalocean.com/products/droplets/
4344
[Exoscale]: https://www.exoscale.com/compute/
4445
[Google Cloud]: https://cloud.google.com/compute
46+
[Hetzner Cloud]: https://www.hetzner.com/cloud
4547
[Microsoft Hyper-V]: https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/
4648
[IBM Cloud]: https://www.ibm.com/cloud/vpc
4749
[KubeVirt]: https://kubevirt.io
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Copyright 2023 CoreOS, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// The hetzner provider fetches a remote configuration from the Hetzner Cloud
16+
// user-data metadata service URL.
17+
18+
package hetzner
19+
20+
import (
21+
"net/url"
22+
23+
"github.com/coreos/ignition/v2/config/v3_5_experimental/types"
24+
"github.com/coreos/ignition/v2/internal/platform"
25+
"github.com/coreos/ignition/v2/internal/providers/util"
26+
"github.com/coreos/ignition/v2/internal/resource"
27+
28+
"github.com/coreos/vcontext/report"
29+
)
30+
31+
var (
32+
userdataURL = url.URL{
33+
Scheme: "http",
34+
Host: "169.254.169.254",
35+
Path: "hetzner/v1/userdata",
36+
}
37+
)
38+
39+
func init() {
40+
platform.Register(platform.Provider{
41+
Name: "hetzner",
42+
Fetch: fetchConfig,
43+
})
44+
}
45+
46+
func fetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) {
47+
data, err := f.FetchToBuffer(userdataURL, resource.FetchOptions{})
48+
49+
if err != nil && err != resource.ErrNotFound {
50+
return types.Config{}, report.Report{}, err
51+
}
52+
53+
return util.ParseConfig(f.Logger, data)
54+
}

internal/register/providers.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
_ "github.com/coreos/ignition/v2/internal/providers/exoscale"
2525
_ "github.com/coreos/ignition/v2/internal/providers/file"
2626
_ "github.com/coreos/ignition/v2/internal/providers/gcp"
27+
_ "github.com/coreos/ignition/v2/internal/providers/hetzner"
2728
_ "github.com/coreos/ignition/v2/internal/providers/hyperv"
2829
_ "github.com/coreos/ignition/v2/internal/providers/ibmcloud"
2930
_ "github.com/coreos/ignition/v2/internal/providers/kubevirt"

0 commit comments

Comments
 (0)