From 9c53503051214f4727e36d95c9902522651f9a7d Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Wed, 8 Apr 2020 12:19:34 +0000 Subject: [PATCH] Add zuul-preview service This change adds an optional preview configuration to the spec: preview: image: docker.io/zuul/zuul-preview:latest count: 0 Change-Id: Id9d902b3b9f25b1bf3fa459634396d7520681417 --- conf/zuul/components/Preview.dhall | 40 +++++++++++++++++++++ conf/zuul/input.dhall | 6 ++++ conf/zuul/resources.dhall | 7 ++++ playbooks/files/cr_spec.yaml | 2 ++ playbooks/zuul-operator-functional/run.yaml | 14 ++++++++ roles/zuul/defaults/main.yaml | 1 + 6 files changed, 70 insertions(+) create mode 100644 conf/zuul/components/Preview.dhall diff --git a/conf/zuul/components/Preview.dhall b/conf/zuul/components/Preview.dhall new file mode 100644 index 0000000..b8c2493 --- /dev/null +++ b/conf/zuul/components/Preview.dhall @@ -0,0 +1,40 @@ +let Kubernetes = ../../Kubernetes.dhall + +let F = ../functions.dhall + +let InputPreview = (../input.dhall).Preview.Type + +in \(app-name : Text) + -> \(image-name : Optional Text) + -> \(data-dir : List F.Volume.Type) + -> \(input-preview : InputPreview) + -> F.KubernetesComponent::{ + , Service = Some (F.mkService app-name "preview" "preview" 80) + , Deployment = Some + ( F.mkDeployment + app-name + F.Component::{ + , name = "preview" + , count = F.defaultNat input-preview.count 0 + , data-dir = data-dir + , container = Kubernetes.Container::{ + , name = "preview" + , image = image-name + , imagePullPolicy = Some "IfNotPresent" + , ports = Some + [ Kubernetes.ContainerPort::{ + , name = Some "preview" + , containerPort = 80 + } + ] + , env = Some + [ Kubernetes.EnvVar::{ + , name = "ZUUL_API_URL" + , value = Some "http://web:9000" + } + ] + , volumeMounts = Some (F.mkVolumeMount data-dir) + } + } + ) + } diff --git a/conf/zuul/input.dhall b/conf/zuul/input.dhall index dc1d298..eed5d80 100644 --- a/conf/zuul/input.dhall +++ b/conf/zuul/input.dhall @@ -97,6 +97,10 @@ let Schemas = , public-url = None Text } } + , Preview = + { Type = { image : Optional Text, count : Optional Natural } + , default = { image = None Text, count = None Natural } + } , Launcher = { Type = { image : Optional Text, config : UserSecret } , default.image = None Text @@ -143,6 +147,7 @@ let Input = , web : Schemas.Web.Type , scheduler : Schemas.Scheduler.Type , registry : Schemas.Registry.Type + , preview : Schemas.Preview.Type , launcher : Schemas.Launcher.Type , database : Optional UserSecret , zookeeper : Optional UserSecret @@ -159,6 +164,7 @@ let Input = , web = Schemas.Web.default , scheduler = Schemas.Scheduler.default , registry = Schemas.Registry.default + , preview = Schemas.Preview.default , executor = Schemas.Executor.default , launcher = Schemas.Launcher.default , connections = Schemas.Connections.default diff --git a/conf/zuul/resources.dhall b/conf/zuul/resources.dhall index c831e3b..bc60eaf 100644 --- a/conf/zuul/resources.dhall +++ b/conf/zuul/resources.dhall @@ -390,6 +390,12 @@ in \(input : Input) zuul-data-dir [ etc-zuul-registry ] input.registry + , Preview = + ./components/Preview.dhall + input.name + (zuul-image "preview") + zuul-data-dir + input.preview } , Nodepool = let nodepool-image = @@ -586,6 +592,7 @@ in \(input : Input) # mkUnion Components.Zuul.Web # mkUnion Components.Zuul.Merger # mkUnion Components.Zuul.Registry + # mkUnion Components.Zuul.Preview # mkUnion Components.Nodepool.Launcher ) } diff --git a/playbooks/files/cr_spec.yaml b/playbooks/files/cr_spec.yaml index 781e26b..a94d49d 100644 --- a/playbooks/files/cr_spec.yaml +++ b/playbooks/files/cr_spec.yaml @@ -13,6 +13,8 @@ merger: scheduler: config: secretName: zuul-yaml-conf +preview: + count: 0 registry: count: 0 launcher: diff --git a/playbooks/zuul-operator-functional/run.yaml b/playbooks/zuul-operator-functional/run.yaml index 38872d8..68baec9 100644 --- a/playbooks/zuul-operator-functional/run.yaml +++ b/playbooks/zuul-operator-functional/run.yaml @@ -134,6 +134,8 @@ key: kube.config registry: count: 1 + preview: + count: 1 withCertManager: "{{ withCertManager }}" - name: Wait maximum 4 minutes for the scheduler deployment @@ -172,6 +174,18 @@ command: kubectl get Issuers zuul-ca -o yaml when: withCertManager + - name: Test the preview service + block: + - name: Get preview service ip + command: kubectl get svc preview -o "jsonpath={.spec.clusterIP}" + register: _preview_ip + + - name: Connect to the preview service + uri: + url: "http://{{ _preview_ip.stdout_lines[0] }}" + method: POST + status_code: 403 + - name: Test the registry block: - name: Get registry service ip diff --git a/roles/zuul/defaults/main.yaml b/roles/zuul/defaults/main.yaml index af29210..b790668 100644 --- a/roles/zuul/defaults/main.yaml +++ b/roles/zuul/defaults/main.yaml @@ -14,5 +14,6 @@ cert_manager: "{{ (raw_spec['withCertManager'] | default(true)) | bool }}" spec_defaults: web: {} registry: {} + preview: {} externalConfig: {} withCertManager: true