Skip to content

Commit 25cfcdb

Browse files
committed
test again
1 parent 668da2e commit 25cfcdb

File tree

14 files changed

+147
-240
lines changed

14 files changed

+147
-240
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# THIS PROJECT IS FROZEN NOW
1+
## Switching to TALOS linux (https://github.com/spigell/pulumi-hcloud-kube-hetzner/tree/exp/move-to-talos)
22

3-
## Pulumi Hcloud Kube Hetzner
3+
## Pulumi Hcloud Kube Hetzner (WIP)
44
This is a [Pulumi component](https://www.pulumi.com/docs/concepts/resources/components) (only GO and Typescript/JS are supported now) for creating Kubernetes clusters in Hetzner Cloud. It is inspired by [terraform-hcloud-kube-hetzner](https://github.com/kube-hetzner/terraform-hcloud-kube-hetzner).
55

66
*Note: This project is in active development, and not everything is completed. However, it DOES work and is usable right now. I definitely appreciate feedback and will help with any issues*

go.mod

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ require (
1313
github.com/pulumi/pulumi-kubernetes/sdk/v3 v3.30.2
1414
github.com/pulumi/pulumi-kubernetes/sdk/v4 v4.12.0
1515
github.com/pulumi/pulumi/pkg/v3 v3.118.0
16-
github.com/pulumi/pulumi/sdk/v3 v3.129.0
16+
github.com/pulumi/pulumi/sdk/v3 v3.137.0
1717
github.com/pulumiverse/pulumi-talos/sdk v0.2.1-0.20241010205148-1f0d724ea2b4
1818
github.com/sanity-io/litter v1.5.5
1919
github.com/seancfoley/ipaddress-go v1.6.0
20+
github.com/siderolabs/talos/pkg/machinery v1.8.2
2021
github.com/spigell/pulumi-automation-api-apps v0.0.0-20231022103528-4099afba2f99
2122
github.com/spigell/pulumi-automation-api-apps/hetzner-snapshots-manager/sdk v0.0.0-20231022103528-4099afba2f99
2223
github.com/spigell/pulumi-file/sdk v0.0.0-20240124083824-da5e49302f10
24+
github.com/spigell/pulumi-talos-cluster/sdk v0.0.0-00010101000000-000000000000
2325
github.com/stretchr/testify v1.9.0
2426
golang.org/x/crypto v0.26.0
2527
gopkg.in/yaml.v3 v3.0.1
@@ -143,7 +145,6 @@ require (
143145
github.com/siderolabs/go-pointer v1.0.0 // indirect
144146
github.com/siderolabs/net v0.4.0 // indirect
145147
github.com/siderolabs/protoenc v0.2.1 // indirect
146-
github.com/siderolabs/talos/pkg/machinery v1.8.2 // indirect
147148
github.com/sourcegraph/conc v0.3.0 // indirect
148149
github.com/stoewer/go-strcase v1.2.0 // indirect
149150
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
@@ -288,3 +289,5 @@ require (
288289
gopkg.in/warnings.v0 v0.1.2 // indirect
289290
lukechampine.com/frand v1.4.2 // indirect
290291
)
292+
293+
replace github.com/spigell/pulumi-talos-cluster/sdk => ../pulumi-talos-cluster/sdk

go.sum

+29-62
Large diffs are not rendered by default.

internal/hetzner/hetzner.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (h *Hetzner) FirewallConfigByID(id, pool string) (*firewall.Config, error)
149149

150150
// Up creates hetzner cloud infrastructure.
151151
// It must be refactored.
152-
func (h *Hetzner) Up(keys *sshkeypair.KeyPair) (*Deployed, error) { //nolint: gocognit
152+
func (h *Hetzner) Up(keys *sshkeypair.KeyPair, serverUserdata *pulumi.StringOutput) (*Deployed, error) { //nolint: gocognit
153153
nodes := make(map[string]*Server)
154154
firewalls := make(map[string]*firewall.Firewall)
155155
firewallsByNodeRole := make(map[string]pulumi.IntArray)
@@ -201,7 +201,7 @@ func (h *Hetzner) Up(keys *sshkeypair.KeyPair) (*Deployed, error) { //nolint: go
201201
netID = net.ID
202202
}
203203

204-
s := server.New(srv.Server, key)
204+
s := server.New(srv.Server, key).WithUserata(serverUserdata)
205205
if err := s.Validate(); err != nil {
206206
return nil, err
207207
}

internal/hetzner/server/cloudinit.go

-18
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import (
44
"errors"
55
"fmt"
66

7-
"github.com/spigell/pulumi-hcloud-kube-hetzner/internal/hetzner/server/scripts"
8-
97
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
108
"gopkg.in/yaml.v3"
119
)
@@ -73,19 +71,3 @@ func (c *CloudInit) render() pulumi.StringOutput {
7371
return cloudConfigHeader + string(cfg), nil
7472
}).(pulumi.StringOutput)
7573
}
76-
77-
func RenameInterfaceScript() *CloudInitWriteFile {
78-
return &CloudInitWriteFile{
79-
Path: "/etc/cloud/rename_interface.sh",
80-
Content: scripts.RenameInterface,
81-
Permissions: "0755",
82-
}
83-
}
84-
85-
func WriteTalosScript() *CloudInitWriteFile {
86-
return &CloudInitWriteFile{
87-
Path: "/etc/cloud/write-talos.sh",
88-
Content: scripts.WriteTalos,
89-
Permissions: "0755",
90-
}
91-
}

internal/hetzner/server/scripts/rename-interface.go

-52
This file was deleted.

internal/hetzner/server/scripts/write-talos.go

-16
This file was deleted.

internal/hetzner/server/server.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var (
4545

4646
type Server struct {
4747
Config *config.ServerConfig
48-
Userdata *CloudInit
48+
Userdata *pulumi.StringOutput
4949
KeyName pulumi.StringOutput
5050
}
5151

@@ -104,10 +104,11 @@ func New(srv *config.ServerConfig, key *hcloud.SshKey) *Server {
104104
userdata.Inputs = &CloudInitPulumiInputs{
105105
Key: &key.PublicKey,
106106
}
107+
ud := pulumi.ToSecret(userdata.render()).(pulumi.StringOutput)
107108

108109
return &Server{
109110
Config: srv,
110-
Userdata: userdata,
111+
Userdata: &ud,
111112
KeyName: key.Name,
112113
}
113114
}
@@ -116,6 +117,12 @@ func (s *Server) Validate() error {
116117
return nil
117118
}
118119

120+
func (s *Server) WithUserata(u *pulumi.StringOutput) *Server {
121+
s.Userdata = u
122+
123+
return s
124+
}
125+
119126
func (s *Server) Up(ctx *program.Context, id string, internalIP string, netID pulumi.IntInput, deps []pulumi.Resource) (*Deployed, error) {
120127
// Get image ID from user input
121128
image := pulumi.String(s.Config.Image)
@@ -144,7 +151,7 @@ func (s *Server) Up(ctx *program.Context, id string, internalIP string, netID pu
144151
Location: pulumi.String(s.Config.Location),
145152
Name: pulumi.String(s.Config.Hostname),
146153
Image: image,
147-
Rescue: pulumi.String("linux64"),
154+
// Rescue: pulumi.String("linux64"),
148155
SshKeys: pulumi.StringArray{
149156
s.KeyName,
150157
},
@@ -164,7 +171,7 @@ func (s *Server) Up(ctx *program.Context, id string, internalIP string, netID pu
164171
}
165172
}
166173

167-
args.UserData = pulumi.ToSecret(s.Userdata.render()).(pulumi.StringOutput)
174+
args.UserData = s.Userdata
168175

169176
if os.Getenv(autoApiApps.EnvAutomaionAPIAddr) != "" {
170177
sn, err := snapshots.GetLastSnapshot(&http.Client{}, s.Config.Hostname)

internal/k8s/distributions/distributions.go

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package distributions
22

33
const (
44
K3SDistrName = "k3s"
5+
TalosDistrName = "talos"
56
)
67

78
type Distribution interface {

internal/system/system.go

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ func (s *System) MicroOS() *microos.MicroOS {
4545
return os
4646
}
4747

48+
4849
func (s *System) WithOS(os os.OperatingSystem) *System {
4950
s.OS = os
5051

0 commit comments

Comments
 (0)