Installing new or updating network policies
After you applied the updated custom resource, you can install new network policies.
Before you begin
Generating and installing network policies is not supported if Cloud Pak for Business Automation is installed in
All Namespaces.
About this task
During the upgrade of your CP4BA deployment, the
shared_configuration.sc_generate_sample_network_policies parameter is added to the
custom resource, and the value is set to false by default. If you want to generate
new network policies, then you need to set the parameter value to true.
After you set the sc_generate_sample_network_policies parameter value to
true, you must wait for the operators to complete reconcile before you can retrieve
the network policy templates. You can check the status in the CP4BA custom resource (CR) to make
sure that the deployment is complete (Ready).
The cp4a-network-policies.sh script can be found in the cert-kubernetes repository. The script helps you to install the network policies for your CP4BA production deployment.
The cert-kubernetes/scripts/cp4a-network-policies.sh script has three modes for a production deployment type:
- generate
- The
generatemode copies the network policy files from the operators to the local subfolder named "network-policies".Note: Network policy files are generated only for the capabilities that are included in your deployment. Some operators do not have network policy templates. - install
- The
installmode installs the network policies on your cluster. - delete
- The
deletemode removes the network policies from your cluster.
The script can be run with the following options:
sh ./cp4a-network-policies.sh --help
Usage:
cp4a-network-policies.sh -m [modeType] -n [cp4ba_namespace]
Options:
-h Display help
-m Required: The valid mode types are: [generate], [install], [delete]
-n Required: The target namespace of the CP4BA deployment.
If CP4BA is deployed using separate namespaces for operators and operands/services, the value is the namespace where CP4BA operands/services are deployed.
Additional Information:
STEP 1: Run the script in [generate] mode. This copies the sample network policy templates to folder [cert-kubernetes/scripts/network-policies/<namespace>/templates]
STEP 2: Review and modify (if needed) the network policy templates based on your cluster environment.
STEP 3: Apply the network policies in you cluster manually or optionally run the script in [install] mode to apply templates in the path [cert-kubernetes/scripts/network-policies/<namespace>/templates]
Run the script in generate mode to create files in the following structure.
network-policies
└── <cp4ba-namespace>
├── logs
└── templates
├── Content
│ └── both
| └── egress
| └── ingress
├── CP4BA
| └── egress
| └── ingress
.....
Use the following steps to install network policies for your CP4BA deployment on your cluster.
Procedure
What to do next
If you need to delete the network policies for any reason, run the
cp4a-network-policies.sh script in delete mode.
./cp4a-network-policies.sh -m delete -n $NAMESPACE
The script deletes only the network policies that are created by the CP4BA operators and found in the cert-kubernetes/scripts/network-policies/<namespace>/templates folder. Any other network policies that you created are not deleted.
To uninstall the network policies of the Cloud Pak foundational services, see Uninstalling network policies for foundational services
.
generate and
install modes to apply the new network policies. Always wait for the reconciliation
to complete successfully before you run the script again. Confirm that all the components in the CR
are successfully installed and can be retrieved by checking the status section of the applied CR
file.