GoogleKubernetesEngine

The Google Kubernetes Engine integration is used for building and managing container based applications in Google Cloud Platform (GCP), powered by the open source Kubernetes technology.

IT Services · Google Kubernetes Engine

Details

IDGoogleKubernetesEngine
ProviderGoogle
CategoryIT Services
From Version5.0.0
Docker Imagedemisto/google-k8s-engine:1.0.0.117480
Supported ModulesAgentix XSIAM

README

The Google Kubernetes Engine integration is used for building and managing container based
applications in Google Cloud Platform (GCP), powered by the open source Kubernetes technology.

Command, argument, and output desctiptions were taken from the Google documentation.

Use Cases

  • Mange existing GKE clusters.

  • Mange existing GKE node-pools.

Playbooks

  • Google Kubernetes Engine Operations Generic Polling.

Configure Google Kubernetes Engine setup

  1. Select or create a Cloud Platform project:

    create-project

    The value in the ID column (marked in green) will be used from this point on as the project id.

  2. Enable the Google Container Engine API:

    1. Under the main menu, select APIs & Services -> ‘Libary’:

      Menu

    2. Search for Kubernetes Engine API:

      Search

    3. Click Enable:

      enable-1

    4. Select the project and click ‘OPEN’:

      enable-2

  3. Create a service account with correct restricted permissions:

    1. Under the main menu, select IAM & Admin -> Service Accounts:

      menu

    2. In the top bar, select CREATE SERVICE ACCOUNT:

      create-1

    3. In step number 2, under role, select Kubernetes Engine Admin:

      create-2

    4. Under the main menu, select IAM & Admin -> Service Accounts and open the account you just created.

    5. Generate new credentials:

      1. On the Service account details page, under Keys, click ADD KEY and select Create new key:

        create-3

      2. Under Key type, select JSON and click CREATE. Save the credentials in a secure location. You will need the generated credentials.json file when you configure the instance in Cortex XSOAR:

        create-3

Configure GoogleKubernetesEngine on Cortex XSOAR

  1. Navigate to Settings > Integrations > Servers & Services.
  2. Search for GoogleKubernetesEngine.
  3. Generate credentials.json file by instruction in Google documentation.
  4. Click Add instance to create and configure a new integration instance.
Parameter Description Required
credentials_json JSON credentials - The content of the generated credentials.json file. True
default_project Default project id - Can be overwriten in commands execution. True
default_zone Default zone - Can be overwriten in commands execution. True
  1. Click Test to validate the URLs, credentials.json, and connection.

Commands

You can execute these commands from the Cortex XSOAR CLI, as part of an automation, or in a playbook.
After you successfully execute a command, a DBot message appears in the War Room with the command details.

gcloud-clusters-list


Lists all clusters owned by a project in either the specified zone or all zones.

Base Command

gcloud-clusters-list

Input

Argument Name Description Required
project The Google Developers Console project ID or project number. Optional
zone The name of the Google Compute Engine zone in which the cluster resides, leave empty for all zones. Optional

Context Output

Path Type Description
GKE.Cluster.Name String Cluster name.
GKE.Cluster.MasterAuth.ClusterCaCertificate String Base64-encoded public certificate that is the root of trust for the cluster.
GKE.Cluster.LoggingService String The logging service the cluster should use to write metrics.
GKE.Cluster.MonitoringService String The monitoring service the cluster should use to write metrics.
GKE.Cluster.Network String The name of the Google Compute Engine network to which the cluster is connected. If left unspecified, the default network will be used.
GKE.Cluster.ClusterIpv4Cidr String The IP address range of the container pods in this cluster, in CIDR notation (e.g. 10.0.0.24).
GKE.Cluster.AddonsConfig.HttpLoadBalancing.Disabled Boolean Configuration for the http load balancing addon.
GKE.Cluster.AddonsConfig.HorizontalPodAutoscaling.Disabled Boolean Configuration for the horizontal pod autoscaling addon.
GKE.Cluster.AddonsConfig.KubernetesDashboard.Disabled Boolean Configuration for the kubernetes dashboard addon.
GKE.Cluster.AddonsConfig.NetworkPolicyConfig.Disabled Boolean Configuration for the network policy config addon.
GKE.Cluster.LegacyAbac.Enabled Boolean Configuration for the Legacy ABAC.
GKE.Cluster.SubNetwork String The name of the Google Compute Engine subnetwork to which the cluster is connected.
GKE.Cluster.NodePool.Name String Node pool name.
GKE.Cluster.NodePool.Config.MachineType String Node pool machine type.
GKE.Cluster.NodePool.Config.DiskSizeGb Number Size of the disk attached to each node, specified in GB.
GKE.Cluster.NodePool.Config.OauthScopes String The set of Google API scopes to be made available on all of the node VMs under the “default” service account.
GKE.Cluster.NodePool.Config.Metadata.disable-legacy-endpoints String legacy abac Status.
GKE.Cluster.NodePool.Config.ImageType String The desired image type for the node pool.
GKE.Cluster.NodePool.Config.ServiceAccount String The Google Cloud Platform Service Account to be used by the node VMs. If no Service Account is specified, the “default” service account is used.
GKE.Cluster.NodePool.Config.DiskType String Type of the disk attached to each node (e.g. ‘pd-standard’ or ‘pd-ssd’) If unspecified, the default disk type is ‘pd- standard’.
GKE.Cluster.NodePool.Config.ShieldedInstanceConfig.EnableIntegrityMonitoring Number Defines whether the instance has integrity monitoring enabled.
GKE.Cluster.NodePool.InitialNodeCount Number The initial node count for the pool.
GKE.Cluster.NodePool.Autoscaling.Enabled Number Status of autoscaling.
GKE.Cluster.NodePool.Autoscaling.MinNodeCount Number Minimum number of nodes in the NodePool. Must be >= 1 and <= max_node_count.
GKE.Cluster.NodePool.Autoscaling.MaxNodeCount Number Maximum number of nodes in the NodePool. Must be >= min_node_count. There has to enough quota to scale up the cluster.
GKE.Cluster.NodePool.Management.AutoRepair Number A flag that specifies whether the node auto-repair is enabled for the node pool.
GKE.Cluster.NodePool.MaxPodsConstraint.MaxPodsPerNode String The constraint on the maximum number of pods that can be run simultaneously on a node in the node pool.
GKE.Cluster.NodePool.PodIpv4CidrSize Number The pod CIDR block size per node in this node pool.
GKE.Cluster.NodePool.SelfLink String Server-defined URL for the resource.
GKE.Cluster.NodePool.Version String The version of the Kubernetes of this node.
GKE.Cluster.NodePool.InstanceGroupUrls String The resource URLs of the managed instance groups associated with this node pool.
GKE.Cluster.NodePool.Status String The status of the nodes in this pool instance.
GKE.Cluster.Locations String The desired list of Google Compute Engine zones in which the cluster’s nodes should be located.
GKE.Cluster.LabelFingerprint String The fingerprint of the set of labels for this cluster.
GKE.Cluster.IpAllocationPolicy.UseIpAliases Number Whether alias IPs will be used for pod IPs in the cluster.
GKE.Cluster.IpAllocationPolicy.ClusterIpv4Cidr String The IP address range of the container pods in this cluster, in CIDR notation (e.g. 10.0.0.0/24).
GKE.Cluster.IpAllocationPolicy.ServicesIpv4Cidr String The IP address range of the Kubernetes services in this cluster, in CIDR notation (e.g. 10.0.0.0/24).
GKE.Cluster.IpAllocationPolicy.ClusterSecondaryRangeName String The name of the secondary range to be used for the cluster CIDR block. The secondary range will be used for pod IP addresses.
GKE.Cluster.IpAllocationPolicy.ServicesSecondaryRangeName String The name of the secondary range to be used as for the services CIDR block. The secondary range will be used for service ClusterIPs.
GKE.Cluster.IpAllocationPolicy.ClusterIpv4CidrBlock String The IP address range for the cluster pod IPs.
GKE.Cluster.IpAllocationPolicy.ServicesIpv4CidrBlock String The IP address range of the services IPs in this cluster.
GKE.Cluster.MasterAuthorizedNetworksConfig.CIDR String CIDR which allowed to access master when enabled.
GKE.Cluster.MasterAuthorizedNetworksConfig.Enabled String CIDR which allowed to access master when enabled.
GKE.Cluster.MaintenancePolicy.ResourceVersion String A hash identifying the version of this policy.
GKE.Cluster.NetworkConfig.Network String The relative name of the Google Compute Engine.
GKE.Cluster.NetworkConfig.Subnetwork String The relative name of the Google Compute Engine subnetwork to which the cluster is connected.
GKE.Cluster.DefaultMaxPodsConstraint.MaxPodsPerNode String Constraint enforced on the max num of pods per node.
GKE.Cluster.DatabaseEncryption.State String Configuration of etcd encryption.
GKE.Cluster.SelfLink String erver-defined URL for the resource.
GKE.Cluster.Endpoint String The IP address of this cluster’s master endpoint.
GKE.Cluster.InitialClusterVersion String The initial Kubernetes version for this cluster.
GKE.Cluster.CurrentMasterVersion String The current software version of the master endpoint.
GKE.Cluster.CreateTime Date The time the cluster was created, in RFC3339 text format.
GKE.Cluster.Status String The current status of this cluster.
GKE.Cluster.ServicesIpv4Cidr String The IP address range of the Kubernetes services in this cluster, in CIDR notation (e.g. 10.0.0.0/24).’
GKE.Cluster.Location String The name of the Google Compute Engine zone or region in which the cluster resides.

Command Example

!gcloud-clusters-list project=gcp-integrations zone=us-central1-c

Context Example

