Created
October 5, 2019 03:39
-
-
Save ohmrefresh/2548baca745e8ae5baaeb70800242a3d to your computer and use it in GitHub Desktop.
[OCP] Get All network policy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| namespace_arr=(animal fruit) | |
| environment_arr=(dev qa) | |
| basePath="NetworkPolicy/" | |
| rm -rf ${basePath} || true | |
| for name in "${namespace_arr[@]}"; do | |
| for environment in "${environment_arr[@]}"; do | |
| namespace="${name}-${environment}" | |
| policy_arr=($(oc get NetworkPolicy --namespace=${namespace} | awk 'FNR > 1 {print $1}')) | |
| for policy in "${policy_arr[@]}"; do | |
| mkdir -p ${basePath}/${namespace}/ | |
| echo "${policy}" | |
| oc get networkpolicy ${policy} --namespace=${namespace} -o yaml > ${basePath}/${namespace}/${policy}.yml | |
| done | |
| done | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment