feat: EncryptionAtHost support (#3041)

This commit is contained in:
Andy Zhang 2020-04-09 08:38:03 +08:00 коммит произвёл GitHub
Родитель 5a34150f0e
Коммит 51bde0dbbe
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 67 добавлений и 13 удалений

Просмотреть файл

@ -523,6 +523,7 @@ func convertMasterProfileToVLabs(api *MasterProfile, vlabsProfile *vlabs.MasterP
vlabsProfile.CosmosEtcd = api.CosmosEtcd vlabsProfile.CosmosEtcd = api.CosmosEtcd
vlabsProfile.AuditDEnabled = api.AuditDEnabled vlabsProfile.AuditDEnabled = api.AuditDEnabled
vlabsProfile.UltraSSDEnabled = api.UltraSSDEnabled vlabsProfile.UltraSSDEnabled = api.UltraSSDEnabled
vlabsProfile.EncryptionAtHost = api.EncryptionAtHost
convertCustomFilesToVlabs(api, vlabsProfile) convertCustomFilesToVlabs(api, vlabsProfile)
vlabsProfile.SysctlDConfig = map[string]string{} vlabsProfile.SysctlDConfig = map[string]string{}
for key, val := range api.SysctlDConfig { for key, val := range api.SysctlDConfig {
@ -574,6 +575,7 @@ func convertAgentPoolProfileToVLabs(api *AgentPoolProfile, p *vlabs.AgentPoolPro
p.AuditDEnabled = api.AuditDEnabled p.AuditDEnabled = api.AuditDEnabled
p.UltraSSDEnabled = api.UltraSSDEnabled p.UltraSSDEnabled = api.UltraSSDEnabled
p.DiskEncryptionSetID = api.DiskEncryptionSetID p.DiskEncryptionSetID = api.DiskEncryptionSetID
p.EncryptionAtHost = api.EncryptionAtHost
for k, v := range api.CustomNodeLabels { for k, v := range api.CustomNodeLabels {
p.CustomNodeLabels[k] = v p.CustomNodeLabels[k] = v

Просмотреть файл

@ -579,6 +579,7 @@ func convertVLabsMasterProfile(vlabs *vlabs.MasterProfile, api *MasterProfile) {
api.SinglePlacementGroup = vlabs.SinglePlacementGroup api.SinglePlacementGroup = vlabs.SinglePlacementGroup
api.CosmosEtcd = vlabs.CosmosEtcd api.CosmosEtcd = vlabs.CosmosEtcd
api.UltraSSDEnabled = vlabs.UltraSSDEnabled api.UltraSSDEnabled = vlabs.UltraSSDEnabled
api.EncryptionAtHost = vlabs.EncryptionAtHost
api.AuditDEnabled = vlabs.AuditDEnabled api.AuditDEnabled = vlabs.AuditDEnabled
convertCustomFilesToAPI(vlabs, api) convertCustomFilesToAPI(vlabs, api)
api.SysctlDConfig = map[string]string{} api.SysctlDConfig = map[string]string{}
@ -620,6 +621,7 @@ func convertVLabsAgentPoolProfile(vlabs *vlabs.AgentPoolProfile, api *AgentPoolP
api.AuditDEnabled = vlabs.AuditDEnabled api.AuditDEnabled = vlabs.AuditDEnabled
api.DiskEncryptionSetID = vlabs.DiskEncryptionSetID api.DiskEncryptionSetID = vlabs.DiskEncryptionSetID
api.UltraSSDEnabled = vlabs.UltraSSDEnabled api.UltraSSDEnabled = vlabs.UltraSSDEnabled
api.EncryptionAtHost = vlabs.EncryptionAtHost
api.CustomNodeLabels = map[string]string{} api.CustomNodeLabels = map[string]string{}
for k, v := range vlabs.CustomNodeLabels { for k, v := range vlabs.CustomNodeLabels {

Просмотреть файл

@ -572,6 +572,7 @@ type MasterProfile struct {
SinglePlacementGroup *bool `json:"singlePlacementGroup,omitempty"` SinglePlacementGroup *bool `json:"singlePlacementGroup,omitempty"`
AuditDEnabled *bool `json:"auditDEnabled,omitempty"` AuditDEnabled *bool `json:"auditDEnabled,omitempty"`
UltraSSDEnabled *bool `json:"ultraSSDEnabled,omitempty"` UltraSSDEnabled *bool `json:"ultraSSDEnabled,omitempty"`
EncryptionAtHost *bool `json:"encryptionAtHost,omitempty"`
CustomVMTags map[string]string `json:"customVMTags,omitempty"` CustomVMTags map[string]string `json:"customVMTags,omitempty"`
// Master LB public endpoint/FQDN with port // Master LB public endpoint/FQDN with port
// The format will be FQDN:2376 // The format will be FQDN:2376
@ -658,6 +659,7 @@ type AgentPoolProfile struct {
DiskEncryptionSetID string `json:"diskEncryptionSetID,omitempty"` DiskEncryptionSetID string `json:"diskEncryptionSetID,omitempty"`
SysctlDConfig map[string]string `json:"sysctldConfig,omitempty"` SysctlDConfig map[string]string `json:"sysctldConfig,omitempty"`
UltraSSDEnabled *bool `json:"ultraSSDEnabled,omitempty"` UltraSSDEnabled *bool `json:"ultraSSDEnabled,omitempty"`
EncryptionAtHost *bool `json:"encryptionAtHost,omitempty"`
} }
// AgentPoolProfileRole represents an agent role // AgentPoolProfileRole represents an agent role

Просмотреть файл

@ -684,17 +684,18 @@ func TestMasterProfileGetCosmosEndPointURI(t *testing.T) {
func TestHasStorageProfile(t *testing.T) { func TestHasStorageProfile(t *testing.T) {
cases := []struct { cases := []struct {
name string name string
p Properties p Properties
expectedHasMD bool expectedHasMD bool
expectedHasSA bool expectedHasSA bool
expectedMasterMD bool expectedMasterMD bool
expectedAgent0E bool expectedAgent0E bool
expectedAgent0MD bool expectedAgent0MD bool
expectedPrivateJB bool expectedPrivateJB bool
expectedHasDisks bool expectedHasDisks bool
expectedDesID string expectedDesID string
expectedUltraSSDEnabled bool expectedUltraSSDEnabled bool
expectedEncryptionAtHost bool
}{ }{
{ {
name: "Storage Account", name: "Storage Account",
@ -925,6 +926,35 @@ func TestHasStorageProfile(t *testing.T) {
expectedPrivateJB: false, expectedPrivateJB: false,
expectedUltraSSDEnabled: true, expectedUltraSSDEnabled: true,
}, },
{
name: "EncryptionAtHost setting",
p: Properties{
OrchestratorProfile: &OrchestratorProfile{
OrchestratorType: Kubernetes,
},
MasterProfile: &MasterProfile{
StorageProfile: ManagedDisks,
EncryptionAtHost: to.BoolPtr(true),
},
AgentPoolProfiles: []*AgentPoolProfile{
{
StorageProfile: ManagedDisks,
EncryptionAtHost: to.BoolPtr(true),
},
{
StorageProfile: ManagedDisks,
EncryptionAtHost: to.BoolPtr(true),
},
},
},
expectedHasMD: true,
expectedHasSA: false,
expectedMasterMD: true,
expectedAgent0MD: true,
expectedAgent0E: false,
expectedPrivateJB: false,
expectedEncryptionAtHost: true,
},
} }
for _, c := range cases { for _, c := range cases {
@ -946,6 +976,9 @@ func TestHasStorageProfile(t *testing.T) {
if to.Bool(c.p.MasterProfile.UltraSSDEnabled) != c.expectedUltraSSDEnabled { if to.Bool(c.p.MasterProfile.UltraSSDEnabled) != c.expectedUltraSSDEnabled {
t.Fatalf("expected UltraSSDEnabled to return %v but instead returned %v", c.expectedUltraSSDEnabled, to.Bool(c.p.MasterProfile.UltraSSDEnabled)) t.Fatalf("expected UltraSSDEnabled to return %v but instead returned %v", c.expectedUltraSSDEnabled, to.Bool(c.p.MasterProfile.UltraSSDEnabled))
} }
if to.Bool(c.p.MasterProfile.EncryptionAtHost) != c.expectedEncryptionAtHost {
t.Fatalf("expected EncryptionAtHost to return %v but instead returned %v", c.expectedEncryptionAtHost, to.Bool(c.p.MasterProfile.EncryptionAtHost))
}
if c.p.AgentPoolProfiles[0].IsManagedDisks() != c.expectedAgent0MD { if c.p.AgentPoolProfiles[0].IsManagedDisks() != c.expectedAgent0MD {
t.Fatalf("expected IsManagedDisks() to return %t but instead returned %t", c.expectedAgent0MD, c.p.AgentPoolProfiles[0].IsManagedDisks()) t.Fatalf("expected IsManagedDisks() to return %t but instead returned %t", c.expectedAgent0MD, c.p.AgentPoolProfiles[0].IsManagedDisks())
} }
@ -968,6 +1001,9 @@ func TestHasStorageProfile(t *testing.T) {
if to.Bool(c.p.AgentPoolProfiles[0].UltraSSDEnabled) != c.expectedUltraSSDEnabled { if to.Bool(c.p.AgentPoolProfiles[0].UltraSSDEnabled) != c.expectedUltraSSDEnabled {
t.Fatalf("expected UltraSSDEnabled to return %v but instead returned %v", c.expectedUltraSSDEnabled, to.Bool(c.p.AgentPoolProfiles[0].UltraSSDEnabled)) t.Fatalf("expected UltraSSDEnabled to return %v but instead returned %v", c.expectedUltraSSDEnabled, to.Bool(c.p.AgentPoolProfiles[0].UltraSSDEnabled))
} }
if to.Bool(c.p.AgentPoolProfiles[0].EncryptionAtHost) != c.expectedEncryptionAtHost {
t.Fatalf("expected EncryptionAtHost to return %v but instead returned %v", c.expectedUltraSSDEnabled, to.Bool(c.p.AgentPoolProfiles[0].UltraSSDEnabled))
}
}) })
} }
} }

Просмотреть файл

@ -438,6 +438,7 @@ type MasterProfile struct {
CustomVMTags map[string]string `json:"customVMTags,omitempty"` CustomVMTags map[string]string `json:"customVMTags,omitempty"`
SysctlDConfig map[string]string `json:"sysctldConfig,omitempty"` SysctlDConfig map[string]string `json:"sysctldConfig,omitempty"`
UltraSSDEnabled *bool `json:"ultraSSDEnabled,omitempty"` UltraSSDEnabled *bool `json:"ultraSSDEnabled,omitempty"`
EncryptionAtHost *bool `json:"encryptionAtHost,omitempty"`
// subnet is internal // subnet is internal
subnet string subnet string
@ -509,6 +510,7 @@ type AgentPoolProfile struct {
CustomVMTags map[string]string `json:"customVMTags,omitempty"` CustomVMTags map[string]string `json:"customVMTags,omitempty"`
DiskEncryptionSetID string `json:"diskEncryptionSetID,omitempty"` DiskEncryptionSetID string `json:"diskEncryptionSetID,omitempty"`
UltraSSDEnabled *bool `json:"ultraSSDEnabled,omitempty"` UltraSSDEnabled *bool `json:"ultraSSDEnabled,omitempty"`
EncryptionAtHost *bool `json:"encryptionAtHost,omitempty"`
// subnet is internal // subnet is internal
subnet string subnet string

Просмотреть файл

@ -145,6 +145,10 @@ func TestAgentPoolProfile(t *testing.T) {
t.Fatalf("AgentPoolProfile.UltraSSDEnabled should be false by default") t.Fatalf("AgentPoolProfile.UltraSSDEnabled should be false by default")
} }
if to.Bool(ap.EncryptionAtHost) {
t.Fatalf("AgentPoolProfile.EncryptionAtHost should be false by default")
}
// With osType Windows // With osType Windows
AgentPoolProfileText = `{ "name": "linuxpool1", "osType" : "Windows", "count": 1, "vmSize": "Standard_D2_v2", AgentPoolProfileText = `{ "name": "linuxpool1", "osType" : "Windows", "count": 1, "vmSize": "Standard_D2_v2",
"availabilityProfile": "AvailabilitySet", "storageProfile" : "ManagedDisks", "vnetSubnetID" : "12345" }` "availabilityProfile": "AvailabilitySet", "storageProfile" : "ManagedDisks", "vnetSubnetID" : "12345" }`
@ -167,7 +171,7 @@ func TestAgentPoolProfile(t *testing.T) {
// With osType Windows and Ephemeral disks // With osType Windows and Ephemeral disks
AgentPoolProfileText = `{ "name": "linuxpool1", "osType" : "Windows", "count": 1, "vmSize": "Standard_D2_v2", AgentPoolProfileText = `{ "name": "linuxpool1", "osType" : "Windows", "count": 1, "vmSize": "Standard_D2_v2",
"availabilityProfile": "AvailabilitySet", "storageProfile" : "Ephemeral", "vnetSubnetID" : "12345", "diskEncryptionSetID": "diskEncryptionSetID", "ultraSSDEnabled": true }` "availabilityProfile": "AvailabilitySet", "storageProfile" : "Ephemeral", "vnetSubnetID" : "12345", "diskEncryptionSetID": "diskEncryptionSetID", "ultraSSDEnabled": true, "encryptionAtHost": true }`
ap = &AgentPoolProfile{} ap = &AgentPoolProfile{}
if e := json.Unmarshal([]byte(AgentPoolProfileText), ap); e != nil { if e := json.Unmarshal([]byte(AgentPoolProfileText), ap); e != nil {
t.Fatalf("unexpectedly detected unmarshal failure for AgentPoolProfile, %+v", e) t.Fatalf("unexpectedly detected unmarshal failure for AgentPoolProfile, %+v", e)
@ -197,6 +201,9 @@ func TestAgentPoolProfile(t *testing.T) {
t.Fatalf("AgentPoolProfile.UltraSSDEnabled should be true after unmarshal") t.Fatalf("AgentPoolProfile.UltraSSDEnabled should be true after unmarshal")
} }
if !to.Bool(ap.EncryptionAtHost) {
t.Fatalf("AgentPoolProfile.EncryptionAtHost should be true after unmarshal")
}
// With osType Linux and RHEL distro // With osType Linux and RHEL distro
AgentPoolProfileText = `{ "name": "linuxpool1", "osType" : "Linux", "distro" : "rhel", "count": 1, "vmSize": "Standard_D2_v2", AgentPoolProfileText = `{ "name": "linuxpool1", "osType" : "Linux", "distro" : "rhel", "count": 1, "vmSize": "Standard_D2_v2",
"availabilityProfile": "AvailabilitySet", "storageProfile" : "ManagedDisks", "vnetSubnetID" : "12345", "diskEncryptionSetID": "diskEncryptionSetID" }` "availabilityProfile": "AvailabilitySet", "storageProfile" : "ManagedDisks", "vnetSubnetID" : "12345", "diskEncryptionSetID": "diskEncryptionSetID" }`
@ -231,7 +238,7 @@ func TestAgentPoolProfile(t *testing.T) {
// With VMSS and Spot VMs // With VMSS and Spot VMs
AgentPoolProfileText = `{"name":"linuxpool1","osType":"Linux","distro":"rhel","count":1,"vmSize":"Standard_D2_v2", AgentPoolProfileText = `{"name":"linuxpool1","osType":"Linux","distro":"rhel","count":1,"vmSize":"Standard_D2_v2",
"availabilityProfile":"VirtualMachineScaleSets","scaleSetPriority":"Spot","ScaleSetEvictionPolicy":"Delete","SpotMaxPrice":88, "ultraSSDEnabled": true}` "availabilityProfile":"VirtualMachineScaleSets","scaleSetPriority":"Spot","ScaleSetEvictionPolicy":"Delete","SpotMaxPrice":88, "ultraSSDEnabled": true, "encryptionAtHost": true}`
ap = &AgentPoolProfile{} ap = &AgentPoolProfile{}
if e := json.Unmarshal([]byte(AgentPoolProfileText), ap); e != nil { if e := json.Unmarshal([]byte(AgentPoolProfileText), ap); e != nil {
t.Fatalf("unexpectedly detected unmarshal failure for AgentPoolProfile, %+v", e) t.Fatalf("unexpectedly detected unmarshal failure for AgentPoolProfile, %+v", e)
@ -253,6 +260,9 @@ func TestAgentPoolProfile(t *testing.T) {
t.Fatalf("AgentPoolProfile.UltraSSDEnabled should be true after unmarshal") t.Fatalf("AgentPoolProfile.UltraSSDEnabled should be true after unmarshal")
} }
if !to.Bool(ap.EncryptionAtHost) {
t.Fatalf("AgentPoolProfile.EncryptionAtHost should be true after unmarshal")
}
// With osType Linux and coreos distro // With osType Linux and coreos distro
AgentPoolProfileText = `{ "name": "linuxpool1", "osType" : "Linux", "distro" : "coreos", "count": 1, "vmSize": "Standard_D2_v2", AgentPoolProfileText = `{ "name": "linuxpool1", "osType" : "Linux", "distro" : "coreos", "count": 1, "vmSize": "Standard_D2_v2",
"availabilityProfile": "VirtualMachineScaleSets", "storageProfile" : "ManagedDisks", "diskSizesGB" : [750, 250, 600, 1000], "diskEncryptionSetID": "diskEncryptionSetID" }` "availabilityProfile": "VirtualMachineScaleSets", "storageProfile" : "ManagedDisks", "diskSizesGB" : [750, 250, 600, 1000], "diskEncryptionSetID": "diskEncryptionSetID" }`