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

Commit ec005cf

Browse files
committed
Install our knative operators on minikube
We can't use the Maistra operator, since it's dependent on OpenShift, so we install the istio.yaml released with knative-serving instead. We do install OLM and the knative operators, of course.
1 parent 93d6366 commit ec005cf

File tree

3 files changed

+91
-35
lines changed

3 files changed

+91
-35
lines changed

etc/scripts/install-on-minikube.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
# WARNING: this totally destroys and recreates your `knative` profile,
4+
# thereby guaranteeing (hopefully) a clean environment upon successful
5+
# completion.
6+
7+
if minikube status | grep "host: Running" >/dev/null; then
8+
echo "Please stop your running minikube to acknowledge this script will destroy it."
9+
exit 1
10+
fi
11+
12+
set -x
13+
14+
# blow away everything in the knative profile
15+
minikube delete --profile knative
16+
17+
# configure knative profile
18+
minikube profile knative
19+
minikube config set kubernetes-version v1.11.5 -p knative
20+
minikube config set memory 10240 -p knative
21+
minikube config set cpus 4 -p knative
22+
minikube config set disk-size 50g -p knative
23+
24+
# Start minikube
25+
minikube start -p knative --extra-config=apiserver.enable-admission-plugins="LimitRanger,NamespaceExists,NamespaceLifecycle,ResourceQuota,ServiceAccount,DefaultStorageClass,MutatingAdmissionWebhook"
26+
27+
#oc login -u admin -p admin
28+
29+
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
30+
"$DIR/install.sh" -q

etc/scripts/install.sh

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
#!/usr/bin/env bash
22

3-
# Installs OLM first, and then istio and knative using OLM operators
3+
# Attempts to install istio, knative, and OLM, ideally not in that order.
44

55
if [ "$1" != "-q" ]; then
66
echo
7-
echo " WARNING: This script will blindly attempt to install OLM, istio, and knative"
8-
echo " on your OpenShift cluster, so if any are already there, hijinks may ensue."
7+
echo " This script will attempt to install istio, knative, and OLM in your "
8+
echo " Kubernetes/OpenShift cluster."
9+
echo
10+
echo " A recent version of the `oc` CLI should be in your PATH"
911
echo
1012
echo " If using OpenShift 3.11 and your cluster isn't minishift, ensure"
1113
echo " \$KUBE_SSH_KEY and \$KUBE_SSH_USER are set"
1214
echo
13-
echo " Pass -q to disable this warning"
15+
echo " Pass -q to disable this prompt"
1416
echo
1517
read -p "Enter to continue or Ctrl-C to exit: "
1618
fi
@@ -37,16 +39,22 @@ wait_for_all_pods knative-serving
3739
# the two hostnames here
3840
oc -n knative-serving get cm config-controller -oyaml | sed "s/\(^ *registriesSkippingTagResolving.*$\)/\1,docker-registry.default.svc:5000,image-registry.openshift-image-registry.svc:5000/" | oc apply -f -
3941

40-
# Add Golang imagestreams to be able to build go based images
41-
oc import-image -n openshift golang --from=centos/go-toolset-7-centos7 --confirm
42-
oc import-image -n openshift golang:1.11 --from=centos/go-toolset-7-centos7 --confirm
43-
44-
# these perms are required by istio
45-
if ! oc project myproject 2>/dev/null; then
46-
oc new-project myproject
42+
if oc get ns openshift 2>/dev/null; then
43+
# Add Golang imagestreams to be able to build go based images
44+
oc import-image -n openshift golang --from=centos/go-toolset-7-centos7 --confirm
45+
oc import-image -n openshift golang:1.11 --from=centos/go-toolset-7-centos7 --confirm
46+
47+
if ! oc project myproject 2>/dev/null; then
48+
oc new-project myproject
49+
fi
50+
# these perms are required by istio
51+
oc adm policy add-scc-to-user privileged -z default
52+
oc adm policy add-scc-to-user anyuid -z default
53+
else
54+
oc create namespace myproject
55+
oc label namespace myproject istio-injection=enabled
56+
oc project myproject
4757
fi
48-
oc adm policy add-scc-to-user privileged -z default
49-
oc adm policy add-scc-to-user anyuid -z default
5058

51-
# show all the pods
59+
# show all the running pods
5260
oc get pods --all-namespaces

etc/scripts/installation-functions.sh

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@ function wait_for_all_pods {
2626
}
2727

2828
function check_minishift {
29-
(hash minishift && oc whoami --show-server | grep "$(minishift ip)") >/dev/null 2>&1
29+
(hash minishift &&
30+
minishift ip | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" &&
31+
oc whoami --show-server | grep "$(minishift ip)"
32+
) >/dev/null 2>&1
33+
}
34+
35+
function check_minikube {
36+
(hash minikube &&
37+
minikube ip | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" &&
38+
oc whoami --show-server | grep "$(minikube ip)"
39+
) >/dev/null 2>&1
3040
}
3141

