External LoadBalancer Service in use

Verify the actual exposure of LoadBalancer Services and restrict unnecessary external routes to internal services.

Description

type: LoadBalancer requests a load balancer. The cloud provider and installed controller determine whether its endpoint is public or internal.

Potential impact

A public endpoint for an internal service allows unintended direct connections. Weak authentication or access rules can expose data.

Remediation

Use ClusterIP for cluster-only traffic or an internal load balancer for private-network clients. Approve public access only where required, then verify the provisioned endpoint and its access rules.

Examples

The different Service names create separate resources. AWS Load Balancer Controller gives aws-load-balancer-scheme precedence over the older annotation shown here. Check support in the installed controller version.

Before

yaml
apiVersion: v1
kind: Service
metadata:
  name: sample-service-public
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  type: LoadBalancer
  selector:
    app: nginx

After

yaml
apiVersion: v1
kind: Service
metadata:
  name: sample-service-internal
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-internal: "true"
spec:
  ports:
    - port: 80
      targetPort: 80
      protocol: TCP
  type: LoadBalancer
  selector:
    app: nginx

Explanation:

  • Before: The name sample-service-public alone does not establish exposure. Check the load balancer’s actual scheme.
  • After: On a supporting AWS controller, sample-service-internal requests an internal load balancer. Test the internal route before removing an unneeded public path.

References