diff --git a/doc/source/index.rst b/doc/source/index.rst index accb78d..2d3ef6b 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -182,6 +182,17 @@ are used: See the reference documentation for the specific `secretName` entry 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 ----------------------- @@ -255,6 +266,11 @@ verbatim): 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 :default: latest @@ -458,3 +474,10 @@ verbatim): .. attr:: volume A mapping corresponding to a Kubernetes volume. + + .. attr:: preview + + .. attr:: count + :default: 0 + + How many Zuul Preview servers to manage. diff --git a/playbooks/zuul-operator-functional/run.yaml b/playbooks/zuul-operator-functional/run.yaml index 940fc59..28d5e8f 100644 --- a/playbooks/zuul-operator-functional/run.yaml +++ b/playbooks/zuul-operator-functional/run.yaml @@ -47,8 +47,5 @@ include_tasks: ./tasks/test_cert_manager.yaml # TODO: implement - # - name: Test the preview - # include_tasks: ./tasks/test_preview.yaml - # - name: Test the registry # include_tasks: ./tasks/test_registry.yaml diff --git a/playbooks/zuul-operator-functional/tasks/test_preview.yaml b/playbooks/zuul-operator-functional/tasks/test_preview.yaml index 7e2532c..fc2fa3e 100644 --- a/playbooks/zuul-operator-functional/tasks/test_preview.yaml +++ b/playbooks/zuul-operator-functional/tasks/test_preview.yaml @@ -1,9 +1,10 @@ - name: Get preview service ip - command: kubectl get svc preview -o "jsonpath={.spec.clusterIP}" - register: _preview_ip + command: kubectl get svc zuul-preview -o jsonpath='{.spec.ports[0].nodePort}' + register: _preview_port - name: Connect to the preview service uri: - url: "http://{{ _preview_ip.stdout_lines[0] }}" + url: "http://{{ cluster_ip}}:{{ _preview_port.stdout_lines[0] }}" method: POST status_code: 403 + timeout: 60 diff --git a/playbooks/zuul-operator-functional/test.yaml b/playbooks/zuul-operator-functional/test.yaml index c61ac83..ff5ce0e 100644 --- a/playbooks/zuul-operator-functional/test.yaml +++ b/playbooks/zuul-operator-functional/test.yaml @@ -153,3 +153,6 @@ # when: "'Demo job is running' not in console_stream.stdout" fail: msg: "Task output is missing from: {{ console_stream.stdout }}" + + - name: Test the preview + include_tasks: ./tasks/test_preview.yaml diff --git a/zuul_operator/templates/zuul.yaml b/zuul_operator/templates/zuul.yaml index 79af07f..47a8ee5 100644 --- a/zuul_operator/templates/zuul.yaml +++ b/zuul_operator/templates/zuul.yaml @@ -423,3 +423,60 @@ spec: - name: zookeeper-client-tls secret: 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/ diff --git a/zuul_operator/zuul.py b/zuul_operator/zuul.py index 126bccc..19bcf3e 100644 --- a/zuul_operator/zuul.py +++ b/zuul_operator/zuul.py @@ -71,9 +71,11 @@ class Zuul: self.spec.setdefault('merger', {}).setdefault('count', 0) self.spec.setdefault('web', {}).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('zuulImageVersion', 'latest') + self.spec.setdefault('zuulPreviewImageVersion', 'latest') self.spec.setdefault('nodepoolImageVersion', 'latest') self.cert_manager = certmanager.CertManager(