Optional: Installing network policies
The CP4BA operators do not create network policies, but you can use the utility script cp4a-network-policies.sh to retrieve and install network policy templates to restrict network access.
Before you begin
As a prerequisite to use the cp4a-network-policies.sh script, you must select the option to generate the network policy templates during the installation. If you want to generate the network policy templates after the installation, you can set the customer source parameter to true.
shared_configuration.sc_generate_sample_network_policies: true
If you chose to generate network policies, then wait for all the operators to complete the
generation of the sample files in the
/tmp/<ns>/network-policies/templates folder inside the CP4BA operator
pod. You can check the status in the CP4BA custom resource (CR) to make sure that the deployment is
complete (Ready).
All Namespaces.About this task
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. For more information about downloading cert-kubernetes, see Preparing a client to connect to the cluster.
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. Some capabilities need you to follow post-deployment steps. For more information, see Completing post-installation tasks.