(http(s)?://)?<svc>(.<ns>(.svc.cluster.local)?)?(:<portNum>)? (1)
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.
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
, and StatefulSet
as YAML files in the specified directory.
Verify that you can apply these YAML files as-is using the kubectl apply -f
command. 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>)? (1)
1 | In this pattern,
|
Following are some examples that match the pattern:
wordpress-mysql:3306
redis-follower.redis.svc.cluster.local:6379
redis-leader.redis
http://rating-service.
Verify that the build-time network policy generation feature is available by running the help command:
$ roxctl netpol generate -h
Generate the policies by using the netpol generate
command:
$ roxctl netpol generate <folder-path> (1)
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 |