CloudWiki
Rules
Detect, troubleshoot & optimize AWS environments in real-time ->
Medium

Prevent Service from exposing node port

Security & Compliance
No items found.
Description

Prevent Service from exposing node port is a best practice to ensure that Kubernetes Services are not directly exposed on the host network, which could potentially introduce security vulnerabilities. This practice involves configuring Services to use ClusterIP or LoadBalancer types, rather than NodePort type, to avoid exposing unnecessary ports on the host machine.

Remediation

To prevent a Kubernetes service from exposing a node port, you can remove the nodePort field from the service manifest file or set it to null. Here are the remediation steps:

  1. Identify the name of the service that is exposing a node port.
  2. Open the service manifest file using a text editor or by running the command kubectl edit svc <service-name>.
  3. Locate the nodePort field in the file and remove it or set it to null.
  4. Save the changes to the file.
  5. Verify that the service no longer exposes a node port by running the command kubectl describe svc <service-name> and checking the output for the absence of the NodePort: field.
  6. Repeat the process for any other services that are exposing node ports.
  7. Finally, it is recommended to enforce this configuration by using a network policy to block traffic to node ports.
Enforced Resources
Note: Remediation steps provided by Lightlytics are meant to be suggestions and guidelines only. It is crucial to thoroughly verify and test any remediation steps before applying them to production environments. Each organization's infrastructure and security needs may differ, and blindly applying suggested remediation steps without proper testing could potentially cause unforeseen issues or vulnerabilities. Therefore, it is strongly recommended that you validate and customize any remediation steps to meet your organization's specific requirements and ensure that they align with your security policies and best practices.
Deploy cloud infrastructure changes with confidence. Troubleshoot faster with the complete context of your cloud environment.
GET STARTED