This documentation is for a release that is no longer maintained.
You can select a different version or view all RHACS documentation.Chapter 6. Generating build-time network policies
The build-time network policy generator is included in the roxctl CLI. For the build-time network policy generation feature, roxctl CLI does not need to communicate with RHACS Central so you can use it in any development environment.
6.1. Using the build-time network policy generator Copy linkLink copied to clipboard!
Prerequisites
-
The build-time network policy generator recursively scans the directory you specify when you run the command. Therefore, before you run the command, you must already have service manifests, config maps, and workload manifests such as
Pod,Deployment,ReplicaSet,Job,DaemonSet, andStatefulSetas YAML files in the specified directory. -
Verify that you can apply these YAML files as-is using the
kubectl apply -fcommand. The build-time network policy generator does not work with files that use Helm-style templating. Verify that the service network addresses are not hardcoded. Every workload that needs to connect to a service must specify the service network address as a variable. You can specify this variable by using the workload’s resource environment variable or in a config map.
Service network addresses must match the following official regular expression pattern:
(http(s)?://)?<svc>(.<ns>(.svc.cluster.local)?)?(:<portNum>)?
(http(s)?://)?<svc>(.<ns>(.svc.cluster.local)?)?(:<portNum>)?1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- In this pattern,
- <svc> is the service name.
- <ns> is the namespace where you defined the service.
- <portNum> is the exposed service port number.
Following are some examples that match the pattern:
-
wordpress-mysql:3306 -
redis-follower.redis.svc.cluster.local:6379 -
redis-leader.redis -
http://rating-service.
Procedure
Verify that the build-time network policy generation feature is available by running the help command:
roxctl netpol generate -h
$ roxctl netpol generate -hCopy to Clipboard Copied! Toggle word wrap Toggle overflow Generate the policies by using the
netpol generatecommand:roxctl netpol generate <folder-path>
$ roxctl netpol generate <folder-path>1 Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the path of the folder that has the Kubernetes manifests.
The roxctl netpol generate command supports the following options:
|
| Description |
|
|
View the help text for the |
|
| Save the generated policies into a target folder. One file per policy. |
|
| Save and merge the generated policies into a single YAML file. |
|
|
Fail on the first encountered error. The default value is |
|
| Remove the output path if it already exist. |
|
|
Treat warnings as errors. The default value is |