Event Information

Meaning

  • This event indicates that a pod in the Kubernetes cluster is attempting to establish an outbound connection to a destination that is not expected based on the defined network policies.
  • To investigate further, you can use the following kubectl command to identify the pod generating the unexpected outbound connection: kubectl get pods --all-namespaces -o wide
  • Once you have identified the pod, you can review its configuration and network policies to determine why it is attempting to connect to the unexpected destination: kubectl describe pod <pod_name> -n <namespace>

Remediation

  • Create a NetworkPolicy to restrict outbound connections:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: restrict-outbound-connections
spec:
  podSelector: {}
  policyTypes:
  - Egress
  egress:
  - ports:
    - port: 80
      protocol: TCP
    - port: 443
      protocol: TCP
  • Apply the NetworkPolicy to the namespace where the affected pods are running:
kubectl apply -f networkpolicy.yaml -n <namespace>
  • Verify that the NetworkPolicy is applied correctly:
kubectl get networkpolicy restrict-outbound-connections -n <namespace>