{
    "GKE": {
        "Cluster": {
            "AddonsConfig": {
                "HorizontalPodAutoscaling": {
                    "Disabled": {}
                },
                "HttpLoadBalancing": {
                    "Disbaled": {}
                },
                "KubernetesDashboard": {
                    "Disabled": true
                },
                "NetworkPolicyConfig": {
                    "Disabled": null
                }
            },
            "AuthenticatorGroupsConfig": {},
            "ClusterIpv4Cidr": "xxxx",
            "CreateTime": "xxxx",
            "CurrentMasterVersion": "xxxx",
            "DatabaseEncryption": {
                "State": "DECRYPTED"
            },
            "DefaultMaxPodsConstraint": {
                "MaxPodsPerNode": "110"
            },
            "Endpoint": "xxxx",
            "InitialClusterVersion": "xxxx",
            "IpAllocationPolicy": {
                "ClusterIpv4Cidr": "xxxx",
                "ClusterIpv4CidrBlock": "xxxx",
                "ClusterSecondaryRangeName": "xxxx",
                "ServicesIpv4Cidr": "xxxx",
                "ServicesIpv4CidrBlock": "xxxx",
                "ServicesSecondaryRangeName": "xxxx",
                "UseIpAliases": true
            },
            "LabelFingerprint": "xxxx",
            "LegacyAbac": {
                "Enabled": null
            },
            "Location": "xxxx",
            "Locations": [
                "xxxx"
            ],
            "LoggingService": "google.com",
            "MaintenancePolicy": {
                "ResourceVersion": "xxxx"
            },
            "MasterAuth": {
                "ClusterCaCertificate": "xxxx"
            },
            "MasterAuthorizedNetworksConfig": {
                "CIDR": [],
                "Enabled": null
            },
            "MonitoringService": "google.com",
            "Name": "xxxx",
            "Network": "default",
            "NetworkConfig": {
                "Network": "xxxx",
                "Subnetwork": "xxxx"
            },
            "NetworkPolicy": {},
            "NodePools": [
                {
                    "Autoscaling": {
                        "Enabled": null,
                        "MaxNodeCount": null,
                        "MinNodeCount": null
                    },
                    "Config": {
                        "DiskSizeGb": 100,
                        "DiskType": "xxxx",
                        "ImageType": "xxxx",
                        "MachineType": "xxxx",
                        "Metadata": {
                            "DisableLegacyEndpoints": "true"
                        },
                        "OauthScopes": [
                            "https://www.google.com/auth/devstorage.read_only",
                            "https://www.google.com/auth/logging.write",
                            "https://www.google.com/auth/monitoring",
                            "https://www.google.com/auth/servicecontrol",
                            "https://www.google.com/auth/service.management.readonly",
                            "https://www.google.com/auth/trace.append"
                        ],
                        "ServiceAccount": "xxxx",
                        "ShieldedInstanceConfig": {
                            "EnableIntegrityMonitoring": true
                        }
                    },
                    "InitialNodeCount": 3,
                    "InstanceGroupUrls": [
                        "https://www.google.com/compute/v1/projects/"
                    ],
                    "Management": {
                        "AutoRepair": true
                    },
                    "MaxPodsConstraint": {
                        "MaxPodsPerNode": "110"
                    },
                    "Name": "default-pool",
                    "PodIpv4CidrSize": 24,
                    "SelfLink": "https://.googleapis.com/v1/projects/",
                    "Status": "RUNNING",
                    "Version": "xxxx"
                }
            ],
            "SelfLink": "https://.googleapis.com/v1/projects/",
            "ServicesIpv4Cidr": "xxxx",
            "Status": "RECONCILING",
            "SubNetwork": "default"
        }
    }
}

Human Readable Output

Clusters (Project=gcp-integrations, Zone=us-central1-c)

Location Master IP Master version Name Status
us-central1-c xxxx xxxx xxxx RECONCILING

gcloud-clusters-describe


Gets the details of a specific cluster.

Base Command

gcloud-clusters-describe

Input

Argument Name Description Required
project The Google Developers Console project ID or project number. Optional
cluster The name of the cluster to retrieve. The name of the cluster to retrieve. Required
zone The name of the Google Compute Engine zone in which the cluster resides. Optional

Context Output

Path Type Description
GKE.Cluster.Name String Cluster name.
GKE.Cluster.MasterAuth.ClusterCaCertificate String Base64-encoded public certificate that is the root of trust for the cluster.
GKE.Cluster.LoggingService String The logging service the cluster should use to write metrics.
GKE.Cluster.MonitoringService String The monitoring service the cluster should use to write metrics.
GKE.Cluster.Network String The name of the Google Compute Engine network to which the cluster is connected. If left unspecified, the default network will be used.
GKE.Cluster.ClusterIpv4Cidr String The IP address range of the container pods in this cluster, in CIDR notation (e.g. 10.0.0.0/24).
GKE.Cluster.AddonsConfig.HttpLoadBalancing.Disabled Boolean Configuration for the http load balancing addon.
GKE.Cluster.AddonsConfig.HorizontalPodAutoscaling.Disabled Boolean Configuration for the horizontal pod autoscaling addon.
GKE.Cluster.AddonsConfig.KubernetesDashboard.Disabled Boolean Configuration for the kubernetes dashboard addon.
GKE.Cluster.AddonsConfig.NetworkPolicyConfig.Disabled Boolean Configuration for the network policy config addon.
GKE.Cluster.LegacyAbac.Enabled Boolean Configuration for the Legacy ABAC.
GKE.Cluster.SubNetwork String The name of the Google Compute Engine subnetwork to which the cluster is connected.
GKE.Cluster.NodePool.Name String Node pool name.
GKE.Cluster.NodePool.Config.MachineType String Node pool machine type.
GKE.Cluster.NodePool.Config.DiskSizeGb Number Size of the disk attached to each node, specified in GB.
GKE.Cluster.NodePool.Config.OauthScopes String The set of Google API scopes to be made available on all of the node VMs under the “default” service account.
GKE.Cluster.NodePool.Config.Metadata.disable-legacy-endpoints String legacy abac Status.
GKE.Cluster.NodePool.Config.ImageType String The desired image type for the node pool.
GKE.Cluster.NodePool.Config.ServiceAccount String The Google Cloud Platform Service Account to be used by the node VMs. If no Service Account is specified, the “default” service account is used.
GKE.Cluster.NodePool.Config.DiskType String Type of the disk attached to each node (e.g. ‘pd-standard’ or ‘pd-ssd’) If unspecified, the default disk type is ‘pd- standard’.
GKE.Cluster.NodePool.Config.ShieldedInstanceConfig.EnableIntegrityMonitoring Number Defines whether the instance has integrity monitoring enabled.
GKE.Cluster.NodePool.InitialNodeCount Number The initial node count for the pool.
GKE.Cluster.NodePool.Autoscaling.Enabled Number Status of autoscaling.
GKE.Cluster.NodePool.Autoscaling.MinNodeCount Number Minimum number of nodes in the NodePool. Must be >= 1 and <= max_node_count.
GKE.Cluster.NodePool.Autoscaling.MaxNodeCount Number Maximum number of nodes in the NodePool. Must be >= min_node_count. There has to enough quota to scale up the cluster.
GKE.Cluster.NodePool.Management.AutoRepair Number A flag that specifies whether the node auto-repair is enabled for the node pool.
GKE.Cluster.NodePool.MaxPodsConstraint.MaxPodsPerNode String The constraint on the maximum number of pods that can be run simultaneously on a node in the node pool.
GKE.Cluster.NodePool.PodIpv4CidrSize Number The pod CIDR block size per node in this node pool.
GKE.Cluster.NodePool.SelfLink String Server-defined URL for the resource.
GKE.Cluster.NodePool.Version String The version of the Kubernetes of this node.
GKE.Cluster.NodePool.InstanceGroupUrls String The resource URLs of the managed instance groups associated with this node pool.
GKE.Cluster.NodePool.Status String The status of the nodes in this pool instance.
GKE.Cluster.Locations String The desired list of Google Compute Engine zones in which the cluster’s nodes should be located.
GKE.Cluster.LabelFingerprint String The fingerprint of the set of labels for this cluster.
GKE.Cluster.IpAllocationPolicy.UseIpAliases Number Whether alias IPs will be used for pod IPs in the cluster.
GKE.Cluster.IpAllocationPolicy.ClusterIpv4Cidr String The IP address range of the container pods in this cluster, in CIDR notation (e.g. 10.0.0.0/24).
GKE.Cluster.IpAllocationPolicy.ServicesIpv4Cidr String The IP address range of the Kubernetes services in this cluster, in CIDR notation (e.g. 10.0.0.0/24).
GKE.Cluster.IpAllocationPolicy.ClusterSecondaryRangeName String The name of the secondary range to be used for the cluster CIDR block. The secondary range will be used for pod IP addresses.
GKE.Cluster.IpAllocationPolicy.ServicesSecondaryRangeName String The name of the secondary range to be used as for the services CIDR block. The secondary range will be used for service ClusterIPs.
GKE.Cluster.IpAllocationPolicy.ClusterIpv4CidrBlock String The IP address range for the cluster pod IPs.
GKE.Cluster.IpAllocationPolicy.ServicesIpv4CidrBlock String The IP address range of the services IPs in this cluster.
GKE.Cluster.MasterAuthorizedNetworksConfig.CIDR String CIDR which allowed to access master when enabled.
GKE.Cluster.MasterAuthorizedNetworksConfig.Enabled String CIDR which allowed to access master when enabled.
GKE.Cluster.MaintenancePolicy.ResourceVersion String A hash identifying the version of this policy.
GKE.Cluster.NetworkConfig.Network String The relative name of the Google Compute Engine.
GKE.Cluster.NetworkConfig.Subnetwork String The relative name of the Google Compute Engine subnetwork to which the cluster is connected.
GKE.Cluster.DefaultMaxPodsConstraint.MaxPodsPerNode String Constraint enforced on the max num of pods per node.
GKE.Cluster.DatabaseEncryption.State String Configuration of etcd encryption.
GKE.Cluster.SelfLink String erver-defined URL for the resource.
GKE.Cluster.Endpoint String The IP address of this cluster’s master endpoint.
GKE.Cluster.InitialClusterVersion String The initial Kubernetes version for this cluster.
GKE.Cluster.CurrentMasterVersion String The current software version of the master endpoint.
GKE.Cluster.CreateTime Date The time the cluster was created, in RFC3339 text format.
GKE.Cluster.Status String The current status of this cluster.
GKE.Cluster.ServicesIpv4Cidr String The IP address range of the Kubernetes services in this cluster, in CIDR notation (e.g. 10.0.0.0/24).’
GKE.Cluster.Location String The name of the Google Compute Engine zone or region in which the cluster resides.

Command Example

!gcloud-clusters-describe project=gcp-integrations zone=us-central1-c cluster=xsoar-integration

Context Example

{
    "GKE": {
        "Cluster": {
            "AddonsConfig": {
                "HorizontalPodAutoscaling": {
                    "Disabled": {}
                },
                "HttpLoadBalancing": {
                    "Disbaled": {}
                },
                "KubernetesDashboard": {
                    "Disabled": true
                },
                "NetworkPolicyConfig": {
                    "Disabled": null
                }
            },
            "AuthenticatorGroupsConfig": {},
            "ClusterIpv4Cidr": "xxxx",
            "CreateTime": "xxxx",
            "CurrentMasterVersion": "xxxx",
            "DatabaseEncryption": {
                "State": "DECRYPTED"
            },
            "DefaultMaxPodsConstraint": {
                "MaxPodsPerNode": "110"
            },
            "Endpoint": "xxxx",
            "InitialClusterVersion": "xxxx",
            "IpAllocationPolicy": {
                "ClusterIpv4Cidr": "xxxx",
                "ClusterIpv4CidrBlock": "xxxx",
                "ClusterSecondaryRangeName": "xxxx",
                "ServicesIpv4Cidr": "xxxx",
                "ServicesIpv4CidrBlock": "xxxx",
                "ServicesSecondaryRangeName": "xxxx",
                "UseIpAliases": true
            },
            "LabelFingerprint": "xxxx",
            "LegacyAbac": {
                "Enabled": null
            },
            "Location": "xxxx",
            "Locations": [
                "xxxx"
            ],
            "LoggingService": "google.com",
            "MaintenancePolicy": {
                "ResourceVersion": "xxxx"
            },
            "MasterAuth": {
                "ClusterCaCertificate": "xxxx"
            },
            "MasterAuthorizedNetworksConfig": {
                "CIDR": [],
                "Enabled": null
            },
            "MonitoringService": "google.com",
            "Name": "xxxx",
            "Network": "default",
            "NetworkConfig": {
                "Network": "xxxx",
                "Subnetwork": "xxxx"
            },
            "NetworkPolicy": {},
            "NodePools": [
                {
                    "Autoscaling": {
                        "Enabled": null,
                        "MaxNodeCount": null,
                        "MinNodeCount": null
                    },
                    "Config": {
                        "DiskSizeGb": 100,
                        "DiskType": "xxxx",
                        "ImageType": "xxxx",
                        "MachineType": "xxxx",
                        "Metadata": {
                            "DisableLegacyEndpoints": "true"
                        },
                        "OauthScopes": [
                            "https://www.google.com/auth/devstorage.read_only",
                            "https://www.google.com/auth/logging.write",
                            "https://www.google.com/auth/monitoring",
                            "https://www.google.com/auth/servicecontrol",
                            "https://www.google.com/auth/service.management.readonly",
                            "https://www.google.com/auth/trace.append"
                        ],
                        "ServiceAccount": "xxxx",
                        "ShieldedInstanceConfig": {
                            "EnableIntegrityMonitoring": true
                        }
                    },
                    "InitialNodeCount": 3,
                    "InstanceGroupUrls": [
                        "https://www.google.com/compute/v1/projects/"
                    ],
                    "Management": {
                        "AutoRepair": true
                    },
                    "MaxPodsConstraint": {
                        "MaxPodsPerNode": "110"
                    },
                    "Name": "default-pool",
                    "PodIpv4CidrSize": 24,
                    "SelfLink": "https://.googleapis.com/v1/projects/",
                    "Status": "RUNNING",
                    "Version": "xxxx"
                }
            ],
            "SelfLink": "https://.googleapis.com/v1/projects/",
            "ServicesIpv4Cidr": "xxxx",
            "Status": "RECONCILING",
            "SubNetwork": "default"
        }
    }
}

