diff --git a/content/rancher/v2.x/en/upgrades/upgrades/namespace-migration/_index.md b/content/rancher/v2.x/en/upgrades/upgrades/namespace-migration/_index.md index 019e7a3ac38..ad7b5398ec6 100644 --- a/content/rancher/v2.x/en/upgrades/upgrades/namespace-migration/_index.md +++ b/content/rancher/v2.x/en/upgrades/upgrades/namespace-migration/_index.md @@ -72,14 +72,14 @@ Reset the cluster nodes' network policies to restore connectivity. 1. Before repairing networking, run the following two commands to make sure that your nodes have a status of `Ready` and that your cluster components are `Healthy`. ``` - kubectl get nodes --kubeconfig kube_config_rancher-cluster.yml + kubectl --kubeconfig kube_config_rancher-cluster.yml get nodes NAME STATUS ROLES AGE VERSION 165.227.114.63 Ready controlplane,etcd,worker 11m v1.10.1 165.227.116.167 Ready controlplane,etcd,worker 11m v1.10.1 165.227.127.226 Ready controlplane,etcd,worker 11m v1.10.1 - kubectl get cs --kubeconfig kube_config_rancher-cluster.yml + kubectl --kubeconfig kube_config_rancher-cluster.yml get cs NAME STATUS MESSAGE ERROR scheduler Healthy ok @@ -126,7 +126,7 @@ Reset the cluster nodes' network policies to restore connectivity. c-59ptz custom false false false local local false false false -1. Now remove all network policies from all namespaces. Run this command for each cluster, using the kubeconfig generated by RKE. +1. Remove all network policies from all namespaces. Run this command for each cluster, using the kubeconfig generated by RKE. ``` for namespace in $(kubectl --kubeconfig kube_config_rancher-cluster.yml get ns -o custom-columns=NAME:.metadata.name --no-headers); do @@ -134,6 +134,24 @@ Reset the cluster nodes' network policies to restore connectivity. done ``` +1. Remove all the projectnetworkpolicies created for the clusters, to make sure networkpolicies are not recreated. + + ``` + for cluster in $(kubectl --kubeconfig kube_config_rancher-cluster.yml get clusters -o custom-columns=NAME:.metadata.name --no-headers); do + for project in $(kubectl --kubeconfig kube_config_rancher-cluster.yml get project -n $cluster -o custom-columns=NAME:.metadata.name --no-headers); do + kubectl --kubeconfig kube_config_rancher-cluster.yml delete projectnetworkpolicy -n $project --all + done + done + ``` + + >**Tip:** If you want to keep `networkPolicy` enabled for all created clusters, you can run the following command to disable `networkPolicy` for `local` cluster (i.e., your Rancher Server nodes): + > + >``` + for project in $(kubectl --kubeconfig kube_config_rancher-cluster.yml get project -n local -o custom-columns=NAME:.metadata.name --no-headers); do + kubectl --kubeconfig kube_config_rancher-cluster.yml -n $project delete projectnetworkpolicy --all; + done + ``` + 1. Wait a few minutes and then log into the Rancher UI. - If you can access Rancher, you're done, so you can skip the rest of the steps.