|
1 | 1 | #!/usr/bin/env bash |
2 | 2 |
|
3 | | -# Installs istio, OLM and all knative operators on minishift |
4 | | - |
5 | | -# WARNING: it totally destroys and recreates your `knative` profile, |
6 | | -# thereby guaranteeing (hopefully) a clean environment upon successful |
7 | | -# completion. |
8 | | - |
9 | | -KNATIVE_SERVING_VERSION=v0.2.2 |
10 | | -KNATIVE_BUILD_VERSION=v0.2.0 |
11 | | -KNATIVE_EVENTING_VERSION=v0.2.0 |
12 | | - |
13 | | -DIR=$(cd $(dirname "$0") && pwd) |
14 | | -ROOT_DIR=$DIR/../.. |
15 | | -REPO_DIR=$ROOT_DIR/.repos |
| 3 | +# Installs OLM first, and then istio and knative using OLM operators |
| 4 | + |
| 5 | +if [ "$1" != "-q" ]; then |
| 6 | + echo |
| 7 | + echo " WARNING: This script will blindly attempt to install OLM, istio, and knative" |
| 8 | + echo " on your OKD cluster, so if any are already there, hijinks will ensue." |
| 9 | + echo |
| 10 | + echo " If your cluster is minishift, run $(dirname $0)/install-on-minishift.sh instead." |
| 11 | + echo |
| 12 | + echo " Pass -q to disable this warning" |
| 13 | + echo |
| 14 | + read -p "Enter to continue or Ctrl-C to exit: " |
| 15 | +fi |
16 | 16 |
|
17 | 17 | set -x |
18 | 18 |
|
19 | | -# Loops until duration (car) is exceeded or command (cdr) returns non-zero |
20 | | -function timeout() { |
21 | | - SECONDS=0; TIMEOUT=$1; shift |
22 | | - while eval $*; do |
23 | | - sleep 5 |
24 | | - [[ $SECONDS -gt $TIMEOUT ]] && echo "ERROR: Timed out" && exit -1 |
25 | | - done |
26 | | -} |
27 | | - |
28 | | -# Waits for all pods in the given namespace to complete successfully. |
29 | | -function wait_for_all_pods { |
30 | | - timeout 300 "oc get pods -n $1 2>&1 | grep -v -E '(Running|Completed|STATUS)'" |
31 | | -} |
32 | | - |
33 | | -# initialize local repos dir |
34 | | -rm -rf "$REPO_DIR" |
35 | | -mkdir -p "$REPO_DIR" |
36 | | - |
37 | | -# initialize the minishift knative profile |
38 | | -"$DIR/init-minishift-for-knative.sh" |
39 | | - |
40 | | -# OLM |
41 | | -git clone https://github.com/operator-framework/operator-lifecycle-manager "$REPO_DIR/olm" |
42 | | -cat $REPO_DIR/olm/deploy/okd/manifests/latest/*.crd.yaml | oc apply -f - |
43 | | -sleep 1 |
44 | | -find $REPO_DIR/olm/deploy/okd/manifests/latest/ -type f ! -name "*crd.yaml" | sort | xargs cat | oc create -f - |
45 | | -wait_for_all_pods openshift-operator-lifecycle-manager |
46 | | -# perms required by the OLM console: $REPO_DIR/olm/scripts/run_console_local.sh |
47 | | -oc adm policy add-cluster-role-to-user cluster-admin system:serviceaccount:kube-system:default |
48 | | - |
49 | | -# knative catalog source |
50 | | -oc apply -f "$ROOT_DIR/knative-operators.catalogsource.yaml" |
51 | | -oc apply -f "$ROOT_DIR/maistra-operators.catalogsource.yaml" |
52 | | - |
53 | | -# istio |
54 | | -oc create ns istio-operator |
55 | | -cat <<EOF | oc apply -f - |
56 | | -apiVersion: operators.coreos.com/v1alpha1 |
57 | | -kind: Subscription |
58 | | -metadata: |
59 | | - name: maistra |
60 | | - namespace: istio-operator |
61 | | -spec: |
62 | | - channel: alpha |
63 | | - name: maistra |
64 | | - source: maistra-operators |
65 | | -EOF |
66 | | -wait_for_all_pods istio-operator |
67 | | - |
68 | | -cat <<EOF | oc apply -f - |
69 | | -apiVersion: istio.openshift.com/v1alpha1 |
70 | | -kind: Installation |
71 | | -metadata: |
72 | | - namespace: istio-operator |
73 | | - name: istio-installation |
74 | | -spec: |
75 | | - istio: |
76 | | - authentication: false |
77 | | - community: true |
78 | | - version: 0.2.0 |
79 | | - kiali: |
80 | | - username: admin |
81 | | - password: admin |
82 | | - prefix: kiali/ |
83 | | - version: v0.7.1 |
84 | | -EOF |
85 | | -timeout 900 'oc get pods -n istio-system && [[ $(oc get pods -n istio-system | grep openshift-ansible-istio-installer | grep -c Completed) -eq 0 ]]' |
86 | | - |
87 | | -# Scale down unused services deployed by the istio addon. The jaeger |
88 | | -# pods will fail anyway due to the elasticsearch pod failing due to |
89 | | -# "max virtual memory areas vm.max_map_count [65530] is too low, |
90 | | -# increase to at least [262144]" which could be mitigated on minishift |
91 | | -# with: |
92 | | -# minishift ssh "echo 'echo vm.max_map_count = 262144 >/etc/sysctl.d/99-elasticsearch.conf' | sudo sh" |
93 | | -oc scale -n istio-system --replicas=0 deployment/grafana |
94 | | -oc scale -n istio-system --replicas=0 deployment/jaeger-collector |
95 | | -oc scale -n istio-system --replicas=0 deployment/jaeger-query |
96 | | -oc scale -n istio-system --replicas=0 statefulset/elasticsearch |
| 19 | +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" |
97 | 20 |
|
98 | | -# for now, we must install the operators in specific namespaces, so... |
99 | | -oc create ns knative-build |
100 | | -oc create ns knative-serving |
101 | | -oc create ns knative-eventing |
| 21 | +source "$DIR/install-functions.sh" |
102 | 22 |
|
103 | | -# install the operators for build, serving, and eventing |
104 | | -cat <<EOF | oc apply -f - |
105 | | -apiVersion: operators.coreos.com/v1alpha1 |
106 | | -kind: Subscription |
107 | | -metadata: |
108 | | - name: knative-build-subscription |
109 | | - generateName: knative-build- |
110 | | - namespace: knative-build |
111 | | -spec: |
112 | | - source: knative-operators |
113 | | - name: knative-build |
114 | | - startingCSV: knative-build.${KNATIVE_BUILD_VERSION} |
115 | | - channel: alpha |
116 | | ---- |
117 | | -apiVersion: operators.coreos.com/v1alpha1 |
118 | | -kind: Subscription |
119 | | -metadata: |
120 | | - name: knative-serving-subscription |
121 | | - generateName: knative-serving- |
122 | | - namespace: knative-serving |
123 | | -spec: |
124 | | - source: knative-operators |
125 | | - name: knative-serving |
126 | | - startingCSV: knative-serving.${KNATIVE_SERVING_VERSION} |
127 | | - channel: alpha |
128 | | ---- |
129 | | -apiVersion: operators.coreos.com/v1alpha1 |
130 | | -kind: Subscription |
131 | | -metadata: |
132 | | - name: knative-eventing-subscription |
133 | | - generateName: knative-eventing- |
134 | | - namespace: knative-eventing |
135 | | -spec: |
136 | | - source: knative-operators |
137 | | - name: knative-eventing |
138 | | - startingCSV: knative-eventing.${KNATIVE_EVENTING_VERSION} |
139 | | - channel: alpha |
140 | | -EOF |
| 23 | +install_olm |
| 24 | +install_istio |
| 25 | +install_knative_build |
| 26 | +install_knative_serving |
| 27 | +install_knative_eventing |
141 | 28 |
|
142 | 29 | wait_for_all_pods knative-build |
143 | 30 | wait_for_all_pods knative-eventing |
|
0 commit comments