From 563167f53a36fba31fb809711b6ecac94c77cc60 Mon Sep 17 00:00:00 2001 From: Denilson Nastacio Date: Fri, 17 Mar 2023 14:12:31 -0400 Subject: [PATCH] fix: Do not label ingress in managed OCP Signed-off-by: Denilson Nastacio --- config/cloudpaks/cp4i/install-prereqs/Chart.yaml | 2 +- .../0050-sync-configure-network-policy.yaml | 8 ++++++++ config/cloudpaks/cp4waiops/install-aimgr/Chart.yaml | 4 ++-- .../templates/subscriptions/030-sync-prereqs.yaml | 13 ++++++++++--- config/cloudpaks/cp4waiops/install-emgr/Chart.yaml | 4 ++-- .../templates/subscriptions/030-sync-prereqs.yaml | 13 ++++++++++--- 6 files changed, 33 insertions(+), 11 deletions(-) diff --git a/config/cloudpaks/cp4i/install-prereqs/Chart.yaml b/config/cloudpaks/cp4i/install-prereqs/Chart.yaml index 533130ba..1bf256a7 100644 --- a/config/cloudpaks/cp4i/install-prereqs/Chart.yaml +++ b/config/cloudpaks/cp4i/install-prereqs/Chart.yaml @@ -16,7 +16,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.3.0 +version: 0.3.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/config/cloudpaks/cp4i/install-prereqs/templates/0050-sync-configure-network-policy.yaml b/config/cloudpaks/cp4i/install-prereqs/templates/0050-sync-configure-network-policy.yaml index 7305ff6f..d72a9f5b 100644 --- a/config/cloudpaks/cp4i/install-prereqs/templates/0050-sync-configure-network-policy.yaml +++ b/config/cloudpaks/cp4i/install-prereqs/templates/0050-sync-configure-network-policy.yaml @@ -26,6 +26,14 @@ spec: set -eo pipefail set -x + is_managed_ocp=0 + managed_ocp=$(oc get Infrastructure cluster \ + -o jsonpath='{.status.platformStatus.*.resourceTags[?(@.key=="red-hat-managed")].value}' || is_managed_ocp=0) + if [ "${managed_ocp}" == "true" ]; then + echo "INFO: Do not attempt to adjust network policy for managed OCP environments." + exit 0 + fi + default_policy=$(oc get namespace default -o jsonpath={.metadata.labels.'network\.openshift\.io/policy-group'}) \ || { echo "ERROR: Unable to get default ingress policy ." diff --git a/config/cloudpaks/cp4waiops/install-aimgr/Chart.yaml b/config/cloudpaks/cp4waiops/install-aimgr/Chart.yaml index e103c4c9..0c8f731c 100644 --- a/config/cloudpaks/cp4waiops/install-aimgr/Chart.yaml +++ b/config/cloudpaks/cp4waiops/install-aimgr/Chart.yaml @@ -13,9 +13,9 @@ description: Cloud Pak for Watson AIOps - AI Manager # pipeline. Library charts do not define any templates and therefore cannot be deployed. type: application -version: 0.13.0 +version: 0.13.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: 3.6.0 +appVersion: 3.6.2 diff --git a/config/cloudpaks/cp4waiops/install-aimgr/templates/subscriptions/030-sync-prereqs.yaml b/config/cloudpaks/cp4waiops/install-aimgr/templates/subscriptions/030-sync-prereqs.yaml index 33f4c145..028e630a 100644 --- a/config/cloudpaks/cp4waiops/install-aimgr/templates/subscriptions/030-sync-prereqs.yaml +++ b/config/cloudpaks/cp4waiops/install-aimgr/templates/subscriptions/030-sync-prereqs.yaml @@ -45,11 +45,18 @@ spec: --from-file=.dockerconfigjson=/tmp/.dockerconfigjson fi \ && rm -rf /tmp/.dockerconfigjson \ - && if [ $(oc get ingresscontroller default -n openshift-ingress-operator -o jsonpath='{.status.endpointPublishingStrategy.type}') = "HostNetwork" ]; then - oc patch namespace default --type=json -p '[{"op":"add","path":"/metadata/labels","value":{"network.openshift.io/policy-group":"ingress"}}]' - fi \ || result=1 + is_managed_ocp=0 + managed_ocp=$(oc get Infrastructure cluster \ + -o jsonpath='{.status.platformStatus.*.resourceTags[?(@.key=="red-hat-managed")].value}' || is_managed_ocp=0) + if [ "${managed_ocp}" != "true" ]; then + if [ $(oc get ingresscontroller default -n openshift-ingress-operator -o jsonpath='{.status.endpointPublishingStrategy.type}') = "HostNetwork" ]; then + oc patch namespace default --type=json -p '[{"op":"add","path":"/metadata/labels","value":{"network.openshift.io/policy-group":"ingress"}}]' + fi \ + || result=1 + fi + oc get ServiceAccount aiops-topology-service-account --namespace "${TARGET_NAMESPACE}" -o yaml 2> /dev/null \ && echo "INFO: Topology service account exists." \ || { diff --git a/config/cloudpaks/cp4waiops/install-emgr/Chart.yaml b/config/cloudpaks/cp4waiops/install-emgr/Chart.yaml index e8188e38..54b4006f 100644 --- a/config/cloudpaks/cp4waiops/install-emgr/Chart.yaml +++ b/config/cloudpaks/cp4waiops/install-emgr/Chart.yaml @@ -16,9 +16,9 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.13.0 +version: 0.13.2 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: 3.6.0 +appVersion: 3.6.2 diff --git a/config/cloudpaks/cp4waiops/install-emgr/templates/subscriptions/030-sync-prereqs.yaml b/config/cloudpaks/cp4waiops/install-emgr/templates/subscriptions/030-sync-prereqs.yaml index 21eee22d..1027fcdf 100644 --- a/config/cloudpaks/cp4waiops/install-emgr/templates/subscriptions/030-sync-prereqs.yaml +++ b/config/cloudpaks/cp4waiops/install-emgr/templates/subscriptions/030-sync-prereqs.yaml @@ -45,12 +45,19 @@ spec: --from-file=.dockerconfigjson=/tmp/.dockerconfigjson fi \ && rm -rf /tmp/.dockerconfigjson \ - && if [ $(oc get ingresscontroller default -n openshift-ingress-operator -o jsonpath='{.status.endpointPublishingStrategy.type}') = "HostNetwork" ]; then - oc patch namespace default --type=json -p '[{"op":"add","path":"/metadata/labels","value":{"network.openshift.io/policy-group":"ingress"}}]' - fi \ && echo "INFO: Event Manager prereq configuration successful." \ || result=1 + is_managed_ocp=0 + managed_ocp=$(oc get Infrastructure cluster \ + -o jsonpath='{.status.platformStatus.*.resourceTags[?(@.key=="red-hat-managed")].value}' || is_managed_ocp=0) + if [ "${managed_ocp}" != "true" ]; then + if [ $(oc get ingresscontroller default -n openshift-ingress-operator -o jsonpath='{.status.endpointPublishingStrategy.type}') = "HostNetwork" ]; then + oc patch namespace default --type=json -p '[{"op":"add","path":"/metadata/labels","value":{"network.openshift.io/policy-group":"ingress"}}]' + fi \ + || result=1 + fi + # https://www.ibm.com/docs/en/noi/1.6.5?topic=preparing-your-cluster oc get ServiceAccount noi-service-account --namespace "${TARGET_NAMESPACE}" -o yaml 2> /dev/null \ && echo "INFO: NOI service account exists." \