Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GKE Hub]: Add Fleet binary authorization config #9545

Merged
merged 10 commits into from
Dec 4, 2023
22 changes: 21 additions & 1 deletion mmv1/products/gkehub2/Fleet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,27 @@ properties:
name: "defaultClusterConfig"
description: The default cluster configurations to apply across the fleet.
properties:
- !ruby/object:Api::Type::NestedObject
name: "binaryAuthorizationConfig"
description: Enable/Disable binary authorization features for the cluster.
properties:
- !ruby/object:Api::Type::Enum
name: "evaluationMode"
description: Mode of operation for binauthz policy evaluation.
values:
- DISABLED
- POLICY_BINDINGS
- !ruby/object:Api::Type::Array
name: "policyBindings"
description: Binauthz policies that apply to this cluster.
item_type: !ruby/object:Api::Type::NestedObject
properties:
- !ruby/object:Api::Type::String
name: "name"
description: |
The relative resource name of the binauthz platform policy to audit. GKE
platform policies have the following format:
`projects/{project_number}/platforms/gke/policies/{policy_id}`.
- !ruby/object:Api::Type::NestedObject
name: "securityPostureConfig"
description: Enable/Disable Security Posture features for the cluster.
Expand All @@ -109,7 +130,6 @@ properties:
values:
- DISABLED
- BASIC
- ENTERPRISE
- !ruby/object:Api::Type::Enum
name: "vulnerabilityMode"
description: Sets which mode to use for vulnerability scanning.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ func TestAccGKEHub2Fleet_gkehubFleetBasicExample_update(t *testing.T) {
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccGKEHub2Fleet_removedDefaultClusterConfig(context),
},
{
ResourceName: "google_gke_hub_fleet.default",
ImportState: true,
ImportStateVerify: true,
},
},
})
}
Expand All @@ -58,6 +66,9 @@ resource "google_gke_hub_fleet" "default" {
project = google_project.project.project_id
display_name = "my production fleet"
default_cluster_config {
binary_authorization_config {
evaluation_mode = "DISABLED"
}
security_posture_config {
mode = "DISABLED"
vulnerability_mode = "VULNERABILITY_DISABLED"
Expand All @@ -72,8 +83,14 @@ func testAccGKEHub2Fleet_update(context map[string]interface{}) string {
return gkeHubFleetProjectSetupForGA(context) + acctest.Nprintf(`
resource "google_gke_hub_fleet" "default" {
project = google_project.project.project_id
display_name = "my staging fleet"
display_name = "my updated fleet"
default_cluster_config {
binary_authorization_config {
ScottSuarez marked this conversation as resolved.
Show resolved Hide resolved
evaluation_mode = "POLICY_BINDINGS"
policy_bindings {
name = "projects/${google_project.project.project_id}/platforms/gke/policies/policy_id"
}
}
security_posture_config {
mode = "BASIC"
vulnerability_mode = "VULNERABILITY_BASIC"
Expand All @@ -84,6 +101,17 @@ resource "google_gke_hub_fleet" "default" {
`, context)
}

func testAccGKEHub2Fleet_removedDefaultClusterConfig(context map[string]interface{}) string {
return gkeHubFleetProjectSetupForGA(context) + acctest.Nprintf(`
resource "google_gke_hub_fleet" "default" {
project = google_project.project.project_id
display_name = "my updated fleet"

depends_on = [time_sleep.wait_for_gkehub_enablement]
}
`, context)
}

func gkeHubFleetProjectSetupForGA(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_project" "project" {
Expand Down