@@ -57,7 +57,11 @@ function check_minikube {
5757}
5858
5959function check_openshift_4 {
60- ($CMD get ns openshift && $CMD version | tail -1 | grep " v1.12" ) > /dev/null 2>&1
60+ if $CMD api-resources > /dev/null; then
61+ $CMD api-resources | grep machineconfigs | grep machineconfiguration.openshift.io > /dev/null 2>&1
62+ else
63+ ($CMD get ns openshift && $CMD version | tail -1 | grep " v1.12" ) > /dev/null 2>&1
64+ fi
6165}
6266
6367function check_operatorgroups {
@@ -242,6 +246,8 @@ function install_istio {
242246 $CMD scale -n istio-system --replicas=0 deployment/jaeger-collector
243247 $CMD scale -n istio-system --replicas=0 deployment/jaeger-query
244248 $CMD scale -n istio-system --replicas=0 statefulset/elasticsearch
249+
250+ patch_istio_for_knative
245251 fi
246252}
247253
@@ -280,3 +286,34 @@ function install_knative {
280286 channel: alpha
281287 EOF
282288}
289+
290+ function enable_interaction_with_registry() {
291+ if check_openshift_4; then
292+ local ns=${1:- knative-serving}
293+ local configmap_name=config-service-ca
294+ local cert_name=service-ca.crt
295+ local mount_path=/var/run/secrets/kubernetes.io/servicecerts
296+
297+ $CMD -n $ns create configmap $configmap_name
298+ $CMD -n $ns annotate configmap $configmap_name service.alpha.openshift.io/inject-cabundle=" true"
299+ timeout 180 ' ! $CMD -n $ns get cm $configmap_name -oyaml | grep $cert_name'
300+ $CMD -n $ns set volume deployment/controller --add --name=service-ca --configmap-name=$configmap_name --mount-path=$mount_path
301+ $CMD -n $ns set env deployment/controller SSL_CERT_FILE=$mount_path /$cert_name
302+ else
303+ echo " Registry configuration only required for OCP4"
304+ fi
305+ }
306+
307+ function patch_istio_for_knative() {
308+ local sidecar_config=$( $CMD get configmap -n istio-system istio-sidecar-injector -o yaml)
309+ if [[ -z " ${sidecar_config} " ]]; then
310+ return 1
311+ fi
312+ echo " ${sidecar_config} " | grep lifecycle
313+ if [[ $? -eq 1 ]]; then
314+ echo " Patching Istio's preStop hook for graceful shutdown"
315+ echo " ${sidecar_config} " | sed ' s/\(name: istio-proxy\)/\1\\n lifecycle:\\n preStop:\\n exec:\\n command: [\\"sh\\", \\"-c\\", \\"sleep 20; while [ $(netstat -plunt | grep tcp | grep -v envoy | wc -l | xargs) -ne 0 ]; do sleep 1; done\\"]/' | $CMD replace -f -
316+ $CMD delete pod -n istio-system -l istio=sidecar-injector
317+ wait_for_all_pods istio-system
318+ fi
319+ }
0 commit comments