Human Readable Output

Clusters (Project=gcp-integrations, Zone=us-central1-c, Cluster=xsoar-integration)

Location Master IP Master version Name Status
us-central1-c xxxx xxxx xxxx RECONCILING

gcloud-clusters-set-muster-auth


Enable basic (username/password) auth for the cluster. Enable will create user admin with generated password.

Base Command

gcloud-clusters-set-muster-auth

Input

Argument Name Description Required
project The Google Developers Console project ID or project number. Optional
cluster The name of the cluster to retrieve. Required
zone The name of the Google Compute Engine zone in which the cluster resides. Optional
basic_auth Sets master enabled or disabled. Required

Context Output

Path Type Description
GKE.Operation.Name String The server-assigned ID for the operation
GKE.Operation.Zone String The name of the Google Compute Engine zone in which the operation is taking place. This field is deprecated, use location instead.
GKE.Operation.OperationType String Operaion type. (update, etc.)
GKE.Operation.Status String Operation status (Running, Finished).
GKE.Operation.SelfLink Unknown Server-defined URL for the resource.
GKE.Operation.TargetLink String Server-defined URL for the target of the operation.
GKE.Operation.StartTime Date The time the operation started, in RFC3339 text format.

Command Example

!gcloud-clusters-set-muster-auth project=gcp-integrations zone=us-central1-c cluster=xsoar-integration basic_auth=enable

Context Example

{
    "GKE": {
        "Operation": {
            "Name": "operation-xxxx",
            "OperationType": "UPDATE_CLUSTER",
            "SelfLink": "https://container.google.com/v1/projects/",
            "StartTime": "xxxx",
            "Status": "DONE",
            "TargetLink": "https://container.google.com/v1/projects/",
            "Zone": "xxxx"
        }
    }
}

Human Readable Output

Project gcp-integrations - Zone us-central1-c - Operation operation-xxxx

Name Zone Status StartTime
operation-xxxx xxxx DONE xxxx

gcloud-clusters-set-addons


Sets the addons for a specific cluster.

Base Command

gcloud-clusters-set-addons

Input

Argument Name Description Required
project The Google Developers Console project ID or project number. Optional
cluster The name of the cluster to retrieve. The name of the cluster to retrieve. Required
zone The name of the Google Compute Engine zone in which the cluster resides. Optional
http_load_balancing Configuration for the HTTP (L7) load balancing controller addon, which makes it easy to set up HTTP load balancers for services in a cluster. Optional
kubernetes_dashboard Configuration for the Kubernetes Dashboard. Optional
network_policy Configuration for NetworkPolicy.
This only tracks whether the addon is enabled or not on the Master, it does not track whether network policy is enabled for the nodes.
Optional

Context Output

Path Type Description
GKE.Operation.Name String The server-assigned ID for the operation
GKE.Operation.Zone String The name of the Google Compute Engine zone in which the operation is taking place. This field is deprecated, use location instead.
GKE.Operation.OperationType String Operaion type. (update, etc.)
GKE.Operation.Status String Operation status (Running, Finished).
GKE.Operation.SelfLink Unknown Server-defined URL for the resource.
GKE.Operation.TargetLink String Server-defined URL for the target of the operation.
GKE.Operation.StartTime Date The time the operation started, in RFC3339 text format.

Command Example

!gcloud-clusters-set-addons project=gcp-integrations zone=us-central1-c cluster=xsoar-integration http_load_balancing=enable kubernetes_dashboard=disable network_policy=enable

Context Example

{
    "GKE": {
        "Operation": {
            "Name": "operation-xxxx",
            "OperationType": "UPDATE_CLUSTER",
            "SelfLink": "https://container.google.com/v1/projects/",
            "StartTime": "xxxx",
            "Status": "DONE",
            "TargetLink": "https://container.google.com/v1/projects/",
            "Zone": "xxxx"
        }
    }
}

Human Readable Output

Project gcp-integrations - Zone us-central1-c - Operation operation-xxxx

Name Zone Status StartTime
operation-xxxx xxxx DONE xxxx

gcloud-clusters-set-legacy-auth


Configuration for the legacy Attribute Based Access Control authorization mode.

Base Command

gcloud-clusters-set-legacy-auth

Input

Argument Name Description Required
project The Google Developers Console project ID or project number. Optional
cluster The name of the cluster to retrieve. The name of the cluster to retrieve. Required
zone The name of the Google Compute Engine zone in which the cluster resides. Optional
enable Whether the ABAC authorizer is enabled for this cluster. When enabled, identities in the system, including service accounts, nodes, and controllers, will have statically granted permissions beyond those provided by the RBAC configuration or IAM. Required

Context Output

Path Type Description
GKE.Operation.Name String The server-assigned ID for the operation
GKE.Operation.Zone String The name of the Google Compute Engine zone in which the operation is taking place. This field is deprecated, use location instead.
GKE.Operation.OperationType String Operaion type. (update, etc.)
GKE.Operation.Status String Operation status (Running, Finished).
GKE.Operation.SelfLink Unknown Server-defined URL for the resource.
GKE.Operation.TargetLink String Server-defined URL for the target of the operation.
GKE.Operation.StartTime Date The time the operation started, in RFC3339 text format.

Command Example

!gcloud-clusters-set-legacy-auth project=gcp-integrations zone=us-central1-c cluster=xsoar-integration enable=true

Context Example

{
    "GKE": {
        "Operation": {
            "Name": "operation-xxxx",
            "OperationType": "UPDATE_CLUSTER",
            "SelfLink": "https://container.google.com/v1/projects/",
            "StartTime": "xxxx",
            "Status": "DONE",
            "TargetLink": "https://container.google.com/v1/projects/",
            "Zone": "xxxx"
        }
    }
}

Human Readable Output

Project gcp-integrations - Zone us-central1-c - Operation operation-xxxx

Name Zone Status StartTime
operation-xxxx xxxx DONE xxxx

gcloud-clusters-set-master-authorized-network


Configuration options for the master authorized networks feature.
Enabled master authorized networks will disallow all external traffic to access Kubernetes master through HTTPS except traffic from the given CIDR blocks, Google Compute Engine Public IPs and Google Prod IPs.

Base Command

gcloud-clusters-set-master-authorized-network

Input

Argument Name Description Required
project The Google Developers Console project ID or project number. Optional
cluster The name of the cluster to retrieve. The name of the cluster to retrieve. Required
zone The name of the Google Compute Engine zone in which the cluster resides. Optional
enable Whether or not master authorized networks is enabled. Required
cidrs Cidrs define up to 50 external networks that could access Kubernetes master through HTTPS. Comma-seprated e.g. “192.168.0.0/24,10.0.0.0/32” Optional

Context Output

Path Type Description
GKE.Operation.Name String The server-assigned ID for the operation
GKE.Operation.Zone String The name of the Google Compute Engine zone in which the operation is taking place. This field is deprecated, use location instead.
GKE.Operation.OperationType String Operaion type. (update, etc.)
GKE.Operation.Status String Operation status (Running, Finished).
GKE.Operation.SelfLink Unknown Server-defined URL for the resource.
GKE.Operation.TargetLink String Server-defined URL for the target of the operation.
GKE.Operation.StartTime Date The time the operation started, in RFC3339 text format.

Command Example

!gcloud-clusters-set-master-authorized-network project=gcp-integrations zone=us-central1-c cluster=xsoar-integration enable=true cidrs=192.168.0.0/24

Context Example

{
    "GKE": {
        "Operation": {
            "Name": "operation-xxxx",
            "OperationType": "UPDATE_CLUSTER",
            "SelfLink": "https://container.google.com/v1/projects/",
            "StartTime": "xxxx",
            "Status": "DONE",
            "TargetLink": "https://container.google.com/v1/projects/",
            "Zone": "xxxx"
        }
    }
}

Human Readable Output

Project gcp-integrations - Zone us-central1-c - Operation operation-xxxx

Name Zone Status StartTime
operation-xxxx xxxx DONE xxxx

gcloud-clusters-set-k8s-stackdriver


Enable or Disable k8s stackdriver. Important - To use this functinality the user should enable manually logging to “monitoring.googleapis.com/kubernetes” manulally via the GCP console.

Base Command

gcloud-clusters-set-k8s-stackdriver

Input

Argument Name Description Required
project The Google Developers Console project ID or project number. Optional
cluster The name of the cluster to retrieve. The name of the cluster to retrieve. Required
zone The name of the Google Compute Engine zone in which the cluster resides. Required
enable Whether or not k8s stackdriver is enabled. Required

Context Output

Path Type Description
GKE.Operation.Name String The server-assigned ID for the operation
GKE.Operation.Zone String The name of the Google Compute Engine zone in which the operation is taking place. This field is deprecated, use location instead.
GKE.Operation.OperationType String Operaion type. (update, etc.)
GKE.Operation.Status String Operation status (Running, Finished).
GKE.Operation.SelfLink Unknown Server-defined URL for the resource.
GKE.Operation.TargetLink String Server-defined URL for the target of the operation.
GKE.Operation.StartTime Date The time the operation started, in RFC3339 text format.

Command Example

!gcloud-clusters-set-master-authorized-network project=gcp-integrations zone=us-central1-c cluster=xsoar-integration enable=true cidrs=192.168.0.0.24

Context Example

{
    "GKE": {
        "Operation": {
            "Name": "operation-xxxx",
            "OperationType": "UPDATE_CLUSTER",
            "SelfLink": "https://container.google.com/v1/projects/",
            "StartTime": "xxxx",
            "Status": "DONE",
            "TargetLink": "https://container.google.com/v1/projects/",
            "Zone": "xxxx"
        }
    }
}

