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
apiVersion: v1
kind: Service
metadata:
name: sample-service-public
spec:
ports:
- port: 80
targetPort: 80
protocol: TCP
type: LoadBalancer
selector:
app: nginx
After
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-publicalone does not establish exposure. Check the load balancer’s actual scheme. - After: On a supporting AWS controller,
sample-service-internalrequests an internal load balancer. Test the internal route before removing an unneeded public path.