Skip to content

Commit

Permalink
Set default volume encryption to "true" for etcd-manager volumes in AWS
Browse files Browse the repository at this point in the history
  • Loading branch information
hakman committed Jan 26, 2021
1 parent 97c40a3 commit fcea4f5
Show file tree
Hide file tree
Showing 15 changed files with 98 additions and 45 deletions.
7 changes: 6 additions & 1 deletion cmd/kops/create_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func NewCmdCreateCluster(f *util.Factory, out io.Writer) *cobra.Command {

sshPublicKey := ""
associatePublicIP := false
encryptEtcdStorage := false

cmd := &cobra.Command{
Use: "cluster",
Expand All @@ -180,6 +181,10 @@ func NewCmdCreateCluster(f *util.Factory, out io.Writer) *cobra.Command {
options.AssociatePublicIP = &associatePublicIP
}

if cmd.Flag("encrypt-etcd-storage").Changed {
options.EncryptEtcdStorage = &encryptEtcdStorage
}

err := rootCommand.ProcessArgs(args)
if err != nil {
exitWithError(err)
Expand Down Expand Up @@ -244,7 +249,7 @@ func NewCmdCreateCluster(f *util.Factory, out io.Writer) *cobra.Command {
cmd.Flags().StringVar(&options.NetworkCIDR, "network-cidr", options.NetworkCIDR, "Set to override the default network CIDR")
cmd.Flags().BoolVar(&options.DisableSubnetTags, "disable-subnet-tags", options.DisableSubnetTags, "Set to disable automatic subnet tagging")

cmd.Flags().BoolVar(&options.EncryptEtcdStorage, "encrypt-etcd-storage", options.EncryptEtcdStorage, "Generate key in aws kms and use it for encrypt etcd volumes")
cmd.Flags().BoolVar(&encryptEtcdStorage, "encrypt-etcd-storage", false, "Generate key in aws kms and use it for encrypt etcd volumes")
cmd.Flags().StringVar(&options.EtcdStorageType, "etcd-storage-type", options.EtcdStorageType, "The default storage type for etc members")

cmd.Flags().StringVar(&options.Networking, "networking", options.Networking, "Networking mode to use. kubenet, external, weave, flannel-vxlan (or flannel), flannel-udp, calico, canal, kube-router, amazonvpc, cilium, cilium-etcd, cni, lyftvpc.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ spec:
etcdClusters:
- cpuRequest: 200m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: main
- cpuRequest: 100m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: events
Expand Down
18 changes: 12 additions & 6 deletions tests/integration/create_cluster/ha/expected-v1alpha2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,27 @@ spec:
etcdClusters:
- cpuRequest: 200m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
- instanceGroup: master-us-test-1b
- encryptedVolume: true
instanceGroup: master-us-test-1b
name: b
- instanceGroup: master-us-test-1c
- encryptedVolume: true
instanceGroup: master-us-test-1c
name: c
memoryRequest: 100Mi
name: main
- cpuRequest: 100m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
- instanceGroup: master-us-test-1b
- encryptedVolume: true
instanceGroup: master-us-test-1b
name: b
- instanceGroup: master-us-test-1c
- encryptedVolume: true
instanceGroup: master-us-test-1c
name: c
memoryRequest: 100Mi
name: events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,27 @@ spec:
etcdClusters:
- cpuRequest: 200m
etcdMembers:
- instanceGroup: master-us-test-1a-1
- encryptedVolume: true
instanceGroup: master-us-test-1a-1
name: etcd-1
- instanceGroup: master-us-test-1a-2
- encryptedVolume: true
instanceGroup: master-us-test-1a-2
name: etcd-2
- instanceGroup: master-us-test-1a-3
- encryptedVolume: true
instanceGroup: master-us-test-1a-3
name: etcd-3
memoryRequest: 100Mi
name: main
- cpuRequest: 100m
etcdMembers:
- instanceGroup: master-us-test-1a-1
- encryptedVolume: true
instanceGroup: master-us-test-1a-1
name: etcd-1
- instanceGroup: master-us-test-1a-2
- encryptedVolume: true
instanceGroup: master-us-test-1a-2
name: etcd-2
- instanceGroup: master-us-test-1a-3
- encryptedVolume: true
instanceGroup: master-us-test-1a-3
name: etcd-3
memoryRequest: 100Mi
name: events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,39 @@ spec:
etcdClusters:
- cpuRequest: 200m
etcdMembers:
- instanceGroup: master-us-test-1a-1
- encryptedVolume: true
instanceGroup: master-us-test-1a-1
name: a-1
- instanceGroup: master-us-test-1b-1
- encryptedVolume: true
instanceGroup: master-us-test-1b-1
name: b-1
- instanceGroup: master-us-test-1a-2
- encryptedVolume: true
instanceGroup: master-us-test-1a-2
name: a-2
- instanceGroup: master-us-test-1b-2
- encryptedVolume: true
instanceGroup: master-us-test-1b-2
name: b-2
- instanceGroup: master-us-test-1a-3
- encryptedVolume: true
instanceGroup: master-us-test-1a-3
name: a-3
memoryRequest: 100Mi
name: main
- cpuRequest: 100m
etcdMembers:
- instanceGroup: master-us-test-1a-1
- encryptedVolume: true
instanceGroup: master-us-test-1a-1
name: a-1
- instanceGroup: master-us-test-1b-1
- encryptedVolume: true
instanceGroup: master-us-test-1b-1
name: b-1
- instanceGroup: master-us-test-1a-2
- encryptedVolume: true
instanceGroup: master-us-test-1a-2
name: a-2
- instanceGroup: master-us-test-1b-2
- encryptedVolume: true
instanceGroup: master-us-test-1b-2
name: b-2
- instanceGroup: master-us-test-1a-3
- encryptedVolume: true
instanceGroup: master-us-test-1a-3
name: a-3
memoryRequest: 100Mi
name: events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ spec:
etcdClusters:
- cpuRequest: 200m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: main
- cpuRequest: 100m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ spec:
etcdClusters:
- cpuRequest: 200m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: main
- cpuRequest: 100m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ spec:
etcdClusters:
- cpuRequest: 200m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: main
- cpuRequest: 100m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ spec:
etcdClusters:
- cpuRequest: 200m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: main
- cpuRequest: 100m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ spec:
etcdClusters:
- cpuRequest: 200m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: main
- cpuRequest: 100m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ spec:
etcdClusters:
- cpuRequest: 200m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: main
- cpuRequest: 100m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ spec:
etcdClusters:
- cpuRequest: 200m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: main
- cpuRequest: 100m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ spec:
etcdClusters:
- cpuRequest: 200m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: main
- cpuRequest: 100m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ spec:
etcdClusters:
- cpuRequest: 200m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: main
- cpuRequest: 100m
etcdMembers:
- instanceGroup: master-us-test-1a
- encryptedVolume: true
instanceGroup: master-us-test-1a
name: a
memoryRequest: 100Mi
name: events
Expand Down
10 changes: 8 additions & 2 deletions upup/pkg/fi/cloudup/new_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ type NewClusterOptions struct {
// if MasterZones is explicitly nonempty, otherwise defaults to 1.
MasterCount int32
// EncryptEtcdStorage is whether to encrypt the etcd volumes.
EncryptEtcdStorage bool
EncryptEtcdStorage *bool
// EtcdStorageType is the underlying cloud storage class of the etcd volumes.
EtcdStorageType string

Expand Down Expand Up @@ -706,8 +706,14 @@ func setupMasters(opt *NewClusterOptions, cluster *api.Cluster, zoneToSubnetMap
clusters = append(clusters, "cilium")
}

encryptEtcdStorage := false
if opt.EncryptEtcdStorage != nil {
encryptEtcdStorage = fi.BoolValue(opt.EncryptEtcdStorage)
} else if api.CloudProviderID(cluster.Spec.CloudProvider) == api.CloudProviderAWS {
encryptEtcdStorage = true
}
for _, etcdCluster := range clusters {
etcd := createEtcdCluster(etcdCluster, masters, opt.EncryptEtcdStorage, opt.EtcdStorageType)
etcd := createEtcdCluster(etcdCluster, masters, encryptEtcdStorage, opt.EtcdStorageType)
cluster.Spec.EtcdClusters = append(cluster.Spec.EtcdClusters, etcd)
}
}
Expand Down

0 comments on commit fcea4f5

Please sign in to comment.