Human Readable Output

Project gcp-integrations - Zone us-central1-c - Operation operation-xxxx

Name Zone Status StartTime
operation-xxxx xxxx DONE xxxx

gcloud-clusters-set-binary-auth


Enable or Disable binary auth.

Base Command

gcloud-clusters-set-binary-auth

Input

Argument Name Description Required
project The Google Developers Console project ID or project number. Optional
cluster The name of the cluster to retrieve. The name of the cluster to retrieve. Required
zone The name of the Google Compute Engine zone in which the cluster resides. Optional
enable Whether or not master binary auth is enabled. Required

Context Output

Path Type Description
GKE.Operation.Name String The server-assigned ID for the operation
GKE.Operation.Zone String The name of the Google Compute Engine zone in which the operation is taking place. This field is deprecated, use location instead.
GKE.Operation.OperationType String Operaion type. (update, etc.)
GKE.Operation.Status String Operation status (Running, Finished).
GKE.Operation.SelfLink Unknown Server-defined URL for the resource.
GKE.Operation.TargetLink String Server-defined URL for the target of the operation.
GKE.Operation.StartTime Date The time the operation started, in RFC3339 text format.

Command Example

!gcloud-clusters-set-binary-auth project=gcp-integrations zone=us-central1-c cluster=xsoar-integration enable=true

Context Example

{
    "GKE": {
        "Operation": {
            "Name": "operation-xxxx",
            "OperationType": "UPDATE_CLUSTER",
            "SelfLink": "https://container.google.com/v1/projects/",
            "StartTime": "xxxx",
            "Status": "DONE",
            "TargetLink": "https://container.google.com/v1/projects/",
            "Zone": "xxxx"
        }
    }
}

Human Readable Output

Project gcp-integrations - Zone us-central1-c - Operation operation-xxxx

Name Zone Status StartTime
operation-xxxx xxxx DONE xxxx

gcloud-clusters-set-intra-node-visibility


Enable or Disable for intra node visibility in cluster.

Base Command

gcloud-clusters-set-intra-node-visibility

Input

Argument Name Description Required
project The Google Developers Console project ID or project number. Optional
cluster The name of the cluster to retrieve. The name of the cluster to retrieve. Required
zone The name of the Google Compute Engine zone in which the cluster resides. Optional
enable Whether or not intra node visibility is enabled. Required

Context Output

Path Type Description
GKE.Operation.Name String The server-assigned ID for the operation
GKE.Operation.Zone String The name of the Google Compute Engine zone in which the operation is taking place. This field is deprecated, use location instead.
GKE.Operation.OperationType String Operaion type. (update, etc.)
GKE.Operation.Status String Operation status (Running, Finished).
GKE.Operation.SelfLink Unknown Server-defined URL for the resource.
GKE.Operation.TargetLink String Server-defined URL for the target of the operation.
GKE.Operation.StartTime Date The time the operation started, in RFC3339 text format.

Command Example

!gcloud-clusters-set-intra-node-visibility project=gcp-integrations zone=us-central1-c cluster=xsoar-integration enable=true

Context Example

{
    "GKE": {
        "Operation": {
            "Name": "operation-xxxx",
            "OperationType": "UPDATE_CLUSTER",
            "SelfLink": "https://container.google.com/v1/projects/",
            "StartTime": "xxxx",
            "Status": "DONE",
            "TargetLink": "https://container.google.com/v1/projects/",
            "Zone": "xxxx"
        }
    }
}

Human Readable Output

Project gcp-integrations - Zone us-central1-c - Operation operation-xxxx

Name Zone Status StartTime
operation-xxxx xxxx DONE xxxx

gcloud-node-pool-list


Lists the node pools for a cluster.

Base Command

gcloud-node-pool-list

Input

Argument Name Description Required
project The Google Developers Console project ID or project number. Optional
cluster The name of the cluster to retrieve. The name of the cluster to retrieve. Required
zone The name of the Google Compute Engine zone in which the cluster resides. Optional

Context Output

Path Type Description
GKE.NodePool.Name String Node pool name.
GKE.NodePool.Config.MachineType String Node pool machine type.
GKE.NodePool.Config.DiskSizeGb Number Size of the disk attached to each node, specified in GB.
GKE.NodePool.Config.OauthScopes String The set of Google API scopes to be made available on all of the node VMs under the “default” service account.
GKE.NodePool.Config.Metadata.disable-legacy-endpoints String legacy abac Status.
GKE.NodePool.Config.ImageType String The desired image type for the node pool.
GKE.NodePool.Config.ServiceAccount String The Google Cloud Platform Service Account to be used by the node VMs. If no Service Account is specified, the “default” service account is used.
GKE.NodePool.Config.DiskType String Type of the disk attached to each node (e.g. ‘pd-standard’ or ‘pd-ssd’) If unspecified, the default disk type is ‘pd- standard’.
GKE.NodePool.Config.ShieldedInstanceConfig.EnableIntegrityMonitoring Number Defines whether the instance has integrity monitoring enabled.
GKE.NodePool.InitialNodeCount Number The initial node count for the pool.
GKE.NodePool.Autoscaling.Enabled Number Status of autoscaling.
GKE.NodePool.Autoscaling.MinNodeCount Number Minimum number of nodes in the NodePool. Must be >= 1 and <= max_node_count.
GKE.NodePool.Autoscaling.MaxNodeCount Number Maximum number of nodes in the NodePool. Must be >= min_node_count. There has to enough quota to scale up the cluster.
GKE.NodePool.Management.AutoRepair Number A flag that specifies whether the node auto-repair is enabled for the node pool.
GKE.NodePool.MaxPodsConstraint.MaxPodsPerNode String The constraint on the maximum number of pods that can be run simultaneously on a node in the node pool.
GKE.NodePool.PodIpv4CidrSize Number The pod CIDR block size per node in this node pool.
GKE.NodePool.SelfLink String Server-defined URL for the resource.
GKE.NodePool.Version String The version of the Kubernetes of this node.
GKE.NodePool.InstanceGroupUrls String The resource URLs of the managed instance groups associated with this node pool.
GKE.NodePool.Status String The status of the nodes in this pool instance.

Command Example

!gcloud-node-pool-list project=gcp-integrations zone=us-central1-c cluster=xsoar-integration

Context Example

{
    "GKE": {
        "NodePool": {
            "Autoscaling": {
                "Enabled": null,
                "MaxNodeCount": null,
                "MinNodeCount": null
            },
            "Config": {
                "DiskSizeGb": 100,
                "DiskType": "xxxx",
                "ImageType": "xxxx",
                "MachineType": "xxxx",
                "Metadata": {
                    "DisableLegacyEndpoints": "true"
                },
                "OauthScopes": [
                    "https://www.google.com/auth/devstorage.read_only",
                    "https://www.google.com/auth/logging.write",
                    "https://www.google.com/auth/monitoring",
                    "https://www.google.com/auth/servicecontrol",
                    "https://www.google.com/auth/service.management.readonly",
                    "https://www.google.com/auth/trace.append"
                ],
                "ServiceAccount": "default",
                "ShieldedInstanceConfig": {
                    "EnableIntegrityMonitoring": true
                }
            },
            "InitialNodeCount": 3,
            "InstanceGroupUrls": [
                "https://www.google.com/compute/v1/projects/"
            ],
            "Management": {
                "AutoRepair": true
            },
            "MaxPodsConstraint": {
                "MaxPodsPerNode": "110"
            },
            "Name": "xxxx",
            "PodIpv4CidrSize": 24,
            "SelfLink": "https://container.google.com/v1/projects/",
            "Status": "RUNNING",
            "Version": "xxxx"
        }
    }
}

Human Readable Output

Node-pools (Project=gcp-integrations, Zone=us-central1-c, Cluster=xsoar-integration)

Disk size Machine Type Name Node version
100 n1-standard-1 default-pool 1.16.9-gke.2

gcloud-node-pool-describe


Retrieves the requested node pool.

Base Command

gcloud-node-pool-describe

Input

Argument Name Description Required
project The Google Developers Console project ID or project number. Optional
cluster The name of the cluster to retrieve. The name of the cluster to retrieve. Required
zone The name of the Google Compute Engine zone in which the cluster resides. Optional
node_pool The name of the Google Compute Engine node pool. Required

Context Output

Path Type Description
GKE.NodePool.Name String Node pool name.
GKE.NodePool.Config.MachineType String Node pool machine type.
GKE.NodePool.Config.DiskSizeGb Number Size of the disk attached to each node, specified in GB.
GKE.NodePool.Config.OauthScopes String The set of Google API scopes to be made available on all of the node VMs under the “default” service account.
GKE.NodePool.Config.Metadata.disable-legacy-endpoints String legacy abac Status.
GKE.NodePool.Config.ImageType String The desired image type for the node pool.
GKE.NodePool.Config.ServiceAccount String The Google Cloud Platform Service Account to be used by the node VMs. If no Service Account is specified, the “default” service account is used.
GKE.NodePool.Config.DiskType String Type of the disk attached to each node (e.g. ‘pd-standard’ or ‘pd-ssd’) If unspecified, the default disk type is ‘pd- standard’.
GKE.NodePool.Config.ShieldedInstanceConfig.EnableIntegrityMonitoring Number Defines whether the instance has integrity monitoring enabled.
GKE.NodePool.InitialNodeCount Number The initial node count for the pool.
GKE.NodePool.Autoscaling.Enabled Number Status of autoscaling.
GKE.NodePool.Autoscaling.MinNodeCount Number Minimum number of nodes in the NodePool. Must be >= 1 and <= max_node_count.
GKE.NodePool.Autoscaling.MaxNodeCount Number Maximum number of nodes in the NodePool. Must be >= min_node_count. There has to enough quota to scale up the cluster.
GKE.NodePool.Management.AutoRepair Number A flag that specifies whether the node auto-repair is enabled for the node pool.
GKE.NodePool.MaxPodsConstraint.MaxPodsPerNode String The constraint on the maximum number of pods that can be run simultaneously on a node in the node pool.
GKE.NodePool.PodIpv4CidrSize Number The pod CIDR block size per node in this node pool.
GKE.NodePool.SelfLink String Server-defined URL for the resource.
GKE.NodePool.Version String The version of the Kubernetes of this node.
GKE.NodePool.InstanceGroupUrls String The resource URLs of the managed instance groups associated with this node pool.
GKE.NodePool.Status String The status of the nodes in this pool instance.

Command Example

!gcloud-node-pool-describe project=gcp-integrations zone=us-central1-c cluster=xsoar-integration node_pool=default-pool

Context Example

{
    "GKE": {
        "NodePool": {
            "Autoscaling": {
                "Enabled": null,
                "MaxNodeCount": null,
                "MinNodeCount": null
            },
            "Config": {
                "DiskSizeGb": 100,
                "DiskType": "xxxx",
                "ImageType": "xxxx",
                "MachineType": "xxxx",
                "Metadata": {
                    "DisableLegacyEndpoints": "true"
                },
                "OauthScopes": [
                    "https://www.google.com/auth/devstorage.read_only",
                    "https://www.google.com/auth/logging.write",
                    "https://www.google.com/auth/monitoring",
                    "https://www.google.com/auth/servicecontrol",
                    "https://www.google.com/auth/service.management.readonly",
                    "https://www.google.com/auth/trace.append"
                ],
                "ServiceAccount": "default",
                "ShieldedInstanceConfig": {
                    "EnableIntegrityMonitoring": true
                }
            },
            "InitialNodeCount": 3,
            "InstanceGroupUrls": [
                "https://www.google.com/compute/v1/projects/"
            ],
            "Management": {
                "AutoRepair": true
            },
            "MaxPodsConstraint": {
                "MaxPodsPerNode": "110"
            },
            "Name": "xxxx",
            "PodIpv4CidrSize": 24,
            "SelfLink": "https://container.google.com/v1/projects/",
            "Status": "RUNNING",
            "Version": "xxxx"
        }
    }
}