3242
function check_openshift_4 {
@@ -40,6 +50,8 @@ function check_operatorgroups {
4050
function enable_admission_webhooks {
4151
if check_openshift_4; then
4252
echo "Detected OpenShift 4 - skipping enabling admission webhooks."
53+
elif check_minikube; then
54+
echo "Detected minikube - skipping enabling admission webhooks."
4355
elif check_minishift; then
4456
echo "Detected minishift - checking if admission webhooks are enabled."
4557
if ! minishift openshift config view --target=kube | grep ValidatingAdmissionWebhook >/dev/null; then
@@ -121,7 +133,7 @@ function install_olm {
121133
if check_openshift_4; then
122134
echo "Detected OpenShift 4 - skipping OLM installation."
123135
OLM_NS="openshift-operator-lifecycle-manager"
124-
elif oc get ns "$OLM_NS"; then
136+
elif oc get ns "$OLM_NS" 2>/dev/null; then
125137
echo "Detected OpenShift 3 with OLM already installed."
126138
# we'll assume this is v3.11.0, which doesn't support
127139
# OperatorGroups, or ClusterRoles in the CSV, so...
@@ -150,18 +162,23 @@ function install_olm {
150162
}
151163

152164
function install_istio {
153-
# istio
154-
oc create ns istio-operator
155-
if check_operatorgroups; then
156-
cat <<-EOF | oc apply -f -
165+
if check_minikube; then
166+
echo "Detected minikube - incompatible with Maistra operator, so installing upstream istio."
167+
oc apply -f "https://github.com/knative/serving/releases/download/${KNATIVE_SERVING_VERSION}/istio.yaml"
168+
oc label namespace default istio-injection=enabled
169+
wait_for_all_pods istio-system
170+
else
171+
oc create ns istio-operator
172+
if check_operatorgroups; then
173+
cat <<-EOF | oc apply -f -
157174
apiVersion: operators.coreos.com/v1alpha2
158175
kind: OperatorGroup
159176
metadata:
160177
name: istio-operator
161178
namespace: istio-operator
162179
EOF
163-
fi
164-
cat <<-EOF | oc apply -f -
180+
fi
181+
cat <<-EOF | oc apply -f -
165182
apiVersion: operators.coreos.com/v1alpha1
166183
kind: Subscription
167184
metadata:
@@ -172,9 +189,9 @@ function install_istio {
172189
name: maistra
173190
source: maistra-operators
174191
EOF
175-
wait_for_all_pods istio-operator
192+
wait_for_all_pods istio-operator
176193

177-
cat <<-EOF | oc apply -f -
194+
cat <<-EOF | oc apply -f -
178195
apiVersion: istio.openshift.com/v1alpha1
179196
kind: Installation
180197
metadata:
@@ -191,18 +208,19 @@ function install_istio {
191208
prefix: kiali/
192209
version: v0.7.1
193210
EOF
194-
timeout 900 'oc get pods -n istio-system && [[ $(oc get pods -n istio-system | grep openshift-ansible-istio-installer | grep -c Completed) -eq 0 ]]'
211+
timeout 900 'oc get pods -n istio-system && [[ $(oc get pods -n istio-system | grep openshift-ansible-istio-installer | grep -c Completed) -eq 0 ]]'
195212

196-
# Scale down unused services deployed by the istio operator. The
197-
# jaeger pods will fail anyway due to the elasticsearch pod failing
198-
# due to "max virtual memory areas vm.max_map_count [65530] is too
199-
# low, increase to at least [262144]" which could be mitigated on
200-
# minishift with:
201-
# minishift ssh "echo 'echo vm.max_map_count = 262144 >/etc/sysctl.d/99-elasticsearch.conf' | sudo sh"
202-
oc scale -n istio-system --replicas=0 deployment/grafana
203-
oc scale -n istio-system --replicas=0 deployment/jaeger-collector
204-
oc scale -n istio-system --replicas=0 deployment/jaeger-query
205-
oc scale -n istio-system --replicas=0 statefulset/elasticsearch
213+
# Scale down unused services deployed by the istio operator. The
214+
# jaeger pods will fail anyway due to the elasticsearch pod failing
215+
# due to "max virtual memory areas vm.max_map_count [65530] is too
216+
# low, increase to at least [262144]" which could be mitigated on
217+
# minishift with:
218+
# minishift ssh "echo 'echo vm.max_map_count = 262144 >/etc/sysctl.d/99-elasticsearch.conf' | sudo sh"
219+
oc scale -n istio-system --replicas=0 deployment/grafana
220+
oc scale -n istio-system --replicas=0 deployment/jaeger-collector
221+
oc scale -n istio-system --replicas=0 deployment/jaeger-query
222+
oc scale -n istio-system --replicas=0 statefulset/elasticsearch
223+
fi
206224
}
207225

208226
function install_knative_build {

0 commit comments

Comments
 (0)