Skip to content

Commit

Permalink
Merge pull request #9793 from hakman/root-vol-encrypt
Browse files Browse the repository at this point in the history
Add flag for root volume encryption
  • Loading branch information
k8s-ci-robot committed Aug 21, 2020
2 parents 076df5e + 2880e22 commit 6c5150f
Show file tree
Hide file tree
Showing 16 changed files with 42 additions and 2 deletions.
4 changes: 4 additions & 0 deletions k8s/crds/kops.k8s.io_instancegroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,10 @@ spec:
NOTE: This setting applies only to the Launch Configuration and
does not affect Launch Templates.'
type: boolean
rootVolumeEncryption:
description: RootVolumeEncryption enables EBS root volume encryption
for an instance
type: boolean
rootVolumeIops:
description: If volume type is io1, then we need to specify the number
of Iops.
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/instancegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ type InstanceGroupSpec struct {
// The root volume is deleted by default. Cluster deletion does not remove retained root volumes.
// NOTE: This setting applies only to the Launch Configuration and does not affect Launch Templates.
RootVolumeDeleteOnTermination *bool `json:"rootVolumeDeleteOnTermination,omitempty"`
// RootVolumeEncryption enables EBS root volume encryption for an instance
RootVolumeEncryption *bool `json:"rootVolumeEncryption,omitempty"`
// Volumes is a collection of additional volumes to create for instances within this InstanceGroup
Volumes []*VolumeSpec `json:"volumes,omitempty"`
// VolumeMounts a collection of volume mounts
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha2/instancegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ type InstanceGroupSpec struct {
// The root volume is deleted by default. Cluster deletion does not remove retained root volumes.
// NOTE: This setting applies only to the Launch Configuration and does not affect Launch Templates.
RootVolumeDeleteOnTermination *bool `json:"rootVolumeDeleteOnTermination,omitempty"`
// RootVolumeEncryption enables EBS root volume encryption for an instance
RootVolumeEncryption *bool `json:"rootVolumeEncryption,omitempty"`
// Volumes is a collection of additional volumes to create for instances within this InstanceGroup
Volumes []*VolumeSpec `json:"volumes,omitempty"`
// VolumeMounts a collection of volume mounts
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/apis/kops/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/model/awsmodel/autoscalinggroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde
RootVolumeSize: lc.RootVolumeSize,
RootVolumeIops: lc.RootVolumeIops,
RootVolumeType: lc.RootVolumeType,
RootVolumeEncryption: lc.RootVolumeEncryption,
SSHKey: lc.SSHKey,
SecurityGroups: lc.SecurityGroups,
Tags: tags,
Expand Down Expand Up @@ -199,6 +200,7 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchConfigurationTask(c *fi.ModelB
RootVolumeOptimization: ig.Spec.RootVolumeOptimization,
RootVolumeSize: fi.Int64(int64(volumeSize)),
RootVolumeType: fi.String(volumeType),
RootVolumeEncryption: ig.Spec.RootVolumeEncryption,
SecurityGroups: []*awstasks.SecurityGroup{sgLink},
}

Expand Down
6 changes: 4 additions & 2 deletions tests/integration/update_cluster/complex/cloudformation.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@
"Ebs": {
"VolumeType": "gp2",
"VolumeSize": 64,
"DeleteOnTermination": true
"DeleteOnTermination": true,
"Encrypted": true
}
},
{
Expand Down Expand Up @@ -336,7 +337,8 @@
"Ebs": {
"VolumeType": "gp2",
"VolumeSize": 128,
"DeleteOnTermination": true
"DeleteOnTermination": true,
"Encrypted": true
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ spec:
- us-test-1a
detailedInstanceMonitoring: true
rootVolumeDeleteOnTermination: false
rootVolumeEncryption: true
volumes:
- device: /dev/xvdd
deleteOnTermination: false
Expand Down Expand Up @@ -114,6 +115,7 @@ spec:
maxSize: 1
minSize: 1
role: Master
rootVolumeEncryption: true
subnets:
- us-test-1a
additionalUserData:
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/update_cluster/complex/in-v1alpha2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ spec:
- us-test-1a
detailedInstanceMonitoring: true
rootVolumeDeleteOnTermination: false
rootVolumeEncryption: true
volumes:
- device: /dev/xvdd
deleteOnTermination: false
Expand Down Expand Up @@ -114,6 +115,7 @@ spec:
maxSize: 1
minSize: 1
role: Master
rootVolumeEncryption: true
subnets:
- us-test-1a
additionalUserData:
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/update_cluster/complex/kubernetes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ resource "aws_launch_template" "master-us-test-1a-masters-complex-example-com" {
device_name = "/dev/xvda"
ebs {
delete_on_termination = true
encrypted = true
volume_size = 64
volume_type = "gp2"
}
Expand Down Expand Up @@ -356,6 +357,7 @@ resource "aws_launch_template" "nodes-complex-example-com" {
device_name = "/dev/xvda"
ebs {
delete_on_termination = true
encrypted = true
volume_size = 128
volume_type = "gp2"
}
Expand Down
4 changes: 4 additions & 0 deletions upup/pkg/fi/cloudup/awstasks/launchconfiguration.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ type LaunchConfiguration struct {
RootVolumeSize *int64
// RootVolumeType is the type of the EBS root volume to use (e.g. gp2)
RootVolumeType *string
// RootVolumeEncryption enables EBS root volume encryption for an instance
RootVolumeEncryption *bool
// SSHKey is the ssh key for the instances
SSHKey *SSHKey
// SecurityGroups is a list of security group associated
Expand Down Expand Up @@ -201,6 +203,7 @@ func (e *LaunchConfiguration) Find(c *fi.Context) (*LaunchConfiguration, error)
actual.RootVolumeSize = b.Ebs.VolumeSize
actual.RootVolumeType = b.Ebs.VolumeType
actual.RootVolumeIops = b.Ebs.Iops
actual.RootVolumeEncryption = b.Ebs.Encrypted
actual.RootVolumeDeleteOnTermination = b.Ebs.DeleteOnTermination
} else {
_, d := BlockDeviceMappingFromAutoscaling(b)
Expand Down Expand Up @@ -386,6 +389,7 @@ func (t *LaunchConfiguration) buildRootDevice(cloud awsup.AWSCloud) (map[string]
EbsVolumeSize: t.RootVolumeSize,
EbsVolumeType: t.RootVolumeType,
EbsVolumeIops: t.RootVolumeIops,
EbsEncrypted: t.RootVolumeEncryption,
}

return bm, nil
Expand Down
3 changes: 3 additions & 0 deletions upup/pkg/fi/cloudup/awstasks/launchtemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ type LaunchTemplate struct {
RootVolumeSize *int64
// RootVolumeType is the type of the EBS root volume to use (e.g. gp2)
RootVolumeType *string
// RootVolumeEncryption enables EBS root volume encryption for an instance
RootVolumeEncryption *bool
// SSHKey is the ssh key for the instances
SSHKey *SSHKey
// SecurityGroups is a list of security group associated
Expand Down Expand Up @@ -113,6 +115,7 @@ func (t *LaunchTemplate) buildRootDevice(cloud awsup.AWSCloud) (map[string]*Bloc
EbsVolumeSize: t.RootVolumeSize,
EbsVolumeType: t.RootVolumeType,
EbsVolumeIops: t.RootVolumeIops,
EbsEncrypted: t.RootVolumeEncryption,
}

return bm, nil
Expand Down
1 change: 1 addition & 0 deletions upup/pkg/fi/cloudup/awstasks/launchtemplate_target_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ func (t *LaunchTemplate) Find(c *fi.Context) (*LaunchTemplate, error) {
actual.RootVolumeSize = b.Ebs.VolumeSize
actual.RootVolumeType = b.Ebs.VolumeType
actual.RootVolumeIops = b.Ebs.Iops
actual.RootVolumeEncryption = b.Ebs.Encrypted
} else {
_, d := BlockDeviceMappingFromLaunchTemplateBootDeviceRequest(b)
actual.BlockDeviceMappings = append(actual.BlockDeviceMappings, d)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ func (t *LaunchTemplate) RenderCloudformation(target *cloudformation.Cloudformat
IOPS: x.EbsVolumeIops,
VolumeSize: x.EbsVolumeSize,
VolumeType: x.EbsVolumeType,
Encrypted: x.EbsEncrypted,
},
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ func (t *LaunchTemplate) RenderTerraform(target *terraform.TerraformTarget, a, e
EBS: []*terraformLaunchTemplateBlockDeviceEBS{
{
DeleteOnTermination: fi.Bool(true),
Encrypted: x.EbsEncrypted,
IOPS: x.EbsVolumeIops,
VolumeSize: x.EbsVolumeSize,
VolumeType: x.EbsVolumeType,
Expand Down

0 comments on commit 6c5150f

Please sign in to comment.