Human Readable Output

Node-pools (Project=gcp-integrations, Zone=us-central1-c, Cluster=xsoar-integration, Node pool=default-pool)

Disk size Machine Type Name Node version
100 xxxx xxxx xxxx

gcloud-node-pool-set-management


Sets the NodeManagement options for a node pool.

Base Command

gcloud-node-pool-set-management

Input

Argument Name Description Required
project The Google Developers Console project ID or project number. Optional
cluster The name of the cluster to retrieve. The name of the cluster to retrieve. Required
zone The name of the Google Compute Engine zone in which the cluster resides. Optional
node_pool The name of the Google Compute Engine node pool. Required
auto_repair A flag that specifies whether the node auto-repair is enabled for the node pool. If enabled, the nodes in this node pool will be monitored and, if they fail health checks too many times, an automatic repair action will be triggered. Required
auto_upgrade A flag that specifies whether node auto-upgrade is enabled for the node pool. If enabled, node auto-upgrade helps keep the nodes in your node pool up to date with the latest release version of Kubernetes. Required

Context Output

Path Type Description
GKE.Operation.Name String The server-assigned ID for the operation
GKE.Operation.Zone String The name of the Google Compute Engine zone in which the operation is taking place. This field is deprecated, use location instead.
GKE.Operation.OperationType String Operaion type. (update, etc.)
GKE.Operation.Status String Operation status (Running, Finished).
GKE.Operation.SelfLink Unknown Server-defined URL for the resource.
GKE.Operation.TargetLink String Server-defined URL for the target of the operation.
GKE.Operation.StartTime Date The time the operation started, in RFC3339 text format.

Command Example

!gcloud-node-pool-set-management project=gcp-integrations zone=us-central1-c node_pool= auto_repair=false auto_upgrade=true

Context Example

{
    "GKE": {
        "Operation": {
            "Name": "operation-xxxx",
            "OperationType": "UPDATE_CLUSTER",
            "SelfLink": "https://container.google.com/v1/projects/",
            "StartTime": "xxxx",
            "Status": "DONE",
            "TargetLink": "https://container.google.com/v1/projects/",
            "Zone": "xxxx"
        }
    }
}

Human Readable Output

Project gcp-integrations - Zone us-central1-c - Operation operation-xxxx

Name Zone Status StartTime
operation-xxxx xxxx DONE xxxx

gcloud-operations-list


List operations in project-zone.

Base Command

gcloud-operations-list

Input

Argument Name Description Required
project The Google Developers Console project ID or project number. Optional
zone The name of the Google Compute Engine zone in which the cluster resides. Optional

Context Output

Path Type Description
GKE.Operation.Name String The server-assigned ID for the operation
GKE.Operation.Zone String The name of the Google Compute Engine zone in which the operation is taking place. This field is deprecated, use location instead.
GKE.Operation.OperationType String Operaion type. (update, etc.)
GKE.Operation.Status String Operation status (Running, Finished).
GKE.Operation.SelfLink Unknown Server-defined URL for the resource.
GKE.Operation.TargetLink String Server-defined URL for the target of the operation.
GKE.Operation.StartTime Date The time the operation started, in RFC3339 text format.

Command Example

!gcloud-operations-list project=gcp-integrations zone=us-central1-c

Context Example

{
    "GKE": {
        "Operation": [
             {
              "Name": "operation-xxxx",
              "OperationType": "UPDATE_CLUSTER",
              "SelfLink": "https://container.google.com/v1/projects/",
              "StartTime": "xxxx",
              "Status": "DONE",
              "TargetLink": "https://container.google.com/v1/projects/",
              "Zone": "xxxx"
          },
          {
              "Name": "operation-xxxx",
              "OperationType": "UPDATE_CLUSTER",
              "SelfLink": "https://container.google.com/v1/projects/",
              "StartTime": "xxxx",
              "Status": "DONE",
              "TargetLink": "https://container.google.com/v1/projects/",
              "Zone": "xxxx"
          }
        ]
    }
}

Human Readable Output

Project gcp-integrations - Zone us-central1-c - Operations

Name Zone Status StartTime
operation-xxxx xxxx DONE xxxx
operation-xxxx xxxx DONE xxxx

gcloud-operations-describe


Retrieve operation information by name.

Base Command

gcloud-operations-describe

Input

Argument Name Description Required
project The Google Developers Console project ID or project number. Optional
zone The name of the Google Compute Engine zone in which the cluster resides. Optional
operation The name of the Google Compute Engine operation name. Required

Context Output

Path Type Description
GKE.Operation.Name String The server-assigned ID for the operation
GKE.Operation.Zone String The name of the Google Compute Engine zone in which the operation is taking place. This field is deprecated, use location instead.
GKE.Operation.OperationType String Operaion type. (update, etc.)
GKE.Operation.Status String Operation status (Running, Finished).
GKE.Operation.SelfLink Unknown Server-defined URL for the resource.
GKE.Operation.TargetLink String Server-defined URL for the target of the operation.
GKE.Operation.StartTime Date The time the operation started, in RFC3339 text format.

Command Example

!gcloud-operations-describe project=gcp-integrations zone=us-central1-c operation=operation-1591773015046-cc1b6943

Context Example

{
    "GKE": {
        "Operation": {
            "Name": "operation-xxxx",
            "OperationType": "UPDATE_CLUSTER",
            "SelfLink": "https://container.google.com/v1/projects/",
            "StartTime": "xxxx",
            "Status": "DONE",
            "TargetLink": "https://container.google.com/v1/projects/",
            "Zone": "xxxx"
        }
    }
}

Human Readable Output

Project gcp-integrations - Zone us-central1-c - Operation operation-xxxx

Name Zone Status StartTime
operation-xxxx xxxx DONE xxxx

gcloud-operations-cancel


Cancel operation by operation name.

Base Command

gcloud-operations-cancel

Input

Argument Name Description Required
project The Google Developers Console project ID or project number. Optional
cluster The name of the cluster to retrieve. The name of the cluster to retrieve. Required
zone The name of the Google Compute Engine zone in which the cluster resides. Optional
operation The name of the Google Compute Engine operation name. Required

Context Output

There is no context output for this command.

Command Example

!gcloud-operations-cancel project=gcp-integrations zone=xxxx operation=operation-xxxx

Human Readable Output

Project gcp-integrations - Zone xxxx - Operation operation-xxxx canceled

Known limitations

  • After apply new configuration an operation in Google cloud will start, In order to apply another operation the operation must finish running, In order to handle this limitation you can use Google Kubernetes Engine Operations Generic Polling playbook.

Configuration parameters

  • credentials_json — JSON credentials
  • credentials
  • default_project — Default project (required)
  • default_zone — Default zone (required)

Commands (15)

  • gcloud-clusters-describe

    Gets the details of a specific cluster.

  • gcloud-clusters-list

    Lists all clusters owned by a project in either the specified zone or all zones.

  • gcloud-clusters-set-addons

    Sets the addons for a specific cluster.

  • gcloud-clusters-set-binary-auth

    Enable or Disable binary auth.

  • gcloud-clusters-set-intra-node-visibility

    Enable or Disable for intra node visibility in cluster.

  • gcloud-clusters-set-k8s-stackdriver

    Enable or Disable k8s stackdriver. Important - To use this functinality the user should enable manually logging to "monitoring.googleapis.com/kubernetes" manulally via the GCP console.

  • gcloud-clusters-set-legacy-auth

    Configuration for the legacy Attribute Based Access Control authorization mode.

  • gcloud-clusters-set-master-authorized-network

    Configuration options for the master authorized networks feature. Enabled master authorized networks will disallow all external traffic to access Kubernetes master through HTTPS except traffic from the given CIDR blocks, Google Compute Engine Public IPs and Google Prod IPs.

  • gcloud-clusters-set-muster-auth

    Enable basic (username/password) auth for the cluster. Enable will create user admin with generated password.

  • gcloud-node-pool-describe

    Retrieves the requested node pool.

  • gcloud-node-pool-list

    Lists the node pools for a cluster.

  • gcloud-node-pool-set-management

    Sets the NodeManagement options for a node pool.

  • gcloud-operations-cancel

    Cancel operation by operation name.

  • gcloud-operations-describe

    Retrieve operation information by name.

  • gcloud-operations-list

    List operations in project-zone.

from collections.abc import Callable

###########
# IMPORTS #
###########
# STD packages
from typing import Any

import demistomock as demisto  # noqa: F401
from CommonServerPython import *  # noqa: F401

# 3-rd party packages
from google.cloud.container_v1 import AddonsConfig, Cluster, ClusterManagerClient, ClusterUpdate, ListClustersResponse
from google.oauth2 import service_account
from google.protobuf.json_format import MessageToDict

# Local packages
from CommonServerUserPython import *  # noqa: E402 lgtm [py/polluting-import]

#########
# Notes #
#########
"""
    Development info:
    1.This integration implements the gke cli of google cloud platform, For more info -
        https://cloud.google.com/sdk/gcloud/reference/container/clusters
    2.In the implementation we use the official "google-cloud-container" sdk, For more info -
        https://googleapis.dev/python/container/latest/gapic/v1/types.html#google.cloud.container_v1
    3. Authentication done by Google service account, For more info -
        https://cloud.google.com/iam/docs/service-accounts
    Notice - Between updates GKE will not allow to perform new update until the last one finished, check the status in
             operation entry.           
"""  # noqa W291
####################
# GLOBAL CONSTUNTS #
####################
INTEGRATION_NAME = "Google Kubernetes Engine"
INTEGRATION_COMMAND_NAME = "gcloud"
INTEGRATION_CONTEXT_NAME = "GKE"
CLUSTER_CONTEXT = f"{INTEGRATION_CONTEXT_NAME}.Cluster(val.Name && val.Name == obj.Name)"
NODE_POOL_CONTEXT = f"{INTEGRATION_CONTEXT_NAME}.NodePool(val.Name && val.Name == obj.Name)"
OPERATION_CONTEXT = f"{INTEGRATION_CONTEXT_NAME}.Operation(val.Name && val.Name == obj.Name)"
OPERATION_TABLE = ["Name", "Zone", "Status", "StartTime"]
COMMAND_OUTPUT = tuple[str, dict[str, Any], dict[str, Any]]
API_TIMEOUT = 90


####################
# HELPER FUNCTIONS #
####################


def handle_default_configuration():
    """Handle - default configuration if args not configured.

    Returns:
        dict: arguments filled with default configuration if args not configured.
    """
    args = demisto.args()
    params = demisto.params()
    args |= {
        "project": args.get("project") or params.get("credentials", {}).get("identifier") or params.get("default_project"),
        "zone": args.get("zone") or params.get("default_zone"),
    }

    return args


def google_client_setup(json_configuration: str) -> ClusterManagerClient:
    """Setup client for service acount in google cloud - For more information:
        https://cloud.google.com/iam/docs/service-accounts

    Args:
        json_configuration: Json configuration file content from IAM.

    Returns:
        ClusterManagerClient: client manager.
    """
    credentials = service_account.Credentials.from_service_account_info(json.loads(json_configuration))
    client = ClusterManagerClient(credentials=credentials)

    return client


def parse_cluster(cluster: dict) -> dict:
    """Build entry contect entry for a cluster entry.

    Args:
        cluster: Cluster raw response from google API.

    Returns:
        dict: Cluster as defined entry context.
    """
    return {
        "Name": dict_safe_get(cluster, ["name"]),
        "MasterAuth": {
            "ClusterCaCertificate": dict_safe_get(cluster, ["masterAuth", "clusterCaCertificate"]),
        },
        "LoggingService": dict_safe_get(cluster, ["loggingService"]),
        "MonitoringService": dict_safe_get(cluster, ["monitoringService"]),
        "Network": dict_safe_get(cluster, ["network"]),
        "ClusterIpv4Cidr": dict_safe_get(cluster, ["clusterIpv4Cidr"]),
        "AddonsConfig": {
            "HttpLoadBalancing": {
                "Disbaled": dict_safe_get(cluster, ["addonsConfig", "httpLoadBalancing"]),
            },
            "HorizontalPodAutoscaling": {
                "Disabled": dict_safe_get(cluster, ["addonsConfig", "horizontalPodAutoscaling"]),
            },
            "KubernetesDashboard": {
                "Disabled": dict_safe_get(cluster, ["addonsConfig", "kubernetesDashboard", "disabled"]),
            },
            "NetworkPolicyConfig": {
                "Disabled": dict_safe_get(cluster, ["addonsConfig", "networkPolicyConfig", "disabled"]),
            },
        },
        "SubNetwork": dict_safe_get(cluster, ["subnetwork"]),
        "NodePools": [parse_node_pool(node_pool) for node_pool in cluster.get("nodePools", [])],
        "Locations": dict_safe_get(cluster, ["locations"]),
        "LabelFingerprint": dict_safe_get(cluster, ["labelFingerprint"]),
        "LegacyAbac": {
            "Enabled": dict_safe_get(cluster, ["legacyAbac", "enabled"]),
        },
        "NetworkPolicy": dict_safe_get(cluster, ["networkPolicy"]),
        "IpAllocationPolicy": {
            "UseIpAliases": dict_safe_get(cluster, ["ipAllocationPolicy", "useIpAliases"]),
            "ClusterIpv4Cidr": dict_safe_get(cluster, ["ipAllocationPolicy", "clusterIpv4Cidr"]),
            "ServicesIpv4Cidr": dict_safe_get(cluster, ["ipAllocationPolicy", "servicesIpv4Cidr"]),
            "ClusterSecondaryRangeName": dict_safe_get(cluster, ["ipAllocationPolicy", "clusterSecondaryRangeName"]),
            "ServicesSecondaryRangeName": dict_safe_get(cluster, ["ipAllocationPolicy", "servicesSecondaryRangeName"]),
            "ClusterIpv4CidrBlock": dict_safe_get(cluster, ["ipAllocationPolicy", "clusterIpv4CidrBlock"]),
            "ServicesIpv4CidrBlock": dict_safe_get(cluster, ["ipAllocationPolicy", "servicesIpv4CidrBlock"]),
        },
        "MasterAuthorizedNetworksConfig": {
            "CIDR": [
                cidr.get("cidrBlock")
                for cidr in dict_safe_get(cluster, keys=["masterAuthorizedNetworksConfig", "cidrBlocks"], default_return_value={})
            ],
            "Enabled": dict_safe_get(cluster, ["masterAuthorizedNetworksConfig", "enabled"]),
        },
        "MaintenancePolicy": {
            "ResourceVersion": dict_safe_get(cluster, ["maintenancePolicy", "resourceVersion"]),
        },
        "NetworkConfig": {
            "Network": dict_safe_get(cluster, ["networkConfig", "network"]),
            "Subnetwork": dict_safe_get(cluster, ["networkConfig", "subnetwork"]),
        },
        "DefaultMaxPodsConstraint": {
            "MaxPodsPerNode": dict_safe_get(cluster, ["defaultMaxPodsConstraint", "maxPodsPerNode"]),
        },
        "AuthenticatorGroupsConfig": dict_safe_get(cluster, ["authenticatorGroupsConfig"]),
        "DatabaseEncryption": {
            "State": dict_safe_get(cluster, ["databaseEncryption", "state"]),
        },
        "SelfLink": dict_safe_get(cluster, ["selfLink"]),
        "Endpoint": dict_safe_get(cluster, ["endpoint"]),
        "InitialClusterVersion": dict_safe_get(cluster, ["initialClusterVersion"]),
        "CurrentMasterVersion": dict_safe_get(cluster, ["currentMasterVersion"]),
        "CreateTime": dict_safe_get(cluster, ["createTime"]),
        "Status": dict_safe_get(cluster, ["status"]),
        "ServicesIpv4Cidr": dict_safe_get(cluster, ["servicesIpv4Cidr"]),
        "Location": dict_safe_get(cluster, ["location"]),
    }


def parse_cluster_table(entry: dict) -> dict:
    """Build human readable structue

    Args:
        entry: Cluster entry of context entry

    Returns:
        dict: dict object as required for table markdown.
    """
    return {
        "Name": dict_safe_get(entry, ["Name"]),
        "Location": dict_safe_get(entry, ["Location"]),
        "Master version": dict_safe_get(entry, ["CurrentMasterVersion"]),
        "Master IP": dict_safe_get(entry, ["Endpoint"]),
        "Status": dict_safe_get(entry, ["Status"]),
    }


def parse_node_pool(node_pool: dict) -> dict:
    """Build entry context entry for a node pools entry.

    Args:
        node_pool: Node pool raw response from google API.

    Returns:
        dict: Node pool as defined entry context.
    """
    return {
        "Name": dict_safe_get(node_pool, ["name"]),
        "Config": {
            "MachineType": dict_safe_get(node_pool, ["config", "machineType"]),
            "DiskSizeGb": dict_safe_get(node_pool, ["config", "diskSizeGb"]),
            "OauthScopes": dict_safe_get(node_pool, ["config", "oauthScopes"]),
            "Metadata": {"DisableLegacyEndpoints": dict_safe_get(node_pool, ["config", "metadata", "disable-legacy-endpoints"])},
            "ImageType": dict_safe_get(node_pool, ["config", "imageType"]),
            "ServiceAccount": dict_safe_get(node_pool, ["config", "serviceAccount"]),
            "DiskType": dict_safe_get(node_pool, ["config", "diskType"]),
            "ShieldedInstanceConfig": {
                "EnableIntegrityMonitoring": dict_safe_get(
                    node_pool, ["config", "shieldedInstanceConfig", "enableIntegrityMonitoring"]
                )
            },
        },
        "InitialNodeCount": dict_safe_get(node_pool, ["initialNodeCount"]),
        "Autoscaling": {
            "Enabled": dict_safe_get(node_pool, ["autoscaling", "enabled"]),
            "MinNodeCount": dict_safe_get(node_pool, ["autoscaling", "minNodeCount"]),
            "MaxNodeCount": dict_safe_get(node_pool, ["autoscaling", "maxNodeCount"]),
        },
        "Management": {"AutoRepair": dict_safe_get(node_pool, ["management", "autoRepair"])},
        "MaxPodsConstraint": {"MaxPodsPerNode": dict_safe_get(node_pool, ["maxPodsConstraint", "maxPodsPerNode"])},
        "PodIpv4CidrSize": dict_safe_get(node_pool, ["podIpv4CidrSize"]),
        "SelfLink": dict_safe_get(node_pool, ["selfLink"]),
        "Version": dict_safe_get(node_pool, ["version"]),
        "InstanceGroupUrls": dict_safe_get(node_pool, ["instanceGroupUrls"]),
        "Status": dict_safe_get(node_pool, ["status"]),
    }


def parse_node_pool_table(entry: dict) -> dict:
    """Build human readable structue

    Args:
        entry: Node pool entry of context entry

    Returns:
        dict: dict object as required for table markdown.
    """
    return {
        "Name": dict_safe_get(entry, ["Name"]),
        "Machine Type": dict_safe_get(entry, ["Config", "MachineType"]),
        "Disk size": dict_safe_get(entry, ["Config", "DiskSizeGb"]),
        "Node version": dict_safe_get(entry, ["Version"]),
    }


def parse_operation(response_dict: dict):
    return {
        "Name": response_dict.get("name"),
        "Zone": response_dict.get("zone"),
        "OperationType": response_dict.get("operationType"),
        "Status": response_dict.get("status"),
        "SelfLink": response_dict.get("selfLink"),
        "TargetLink": response_dict.get("targetLink"),
        "StartTime": response_dict.get("startTime"),
    }


######################
# COMMANDS FUNCTIONS #
######################


def test_module_command(client: ClusterManagerClient, project: str, zone: str):
    """Test Google Kubernetes Engine client connection using gcloud-clusters-list command:
            1. project.
            2. zone.

    Args:
        client: Google container client.
        project: GCP project from console.
        zone: Project query zone, e.g. "europe-west2-a".

    Returns:
        str: Human readable.
        dict: Cluster entry context.
        dict: Cluster raw response.
    """
    # Query and gPRC unpack - will raise exception if not succeed
    try:
        client.list_clusters(project_id=project, zone=zone, timeout=API_TIMEOUT)
    except Exception:
        raise DemistoException("Unsuccessfull integration test - check configuration...")

    return "ok", {}, {}


def gcloud_clusters_list_command(client: ClusterManagerClient, project: str, zone: str) -> COMMAND_OUTPUT:
    """Lists all clusters owned by a project in either the specified zone or all zones.
        Original command - https://cloud.google.com/sdk/gcloud/reference/container/clusters/list

    Args:
        client: Google container client.
        project: GCP project from console.
        zone: Project query zone, e.g. "europe-west2-a".

    Returns:
        str: Human readable.
        dict: Cluster entry context.
        dict: Cluster raw response.
    """
    # Query and gPRC unpack
    raw_response_msg: ListClustersResponse = client.list_clusters(project_id=project, zone=zone, timeout=API_TIMEOUT)
    raw_response_dict: dict = MessageToDict(raw_response_msg._pb)

    # Entry context
    clusters_ec: list[dict] = [parse_cluster(cluster) for cluster in raw_response_dict.get("clusters", [])]
    entry_context = {
        CLUSTER_CONTEXT: clusters_ec,
    }
    # Human readable
    human_readable: str = tableToMarkdown(
        t=[parse_cluster_table(entry) for entry in clusters_ec], name=f"Clusters (Project={project}, Zone={zone})"
    )

    return human_readable, entry_context, raw_response_dict


