mirror of
https://github.com/openshift/community.okd.git
synced 2026-03-27 03:13:08 +00:00
Add openshift_route module for route creation (#40)
* first draft of interface * Add basic implementation * Add validation * rename to openshift_route and add some test tasks * Fix sanity checks * Add checks for missing dependencies * Add port processing like the oc command * Add real tests * Fix waiting * add some more waiting to test * add state parameters and fix RETURN docs * try to fix odd sanity issue * import tests passing * Fix all sanity tests * Do less work when state is absent, and add explicit removal values * insecure_policy disable -> disallow * add proper default for insecure_policy
This commit is contained in:
committed by
GitHub
parent
6942cd6756
commit
e7c3351309
240
molecule/default/tasks/openshift_route.yml
Normal file
240
molecule/default/tasks/openshift_route.yml
Normal file
@@ -0,0 +1,240 @@
|
||||
---
|
||||
- name: Create Deployment
|
||||
community.okd.k8s:
|
||||
wait: yes
|
||||
definition:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: hello-kubernetes
|
||||
namespace: default
|
||||
spec:
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
app: hello-kubernetes
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: hello-kubernetes
|
||||
spec:
|
||||
containers:
|
||||
- name: hello-kubernetes
|
||||
image: docker.io/openshift/hello-openshift
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
|
||||
- name: Create Service
|
||||
community.okd.k8s:
|
||||
wait: yes
|
||||
definition:
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: hello-kubernetes
|
||||
namespace: default
|
||||
spec:
|
||||
ports:
|
||||
- port: 80
|
||||
targetPort: 8080
|
||||
selector:
|
||||
app: hello-kubernetes
|
||||
|
||||
- name: Create Route with fewest possible arguments
|
||||
community.okd.openshift_route:
|
||||
service: hello-kubernetes
|
||||
namespace: default
|
||||
register: route
|
||||
|
||||
- name: Attempt to hit http URL
|
||||
uri:
|
||||
url: 'http://{{ route.result.spec.host }}'
|
||||
return_content: yes
|
||||
until: result is successful
|
||||
retries: 10
|
||||
register: result
|
||||
|
||||
- name: Assert the page content is as expected
|
||||
assert:
|
||||
that:
|
||||
- not result.redirected
|
||||
- result.status == 200
|
||||
- result.content == 'Hello OpenShift!\n'
|
||||
|
||||
- name: Delete route
|
||||
community.okd.openshift_route:
|
||||
name: '{{ route.result.metadata.name }}'
|
||||
namespace: default
|
||||
state: absent
|
||||
wait: yes
|
||||
|
||||
- name: Create Route with custom name and wait
|
||||
community.okd.openshift_route:
|
||||
service: hello-kubernetes
|
||||
namespace: default
|
||||
name: test1
|
||||
wait: yes
|
||||
register: route
|
||||
|
||||
- name: Assert that the condition is properly set
|
||||
assert:
|
||||
that:
|
||||
- route.duration is defined
|
||||
- route.result.status.ingress.0.conditions.0.type == 'Admitted'
|
||||
- route.result.status.ingress.0.conditions.0.status == 'True'
|
||||
|
||||
- name: Attempt to hit http URL
|
||||
uri:
|
||||
url: 'http://{{ route.result.spec.host }}'
|
||||
return_content: yes
|
||||
register: result
|
||||
|
||||
- name: Assert the page content is as expected
|
||||
assert:
|
||||
that:
|
||||
- not result.redirected
|
||||
- result.status == 200
|
||||
- result.content == 'Hello OpenShift!\n'
|
||||
|
||||
- name: Delete route
|
||||
community.okd.openshift_route:
|
||||
name: '{{ route.result.metadata.name }}'
|
||||
namespace: default
|
||||
state: absent
|
||||
wait: yes
|
||||
|
||||
- name: Create edge-terminated route that allows insecure traffic
|
||||
community.okd.openshift_route:
|
||||
service: hello-kubernetes
|
||||
namespace: default
|
||||
name: hello-kubernetes-https
|
||||
tls:
|
||||
insecure_policy: allow
|
||||
termination: edge
|
||||
register: route
|
||||
|
||||
- name: Attempt to hit http URL
|
||||
uri:
|
||||
url: 'http://{{ route.result.spec.host }}'
|
||||
return_content: yes
|
||||
until: result is successful
|
||||
retries: 10
|
||||
register: result
|
||||
|
||||
- name: Assert the page content is as expected
|
||||
assert:
|
||||
that:
|
||||
- not result.redirected
|
||||
- result.status == 200
|
||||
- result.content == 'Hello OpenShift!\n'
|
||||
|
||||
- name: Attempt to hit https URL
|
||||
uri:
|
||||
url: 'https://{{ route.result.spec.host }}'
|
||||
validate_certs: no
|
||||
return_content: yes
|
||||
until: result is successful
|
||||
retries: 10
|
||||
register: result
|
||||
|
||||
- name: Assert the page content is as expected
|
||||
assert:
|
||||
that:
|
||||
- not result.redirected
|
||||
- result.status == 200
|
||||
- result.content == 'Hello OpenShift!\n'
|
||||
|
||||
- name: Alter edge-terminated route to redirect insecure traffic
|
||||
community.okd.openshift_route:
|
||||
service: hello-kubernetes
|
||||
namespace: default
|
||||
name: hello-kubernetes-https
|
||||
tls:
|
||||
insecure_policy: redirect
|
||||
termination: edge
|
||||
register: route
|
||||
|
||||
- name: Attempt to hit http URL
|
||||
uri:
|
||||
url: 'http://{{ route.result.spec.host }}'
|
||||
return_content: yes
|
||||
validate_certs: no
|
||||
until:
|
||||
- result is successful
|
||||
- result.redirected
|
||||
retries: 10
|
||||
register: result
|
||||
|
||||
- name: Assert the page content is as expected
|
||||
assert:
|
||||
that:
|
||||
- result.redirected
|
||||
- result.status == 200
|
||||
- result.content == 'Hello OpenShift!\n'
|
||||
|
||||
- name: Attempt to hit https URL
|
||||
uri:
|
||||
url: 'https://{{ route.result.spec.host }}'
|
||||
validate_certs: no
|
||||
return_content: yes
|
||||
until: result is successful
|
||||
retries: 10
|
||||
register: result
|
||||
|
||||
- name: Assert the page content is as expected
|
||||
assert:
|
||||
that:
|
||||
- not result.redirected
|
||||
- result.status == 200
|
||||
- result.content == 'Hello OpenShift!\n'
|
||||
|
||||
- name: Alter edge-terminated route with insecure traffic disabled
|
||||
community.okd.openshift_route:
|
||||
service: hello-kubernetes
|
||||
namespace: default
|
||||
name: hello-kubernetes-https
|
||||
tls:
|
||||
insecure_policy: disallow
|
||||
termination: edge
|
||||
register: route
|
||||
|
||||
- debug: var=route
|
||||
|
||||
- name: Attempt to hit https URL
|
||||
uri:
|
||||
url: 'https://{{ route.result.spec.host }}'
|
||||
validate_certs: no
|
||||
return_content: yes
|
||||
until: result is successful
|
||||
retries: 10
|
||||
register: result
|
||||
|
||||
- name: Assert the page content is as expected
|
||||
assert:
|
||||
that:
|
||||
- not result.redirected
|
||||
- result.status == 200
|
||||
- result.content == 'Hello OpenShift!\n'
|
||||
|
||||
- name: Attempt to hit http URL
|
||||
uri:
|
||||
url: 'http://{{ route.result.spec.host }}'
|
||||
status_code: 503
|
||||
until: result is successful
|
||||
retries: 10
|
||||
register: result
|
||||
|
||||
- debug: var=result
|
||||
|
||||
- name: Assert the page content is as expected
|
||||
assert:
|
||||
that:
|
||||
- not result.redirected
|
||||
- result.status == 503
|
||||
|
||||
- name: Delete route
|
||||
community.okd.openshift_route:
|
||||
name: '{{ route.result.metadata.name }}'
|
||||
namespace: default
|
||||
state: absent
|
||||
wait: yes
|
||||
Reference in New Issue
Block a user