@@ -22,7 +22,87 @@ function wait_for_all_pods {
2222 timeout 300 " oc get pods -n $1 2>&1 | grep -v -E '(Running|Completed|STATUS)'"
2323}
2424
25+ function check_minishift {
26+ (hash minishift && oc whoami --show-server | grep " $( minishift ip) " ) > /dev/null 2>&1
27+ }
28+
29+ function enable_admission_webhooks {
30+ if check_minishift; then
31+ if ! minishift openshift config view --target=kube | grep ValidatingAdmissionWebhook > /dev/null; then
32+ minishift openshift config set --target=kube --patch ' {
33+ "admissionConfig": {
34+ "pluginConfig": {
35+ "ValidatingAdmissionWebhook": {
36+ "configuration": {
37+ "apiVersion": "apiserver.config.k8s.io/v1alpha1",
38+ "kind": "WebhookAdmission",
39+ "kubeConfigFile": "/dev/null"
40+ }
41+ },
42+ "MutatingAdmissionWebhook": {
43+ "configuration": {
44+ "apiVersion": "apiserver.config.k8s.io/v1alpha1",
45+ "kind": "WebhookAdmission",
46+ "kubeConfigFile": "/dev/null"
47+ }
48+ }
49+ }
50+ }
51+ }'
52+ # wait until the kube-apiserver is restarted
53+ until oc login -u admin -p admin 2> /dev/null; do sleep 5; done ;
54+ fi
55+ else
56+ KUBE_SSH_USER=${KUBE_SSH_USER:- cloud-user}
57+ API_SERVER=$( oc config view --minify | grep server | awk -F' //' ' {print $2}' | awk -F' :' ' {print $1}' )
58+
59+ ssh $KUBE_SSH_USER @$API_SERVER -i $KUBE_SSH_KEY /bin/bash << - EOF
60+ sudo -i
61+ cp -n /etc/origin/master/master-config.yaml /etc/origin/master/master-config.yaml.backup
62+ oc ex config patch /etc/origin/master/master-config.yaml --type=merge -p '{
63+ "admissionConfig": {
64+ "pluginConfig": {
65+ "ValidatingAdmissionWebhook": {
66+ "configuration": {
67+ "apiVersion": "apiserver.config.k8s.io/v1alpha1",
68+ "kind": "WebhookAdmission",
69+ "kubeConfigFile": "/dev/null"
70+ }
71+ },
72+ "MutatingAdmissionWebhook": {
73+ "configuration": {
74+ "apiVersion": "apiserver.config.k8s.io/v1alpha1",
75+ "kind": "WebhookAdmission",
76+ "kubeConfigFile": "/dev/null"
77+ }
78+ }
79+ }
80+ }
81+ }' >/etc/origin/master/master-config.yaml.patched
82+ if [ $? == 0 ]; then
83+ mv /etc/origin/master/master-config.yaml.patched /etc/origin/master/master-config.yaml
84+ /usr/local/bin/master-restart api && /usr/local/bin/master-restart controllers
85+ else
86+ exit
87+ fi
88+ EOF
89+
90+ if [ $? == 0 ]; then
91+ # wait until the kube-apiserver is restarted
92+ until oc status 2> /dev/null; do sleep 5; done
93+ else
94+ echo ' Remote command failed; check $KUBE_SSH_USER and/or $KUBE_SSH_KEY'
95+ return -1
96+ fi
97+ fi
98+ }
99+
25100function install_olm {
101+ # Scale down existing OLM, if any
102+ if oc get ns operator-lifecycle-manager; then
103+ oc scale -n operator-lifecycle-manager --replicas=0 deployment/catalog-operator
104+ oc scale -n operator-lifecycle-manager --replicas=0 deployment/olm-operator
105+ fi
26106 local ROOT_DIR=" $INSTALL_SCRIPT_DIR /../.."
27107 local REPO_DIR=" $ROOT_DIR /.repos"
28108 local OLM_DIR=" $REPO_DIR /olm"
0 commit comments