Browse code

Migrated router and registry startup utilities from util.sh

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>

Steve Kuznetsov authored on 2016/11/09 06:28:57
Showing 8 changed files
... ...
@@ -181,7 +181,7 @@ readonly -f os::start::internal::configure_master
181 181
 function os::start::internal::patch_master_config() {
182 182
 	local sudo=${USE_SUDO:+sudo}
183 183
 	cp "${SERVER_CONFIG_DIR}/master/master-config.yaml" "${SERVER_CONFIG_DIR}/master/master-config.orig.yaml"
184
-	openshift ex config patch ${SERVER_CONFIG_DIR}/master/master-config.orig.yaml --patch="{\"etcdConfig\": {\"address\": \"${API_HOST}:${ETCD_PORT}\"}}" | \
184
+	openshift ex config patch "${SERVER_CONFIG_DIR}/master/master-config.orig.yaml" --patch="{\"etcdConfig\": {\"address\": \"${API_HOST}:${ETCD_PORT}\"}}" | \
185 185
 	openshift ex config patch - --patch="{\"etcdConfig\": {\"servingInfo\": {\"bindAddress\": \"${API_HOST}:${ETCD_PORT}\"}}}" | \
186 186
 	openshift ex config patch - --type json --patch="[{\"op\": \"replace\", \"path\": \"/etcdClientInfo/urls\", \"value\": [\"${API_SCHEME}://${API_HOST}:${ETCD_PORT}\"]}]" | \
187 187
 	openshift ex config patch - --patch="{\"etcdConfig\": {\"peerAddress\": \"${API_HOST}:${ETCD_PEER_PORT}\"}}" | \
... ...
@@ -595,3 +595,66 @@ function os::start::internal::print_server_info() {
595 595
 	os::log::info "Using images:             ${USE_IMAGES}"
596 596
 	os::log::info "MasterIP is:              ${MASTER_ADDR}"
597 597
 }
598
+
599
+# os::start::router installs the OpenShift router and optionally creates
600
+# the server cert as well.
601
+#
602
+# Globals:
603
+#  - CREATE_ROUTER_CERT
604
+#  - MASTER_CONFIG_DIR
605
+#  - API_HOST
606
+#  - ADMIN_KUBECONFIG
607
+#  - USE_IMAGES
608
+#  - DROP_SYN_DURING_RESTART
609
+# Arguments:
610
+#  None
611
+# Returns:
612
+#  None
613
+function os::start::router() {
614
+	os::log::info "Installing the router"
615
+	oadm policy add-scc-to-user privileged --serviceaccount='router' --config="${ADMIN_KUBECONFIG}"
616
+	# Create a TLS certificate for the router
617
+	if [[ -n "${CREATE_ROUTER_CERT:-}" ]]; then
618
+		os::log::info "Generating router TLS certificate"
619
+		oadm ca create-server-cert --hostnames="*.${API_HOST}.xip.io"          \
620
+		                           --key="${MASTER_CONFIG_DIR}/router.key"     \
621
+		                           --cert="${MASTER_CONFIG_DIR}/router.crt"    \
622
+		                           --signer-key="${MASTER_CONFIG_DIR}/ca.key"  \
623
+		                           --signer-cert="${MASTER_CONFIG_DIR}/ca.crt" \
624
+		                           --signer-serial="${MASTER_CONFIG_DIR}/ca.serial.txt"
625
+		cat "${MASTER_CONFIG_DIR}/router.crt" \
626
+		    "${MASTER_CONFIG_DIR}/router.key" \
627
+			"${MASTER_CONFIG_DIR}/ca.crt" > "${MASTER_CONFIG_DIR}/router.pem"
628
+		openshift admin router --config="${ADMIN_KUBECONFIG}" --images="${USE_IMAGES}" --service-account=router --default-cert="${MASTER_CONFIG_DIR}/router.pem"
629
+	else
630
+		openshift admin router --config="${ADMIN_KUBECONFIG}" --images="${USE_IMAGES}" --service-account=router
631
+	fi
632
+
633
+	# Set the SYN eater to make router reloads more robust
634
+	if [[ -n "${DROP_SYN_DURING_RESTART:-}" ]]; then
635
+		# Rewrite the DC for the router to add the environment variable into the pod definition
636
+		os::log::info "Changing the router DC to drop SYN packets during a reload"
637
+		oc set env dc/router -c router DROP_SYN_DURING_RESTART=true
638
+	fi
639
+}
640
+readonly -f os::start::router
641
+
642
+# os::start::registry installs the OpenShift integrated registry
643
+#
644
+# Globals:
645
+#  - ADMIN_KUBECONFIG
646
+#  - USE_IMAGES
647
+# Arguments:
648
+#  None
649
+# Returns:
650
+#  None
651
+function os::start::registry() {
652
+	# The --mount-host option is provided to reuse local storage.
653
+	os::log::info "Installing the registry"
654
+	# For testing purposes, ensure the quota objects are always up to date in the registry by
655
+	# disabling project cache.
656
+	openshift admin registry --config="${ADMIN_KUBECONFIG}" --images="${USE_IMAGES}" --enforce-quota -o json | \
657
+		oc env -f - --output json "REGISTRY_MIDDLEWARE_REPOSITORY_OPENSHIFT_PROJECTCACHETTL=0" | \
658
+		oc create -f -
659
+}
660
+readonly -f os::start::registry
598 661
\ No newline at end of file
... ...
@@ -219,7 +219,7 @@ os::test::junit::declare_suite_end
219 219
 export OPENSHIFT_PROFILE="${CLI_PROFILE-}"
220 220
 
221 221
 # start up a registry for images tests
222
-ADMIN_KUBECONFIG="${MASTER_CONFIG_DIR}/admin.kubeconfig" KUBECONFIG="${MASTER_CONFIG_DIR}/admin.kubeconfig" install_registry
222
+ADMIN_KUBECONFIG="${MASTER_CONFIG_DIR}/admin.kubeconfig" KUBECONFIG="${MASTER_CONFIG_DIR}/admin.kubeconfig" os::start::registry
223 223
 
224 224
 #
225 225
 # Begin tests
... ...
@@ -144,45 +144,6 @@ function cleanup_openshift() {
144 144
 }
145 145
 readonly -f cleanup_openshift
146 146
 
147
-# install the router for the extended tests
148
-function install_router() {
149
-	os::log::info "Installing the router"
150
-	oadm policy add-scc-to-user privileged -z router --config="${ADMIN_KUBECONFIG}"
151
-	# Create a TLS certificate for the router
152
-	if [[ -n "${CREATE_ROUTER_CERT:-}" ]]; then
153
-		os::log::info "Generating router TLS certificate"
154
-		oadm ca create-server-cert --signer-cert=${MASTER_CONFIG_DIR}/ca.crt \
155
-			--signer-key=${MASTER_CONFIG_DIR}/ca.key \
156
-			--signer-serial=${MASTER_CONFIG_DIR}/ca.serial.txt \
157
-			--hostnames="*.${API_HOST}.xip.io" \
158
-			--cert=${MASTER_CONFIG_DIR}/router.crt --key=${MASTER_CONFIG_DIR}/router.key
159
-		cat ${MASTER_CONFIG_DIR}/router.crt ${MASTER_CONFIG_DIR}/router.key \
160
-			${MASTER_CONFIG_DIR}/ca.crt > ${MASTER_CONFIG_DIR}/router.pem
161
-		ROUTER_DEFAULT_CERT="--default-cert=${MASTER_CONFIG_DIR}/router.pem"
162
-	fi
163
-	openshift admin router --config="${ADMIN_KUBECONFIG}" --images="${USE_IMAGES}" --service-account=router ${ROUTER_DEFAULT_CERT-}
164
-
165
-	# Set the SYN eater to make router reloads more robust
166
-	if [[ -n "${DROP_SYN_DURING_RESTART:-}" ]]; then
167
-		# Rewrite the DC for the router to add the environment variable into the pod definition
168
-		os::log::info "Changing the router DC to drop SYN packets during a reload"
169
-		oc set env dc/router -c router DROP_SYN_DURING_RESTART=true
170
-	fi
171
-}
172
-readonly -f install_router
173
-
174
-# install registry for the extended tests
175
-function install_registry() {
176
-	# The --mount-host option is provided to reuse local storage.
177
-	os::log::info "Installing the registry"
178
-	# For testing purposes, ensure the quota objects are always up to date in the registry by
179
-	# disabling project cache.
180
-	openshift admin registry --config="${ADMIN_KUBECONFIG}" --images="${USE_IMAGES}" --enforce-quota -o json | \
181
-		oc env -f - --output json "REGISTRY_MIDDLEWARE_REPOSITORY_OPENSHIFT_PROJECTCACHETTL=0" | \
182
-		oc create -f -
183
-}
184
-readonly -f install_registry
185
-
186 147
 ######
187 148
 # end of common functions for extended test group's run.sh scripts
188 149
 ######
... ...
@@ -98,8 +98,8 @@ Common functions for extended tests are located in `./hack/util.sh`. Environment
98 98
 * `os::util::environment::setup_all_server_vars()` setup all required environment variables related to OpenShift server.
99 99
 * `os::start::configure_server()` generates all configuration files for OpenShift server.
100 100
 * `os::start::server()` starts the OpenShift master and node.
101
-* `install_router_extended()` installs the OpenShift router service.
102
-* `install_registry_extended()` installs the OpenShift Docker registry service.
101
+* `os::start::router()` installs the OpenShift router service.
102
+* `os::start::registry()` installs the OpenShift Docker registry service.
103 103
 * `create_image_streams_extended()` creates ImageStream(s) for all OpenShift images.
104 104
 
105 105
 CLI interface
... ...
@@ -37,7 +37,7 @@ oc login -u system:admin -n default
37 37
 # let everyone be able to see stuff in the default namespace
38 38
 oadm policy add-role-to-group view system:authenticated -n default
39 39
 
40
-install_registry
40
+os::start::registry
41 41
 oc rollout status dc/docker-registry
42 42
 docker_registry="$( oc get service/docker-registry -n default -o jsonpath='{.spec.clusterIP}:{.spec.ports[0].port}' )"
43 43
 
... ...
@@ -88,7 +88,7 @@ os::start::server
88 88
 
89 89
 export KUBECONFIG="${ADMIN_KUBECONFIG}"
90 90
 
91
-install_registry
91
+os::start::registry
92 92
 os::cmd::expect_success 'oc rollout status dc/docker-registry'
93 93
 
94 94
 os::cmd::expect_success 'oc login -u system:admin'
... ...
@@ -32,7 +32,7 @@ os::start::server
32 32
 
33 33
 export KUBECONFIG="${ADMIN_KUBECONFIG}"
34 34
 
35
-install_registry
35
+os::start::registry
36 36
 oc rollout status dc/docker-registry
37 37
 
38 38
 oc login ${MASTER_ADDR} -u ldap -p password --certificate-authority=${MASTER_CONFIG_DIR}/ca.crt
... ...
@@ -118,11 +118,11 @@ function os::test::extended::setup () {
118 118
 
119 119
 		export KUBECONFIG="${ADMIN_KUBECONFIG}"
120 120
 
121
-		install_registry
121
+		os::start::registry
122 122
 		if [[ -z "${SKIP_NODE:-}" ]]; then
123 123
 			oc rollout status dc/docker-registry
124 124
 		fi
125
-		DROP_SYN_DURING_RESTART=1 CREATE_ROUTER_CERT=1 install_router
125
+		DROP_SYN_DURING_RESTART=1 CREATE_ROUTER_CERT=1 os::start::router
126 126
 
127 127
 		os::log::info "Creating image streams"
128 128
 		oc create -n openshift -f "${OS_ROOT}/examples/image-streams/image-streams-centos7.json" --config="${ADMIN_KUBECONFIG}"