Skip to content

Commit dca8978

Browse files
Merge pull request #541 from linode/proj/disk-encryption
project: Linode Disk Encryption
2 parents e0f3b86 + 31debfb commit dca8978

32 files changed

+3928
-4728
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
vendor/**/
2222
.env
2323
coverage.txt
24+
go.work.sum

go.work.sum

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/
3434
github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE=
3535
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
3636
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
37+
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
38+
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
39+
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
3740
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
3841
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
3942
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=

instance_disks.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ type InstanceDisk struct {
1717
Filesystem DiskFilesystem `json:"filesystem"`
1818
Created *time.Time `json:"-"`
1919
Updated *time.Time `json:"-"`
20+
21+
// NOTE: Disk encryption may not currently be available to all users.
22+
DiskEncryption InstanceDiskEncryption `json:"disk_encryption"`
2023
}
2124

2225
// DiskFilesystem constants start with Filesystem and include Linode API Filesystems

instances.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ type Instance struct {
6363

6464
// NOTE: Placement Groups may not currently be available to all users.
6565
PlacementGroup *InstancePlacementGroup `json:"placement_group"`
66+
67+
// NOTE: Disk encryption may not currently be available to all users.
68+
DiskEncryption InstanceDiskEncryption `json:"disk_encryption"`
69+
70+
LKEClusterID int `json:"lke_cluster_id"`
6671
}
6772

6873
// InstanceSpec represents a linode spec
@@ -93,6 +98,13 @@ type InstanceBackup struct {
9398
} `json:"schedule,omitempty"`
9499
}
95100

101+
type InstanceDiskEncryption string
102+
103+
const (
104+
InstanceDiskEncryptionEnabled InstanceDiskEncryption = "enabled"
105+
InstanceDiskEncryptionDisabled InstanceDiskEncryption = "disabled"
106+
)
107+
96108
// InstanceTransfer pool stats for a Linode Instance during the current billing month
97109
type InstanceTransfer struct {
98110
// Bytes of transfer this instance has consumed
@@ -140,6 +152,9 @@ type InstanceCreateOptions struct {
140152
Metadata *InstanceMetadataOptions `json:"metadata,omitempty"`
141153
FirewallID int `json:"firewall_id,omitempty"`
142154

155+
// NOTE: Disk encryption may not currently be available to all users.
156+
DiskEncryption InstanceDiskEncryption `json:"disk_encryption,omitempty"`
157+
143158
// NOTE: Placement Groups may not currently be available to all users.
144159
PlacementGroup *InstanceCreatePlacementGroupOptions `json:"placement_group,omitempty"`
145160

@@ -356,6 +371,9 @@ type InstanceRebuildOptions struct {
356371
Booted *bool `json:"booted,omitempty"`
357372
Metadata *InstanceMetadataOptions `json:"metadata,omitempty"`
358373
Type string `json:"type,omitempty"`
374+
375+
// NOTE: Disk encryption may not currently be available to all users.
376+
DiskEncryption InstanceDiskEncryption `json:"disk_encryption,omitempty"`
359377
}
360378

361379
// RebuildInstance Deletes all Disks and Configs on this Linode,

k8s/pkg/condition/lke.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,39 @@ func ClusterHasReadyNode(ctx context.Context, options linodego.ClusterConditionO
3333
return false, nil
3434
}
3535

36+
// ClusterNodesReady is a ClusterConditionFunc which polls for all nodes to have the
37+
// condition NodeReady=True.
38+
func ClusterNodesReady(ctx context.Context, options linodego.ClusterConditionOptions) (bool, error) {
39+
clientset, err := k8s.BuildClientsetFromConfig(options.LKEClusterKubeconfig, options.TransportWrapper)
40+
if err != nil {
41+
return false, err
42+
}
43+
44+
nodes, err := clientset.CoreV1().Nodes().List(ctx, v1.ListOptions{})
45+
if err != nil {
46+
return false, fmt.Errorf("failed to get nodes for cluster: %w", err)
47+
}
48+
49+
for _, node := range nodes.Items {
50+
for _, condition := range node.Status.Conditions {
51+
if condition.Type == corev1.NodeReady && condition.Status != corev1.ConditionTrue {
52+
return false, nil
53+
}
54+
}
55+
}
56+
return true, nil
57+
}
58+
3659
// WaitForLKEClusterReady polls with a given timeout for the LKE Cluster's api-server
3760
// to be healthy and for the cluster to have at least one node with the NodeReady
3861
// condition true.
3962
func WaitForLKEClusterReady(ctx context.Context, client linodego.Client, clusterID int, options linodego.LKEClusterPollOptions) error {
4063
return client.WaitForLKEClusterConditions(ctx, clusterID, options, ClusterHasReadyNode)
4164
}
65+
66+
// WaitForLKEClusterAndNodesReady polls with a given timeout for the LKE
67+
// Cluster's api-server to be healthy and for all cluster nodes to have the
68+
// NodeReady condition true.
69+
func WaitForLKEClusterAndNodesReady(ctx context.Context, client linodego.Client, clusterID int, options linodego.LKEClusterPollOptions) error {
70+
return client.WaitForLKEClusterConditions(ctx, clusterID, options, ClusterNodesReady)
71+
}

lke_node_pools.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ type LKENodePool struct {
6464
Taints []LKENodePoolTaint `json:"taints"`
6565

6666
Autoscaler LKENodePoolAutoscaler `json:"autoscaler"`
67+
68+
// NOTE: Disk encryption may not currently be available to all users.
69+
DiskEncryption InstanceDiskEncryption `json:"disk_encryption,omitempty"`
6770
}
6871

6972
// LKENodePoolCreateOptions fields are those accepted by CreateLKENodePool

0 commit comments

Comments
 (0)