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

Commit

Permalink
Sync with fixes from CI for registry/isto [OCF-199] [SRVKS-32]
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrossley3 committed Mar 7, 2019
1 parent 4dd0130 commit a80c9d9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
2 changes: 0 additions & 2 deletions etc/hacks/knative-serving-0.3.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ spec:
- knative-ingressgateway
- --zipkinAddress
- zipkin:9411
- --statsdUdpAddress
- istio-statsd-prom-bridge:9125
- --proxyAdminPort
- "15000"
- --controlPlaneAuthPolicy
Expand Down
2 changes: 2 additions & 0 deletions etc/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ wait_for_all_pods knative-build
wait_for_all_pods knative-eventing
wait_for_all_pods knative-serving

enable_interaction_with_registry

# skip tag resolving for internal registry
# OpenShift 3 and 4 place the registry in different locations, hence
# the two hostnames here
Expand Down
39 changes: 38 additions & 1 deletion etc/scripts/installation-functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ function check_minikube {
}

function check_openshift_4 {
($CMD get ns openshift && $CMD version | tail -1 | grep "v1.12") >/dev/null 2>&1
if $CMD api-resources >/dev/null; then
$CMD api-resources | grep machineconfigs | grep machineconfiguration.openshift.io > /dev/null 2>&1
else
($CMD get ns openshift && $CMD version | tail -1 | grep "v1.12") >/dev/null 2>&1
fi
}

function check_operatorgroups {
Expand Down Expand Up @@ -242,6 +246,8 @@ function install_istio {
$CMD scale -n istio-system --replicas=0 deployment/jaeger-collector
$CMD scale -n istio-system --replicas=0 deployment/jaeger-query
$CMD scale -n istio-system --replicas=0 statefulset/elasticsearch

patch_istio_for_knative
fi
}

Expand Down Expand Up @@ -280,3 +286,34 @@ function install_knative {
channel: alpha
EOF
}

function enable_interaction_with_registry() {
if check_openshift_4; then
local ns=${1:-knative-serving}
local configmap_name=config-service-ca
local cert_name=service-ca.crt
local mount_path=/var/run/secrets/kubernetes.io/servicecerts

$CMD -n $ns create configmap $configmap_name
$CMD -n $ns annotate configmap $configmap_name service.alpha.openshift.io/inject-cabundle="true"
timeout 180 '! $CMD -n $ns get cm $configmap_name -oyaml | grep $cert_name'
$CMD -n $ns set volume deployment/controller --add --name=service-ca --configmap-name=$configmap_name --mount-path=$mount_path
$CMD -n $ns set env deployment/controller SSL_CERT_FILE=$mount_path/$cert_name
else
echo "Registry configuration only required for OCP4"
fi
}

function patch_istio_for_knative() {
local sidecar_config=$($CMD get configmap -n istio-system istio-sidecar-injector -o yaml)
if [[ -z "${sidecar_config}" ]]; then
return 1
fi
echo "${sidecar_config}" | grep lifecycle
if [[ $? -eq 1 ]]; then
echo "Patching Istio's preStop hook for graceful shutdown"
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 -
$CMD delete pod -n istio-system -l istio=sidecar-injector
wait_for_all_pods istio-system
fi
}

0 comments on commit a80c9d9

Please sign in to comment.