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

Commit 92c3564

Browse files
committed
Revert "Validate LB created with the OCI Cloud Controller in test cluster."
This reverts commit ee761fc.
1 parent adbb94b commit 92c3564

File tree

3 files changed

+39
-31
lines changed

3 files changed

+39
-31
lines changed

tests/create/runner.py

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ def _wait_until(predicate, timeoutSeconds, delaySeconds=0.25, *args, **kwargs):
9898
except Exception:
9999
pass
100100
time.sleep(delaySeconds)
101-
101+
102102
print("Condition not met within " + str(timeoutSeconds))
103-
raise
103+
raise Exception("Condition not met within " + str(timeoutSeconds))
104+
104105

105106
def _utf_encode_list(list):
106107
return [s.encode("UTF8") for s in list]
@@ -197,6 +198,9 @@ def _verifyConfig(tfvars_file, no_create=None, no_destroy=None):
197198
numWorkers = len(outputJSON["value"])
198199
workerPublicAddressList = _utf_encode_list(outputJSON["value"])
199200

201+
outputJSON = json.loads(_terraform("output -json control_plane_subnet_access"))
202+
controlPlaneSubnetAccess = outputJSON["value"]
203+
200204
_log("K8s Master Public LB Address: " + masterPublicLBAddress)
201205
_log("K8s Worker Public Addresses: " + str(workerPublicAddressList))
202206

@@ -225,29 +229,32 @@ def _verifyConfig(tfvars_file, no_create=None, no_destroy=None):
225229
_log("Sleeping 30 seconds to let pods initialize", as_banner=True)
226230
time.sleep(30)
227231

228-
_kubectl("apply -f " + TEST_ROOT_DIR + "/resources/hello-service.yml", exit_on_error=True)
229-
_kubectl("apply -f " + TEST_ROOT_DIR + "/resources/frontend-service.yml", exit_on_error=True)
232+
helloServicePort = _kubectl("get svc/hello -o jsonpath={.spec.ports[0].nodePort}", exit_on_error=True)
233+
_log("Hello service port: " + str(helloServicePort))
230234

231-
_log("Waiting for the LoadBalancer to initialize", as_banner=True)
232-
externalIPReady = lambda: _kubectl("get svc/frontend -o jsonpath={.status.loadBalancer.ingress[0].ip}", exit_on_error=True) != ""
233-
_wait_until(externalIPReady, 600)
234-
externalIP = _kubectl("get svc/frontend -o jsonpath={.status.loadBalancer.ingress[0].ip}", exit_on_error=True)
235-
_log("Frontend service IP (OCI Load Balancer): " + str(externalIP))
235+
frontendServicePort = _kubectl("get svc/frontend -o jsonpath={.spec.ports[0].nodePort}", exit_on_error=True)
236+
_log("Frontend service port: " + str(frontendServicePort))
236237

237-
_log("Checking " + "http://" + externalIP)
238-
applicationAvailable = lambda: requests.get("http://" + externalIP).status_code == 200
239-
_wait_until(applicationAvailable, 60)
238+
if controlPlaneSubnetAccess == "public":
239+
# Ping deployment
240+
_log("Pinging hello and frontend deployments for each K8s worker", as_banner=True)
241+
for workerPublicAddress in workerPublicAddressList:
242+
serviceAddressList = ["http://" + workerPublicAddress + ":" + str(helloServicePort),
243+
"http://" + workerPublicAddress + ":" + str(frontendServicePort)]
244+
for serviceAddress in serviceAddressList:
245+
_log("Checking " + serviceAddress)
246+
deploymentReady = lambda: requests.get(serviceAddress).status_code == 200
247+
_wait_until(deploymentReady, 180)
240248

241249
except Exception, e:
242250
_log("Unexpected error:", str(e))
243251
traceback.print_exc()
244252
success = False
245253
finally:
246-
_log("Undeploying the hello service", as_banner=True)
247-
_kubectl("delete -f " + TEST_ROOT_DIR + "/resources/hello-service.yml", exit_on_error=False)
248-
_kubectl("delete -f " + TEST_ROOT_DIR + "/resources/frontend-service.yml", exit_on_error=False)
249-
# Wait a minute for OCI Load Balancer to be deleted before starting terraform destroy
250-
time.sleep(120)
254+
if masterPublicLBAddress != None:
255+
_log("Undeploying the hello service", as_banner=True)
256+
_kubectl("delete -f " + TEST_ROOT_DIR + "/resources/hello-service.yml", exit_on_error=False)
257+
_kubectl("delete -f " + TEST_ROOT_DIR + "/resources/frontend-service.yml", exit_on_error=False)
251258

252259
if not no_destroy:
253260
_log("Destroying the K8s cluster from " + str(os.path.basename(tfvars_file)), as_banner=True)
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
apiVersion: v1
21
kind: Service
2+
apiVersion: v1
33
metadata:
44
name: frontend
55
spec:
66
selector:
77
app: hello
88
tier: frontend
99
ports:
10-
- protocol: "TCP"
11-
port: 80
12-
targetPort: 80
13-
type: LoadBalancer
10+
- protocol: "TCP"
11+
port: 80
12+
targetPort: 80
13+
type: NodePort
1414
---
1515
apiVersion: apps/v1beta1
1616
kind: Deployment
@@ -26,9 +26,9 @@ spec:
2626
track: stable
2727
spec:
2828
containers:
29-
- name: nginx
30-
image: "gcr.io/google-samples/hello-frontend:1.0"
31-
lifecycle:
32-
preStop:
33-
exec:
34-
command: ["/usr/sbin/nginx","-s","quit"]
29+
- name: nginx
30+
image: "gcr.io/google-samples/hello-frontend:1.0"
31+
lifecycle:
32+
preStop:
33+
exec:
34+
command: ["/usr/sbin/nginx","-s","quit"]

tests/resources/hello-service.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ spec:
77
app: hello
88
tier: backend
99
ports:
10-
- protocol: TCP
11-
port: 80
12-
targetPort: http
10+
- protocol: TCP
11+
port: 80
12+
targetPort: http
13+
type: NodePort
1314
---
1415
apiVersion: apps/v1beta1
1516
kind: Deployment

0 commit comments

Comments
 (0)