GatekeeperPolicy Examples

Policy Examples

SRExpert provides 50+ pre-built Gatekeeper policies organized by category. Use these policies to enforce security, best practices, and governance in your Kubernetes clusters.

How to Use

  1. Go to Security > Gatekeeper in SRExpert
  2. Click + Create Policy
  3. Select a template from the dropdown
  4. Configure target clusters and parameters
  5. Click Create

For detailed instructions, see the Gatekeeper Overview.

Security Policies

This section contains critical policies to protect your clusters from security vulnerabilities.

PolicyKindDescriptionSeverity
Block PrivilegedK8sBlockPrivilegedBlocks privileged containers that have root access to the hostCritical
Block Host NetworkK8sBlockHostNetworkPrevents pods from using host network namespaceCritical
Block Host PathK8sBlockHostPathPrevents use of hostPath volumes that expose host filesystemCritical
Block Host IPCK8sBlockHostIPCPrevents pods from using host IPC and PID namespacesCritical
Block Cluster AdminK8sBlockClusterAdminPrevents binding of cluster-admin role to users/groupsCritical
Block Special GroupsK8sBlockSpecialGroupsPrevents use of dangerous supplementalGroups (like docker group)Critical
Block Wildcard SecretsK8sBlockWildcardSecretsPrevents RBAC rules with wildcard access to secretsCritical
Require Non-RootK8sRequireNonRootRequires containers to run as non-root userHigh
Block Privilege EscalationK8sBlockPrivilegeEscalationPrevents privilege escalation in containersHigh
Require Security ContextK8sRequireSecurityContextRequires pods and containers to define securityContextHigh
Read-Only Root FilesystemK8sReadOnlyRootFilesystemRequires containers to use read-only root filesystemHigh
Require PSSK8sRequirePSSRequires namespaces to have Pod Security Standards labelsHigh
Seccomp ProfileK8sSeccompRequires pods to use RuntimeDefault or Localhost seccomp profileHigh
Limit CapabilitiesK8sLimitCapabilitiesLimits Linux capabilities that containers can requestHigh
Drop CapabilitiesK8sDropCapabilitiesRequires containers to drop ALL capabilities by defaultHigh
Block Bind Host PortsK8sBlockBindHostPortsPrevents containers from binding to host portsHigh
Block External IPsK8sBlockExternalIPsPrevents services from using externalIPsHigh
Block Default SA TokenK8sBlockDefaultSATokenPrevents manual creation of default ServiceAccount token secretsHigh
Require Ingress TLSK8sRequireIngressTLSRequires all Ingress resources to use TLS/HTTPSHigh
Require Pod Security PolicyK8sRequirePodSecurityPolicyRequires pods to reference a PodSecurityPolicyHigh
Block Docker ImagesK8sBlockDockerImagesPrevents use of public Docker Hub images without registry prefixMedium
Block Wildcard IngressK8sBlockWildcardIngressPrevents wildcard hosts in Ingress resourcesMedium
AppArmor ProfileK8sAppArmorRequires containers to use AppArmor profileMedium
Require Service AccountK8sRequireServiceAccountNameRequires pods to explicitly define serviceAccountNameMedium
Block Automount SA TokenK8sBlockAutomountSATokenPrevents automatic mounting of service account tokensMedium

Reliability Policies

Ensure your applications are resilient and highly available.

PolicyKindDescriptionSeverity
Require PDBK8sRequirePDBRequires HA deployments to have PodDisruptionBudgetMedium
Require Valid PDBK8sRequireValidPDBRequires PodDisruptionBudget to have valid minAvailableMedium
Require Rolling StrategyK8sRequireRollingStrategyRequires deployments to use RollingUpdate strategyMedium
Require Anti-AffinityK8sRequireAntiAffinityRequires HA deployments to use pod anti-affinityMedium
Require CronJob TimeoutK8sRequireCronJobTimeoutRequires CronJobs to have activeDeadlineSecondsMedium
Require Backup AnnotationK8sRequireBackupAnnotationRequires StatefulSets to have backup strategy annotationMedium
Require Lifecycle HooksK8sRequireLifecycleHooksRequires containers to define preStop hook for graceful shutdownLow
Require Startup ProbeK8sRequireStartupProbeRequires slow-starting containers to have startupProbeLow
Require Probe PeriodK8sRequireProbePeriodRequires probes to have appropriate periodSecondsLow
Require HPAK8sRequireHPARequires production deployments to have HPA configuredLow
Require Termination GraceK8sRequireTerminationGracePeriodRequires appropriate terminationGracePeriodSecondsLow

Networking Policies

Control network access and traffic flow.

PolicyKindDescriptionSeverity
Require Network PolicyK8sRequireNetworkPolicyRequires deployments to have network-policy labelHigh
Require Egress RulesK8sRequireEgressRequires NetworkPolicy to define egress rulesHigh
Require Ingress RulesK8sRequireIngressRequires NetworkPolicy to define ingress rulesHigh

Best Practices

Enforce Kubernetes best practices across your clusters.

PolicyKindDescriptionSeverity
Block Deprecated APIK8sBlockDeprecatedAPIBlocks deprecated Kubernetes API versionsHigh
Require Resource RequestsK8sRequireResourceRequestsRequires containers to define CPU and memory requestsMedium
Block Priority Class HighK8sBlockPriorityClassHighPrevents non-system pods from using high priority classesMedium
Block EmptyDir SizeK8sBlockEmptyDirSizeRequires emptyDir volumes to have sizeLimitMedium
Require Owner LabelK8sRequireOwnerLabelRequires owner labels for resource trackingMedium
Block Default NamespaceK8sBlockDefaultNamespacePrevents deployment of resources in default namespaceLow
Require Revision HistoryK8sRequireRevisionHistoryRequires appropriate revisionHistoryLimitLow
Require Node SelectorK8sRequireNodeSelectorRequires pods to have nodeSelector for workload isolationLow
Require TolerationsK8sRequireTolerationsRequires pods to define tolerations for tainted nodesLow
Require Container ResourcesK8sRequireContainerResourcesRequires container requests to match limits (guaranteed QoS)Low

Governance Policies

Maintain consistent labeling and metadata standards.

PolicyKindDescriptionSeverity
Require Valid LabelsK8sRequireValidLabelsEnsures labels follow naming conventionsLow
Require AnnotationsK8sRequireAnnotationsRequires specific annotations for governanceLow

Cost Optimization Policies

Control cloud costs and resource usage.

PolicyKindDescriptionSeverity
Require Limit RangeK8sRequireLimitRangeRequires namespaces to have LimitRange annotationMedium
Require Namespace QuotaK8sRequireNamespaceQuotaRequires namespaces to have ResourceQuota annotationMedium
Block LB Without AnnotationK8sBlockLoadBalancerWithoutAnnotationRequires LoadBalancer services to have cost-tracking annotationsMedium
Limit ReplicasK8sLimitReplicasLimits maximum number of replicas for cost controlLow

Severity Guide

SeverityResponse TimeDescription
CriticalImmediateSecurity vulnerabilities that could lead to cluster compromise
HighSame dayImportant security or reliability issues
MediumWithin a weekBest practices that improve security and operations
LowWhen convenientRecommendations for better organization and efficiency

Next Steps