def gcloud_clusters_describe_command(
    client: ClusterManagerClient, project: str = "", cluster: str = "", zone: str = ""
) -> COMMAND_OUTPUT:
    """Gets the details of a specific cluster.
        https://cloud.google.com/sdk/gcloud/reference/container/clusters/describe

    Args:
        client: Google container client.
        project: GCP project from console.
        cluster: Cluster ID, e.g. "dmst-gcloud-cluster-1".
        zone: Project query zone, e.g. "europe-west2-a".

    Returns:
        str: Human readable.
        dict: Cluster entry context.
        dict: Cluster raw response.
    """
    # Query and gPRC unpack
    raw_response_msg: Cluster = client.get_cluster(cluster_id=cluster, project_id=project, zone=zone, timeout=API_TIMEOUT)
    # Entry context
    raw_response_dict: dict = MessageToDict(raw_response_msg._pb)  # type: ignore[attr-defined]
    cluster_ec = parse_cluster(raw_response_dict)
    entry_context = {
        CLUSTER_CONTEXT: cluster_ec,
    }
    # Human readable
    human_readable: str = tableToMarkdown(
        t=parse_cluster_table(cluster_ec),
        name=f"Clusters (Project={project}, Zone={zone}, Cluster={cluster})",
    )

    return human_readable, entry_context, raw_response_dict


def gcloud_clusters_set_master_auth(
    client: ClusterManagerClient, project: str, cluster: str, zone: str, basic_auth: str | None = None
) -> COMMAND_OUTPUT:
    """Enable basic (username/password) auth for the cluster. Enable will create user admin with generated password.
        https://cloud.google.com/sdk/gcloud/reference/container/clusters/update#--enable-basic-auth

    Args:
        client: Google container client.
        project: GCP project from console.
        zone: Project query zone, e.g. "europe-west2-a".
        cluster: Cluster ID, e.g. "dmst-gcloud-cluster-1".
        basic_auth: "enable" or "disable".

    Returns:
        str: Human readable.
        dict: Operation entry context.
        dict: Operation raw response.
    """
    # Perform cluster update
    update = {"username": "admin" if basic_auth == "enable" else ""}
    raw_response_msg = client.set_master_auth(
        request={
            "action": "SET_USERNAME",
            "project_id": project,
            "zone": zone,
            "cluster_id": cluster,
            "update": update,
        },
        timeout=API_TIMEOUT,
    )
    raw_response_dict: dict = MessageToDict(raw_response_msg._pb)
    # Entry context
    operation: dict = parse_operation(raw_response_dict)
    entry_context = {OPERATION_CONTEXT: operation}
    # Human readable
    human_readable: str = tableToMarkdown(
        t=operation, headers=OPERATION_TABLE, name=f'Set master-auth operation - {operation.get("Name")}'
    )

    return human_readable, entry_context, raw_response_dict


def gcloud_clusters_set_addons_command(
    client: ClusterManagerClient,
    project: str,
    cluster: str,
    zone: str,
    http_load_balancing: str | None = None,
    kubernetes_dashboard: str | None = None,
    network_policy: str | None = None,
) -> COMMAND_OUTPUT:
    """Sets the addons for a specific cluster.
        https://cloud.google.com/sdk/gcloud/reference/container/clusters/update#--update-addons

    Args:
        client: Google container client.
        project: GCP project from console.
        zone: Project query zone, e.g. "europe-west2-a".
        cluster: Cluster ID, e.g. "dmst-gcloud-cluster-1".
        http_load_balancing: "enable" or "disable".
        kubernetes_dashboard: "enable" or "disable".
        network_policy: "enable" or "disable".

    Returns:
        str: Human readable.
        dict: Operation entry context.
        dict: Operation raw response.
    """
    # Perform cluster update
    update: AddonsConfig = {}  # type: ignore[assignment]
    if http_load_balancing:
        update["http_load_balancing"] = {"disabled": http_load_balancing != "enable"}
    if kubernetes_dashboard:
        update["kubernetes_dashboard"] = {"disabled": kubernetes_dashboard != "enable"}
    if network_policy:
        update["network_policy_config"] = {"disabled": network_policy != "enable"}
    raw_response_msg = client.set_addons_config(
        project_id=project, zone=zone, cluster_id=cluster, addons_config=update, timeout=API_TIMEOUT
    )
    raw_response_dict: dict = MessageToDict(raw_response_msg._pb)
    # Entry context
    operation: dict = parse_operation(raw_response_dict)
    entry_context = {
        OPERATION_CONTEXT: operation,
    }
    # Human readable
    human_readable: str = tableToMarkdown(
        t=operation, headers=OPERATION_TABLE, name=f'Set addons - Operation: {operation.get("Name")}'
    )

    return human_readable, entry_context, raw_response_dict


def gcloud_clusters_set_legacy_auth_command(
    client: ClusterManagerClient, project: str, cluster: str, zone: str, enable: str | None = None
) -> COMMAND_OUTPUT:
    """Enable or Disable legacy ABAC auth.
        https://cloud.google.com/sdk/gcloud/reference/container/clusters/update#--enable-legacy-authorization

    Args:
        client: Google container client.
        project: GCP project from console.
        zone: Project query zone, e.g. "europe-west2-a".
        cluster: Cluster ID, e.g. "dmst-gcloud-cluster-1".
        enable: "true" or "false"

    Returns:
        str: Human readable.
        dict: Operation entry context.
        dict: Operation raw response.
    """
    # Perform cluster update
    raw_response_msg = client.set_legacy_abac(
        project_id=project, zone=zone, cluster_id=cluster, enabled=(enable == "true"), timeout=API_TIMEOUT
    )
    raw_response_dict: dict = MessageToDict(raw_response_msg._pb)  # type: ignore[attr-defined]
    # Entry context
    operation: dict = parse_operation(raw_response_dict)
    entry_context = {
        OPERATION_CONTEXT: operation,
    }
    # Human readable
    human_readable: str = tableToMarkdown(
        t=operation, headers=OPERATION_TABLE, name=f'Set legacy auth - Operation: {operation.get("Name")}'
    )

    return human_readable, entry_context, raw_response_dict


def gcloud_clusters_set_master_authorized_network_command(
    client: ClusterManagerClient, project: str, cluster: str, zone: str, enable: str | None = None, cidrs: str | None = None
) -> COMMAND_OUTPUT:
    """Enable or Disable authorized CIDRs to master node and add cidrs.
        https://cloud.google.com/sdk/gcloud/reference/container/clusters/update#--master-authorized-networks

    Args:
        client: Google container client.
        project: GCP project from console.
        zone: Project query zone, e.g. "europe-west2-a".
        cluster: Cluster ID, e.g. "dmst-gcloud-cluster-1".
        enable: "true" or "false"
        cidrs: Comma separated list of CIDRs 192.160.0.0/24,10.0.0.0/24,

    Returns:
        str: Human readable.
        dict: Operation entry context.
        dict: Operation raw response.
    """
    # Perform cluster update
    update = {
        "desired_master_authorized_networks_config": {
            "enabled": enable == "true",
            "cidr_blocks": [{"cidr_block": cidr_block} for cidr_block in argToList(cidrs)],
        }
    }

    raw_response_msg = client.update_cluster(
        project_id=project,
        zone=zone,
        cluster_id=cluster,
        update=update,  # type: ignore[arg-type]
        timeout=API_TIMEOUT,
    )
    raw_response_dict: dict = MessageToDict(raw_response_msg._pb)
    # Entry context
    operation: dict = parse_operation(raw_response_dict)
    entry_context = {
        OPERATION_CONTEXT: operation,
    }
    # Human readable
    human_readable: str = tableToMarkdown(
        t=operation, headers=OPERATION_TABLE, name=f'Set master authorized networks - Operation: {operation.get("Name")}'
    )

    return human_readable, entry_context, raw_response_dict


def gcloud_clusters_set_k8s_stackdriver_command(
    client: ClusterManagerClient, project: str, cluster: str, zone: str, enable: str | None = None
) -> COMMAND_OUTPUT:
    """Enable or Disable k8s stackdriver.
        https://cloud.google.com/sdk/gcloud/reference/container/clusters/update#--enable-stackdriver-kubernetes

    Args:
        client: Google container client.
        project: GCP project from console.
        zone: Project query zone, e.g. "europe-west2-a".
        cluster: Cluster ID, e.g. "dmst-gcloud-cluster-1".
        enable: "true" or "false"

    Returns:
        str: Human readable.
        dict: Operation entry context.
        dict: Operation raw response.

    Notes:
        1. The monitoring and logging should be configured to same resource and it can done only via gcp console.
    """
    # Perform cluster update
    update = "monitoring.googleapis.com/kubernetes" if enable == "true" else ""
    raw_response_msg = client.set_monitoring_service(
        project_id=project, zone=zone, cluster_id=cluster, monitoring_service=update, timeout=API_TIMEOUT
    )

    raw_response_dict: dict = MessageToDict(raw_response_msg._pb)  # type: ignore[attr-defined]
    # Entry context
    operation: dict = parse_operation(raw_response_dict)
    entry_context = {
        OPERATION_CONTEXT: operation,
    }
    # Human readable
    human_readable: str = tableToMarkdown(
        t=operation, headers=OPERATION_TABLE, name=f'Set kubernetes stackdriver - Operation: {operation.get("Name")}'
    )

    return human_readable, entry_context, raw_response_dict


def gcloud_clusters_set_binary_auth(
    client: ClusterManagerClient, project: str, cluster: str, zone: str, enable: str | None = None
) -> COMMAND_OUTPUT:
    """Enable or Disable binary authorize.
        https://cloud.google.com/sdk/gcloud/reference/container/clusters/update#--enable-binauthz

    Args:
        client: Google container client.
        project: GCP project from console.
        zone: Project query zone, e.g. "europe-west2-a".
        cluster: Cluster ID, e.g. "dmst-gcloud-cluster-1".
        enable: "true" or "false"

    Returns:
        str: Human readable.
        dict: Operation entry context.
        dict: Operation raw response.
    """
    # Perform cluster update
    update: ClusterUpdate = {
        "desired_binary_authorization": {
            "enabled": enable == "enable",
        }
    }  # type: ignore[assignment]
    raw_response_msg = client.update_cluster(
        project_id=project, zone=zone, cluster_id=cluster, update=update, timeout=API_TIMEOUT
    )
    raw_response_dict: dict = MessageToDict(raw_response_msg._pb)
    # Entry context
    operation: dict = parse_operation(raw_response_dict)
    entry_context = {
        OPERATION_CONTEXT: operation,
    }
    # Human readable
    human_readable: str = tableToMarkdown(
        t=operation, headers=OPERATION_TABLE, name=f'Set kubernetes binary authorization - Operation: {operation.get("Name")}'
    )

    return human_readable, entry_context, raw_response_dict


