Skip to content

Commit

Permalink
✨ Add GCP GKE cluster network config (#968)
Browse files Browse the repository at this point in the history
Add an extra property for the GCP GKE cluster network config:
```typescript
cnquery> gcp.project.gke.clusters{networkConfig{*}}
gcp.project.gke.clusters: [
  0: {
    networkConfig: {
      enableL4IlbSubsetting: false
      id: "gcp.project.gkeService.cluster/dasf432tgfre345fg/networkConfig"
      dnsConfig: {}
      serviceExternalIpsConfig: {
        enabled: false
      }
      subnetworkPath: "projects/project-1/regions/us-central1/subnetworks/mondoo-gke-cluster-2-subnet"
      privateIpv6GoogleAccess: "PRIVATE_IPV6_GOOGLE_ACCESS_UNSPECIFIED"
      datapathProvider: "DATAPATH_PROVIDER_UNSPECIFIED"
      networkPath: "projects/project-1/global/networks/mondoo-gke-cluster-2"
      subnetwork: gcp.project.computeService.subnetwork name="mondoo-gke-cluster-2-subnet"
      enableIntraNodeVisibility: false
      defaultSnatStatus: {
        disabled: false
      }
      network: gcp.project.computeService.network name="mondoo-gke-cluster-2"
    }
  }
]
```

---------

Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev authored Feb 27, 2023
1 parent b5b7b29 commit 62dc838
Show file tree
Hide file tree
Showing 8 changed files with 675 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ wfascimprov
wil
Filestore
tpu
datapath
Snat
ilb
11 changes: 7 additions & 4 deletions resources/packs/gcp/bigquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,13 @@ func (g *mqlGcpProjectBigqueryServiceDataset) init(args *resources.Args) (*resou
return args, nil, nil
}

if ids := getAssetIdentifier(g.MotorRuntime); ids != nil {
(*args)["id"] = ids.name
(*args)["location"] = ids.region
(*args)["projectId"] = ids.project
// If no args are set, try reading them from the platform ID
if len(*args) == 0 {
if ids := getAssetIdentifier(g.MotorRuntime); ids != nil {
(*args)["id"] = ids.name
(*args)["location"] = ids.region
(*args)["projectId"] = ids.project
}
}

obj, err := g.MotorRuntime.CreateResource("gcp.project.bigqueryService", "projectId", (*args)["projectId"])
Expand Down
38 changes: 25 additions & 13 deletions resources/packs/gcp/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -758,9 +758,12 @@ func (g *mqlGcpProjectComputeServiceFirewall) init(args *resources.Args) (*resou
return args, nil, nil
}

if ids := getAssetIdentifier(g.MotorRuntime); ids != nil {
(*args)["name"] = ids.name
(*args)["projectId"] = ids.project
// If no args are set, try reading them from the platform ID
if len(*args) == 0 {
if ids := getAssetIdentifier(g.MotorRuntime); ids != nil {
(*args)["name"] = ids.name
(*args)["projectId"] = ids.project
}
}

obj, err := g.MotorRuntime.CreateResource("gcp.project.computeService", "projectId", (*args)["projectId"])
Expand Down Expand Up @@ -959,9 +962,12 @@ func (g *mqlGcpProjectComputeServiceImage) init(args *resources.Args) (*resource
return args, nil, nil
}

if ids := getAssetIdentifier(g.MotorRuntime); ids != nil {
(*args)["name"] = ids.name
(*args)["projectId"] = ids.project
// If no args are set, try reading them from the platform ID
if len(*args) == 0 {
if ids := getAssetIdentifier(g.MotorRuntime); ids != nil {
(*args)["name"] = ids.name
(*args)["projectId"] = ids.project
}
}

obj, err := g.MotorRuntime.CreateResource("gcp.project.computeService", "projectId", (*args)["projectId"])
Expand Down Expand Up @@ -1095,9 +1101,12 @@ func (g *mqlGcpProjectComputeServiceNetwork) init(args *resources.Args) (*resour
return args, nil, nil
}

if ids := getAssetIdentifier(g.MotorRuntime); ids != nil {
(*args)["name"] = ids.name
(*args)["projectId"] = ids.project
// If no args are set, try reading them from the platform ID
if len(*args) == 0 {
if ids := getAssetIdentifier(g.MotorRuntime); ids != nil {
(*args)["name"] = ids.name
(*args)["projectId"] = ids.project
}
}

obj, err := g.MotorRuntime.CreateResource("gcp.project.computeService", "projectId", (*args)["projectId"])
Expand Down Expand Up @@ -1209,10 +1218,13 @@ func (g *mqlGcpProjectComputeServiceSubnetwork) init(args *resources.Args) (*res
return args, nil, nil
}

if ids := getAssetIdentifier(g.MotorRuntime); ids != nil {
(*args)["name"] = ids.name
(*args)["region"] = ids.region
(*args)["projectId"] = ids.project
// If no args are set, try reading them from the platform ID
if len(*args) == 0 {
if ids := getAssetIdentifier(g.MotorRuntime); ids != nil {
(*args)["name"] = ids.name
(*args)["region"] = ids.region
(*args)["projectId"] = ids.project
}
}

obj, err := g.MotorRuntime.CreateResource("gcp.project.computeService", "projectId", (*args)["projectId"])
Expand Down
30 changes: 30 additions & 0 deletions resources/packs/gcp/gcp.lr
Original file line number Diff line number Diff line change
Expand Up @@ -1452,6 +1452,8 @@ private gcp.project.gkeService.cluster @defaults("name") {
workloadIdentityConfig dict
// Configuration for cluster IP allocation
ipAllocationPolicy gcp.project.gkeService.cluster.ipAllocationPolicy
// Configuration for cluster networking
networkConfig gcp.project.gkeService.cluster.networkConfig
}

// GKE Cluster Addons Config
Expand Down Expand Up @@ -1510,6 +1512,34 @@ private gcp.project.gkeService.cluster.ipAllocationPolicy {
ipv6AccessType string
}

// GKE Cluster Network Config
private gcp.project.gkeService.cluster.networkConfig {
// Internal ID
id string
// Relative path of the network to which the cluster is connected
networkPath string
// Network to which the cluster is connected
network() gcp.project.computeService.network
// Relative path of the subnetwork to which the cluster is connected
subnetworkPath string
// Subnetwork to which the cluster is connected
subnetwork() gcp.project.computeService.subnetwork
// Whether intra-node visibility is enabled for this cluster
enableIntraNodeVisibility bool
// Whether the cluster disables default in-node sNAT rules
defaultSnatStatus dict
// Whether L4ILB subsetting is enabled for this cluster
enableL4IlbSubsetting bool
// Desired datapath provider for this cluster
datapathProvider string
// Desired state of IPv6 connectivity to Google Services
privateIpv6GoogleAccess string
// Cluster DNS configuration
dnsConfig dict
// Configuration specifying whether services with externalIPs field are blocked
serviceExternalIpsConfig dict
}

// GKE Cluster Node Pool
private gcp.project.gkeService.cluster.nodepool @defaults("name") {
// Internal ID
Expand Down
Loading

0 comments on commit 62dc838

Please sign in to comment.