Skip to content

Commit 8289dce

Browse files
authored
Merge pull request #508 from threefoldtech/development_k8s_same_flist_
use same flist for k8s cluster master and workers
2 parents 0e69242 + a462078 commit 8289dce

File tree

19 files changed

+552
-553
lines changed

19 files changed

+552
-553
lines changed

docs/_index.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -510,17 +510,15 @@ func main() {
510510
}
511511
kubernetes, err := threefold.NewKubernetes(ctx, "kubernetes", &threefold.KubernetesArgs{
512512
Master: &threefold.K8sNodeInputArgs{
513-
VMInput: &threefold.VMInput{
514-
Name: pulumi.String("kubernetes"),
515-
Network_name: pulumi.String("test"),
516-
NodeID: scheduler.Nodes.ApplyT(func(nodes []int) (int, error) {
517-
return nodes[0], nil
518-
}).(pulumi.IntOutput),
519-
Planetary: pulumi.Bool(true),
520-
Mycelium: pulumi.Bool(true),
521-
Cpu: pulumi.Int(2),
522-
Memory: pulumi.Int(2048),
523-
},
513+
Name: pulumi.String("kubernetes"),
514+
Network_name: pulumi.String("test"),
515+
NodeID: scheduler.Nodes.ApplyT(func(nodes []int) (int, error) {
516+
return nodes[0], nil
517+
}).(pulumi.IntOutput),
518+
Planetary: pulumi.Bool(true),
519+
Mycelium: pulumi.Bool(true),
520+
Cpu: pulumi.Int(2),
521+
Memory: pulumi.Int(2048),
524522
Disk_size: pulumi.Int(2),
525523
},
526524
Workers: threefold.K8sNodeInputArray{

go.work.sum

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -751,15 +751,12 @@ github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20240416134707
751751
github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20240416134707-eb36aa90df2d/go.mod h1:dtDKAPiUDxAwIkfHV7xcAFZcOm+xwNIuOI1MLFS+MeQ=
752752
github.com/threefoldtech/tfgrid-sdk-go/grid-client v0.15.11 h1:FmEQplYSZ6pYslmBlUNaUabScOdi6hJialeV/yq0BrY=
753753
github.com/threefoldtech/tfgrid-sdk-go/grid-client v0.15.11/go.mod h1:Obsv0kspgSSwF8jb91Z7CBY2FCQNq6RhiZXIQf26nWY=
754-
github.com/threefoldtech/tfgrid-sdk-go/grid-client v0.15.17 h1:JwjhOz4mSV0qL0/oF+fdLYtE+l0s7fFjObunzTairYA=
755-
github.com/threefoldtech/tfgrid-sdk-go/grid-client v0.15.17/go.mod h1:MwKEEeKN7qApCdabKRBTs18lrJ6JzA2Xx5Hd2/zb4o0=
756754
github.com/threefoldtech/tfgrid-sdk-go/grid-proxy v0.15.10 h1:If91FVqQgd2mZutMMUIrapsqZKDN8/hL5r5Yfr+vFK0=
757755
github.com/threefoldtech/tfgrid-sdk-go/grid-proxy v0.15.10/go.mod h1:yg1BDRR/TSr87mkjxEfsKc0VzMTJcbg87WW7C0GUPXQ=
758756
github.com/threefoldtech/tfgrid-sdk-go/grid-proxy v0.15.11 h1:qsSICIj5cvoVBR4GLWmdu2n3FfJG5isJ2ABnNNWykLU=
759757
github.com/threefoldtech/tfgrid-sdk-go/grid-proxy v0.15.11/go.mod h1:7cKHvKPpfdCpU4a/VCznRDDNMPBPI98cJ0uVJoUGrgg=
760-
github.com/threefoldtech/tfgrid-sdk-go/grid-proxy v0.15.17 h1:rI9viGoLdgMX62Y1nFN6Utjbjp3ovZRfzImZBeNB5K4=
761-
github.com/threefoldtech/tfgrid-sdk-go/grid-proxy v0.15.17/go.mod h1:2Z7uJYHeilN7bASpmkcDxtl+3AT8tim6iIvqZ08pwCg=
762-
github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.15.17/go.mod h1:cDTivSsUl4r1jN+H8/W6yDqByOOliY8HEGuVuL3ixV8=
758+
github.com/threefoldtech/tfgrid-sdk-go/grid-proxy v0.15.16 h1:Bnt9POje9hc9nv1YwAu13ABnl63DBMH0qL4SeVhNsIQ=
759+
github.com/threefoldtech/tfgrid-sdk-go/grid-proxy v0.15.16/go.mod h1:2Z7uJYHeilN7bASpmkcDxtl+3AT8tim6iIvqZ08pwCg=
763760
github.com/threefoldtech/zbus v1.0.1/go.mod h1:E/v/xEvG/l6z/Oj0aDkuSUXFm/1RVJkhKBwDTAIdsHo=
764761
github.com/threefoldtech/zos v0.5.6-0.20240611092312-66184cdeb953 h1:hzqMY2Ydb+N2TBrTJHpy5n5i5nflfre1dhoNQH/tfhI=
765762
github.com/threefoldtech/zos v0.5.6-0.20240611092312-66184cdeb953/go.mod h1:yH6T43SiHvQBBuLgKGElECsIhqzJ6fy/dJyaxtO/X0M=

provider/annotations.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ package provider
22

33
import (
44
"fmt"
5+
"os"
56

67
"github.com/pulumi/pulumi-go-provider/infer"
78
)
89

9-
// TODO: computed
10-
1110
var _ = (infer.Annotated)((*NetworkArgs)(nil))
1211
var _ = (infer.Annotated)((*NetworkState)(nil))
1312

@@ -80,7 +79,7 @@ func (v *VMInput) Annotate(a infer.Annotator) {
8079
a.Describe(&v.Description, "The description of the virtual machine workload, optional with no restrictions")
8180
a.Describe(&v.NodeID, "The node ID to deploy the virtual machine on, required and should match the requested resources")
8281
a.Describe(&v.Flist, "The flist to be mounted in the virtual machine, required and should be valid. Example: https://hub.grid.tf/tf-official-apps/base:latest.flist")
83-
a.Describe(&v.Entrypoint, "The entry point for the flist. Example: /sbin/zinit init")
82+
a.Describe(&v.EntryPoint, "The entry point for the flist. Example: /sbin/zinit init")
8483
a.Describe(&v.FlistChecksum, "The checksum of the flist which should match the checksum of the given flist, optional")
8584
a.Describe(&v.CPU, "The cpu units needed for the virtual machine. Range in [1: 32]")
8685
a.Describe(&v.Memory, "The memory capacity for the virtual machine in MB. Min is 250 MB")
@@ -183,13 +182,17 @@ var _ = (infer.Annotated)((*K8sNodeInput)(nil))
183182

184183
func (k *KubernetesArgs) Annotate(a infer.Annotator) {
185184
a.SetDefault(&k.SolutionType, fmt.Sprintf("kubernetes/%s", k.Master.Name))
185+
a.SetDefault(&k.SSHKey, os.Getenv("SSH_KEY")) // for testing purposes
186186

187187
a.Describe(&k.Master, "Master holds the configuration of master node in the kubernetes cluster")
188188
a.Describe(&k.Workers, "Workers is a list holding the workers configuration for the kubernetes cluster")
189189
a.Describe(&k.NetworkName, "The name of the network, it's required and cannot exceed 50 characters. Only alphanumeric and underscores characters are supported. Network must exist")
190190
a.Describe(&k.SolutionType, "The solution type of the cluster, displayed as project name in contract metadata")
191191
a.Describe(&k.SSHKey, "SSH key to access the cluster nodes")
192192
a.Describe(&k.Token, "The cluster secret token. Each node has to have this token to be part of the cluster. This token should be an alphanumeric non-empty string")
193+
a.Describe(&k.Flist, "The flist to be mounted in the kubernetes cluster nodes. Example: https://hub.grid.tf/tf-official-apps/base:latest.flist")
194+
a.Describe(&k.EntryPoint, "The entry point for the flist. Example: /sbin/zinit init")
195+
a.Describe(&k.FlistChecksum, "The checksum of the flist which should match the checksum of the given flist, optional")
193196
}
194197

195198
func (k *KubernetesState) Annotate(a infer.Annotator) {
@@ -200,6 +203,23 @@ func (k *KubernetesState) Annotate(a infer.Annotator) {
200203
}
201204

202205
func (k *K8sNodeInput) Annotate(a infer.Annotator) {
206+
a.SetDefault(&k.Flist, "https://hub.grid.tf/tf-official-apps/threefoldtech-k3s-latest.flist")
207+
a.SetDefault(&k.EntryPoint, "/sbin/zinit init")
208+
209+
a.Describe(&k.Name, "The name of the kubernetes node, it's required and cannot exceed 50 characters. Only alphanumeric and underscores characters are supported")
210+
a.Describe(&k.NetworkName, "The name of the network, it's required and cannot exceed 50 characters. Only alphanumeric and underscores characters are supported. Network must exist")
211+
a.Describe(&k.Description, "The description of the kubernetes node, optional with no restrictions")
212+
a.Describe(&k.NodeID, "The node ID to deploy the kubernetes node on, required and should match the requested resources")
213+
a.Describe(&k.Flist, "The flist to be mounted in the kubernetes node. Example: https://hub.grid.tf/tf-official-apps/base:latest.flist")
214+
a.Describe(&k.EntryPoint, "The entry point for the flist. Example: /sbin/zinit init")
215+
a.Describe(&k.FlistChecksum, "The checksum of the flist which should match the checksum of the given flist, optional")
216+
a.Describe(&k.CPU, "The cpu units needed for the kubernetes node. Range in [1: 32]")
217+
a.Describe(&k.Memory, "The memory capacity for the kubernetes node in MB. Min is 250 MB")
218+
a.Describe(&k.Mycelium, "A flag to generate a random mycelium IP seed to support mycelium in the kubernetes node")
219+
a.Describe(&k.MyceliumIPSeed, "The seed used for mycelium IP generated for the kubernetes node. It's length should be 6")
220+
a.Describe(&k.Planetary, "A flag to enable generating a yggdrasil IP for the kubernetes node")
221+
a.Describe(&k.PublicIP, "A flag to enable generating a public IP for the kubernetes node, public node is required for it")
222+
a.Describe(&k.PublicIP6, "A flag to enable generating a public IPv6 for the kubernetes node, public node is required for it")
203223
a.Describe(&k.DiskSize, "Data disk size in GBs. Must be between 1GB and 10240GBs (10TBs)")
204224
}
205225

provider/cmd/pulumi-resource-threefold/schema.json

Lines changed: 43 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -155,102 +155,71 @@
155155
"properties": {
156156
"cpu": {
157157
"type": "integer",
158-
"description": "The cpu units needed for the virtual machine. Range in [1: 32]"
158+
"description": "The cpu units needed for the kubernetes node. Range in [1: 32]"
159159
},
160160
"description": {
161161
"type": "string",
162-
"description": "The description of the virtual machine workload, optional with no restrictions"
162+
"description": "The description of the kubernetes node, optional with no restrictions"
163163
},
164164
"disk_size": {
165165
"type": "integer",
166166
"description": "Data disk size in GBs. Must be between 1GB and 10240GBs (10TBs)"
167167
},
168-
"entrypoint": {
168+
"entry_point": {
169169
"type": "string",
170-
"description": "The entry point for the flist. Example: /sbin/zinit init"
171-
},
172-
"env_vars": {
173-
"type": "object",
174-
"additionalProperties": {
175-
"type": "string"
176-
},
177-
"description": "The environment variables to be passed to the virtual machine. Example: SSH_KEY"
170+
"description": "The entry point for the flist. Example: /sbin/zinit init",
171+
"default": "/sbin/zinit init"
178172
},
179173
"flist": {
180174
"type": "string",
181-
"description": "The flist to be mounted in the virtual machine, required and should be valid. Example: https://hub.grid.tf/tf-official-apps/base:latest.flist"
175+
"description": "The flist to be mounted in the kubernetes node. Example: https://hub.grid.tf/tf-official-apps/base:latest.flist",
176+
"default": "https://hub.grid.tf/tf-official-apps/threefoldtech-k3s-latest.flist"
182177
},
183178
"flist_checksum": {
184179
"type": "string",
185180
"description": "The checksum of the flist which should match the checksum of the given flist, optional"
186181
},
187-
"gpus": {
188-
"type": "array",
189-
"items": {
190-
"type": "string"
191-
},
192-
"description": "A list of gpu IDs to be used in the virtual machine. GPU ID format: \u003cslot\u003e/\u003cvendor\u003e/\u003cdevice\u003e. Example: 0000:28:00.0/1002/731f"
193-
},
194182
"memory": {
195183
"type": "integer",
196-
"description": "The memory capacity for the virtual machine in MB. Min is 250 MB"
197-
},
198-
"mounts": {
199-
"type": "array",
200-
"items": {
201-
"$ref": "#/types/threefold:index:Mount"
202-
},
203-
"description": "A list of mounted disks or volumes"
184+
"description": "The memory capacity for the kubernetes node in MB. Min is 250 MB"
204185
},
205186
"mycelium": {
206187
"type": "boolean",
207-
"description": "A flag to generate a random mycelium IP seed to support mycelium in the virtual machine"
188+
"description": "A flag to generate a random mycelium IP seed to support mycelium in the kubernetes node"
208189
},
209190
"mycelium_ip_seed": {
210191
"type": "string",
211-
"description": "The seed used for mycelium IP generated for the virtual machine. It's length should be 6"
192+
"description": "The seed used for mycelium IP generated for the kubernetes node. It's length should be 6"
212193
},
213194
"name": {
214195
"type": "string",
215-
"description": "The name of the virtual machine workload, it's required and cannot exceed 50 characters. Only alphanumeric and underscores characters are supported"
196+
"description": "The name of the kubernetes node, it's required and cannot exceed 50 characters. Only alphanumeric and underscores characters are supported"
216197
},
217198
"network_name": {
218199
"type": "string",
219200
"description": "The name of the network, it's required and cannot exceed 50 characters. Only alphanumeric and underscores characters are supported. Network must exist"
220201
},
221202
"node_id": {
222203
"$ref": "pulumi.json#/Any",
223-
"description": "The node ID to deploy the virtual machine on, required and should match the requested resources"
204+
"description": "The node ID to deploy the kubernetes node on, required and should match the requested resources"
224205
},
225206
"planetary": {
226207
"type": "boolean",
227-
"description": "A flag to enable generating a yggdrasil IP for the virtual machine"
208+
"description": "A flag to enable generating a yggdrasil IP for the kubernetes node"
228209
},
229210
"public_ip": {
230211
"type": "boolean",
231-
"description": "A flag to enable generating a public IP for the virtual machine, public node is required for it"
212+
"description": "A flag to enable generating a public IP for the kubernetes node, public node is required for it"
232213
},
233214
"public_ip6": {
234215
"type": "boolean",
235-
"description": "A flag to enable generating a public IPv6 for the virtual machine, public node is required for it"
236-
},
237-
"rootfs_size": {
238-
"type": "integer",
239-
"description": "The root fs size in GB (type SSD). Can be set as 0 to get the default minimum"
240-
},
241-
"zlogs": {
242-
"type": "array",
243-
"items": {
244-
"$ref": "#/types/threefold:index:Zlog"
245-
},
246-
"description": "A list of virtual machine loggers"
216+
"description": "A flag to enable generating a public IPv6 for the kubernetes node, public node is required for it"
247217
}
248218
},
249219
"type": "object",
250220
"required": [
251221
"cpu",
252222
"disk_size",
253-
"flist",
254223
"memory",
255224
"name",
256225
"network_name",
@@ -1083,6 +1052,18 @@
10831052
},
10841053
"threefold:index:Kubernetes": {
10851054
"properties": {
1055+
"entry_point": {
1056+
"type": "string",
1057+
"description": "The entry point for the flist. Example: /sbin/zinit init"
1058+
},
1059+
"flist": {
1060+
"type": "string",
1061+
"description": "The flist to be mounted in the kubernetes cluster nodes. Example: https://hub.grid.tf/tf-official-apps/base:latest.flist"
1062+
},
1063+
"flist_checksum": {
1064+
"type": "string",
1065+
"description": "The checksum of the flist which should match the checksum of the given flist, optional"
1066+
},
10861067
"master": {
10871068
"$ref": "#/types/threefold:index:K8sNodeInput",
10881069
"description": "Master holds the configuration of master node in the kubernetes cluster"
@@ -1116,7 +1097,8 @@
11161097
},
11171098
"ssh_key": {
11181099
"type": "string",
1119-
"description": "SSH key to access the cluster nodes"
1100+
"description": "SSH key to access the cluster nodes",
1101+
"default": ""
11201102
},
11211103
"token": {
11221104
"type": "string",
@@ -1149,6 +1131,18 @@
11491131
"workers_computed"
11501132
],
11511133
"inputProperties": {
1134+
"entry_point": {
1135+
"type": "string",
1136+
"description": "The entry point for the flist. Example: /sbin/zinit init"
1137+
},
1138+
"flist": {
1139+
"type": "string",
1140+
"description": "The flist to be mounted in the kubernetes cluster nodes. Example: https://hub.grid.tf/tf-official-apps/base:latest.flist"
1141+
},
1142+
"flist_checksum": {
1143+
"type": "string",
1144+
"description": "The checksum of the flist which should match the checksum of the given flist, optional"
1145+
},
11521146
"master": {
11531147
"$ref": "#/types/threefold:index:K8sNodeInput",
11541148
"description": "Master holds the configuration of master node in the kubernetes cluster"
@@ -1164,7 +1158,8 @@
11641158
},
11651159
"ssh_key": {
11661160
"type": "string",
1167-
"description": "SSH key to access the cluster nodes"
1161+
"description": "SSH key to access the cluster nodes",
1162+
"default": ""
11681163
},
11691164
"token": {
11701165
"type": "string",

provider/deployment_parser.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type VMInput struct {
6363
Description string `pulumi:"description,optional"`
6464
GPUs []zos.GPU `pulumi:"gpus,optional"`
6565
RootfsSize int `pulumi:"rootfs_size,optional"`
66-
Entrypoint string `pulumi:"entrypoint,optional"`
66+
EntryPoint string `pulumi:"entrypoint,optional"`
6767
Mounts []Mount `pulumi:"mounts,optional"`
6868
Zlogs []Zlog `pulumi:"zlogs,optional"`
6969
EnvVars map[string]string `pulumi:"env_vars,optional"`
@@ -210,7 +210,7 @@ func parseInputToDeployment(deploymentArgs DeploymentArgs) (workloads.Deployment
210210
CPU: uint8(vm.CPU),
211211
MemoryMB: uint64(vm.Memory),
212212
RootfsSizeMB: uint64(vm.RootfsSize),
213-
Entrypoint: vm.Entrypoint,
213+
Entrypoint: vm.EntryPoint,
214214
Mounts: mounts,
215215
Zlogs: zlogs,
216216
EnvVars: vm.EnvVars,
@@ -347,7 +347,7 @@ func parseDeploymentToState(deployment workloads.Deployment) DeploymentState {
347347
CPU: int(vm.CPU),
348348
Memory: int(vm.MemoryMB),
349349
RootfsSize: int(vm.RootfsSizeMB),
350-
Entrypoint: vm.Entrypoint,
350+
EntryPoint: vm.Entrypoint,
351351
Mounts: mounts,
352352
Zlogs: zlogs,
353353
EnvVars: vm.EnvVars,

provider/deployment_parser_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func generateInputs() (Disk, ZDBInput, VMInput, QSFSInput, DeploymentArgs) {
4242
Description: "vm-description",
4343
GPUs: []zos.GPU{"gpu"},
4444
RootfsSize: 0,
45-
Entrypoint: "entrypoint",
45+
EntryPoint: "entrypoint",
4646
Mounts: []Mount{{
4747
Name: diskInput.Name,
4848
MountPoint: fmt.Sprintf("/%s", diskInput.Name),

provider/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/pulumi/pulumi/pkg/v3 v3.134.0
99
github.com/pulumi/pulumi/sdk/v3 v3.134.0
1010
github.com/stretchr/testify v1.9.0
11-
github.com/threefoldtech/tfgrid-sdk-go/grid-client v0.15.17-0.20240904123303-a296d35314f5
11+
github.com/threefoldtech/tfgrid-sdk-go/grid-client v0.15.17
1212
github.com/threefoldtech/tfgrid-sdk-go/grid-proxy v0.15.16
1313
github.com/threefoldtech/zos v0.5.6-0.20240902110349-172a0a29a6ee
1414
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6
@@ -172,7 +172,7 @@ require (
172172
github.com/spf13/pflag v1.0.5 // indirect
173173
github.com/texttheater/golang-levenshtein v1.0.1 // indirect
174174
github.com/threefoldtech/tfchain/clients/tfchain-client-go v0.0.0-20240827163226-d4e15e206974 // indirect
175-
github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.15.16 // indirect
175+
github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go v0.15.17 // indirect
176176
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
177177
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
178178
github.com/vedhavyas/go-subkey v1.0.3 // indirect

0 commit comments

Comments
 (0)