diff --git a/scripts/loki/loki-released-subscription.yaml b/scripts/loki/loki-released-subscription.yaml deleted file mode 100644 index adcbd32b..00000000 --- a/scripts/loki/loki-released-subscription.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: operators.coreos.com/v1alpha1 -kind: Subscription -metadata: - name: loki-operator - namespace: openshift-operators-redhat -spec: - channel: stable-6.0 - name: loki-operator - source: redhat-operators - sourceNamespace: openshift-marketplace diff --git a/scripts/loki/loki-subscription-template.yaml b/scripts/loki/loki-subscription-template.yaml new file mode 100644 index 00000000..9c9a6cef --- /dev/null +++ b/scripts/loki/loki-subscription-template.yaml @@ -0,0 +1,20 @@ +apiVersion: template.openshift.io/v1 +kind: Template +metadata: + name: loki-subcription-template +objects: +- apiVersion: operators.coreos.com/v1alpha1 + kind: Subscription + metadata: + name: loki-operator + namespace: openshift-operators-redhat + spec: + channel: "${{LOKI_CHANNEL}}" + name: loki-operator + source: "${{SOURCE}}" + sourceNamespace: openshift-marketplace +parameters: + - name: LOKI_CHANNEL + value: "stable-6.0" + - name: SOURCE + value: "redhat-operators" diff --git a/scripts/loki/loki-unreleased-subscription.yaml b/scripts/loki/loki-unreleased-subscription.yaml deleted file mode 100644 index 5de9c9b5..00000000 --- a/scripts/loki/loki-unreleased-subscription.yaml +++ /dev/null @@ -1,10 +0,0 @@ -apiVersion: operators.coreos.com/v1alpha1 -kind: Subscription -metadata: - name: loki-operator - namespace: openshift-operators-redhat -spec: - channel: stable-6.0 - name: loki-operator - source: netobserv-downstream-testing - sourceNamespace: openshift-marketplace diff --git a/scripts/netobserv.sh b/scripts/netobserv.sh index 9ee5d0fc..eda36d96 100755 --- a/scripts/netobserv.sh +++ b/scripts/netobserv.sh @@ -105,12 +105,24 @@ deploy_lokistack() { echo "====> Creating openshift-operators-redhat Namespace and OperatorGroup" oc apply -f $SCRIPTS_DIR/loki/loki-operatorgroup.yaml + echo "====> Check the OCP release version:" + oc_minor_version=$(oc get clusterversion --no-headers | awk '{ print $2 }' | cut -d'.' -f2 -) + + if [[ $(($oc_minor_version)) -ge 14 ]]; + then + loki_channel="stable-6.0" ; echo "=====> Deploying the Loki with stable-6.0 channel..." + else + loki_channel="stable" ; echo "=====> Deploying the Loki with the stable channel..." + fi + echo "====> Creating netobserv-downstream-testing CatalogSource (if applicable) and Loki Operator Subscription" if [[ $LOKI_OPERATOR == "Released" ]]; then - oc apply -f $SCRIPTS_DIR/loki/loki-released-subscription.yaml + oc process --ignore-unknown-parameters=true -f $SCRIPTS_DIR/loki/loki-subscription-template.yaml -p LOKI_CHANNEL=$loki_channel -p SOURCE=redhat-operators -o yaml > /tmp/loki-released-subscription.yaml + oc apply -f /tmp/loki-released-subscription.yaml -n openshift-operators-redhat elif [[ $LOKI_OPERATOR == "Unreleased" ]]; then deploy_downstream_catalogsource - oc apply -f $SCRIPTS_DIR/loki/loki-unreleased-subscription.yaml + oc process --ignore-unknown-parameters=true -f $SCRIPTS_DIR/loki/loki-subscription-template.yaml -p LOKI_CHANNEL=$loki_channel -p SOURCE=netobserv-downstream-testing -o yaml > /tmp/loki-unreleased-subscription.yaml + oc apply -f /tmp/loki-unreleased-subscription.yaml -n openshift-operators-redhat else echo "====> No Loki Operator config was found - using 'Released'" echo "====> To set config, set LOKI_OPERATOR variable to either 'Released' or 'Unreleased'"