def gcloud_clusters_set_intra_node_visibility(
    client: ClusterManagerClient, project: str, cluster: str, zone: str, enable: str | None = None
) -> COMMAND_OUTPUT:
    """Enable or Disable for intra node visibility in cluster.
        https://cloud.google.com/sdk/gcloud/reference/container/clusters/update#--enable-intra-node-visibility

    Args:
        client: Google container client.
        project: GCP project from console.
        zone: Project query zone, e.g. "europe-west2-a".
        cluster: Cluster ID, e.g. "dmst-gcloud-cluster-1".
        enable: "true" or "false"

    Returns:
        str: Human readable.
        dict: Operation entry context.
        dict: Operation raw response.
    """
    # Perform cluster update
    update: ClusterUpdate = {
        "desired_intra_node_visibility_config": {
            "enabled": enable == "enable",
        }
    }  # type: ignore[assignment]

    raw_response_msg = client.update_cluster(
        project_id=project, zone=zone, cluster_id=cluster, update=update, timeout=API_TIMEOUT
    )
    raw_response_dict: dict = MessageToDict(raw_response_msg._pb)
    # Entry context
    operation: dict = parse_operation(raw_response_dict)
    entry_context = {
        OPERATION_CONTEXT: operation,
    }
    # Human readable
    human_readable: str = tableToMarkdown(
        t=operation, headers=OPERATION_TABLE, name=f'Set intra node visibility - Operation: {operation.get("Name")}'
    )

    return human_readable, entry_context, raw_response_dict


def gcloud_node_pool_list_command(client: ClusterManagerClient, project: str, zone: str, cluster: str) -> COMMAND_OUTPUT:
    """gcloud container node-pools list - list existing node pools for a cluster
        https://cloud.google.com/sdk/gcloud/reference/container/node-pools/list

    Args:
        client: Google container client.
        project: GCP project from console.
        zone: Project query zone, e.g. "europe-west2-a".
        cluster: Cluster ID, e.g. "dmst-gcloud-cluster-1".

    Returns:
        str: Human readable.
        dict: Cluster entry context.
        dict: Cluster raw response.
    """
    # Query and gPRC unpack
    raw_response_msg = client.list_node_pools(project_id=project, zone=zone, cluster_id=cluster, timeout=API_TIMEOUT)
    raw_response_dict: dict = MessageToDict(raw_response_msg._pb)
    # Entry context
    node_pools_ec: list[dict] = [parse_node_pool(node_pool) for node_pool in raw_response_dict.get("nodePools", [])]
    entry_context = {NODE_POOL_CONTEXT: node_pools_ec}
    # Human readable
    human_readable: str = tableToMarkdown(
        t=[parse_node_pool_table(entry) for entry in node_pools_ec],
        name=f"Node-pools (Project={project}, Zone={zone}, Cluster={cluster})",
    )

    return human_readable, entry_context, raw_response_dict


def gcloud_node_pool_describe_command(
    client: ClusterManagerClient, project: str, zone: str, cluster: str, node_pool: str
) -> COMMAND_OUTPUT:
    """gcloud container node-pools list - list existing node pools for a cluster
        https://cloud.google.com/sdk/gcloud/reference/container/node-pools/describe

    Args:
        client: Google container client.
        project: GCP project from console.
        zone: Project query zone, e.g. "europe-west2-a".
        cluster: Cluster ID, e.g. "dmst-gcloud-cluster-1".
        node_pool: Node pool id, e.g. "dmst-gke-pool-1".

    Returns:
        str: Human readable.
        dict: Cluster entry context.
        dict: Cluster raw response.
    """
    # Query and gPRC unpack
    raw_response_msg = client.get_node_pool(
        project_id=project, zone=zone, cluster_id=cluster, node_pool_id=node_pool, timeout=API_TIMEOUT
    )
    raw_response_dict: dict = MessageToDict(raw_response_msg._pb)  # type: ignore[attr-defined]
    # Entry context
    node_pools_ec: dict = parse_node_pool(raw_response_dict)
    entry_context = {NODE_POOL_CONTEXT: node_pools_ec}
    # Human readable
    human_readable: str = tableToMarkdown(
        t=parse_node_pool_table(node_pools_ec),
        name=f"Node-pools (Project={project}, Zone={zone}, Cluster={cluster}, Node pool={node_pool})",
    )

    return human_readable, entry_context, raw_response_dict


def gcloud_set_node_pool_management(
    client: ClusterManagerClient,
    project: str,
    zone: str,
    cluster: str,
    node_pool: str,
    auto_repair: str | None = None,
    auto_upgrade: str | None = None,
) -> COMMAND_OUTPUT:
    """Disable or Enable node-pool functionallity:
            1. auto-repair.
            2. auto-upgrade.
        https://cloud.google.com/sdk/gcloud/reference/container/node-pools/update

    Args:
        client: Google container client.
        project: GCP project from console.
        zone: Project query zone, e.g. "europe-west2-a".
        cluster: Cluster ID, e.g. "dmst-gcloud-cluster-1".
        node_pool: Node pool id, e.g. "dmst-gke-pool-1".
        auto_repair: A flag that specifies whether the node auto-repair is enabled for the node pool.
        auto_upgrade: A flag that specifies whether node auto-upgrade is enabled for the node pool.

    Returns:
        str: Human readable.
        dict: Operation entry context.
        dict: Operation raw response.
    """
    # Perform node pools update
    update = {}
    if auto_repair:
        update["auto_repair"] = auto_repair == "enable"
    if auto_upgrade:
        update["auto_upgrade"] = auto_upgrade == "enable"

    raw_response_msg = client.set_node_pool_management(
        request={
            "project_id": project,
            "zone": zone,
            "cluster_id": cluster,
            "node_pool_id": node_pool,
            "management": update,
        },
        timeout=API_TIMEOUT,
    )
    raw_response_dict: dict = MessageToDict(raw_response_msg._pb)  # type: ignore[attr-defined]
    # Entry context
    operation: dict = parse_operation(raw_response_dict)
    entry_context = {
        OPERATION_CONTEXT: operation,
    }
    # Human readable
    human_readable: str = tableToMarkdown(
        t=operation,
        headers=OPERATION_TABLE,
        name=f'Project {project} - Zone {zone} - Cluster {cluster} - {operation.get("Name")}',
    )

    return human_readable, entry_context, raw_response_dict


def gcloud_operations_list_command(client: ClusterManagerClient, project: str, zone: str) -> COMMAND_OUTPUT:
    """List operations in project-zone.
        https://cloud.google.com/sdk/gcloud/reference/container/operations/list

    Args:
        client: Google container client.
        project: GCP project from console.
        zone: Project query zone, e.g. "europe-west2-a".

    Returns:
        str: Human readable.
        dict: Operation entry context.
        dict: Operation raw response.
    """
    # Query operation status

    raw_response_msg = client.list_operations(project_id=project, zone=zone, timeout=API_TIMEOUT)
    raw_response_dict: dict = MessageToDict(raw_response_msg._pb)
    # Entry context
    operations: list[dict] = [parse_operation(operation) for operation in raw_response_dict.get("operations", [])]
    entry_context = {
        OPERATION_CONTEXT: operations,
    }
    # Human readable
    human_readable: str = tableToMarkdown(
        t=operations, headers=OPERATION_TABLE, name=f"Project {project} - Zone {zone} - Operations"
    )

    return human_readable, entry_context, raw_response_dict


def gcloud_operations_describe_command(client: ClusterManagerClient, project: str, zone: str, operation: str) -> COMMAND_OUTPUT:
    """Retrieve operation information by name.
        https://cloud.google.com/sdk/gcloud/reference/container/operations/describe

    Args:
        client: Google container client.
        project: GCP project from console.
        zone: Project query zone, e.g. "europe-west2-a".
        operation: Operation name.

    Returns:
        str: Human readable.
        dict: Operation entry context.
        dict: Operation raw response.
    """
    # Query operation status
    raw_response_msg = client.get_operation(project_id=project, zone=zone, operation_id=operation, timeout=API_TIMEOUT)
    raw_response_dict: dict = MessageToDict(raw_response_msg._pb)
    # Entry context
    operations: dict = parse_operation(raw_response_dict)
    entry_context = {
        OPERATION_CONTEXT: operations,
    }
    # Human readable
    human_readable: str = tableToMarkdown(
        t=operations, headers=OPERATION_TABLE, name=f"Project {project} - Zone {zone} - Operation {operation}"
    )

    return human_readable, entry_context, raw_response_dict


def gcloud_operations_cancel_command(client: ClusterManagerClient, project: str, zone: str, operation: str) -> COMMAND_OUTPUT:
    """Cancel operation by operation name.

    Args:
        client: Google container client.
        project: GCP project from console.
        zone: Project query zone, e.g. "europe-west2-a".
        operation: Operation name.

    Returns:
        str: Human readable.
        dict: Operation entry context - will be empty.
        dict: Operation raw response - will be empty.
    """
    # Query operation status
    client.cancel_operation(project_id=project, zone=zone, operation_id=operation, timeout=API_TIMEOUT)
    # Human readable
    human_readable: str = f"Project {project} - Zone {zone} - Operation {operation} canceled"

    return human_readable, {}, {}


def main():
    """
    PARSE AND VALIDATE INTEGRATION PARAMS
    """
    # Execute command
    command = demisto.command()
    LOG(f"Command being called is {command}")
    commands: dict[str, Callable] = {
        # Clusters
        "test-module": test_module_command,
        f"{INTEGRATION_COMMAND_NAME}-clusters-list": gcloud_clusters_list_command,
        f"{INTEGRATION_COMMAND_NAME}-clusters-describe": gcloud_clusters_describe_command,
        f"{INTEGRATION_COMMAND_NAME}-clusters-set-muster-auth": gcloud_clusters_set_master_auth,
        f"{INTEGRATION_COMMAND_NAME}-clusters-set-addons": gcloud_clusters_set_addons_command,
        f"{INTEGRATION_COMMAND_NAME}-clusters-set-legacy-auth": gcloud_clusters_set_legacy_auth_command,
        f"{INTEGRATION_COMMAND_NAME}-clusters-set-master-authorized-network":  # noqa: E501
        gcloud_clusters_set_master_authorized_network_command,
        f"{INTEGRATION_COMMAND_NAME}-clusters-set-k8s-stackdriver": gcloud_clusters_set_k8s_stackdriver_command,
        f"{INTEGRATION_COMMAND_NAME}-clusters-set-binary-auth": gcloud_clusters_set_binary_auth,
        f"{INTEGRATION_COMMAND_NAME}-clusters-set-intra-node-visibility": gcloud_clusters_set_intra_node_visibility,
        # Node pools
        f"{INTEGRATION_COMMAND_NAME}-node-pool-list": gcloud_node_pool_list_command,
        f"{INTEGRATION_COMMAND_NAME}-node-pool-describe": gcloud_node_pool_describe_command,
        f"{INTEGRATION_COMMAND_NAME}-node-pool-set-management": gcloud_set_node_pool_management,
        # Operation handling
        f"{INTEGRATION_COMMAND_NAME}-operations-list": gcloud_operations_list_command,
        f"{INTEGRATION_COMMAND_NAME}-operations-describe": gcloud_operations_describe_command,
        f"{INTEGRATION_COMMAND_NAME}-operations-cancel": gcloud_operations_cancel_command,
    }
    try:
        client: ClusterManagerClient = google_client_setup(
            demisto.params().get("credentials", {}).get("password") or demisto.params().get("credentials_json")
        )
        command_arguments = handle_default_configuration()
        readable_output, context_entry, raw_response = commands[command](client=client, **command_arguments)

        return_outputs(readable_output=readable_output, outputs=context_entry, raw_response=raw_response)
    except Exception as e:
        # Log exceptions
        return_error(f"Integration {INTEGRATION_NAME} Failed to execute {command} command.\n Error: {e!s}")


if __name__ in ("__main__", "__builtin__", "builtins"):
    main()