Skip to content
This repository was archived by the owner on Aug 2, 2019. It is now read-only.

Commit 155e428

Browse files
committed
Use existing OLM if present
On RHDPS, a v3.11.0 OLM is provided, but that version doesn't support either OperatorGroups or ClusterRoles within a CSV, so we deal with those possibilities in the script in order to successfully install the knative operators there.
1 parent 8e22b0b commit 155e428

File tree

2 files changed

+49
-37
lines changed

2 files changed

+49
-37
lines changed

etc/scripts/install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ install_istio
2626
install_knative_build
2727
install_knative_serving
2828
install_knative_eventing
29+
install_operator_groups
2930

3031
wait_for_all_pods knative-build
3132
wait_for_all_pods knative-eventing

etc/scripts/installation-functions.sh

Lines changed: 48 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -101,26 +101,31 @@ function enable_admission_webhooks {
101101
}
102102

103103
function install_olm {
104-
# Scale down existing OLM, if any
105-
if oc get ns operator-lifecycle-manager; then
106-
oc scale -n operator-lifecycle-manager --replicas=0 deployment/catalog-operator
107-
oc scale -n operator-lifecycle-manager --replicas=0 deployment/olm-operator
108-
fi
109104
local ROOT_DIR="$INSTALL_SCRIPT_DIR/../.."
110-
local REPO_DIR="$ROOT_DIR/.repos"
111-
local OLM_DIR="$REPO_DIR/olm"
112-
mkdir -p "$REPO_DIR"
113-
rm -rf "$OLM_DIR"
114-
git clone https://github.com/operator-framework/operator-lifecycle-manager "$OLM_DIR"
115-
pushd $OLM_DIR; git checkout eaf605cca864e; popd
116-
for i in "$OLM_DIR"/deploy/okd/manifests/latest/*.crd.yaml; do oc apply -f $i; done
117-
for i in $(find "$OLM_DIR/deploy/okd/manifests/latest/" -type f ! -name "*crd.yaml" | sort); do oc create -f $i; done
118-
wait_for_all_pods openshift-operator-lifecycle-manager
119-
# perms required by the OLM console: $OLM_DIR/scripts/run_console_local.sh
120-
oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:kube-system:default
121-
122-
# knative catalog source
123-
local OLM_NS=$(grep "catalog_namespace:" "$OLM_DIR/deploy/okd/values.yaml" | awk '{print $2}')
105+
local OLM_NS="operator-lifecycle-manager"
106+
if oc get ns "$OLM_NS"; then
107+
# we'll assume this is v3.11.0, which doesn't support
108+
# OperatorGroups, or ClusterRoles in the CSV, so...
109+
oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:istio-operator:istio-operator
110+
oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:knative-build:build-controller
111+
oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:knative-serving:controller
112+
oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:knative-eventing:default
113+
else
114+
local REPO_DIR="$ROOT_DIR/.repos"
115+
local OLM_DIR="$REPO_DIR/olm"
116+
mkdir -p "$REPO_DIR"
117+
rm -rf "$OLM_DIR"
118+
git clone https://github.com/operator-framework/operator-lifecycle-manager "$OLM_DIR"
119+
pushd $OLM_DIR; git checkout eaf605cca864e; popd
120+
for i in "$OLM_DIR"/deploy/okd/manifests/latest/*.crd.yaml; do oc apply -f $i; done
121+
for i in $(find "$OLM_DIR/deploy/okd/manifests/latest/" -type f ! -name "*crd.yaml" | sort); do oc create -f $i; done
122+
wait_for_all_pods openshift-operator-lifecycle-manager
123+
# perms required by the OLM console: $OLM_DIR/scripts/run_console_local.sh
124+
oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:kube-system:default
125+
# check our namespace
126+
OLM_NS=$(grep "catalog_namespace:" "$OLM_DIR/deploy/okd/values.yaml" | awk '{print $2}')
127+
fi
128+
# and finally apply the catalog sources
124129
oc apply -f "$ROOT_DIR/knative-operators.catalogsource.yaml" -n "$OLM_NS"
125130
oc apply -f "$ROOT_DIR/maistra-operators.catalogsource.yaml" -n "$OLM_NS"
126131
}
@@ -138,12 +143,6 @@ function install_istio {
138143
channel: alpha
139144
name: maistra
140145
source: maistra-operators
141-
---
142-
apiVersion: operators.coreos.com/v1alpha2
143-
kind: OperatorGroup
144-
metadata:
145-
name: istio-operator
146-
namespace: istio-operator
147146
EOF
148147
wait_for_all_pods istio-operator
149148

@@ -192,12 +191,6 @@ function install_knative_build {
192191
name: knative-build
193192
startingCSV: knative-build.${KNATIVE_BUILD_VERSION}
194193
channel: alpha
195-
---
196-
apiVersion: operators.coreos.com/v1alpha2
197-
kind: OperatorGroup
198-
metadata:
199-
name: knative-build
200-
namespace: knative-build
201194
EOF
202195
}
203196

@@ -215,12 +208,6 @@ function install_knative_serving {
215208
name: knative-serving
216209
startingCSV: knative-serving.${KNATIVE_SERVING_VERSION}
217210
channel: alpha
218-
---
219-
apiVersion: operators.coreos.com/v1alpha2
220-
kind: OperatorGroup
221-
metadata:
222-
name: knative-serving
223-
namespace: knative-serving
224211
EOF
225212
}
226213

@@ -238,11 +225,35 @@ function install_knative_eventing {
238225
name: knative-eventing
239226
startingCSV: knative-eventing.${KNATIVE_EVENTING_VERSION}
240227
channel: alpha
228+
EOF
229+
}
230+
231+
function install_operator_groups {
232+
if oc get crd operatorgroups.operators.coreos.com 2>/dev/null; then
233+
cat <<-EOF | oc apply -f -
234+
apiVersion: operators.coreos.com/v1alpha2
235+
kind: OperatorGroup
236+
metadata:
237+
name: istio-operator
238+
namespace: istio-operator
239+
---
240+
apiVersion: operators.coreos.com/v1alpha2
241+
kind: OperatorGroup
242+
metadata:
243+
name: knative-build
244+
namespace: knative-build
245+
---
246+
apiVersion: operators.coreos.com/v1alpha2
247+
kind: OperatorGroup
248+
metadata:
249+
name: knative-serving
250+
namespace: knative-serving
241251
---
242252
apiVersion: operators.coreos.com/v1alpha2
243253
kind: OperatorGroup
244254
metadata:
245255
name: knative-eventing
246256
namespace: knative-eventing
247257
EOF
258+
fi
248259
}

0 commit comments

Comments
 (0)