Triage and Remediation
Remediation
Using Console
Using Console
To remediate the Pod Security Policy misconfiguration in GCP using the GCP console, follow these steps:
- Open the Google Kubernetes Engine (GKE) console.
- Select the GKE cluster for which you want to enable Pod Security Policy.
- Click on the “Edit” button.
- Under the “Security” section, click on “Enable Pod Security Policy”.
- Click on the “Save” button to apply the changes.
- Once the changes are applied, Pod Security Policy will be enabled for the selected GKE cluster.
Using CLI
Using CLI
To remediate the “Pod Security Policy Should Be Enabled” misconfiguration in GCP, you can follow these step-by-step instructions using GCP CLI:Make sure to replace Make sure to replace
- First, ensure that you have the necessary permissions to create and modify Pod Security Policies in your GCP project.
- Open the Google Cloud Console and navigate to the Kubernetes Engine section.
- Select the cluster where you want to enable Pod Security Policy.
- Click the “Edit” button to edit the cluster configuration.
- Scroll down to the “Security” section and click “Enable Pod Security Policy”.
- Click “Save” to apply the changes.
- Alternatively, you can use the GCP CLI to enable Pod Security Policy for your GCP cluster. Open your terminal or command prompt and run the following command:
CLUSTER_NAME
with the name of your GCP cluster.- Verify that Pod Security Policy has been enabled by running the following command:
CLUSTER_NAME
with the name of your GCP cluster and ZONE
with the zone where your cluster is located.If the output shows "podSecurityPolicyConfig": {"enabled": true}
, then Pod Security Policy has been successfully enabled for your GCP cluster.Using Python
Using Python
To remediate the misconfiguration of Pod Security Policy not being enabled in GCP using Python, follow the below steps:
-
Install the required Python libraries:
-
Authenticate to the GCP project using a service account:
-
Connect to the Kubernetes cluster using the Kubernetes Python client:
-
Create a Pod Security Policy object:
-
Create the Pod Security Policy object in the Kubernetes cluster:
-
Verify that the Pod Security Policy object was created successfully: