Support zuul-preview

The test is moved from run.yaml to test.yaml to benefit from the cluster_ip
variable that is set at the start of test.yaml.

Change-Id: Ia0d1cbac94b6b638b6f410d9647ee1822751a767
This commit is contained in:
James E. Blair 2021-04-10 15:14:23 -07:00
parent a32c31bc3c
commit 6e0fb7fe1b
6 changed files with 89 additions and 6 deletions

View File

@ -182,6 +182,17 @@ are used:
See the reference documentation for the specific `secretName` entry See the reference documentation for the specific `secretName` entry
for details. for details.
Zuul Preview
------------
The operator has optional support for deploying a zuul-preview
service. This is an experimental add-on for Zuul to serve Zuul
artifacts from the root of a domain (this can be useful for serving
static HTML/Javascript sites). If you enable this, the operator will
configure a ``zuul-preview`` service to which you may route an Ingress
or LoadBalancer.
Specification Reference Specification Reference
----------------------- -----------------------
@ -255,6 +266,11 @@ verbatim):
The image tag to append to the Zuul images. The image tag to append to the Zuul images.
.. attr:: zuulPreviewImageVersion
:default: latest
The image tag to append to the Zuul Preview images.
.. attr:: nodepoolImageVersion .. attr:: nodepoolImageVersion
:default: latest :default: latest
@ -458,3 +474,10 @@ verbatim):
.. attr:: volume .. attr:: volume
A mapping corresponding to a Kubernetes volume. A mapping corresponding to a Kubernetes volume.
.. attr:: preview
.. attr:: count
:default: 0
How many Zuul Preview servers to manage.

View File

@ -47,8 +47,5 @@
include_tasks: ./tasks/test_cert_manager.yaml include_tasks: ./tasks/test_cert_manager.yaml
# TODO: implement # TODO: implement
# - name: Test the preview
# include_tasks: ./tasks/test_preview.yaml
# - name: Test the registry # - name: Test the registry
# include_tasks: ./tasks/test_registry.yaml # include_tasks: ./tasks/test_registry.yaml

View File

@ -1,9 +1,10 @@
- name: Get preview service ip - name: Get preview service ip
command: kubectl get svc preview -o "jsonpath={.spec.clusterIP}" command: kubectl get svc zuul-preview -o jsonpath='{.spec.ports[0].nodePort}'
register: _preview_ip register: _preview_port
- name: Connect to the preview service - name: Connect to the preview service
uri: uri:
url: "http://{{ _preview_ip.stdout_lines[0] }}" url: "http://{{ cluster_ip}}:{{ _preview_port.stdout_lines[0] }}"
method: POST method: POST
status_code: 403 status_code: 403
timeout: 60

View File

@ -153,3 +153,6 @@
# when: "'Demo job is running' not in console_stream.stdout" # when: "'Demo job is running' not in console_stream.stdout"
fail: fail:
msg: "Task output is missing from: {{ console_stream.stdout }}" msg: "Task output is missing from: {{ console_stream.stdout }}"
- name: Test the preview
include_tasks: ./tasks/test_preview.yaml

View File

@ -423,3 +423,60 @@ spec:
- name: zookeeper-client-tls - name: zookeeper-client-tls
secret: secret:
secretName: {{ spec.zookeeper.secretName }} secretName: {{ spec.zookeeper.secretName }}
---
apiVersion: v1
kind: Service
metadata:
name: zuul-preview
labels:
app.kubernetes.io/name: zuul
app.kubernetes.io/instance: {{ instance_name }}
app.kubernetes.io/part-of: zuul
app.kubernetes.io/component: zuul-preview
spec:
type: NodePort
ports:
- name: zuul-preview
port: 80
protocol: TCP
targetPort: zuul-preview
selector:
app.kubernetes.io/name: zuul
app.kubernetes.io/instance: {{ instance_name }}
app.kubernetes.io/part-of: zuul
app.kubernetes.io/component: zuul-preview
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: zuul-preview
labels:
app.kubernetes.io/name: zuul
app.kubernetes.io/instance: {{ instance_name }}
app.kubernetes.io/part-of: zuul
app.kubernetes.io/component: zuul-preview
spec:
replicas: {{ spec.preview.count }}
selector:
matchLabels:
app.kubernetes.io/name: zuul
app.kubernetes.io/instance: {{ instance_name }}
app.kubernetes.io/part-of: zuul
app.kubernetes.io/component: zuul-preview
template:
metadata:
labels:
app.kubernetes.io/name: zuul
app.kubernetes.io/instance: {{ instance_name }}
app.kubernetes.io/part-of: zuul
app.kubernetes.io/component: zuul-preview
spec:
containers:
- name: preview
image: {{ spec.imagePrefix }}/zuul-preview:{{ spec.zuulPreviewImageVersion }}
ports:
- name: zuul-preview
containerPort: 80
env:
- name: ZUUL_API_URL
value: http://zuul-web/

View File

@ -71,9 +71,11 @@ class Zuul:
self.spec.setdefault('merger', {}).setdefault('count', 0) self.spec.setdefault('merger', {}).setdefault('count', 0)
self.spec.setdefault('web', {}).setdefault('count', 1) self.spec.setdefault('web', {}).setdefault('count', 1)
self.spec.setdefault('fingergw', {}).setdefault('count', 1) self.spec.setdefault('fingergw', {}).setdefault('count', 1)
self.spec.setdefault('preview', {}).setdefault('count', 0)
self.spec.setdefault('imagePrefix', 'docker.io/zuul') self.spec.setdefault('imagePrefix', 'docker.io/zuul')
self.spec.setdefault('zuulImageVersion', 'latest') self.spec.setdefault('zuulImageVersion', 'latest')
self.spec.setdefault('zuulPreviewImageVersion', 'latest')
self.spec.setdefault('nodepoolImageVersion', 'latest') self.spec.setdefault('nodepoolImageVersion', 'latest')
self.cert_manager = certmanager.CertManager( self.cert_manager = certmanager.CertManager(