Skip to content

Commit

Permalink
Merge pull request #6698 from eranco74/MGMT-12839
Browse files Browse the repository at this point in the history
MGMT-12839: Add Shielded VMs options to gcp mpool and TF
  • Loading branch information
openshift-merge-robot authored Jan 12, 2023
2 parents 68d2bd6 + a0b9c49 commit 8c83507
Show file tree
Hide file tree
Showing 78 changed files with 9,978 additions and 13,811 deletions.
1 change: 1 addition & 0 deletions data/data/gcp/cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module "master" {
ignition = var.ignition_master
subnet = module.network.master_subnet
zones = distinct(var.gcp_master_availability_zones)
secure_boot = var.gcp_master_secure_boot

root_volume_size = var.gcp_master_root_volume_size
root_volume_type = var.gcp_master_root_volume_type
Expand Down
9 changes: 9 additions & 0 deletions data/data/gcp/cluster/master/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,15 @@ resource "google_compute_instance" "master" {
kms_key_self_link = var.root_volume_kms_key_link
}


dynamic "shielded_instance_config" {
for_each = var.secure_boot != "" ? [1] : []

content {
enable_secure_boot = var.secure_boot == "Enabled"
}
}

network_interface {
subnetwork = var.subnet
}
Expand Down
6 changes: 6 additions & 0 deletions data/data/gcp/cluster/master/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,9 @@ variable "root_volume_kms_key_link" {
variable "zones" {
type = list
}

variable "secure_boot" {
type = string
description = "Verify the digital signature of all boot components."
default = ""
}
6 changes: 6 additions & 0 deletions data/data/gcp/variables-gcp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,9 @@ variable "gcp_private_zone_project" {
default = ""
description = "Project where the private managed zone will exist."
}

variable "gcp_master_secure_boot" {
type = string
description = "Verify the digital signature of all boot components."
default = ""
}
35 changes: 35 additions & 0 deletions data/data/install.openshift.io_installconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ spec:
- Insights
- Storage
- CSISnapshot
- NodeTuning
type: string
type: array
baselineCapabilitySet:
Expand All @@ -84,6 +85,7 @@ spec:
- None
- v4.11
- v4.12
- v4.13
- vCurrent
type: string
type: object
Expand Down Expand Up @@ -391,6 +393,17 @@ spec:
required:
- DiskSizeGB
type: object
secureBoot:
description: SecureBoot Defines whether the instance should
have secure boot enabled. secure boot Verify the digital
signature of all boot components, and halt the boot process
if signature verification fails. If omitted, the platform
chooses a default, which is subject to change over time,
currently that default is false.
enum:
- Enabled
- Disabled
type: string
tags:
description: Tags defines a set of network tags which will
be added to instances in the machineset
Expand Down Expand Up @@ -1038,6 +1051,17 @@ spec:
required:
- DiskSizeGB
type: object
secureBoot:
description: SecureBoot Defines whether the instance should
have secure boot enabled. secure boot Verify the digital
signature of all boot components, and halt the boot process
if signature verification fails. If omitted, the platform
chooses a default, which is subject to change over time,
currently that default is false.
enum:
- Enabled
- Disabled
type: string
tags:
description: Tags defines a set of network tags which will
be added to instances in the machineset
Expand Down Expand Up @@ -2264,6 +2288,17 @@ spec:
required:
- DiskSizeGB
type: object
secureBoot:
description: SecureBoot Defines whether the instance should
have secure boot enabled. secure boot Verify the digital
signature of all boot components, and halt the boot process
if signature verification fails. If omitted, the platform
chooses a default, which is subject to change over time,
currently that default is false.
enum:
- Enabled
- Disabled
type: string
tags:
description: Tags defines a set of network tags which will
be added to instances in the machineset
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ require (
github.com/microsoft/kiota-authentication-azure-go v0.5.0
github.com/microsoftgraph/msgraph-sdk-go v0.47.0
github.com/nutanix-cloud-native/prism-go-client v0.2.1-0.20220804130801-c8a253627c64
github.com/openshift/api v3.9.1-0.20191111211345-a27ff30ebf09+incompatible
github.com/openshift/api v0.0.0-20230110144457-3299573be149
github.com/openshift/assisted-image-service v0.0.0-20220506122314-2f689a1084b8
github.com/openshift/assisted-service v0.0.0-20220928142635-a40422bdea61
github.com/openshift/assisted-service/api v0.0.0
Expand Down Expand Up @@ -263,7 +263,7 @@ replace sigs.k8s.io/controller-tools => sigs.k8s.io/controller-tools v0.3.1-0.20

// Override the OpenShift API version in hive

replace github.com/openshift/api => github.com/openshift/api v0.0.0-20221004120407-c46852673d03
replace github.com/openshift/api => github.com/openshift/api v0.0.0-20230110144457-3299573be149

replace github.com/terraform-providers/terraform-provider-nutanix => github.com/nutanix/terraform-provider-nutanix v1.5.0

Expand Down
15 changes: 2 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,6 @@ github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/daixiang0/gci v0.9.0 h1:t8XZ0vK6l0pwPoOmoGyqW2NwQlvbpAQNVvu/GRBgykM=
github.com/daixiang0/gci v0.9.0/go.mod h1:EpVfrztufwVgQRXjnX4zuNinEpLj5OmMjtu/+MB0V0c=
github.com/dave/dst v0.26.2/go.mod h1:UMDJuIRPfyUCC78eFuB+SV/WI8oDeyFDvM/JR6NI3IU=
github.com/dave/gopackages v0.0.0-20170318123100-46e7023ec56e/go.mod h1:i00+b/gKdIDIxuLDFob7ustLAVqhsZRk2qVZrArELGQ=
github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg=
github.com/dave/kerr v0.0.0-20170318121727-bc25dd6abe8e/go.mod h1:qZqlPyPvfsDJt+3wHJ1EvSXDuVjFTK0j2p/ca+gtsb8=
github.com/dave/rebecca v0.9.1/go.mod h1:N6XYdMD/OKw3lkF3ywh8Z6wPGuwNFDNtWYEMFWEmXBA=
github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
Expand Down Expand Up @@ -753,7 +748,6 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk=
github.com/google/pprof v0.0.0-20181127221834-b4f47329b966/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
Expand Down Expand Up @@ -1143,8 +1137,8 @@ github.com/opencontainers/runc v1.0.0-rc90/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2r
github.com/opencontainers/runc v1.1.2 h1:2VSZwLx5k/BfsBxMMipG/LYUnmqOD/BPkIVgQUcTlLw=
github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/opencontainers/selinux v1.5.2/go.mod h1:yTcKuYAh6R95iDpefGLQaPaRwJFwyzAJufJyiTt7s0g=
github.com/openshift/api v0.0.0-20221004120407-c46852673d03 h1:e8oBXPs3eCJWIeEVw29l+GLvxdo3BPhdpkUd/FzPjeg=
github.com/openshift/api v0.0.0-20221004120407-c46852673d03/go.mod h1:JRz+ZvTqu9u7t6suhhPTacbFl5K65Y6rJbNM7HjWA3g=
github.com/openshift/api v0.0.0-20230110144457-3299573be149 h1:xZhvbDxFT0620YRTSfq0IcU+kesiU0nZeHbHEn7qyt0=
github.com/openshift/api v0.0.0-20230110144457-3299573be149/go.mod h1:OW9hi5XDXOQWm/kRqUww6RVxZSf0nqrS4heerSmHBC4=
github.com/openshift/assisted-image-service v0.0.0-20220506122314-2f689a1084b8 h1:oZ3VAWiM8tPRBM+vYI4GBmlrqyoqizcgZ7pBy5EX2K8=
github.com/openshift/assisted-image-service v0.0.0-20220506122314-2f689a1084b8/go.mod h1:bH4+AsmPy8mQQvtgedBm2Crs93TDWeXEMlIPrlEMpjA=
github.com/openshift/assisted-service v0.0.0-20220928142635-a40422bdea61 h1:HtUYJBAdRgfVYide0bq3GsT/4n5uPWteA1rIZVXEL7k=
Expand All @@ -1161,7 +1155,6 @@ github.com/openshift/baremetal-operator/pkg/hardwareutils v0.0.0-20220128094204-
github.com/openshift/baremetal-operator/pkg/hardwareutils v0.0.0-20220128094204-28771f489634/go.mod h1:/PSTQInIZmfuOmAp/pSgZAs4txs6T49woC0MYIa4QzE=
github.com/openshift/build-machinery-go v0.0.0-20200211121458-5e3d6e570160/go.mod h1:1CkcsT3aVebzRBzVTSbiKSkJMsC/CASqxesfqEMfJEc=
github.com/openshift/build-machinery-go v0.0.0-20200819073603-48aa266c95f7/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE=
github.com/openshift/build-machinery-go v0.0.0-20220913142420-e25cf57ea46d/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE=
github.com/openshift/client-go v0.0.0-20200827190008-3062137373b5/go.mod h1:5rGmrkQ8DJEUXA+AR3rEjfH+HFyg4/apY9iCQFgvPfE=
github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3 h1:SG1aqwleU6bGD0X4mhkTNupjVnByMYYuW4XbnCPavQU=
github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3/go.mod h1:cwhyki5lqBmrT0m8Im+9I7PGFaraOzcYPtEz93RcsGY=
Expand Down Expand Up @@ -1559,7 +1552,6 @@ go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE=
go4.org v0.0.0-20200104003542-c7e774b10ea0/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE=
goji.io v2.0.2+incompatible/go.mod h1:sbqFwrtqZACxLBTQcdgVjFh54yGVCvwq8+w49MVMMIk=
golang.org/x/arch v0.0.0-20180920145803-b19384d3c130/go.mod h1:cYlCBUl1MsqxdiKgmc4uh7TxZfWSFLOGSRR090WDxt8=
golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw=
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd h1:XcWmESyNjXJMLahc3mqVQJcgSTDxFxhETVlfk9uGc38=
golang.org/x/crypto v0.0.0-20220315160706-3147a52a75dd/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
Expand Down Expand Up @@ -1728,7 +1720,6 @@ golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20171026204733-164713f0dfce/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180903190138-2b024373dcd9/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181021155630-eda9bb28ed51/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -1921,7 +1912,6 @@ golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjs
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200505023115-26f46d2f7ef8/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20200601175630-2caf76543d99/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
Expand Down Expand Up @@ -2201,7 +2191,6 @@ gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/square/go-jose.v2 v2.2.2/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/square/go-jose.v2 v2.3.1/go.mod h1:M9dMgbHiYLoDGQrXy7OpJDJWiKiU//h+vD76mk0e1AI=
gopkg.in/src-d/go-billy.v4 v4.3.0/go.mod h1:tm33zBoOwxjYHZIE+OV8bxTWFMJLrconzFMd38aARFk=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
Expand Down
16 changes: 10 additions & 6 deletions pkg/asset/machines/gcp/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ func provider(clusterID string, platform *gcp.Platform, mpool *gcp.MachinePool,
return nil, errors.New("could not find google service account")
}
}

shieldedInstanceConfig := machineapi.GCPShieldedInstanceConfig{}
if mpool.SecureBoot == string(machineapi.SecureBootPolicyEnabled) {
shieldedInstanceConfig.SecureBoot = machineapi.SecureBootPolicyEnabled
}
return &machineapi.GCPMachineProviderSpec{
TypeMeta: metav1.TypeMeta{
APIVersion: "machine.openshift.io/v1beta1",
Expand All @@ -197,11 +200,12 @@ func provider(clusterID string, platform *gcp.Platform, mpool *gcp.MachinePool,
Email: instanceServiceAccount,
Scopes: []string{"https://www.googleapis.com/auth/cloud-platform"},
}},
Tags: append(mpool.Tags, []string{fmt.Sprintf("%s-%s", clusterID, role)}...),
MachineType: mpool.InstanceType,
Region: platform.Region,
Zone: az,
ProjectID: platform.ProjectID,
Tags: append(mpool.Tags, []string{fmt.Sprintf("%s-%s", clusterID, role)}...),
MachineType: mpool.InstanceType,
Region: platform.Region,
Zone: az,
ProjectID: platform.ProjectID,
ShieldedInstanceConfig: shieldedInstanceConfig,
}, nil
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/tfvars/gcp/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type config struct {
ControlPlaneSubnet string `json:"gcp_control_plane_subnet,omitempty"`
ComputeSubnet string `json:"gcp_compute_subnet,omitempty"`
ControlPlaneTags []string `json:"gcp_control_plane_tags,omitempty"`
SecureBoot string `json:"gcp_master_secure_boot,omitempty"`
}

// TFVarsSources contains the parameters to be converted into Terraform variables
Expand Down Expand Up @@ -95,7 +96,9 @@ func TFVars(sources TFVarsSources) ([]byte, error) {
ComputeSubnet: workerConfig.NetworkInterfaces[0].Subnetwork,
PreexistingNetwork: sources.PreexistingNetwork,
ControlPlaneTags: masterConfig.Tags,
SecureBoot: string(masterConfig.ShieldedInstanceConfig.SecureBoot),
}

cfg.PreexistingImage = true
if len(sources.ImageLicenses) > 0 {
cfg.PreexistingImage = false
Expand Down
10 changes: 10 additions & 0 deletions pkg/types/gcp/machinepools.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ type MachinePool struct {
//
// +optional
Tags []string `json:"tags,omitempty"`

// SecureBoot Defines whether the instance should have secure boot enabled.
// secure boot Verify the digital signature of all boot components, and halt the boot process if signature verification fails.
// If omitted, the platform chooses a default, which is subject to change over time, currently that default is false.
// +kubebuilder:validation:Enum=Enabled;Disabled
// +optional
SecureBoot string `json:"secureBoot,omitempty"`
}

// OSDisk defines the disk for machines on GCP.
Expand Down Expand Up @@ -76,6 +83,9 @@ func (a *MachinePool) Set(required *MachinePool) {
}
a.EncryptionKey.Set(required.EncryptionKey)
}
if required.SecureBoot != "" {
a.SecureBoot = required.SecureBoot
}
}

// EncryptionKeyReference describes the encryptionKey to use for a disk's encryption.
Expand Down
Loading

0 comments on commit 8c83507

Please sign in to comment.