Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Webhook feature to Event Streams #243

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
include:
- SCENARIO: default # tests headless scenario too
- SCENARIO: externaldb
# - SCENARIO: ingress # TODO: This scenario currently fails because ui and webhook ingress cannot have the same host and path in minikube nginx ingress controller
# - SCENARIO: ingress # TODO: This scenario currently fails because ui and event_stream ingress cannot have the same host and path in minikube nginx ingress controller
steps:
- name: Checkout sources
uses: actions/checkout@v4
Expand Down
6 changes: 3 additions & 3 deletions config/crd/bases/eda.ansible.com_edas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -429,11 +429,11 @@ spec:
type: object
type: array
type: object
webhook:
description: Defines desired state of eda-webhook resources
event_stream:
description: Defines desired state of Event Stream resources
properties:
prefix:
description: Prefix for the webhook
description: Prefix for the Event Stream URL
type: string
gunicorn_workers:
description: 'The number of gunicorn workers for the api.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,9 @@ spec:
path: api.topology_spread_constraints
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:advanced
- description: Defines desired state of eda-webhook deployment resources
- description: Defines desired state of eda-event-stream deployment resources
displayName: Webhook deployment configuration
path: webhook
path: event_stream
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:advanced
- description: Webhook custom prefix path
Expand All @@ -389,38 +389,38 @@ spec:
- urn:alm:descriptor:com.tectonic.ui:advanced
- description: The number of gunicorn workers for the Webhook.
displayName: Gunicorn Webhook workers
path: webhook.gunicorn_workers
path: event_stream.gunicorn_workers
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:advanced
- urn:alm:descriptor:com.tectonic.ui:number
- displayName: Webhook server resource requirements
path: webhook.resource_requirements
path: event_stream.resource_requirements
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:resourceRequirements
- description: The number of Webhook replicas.
displayName: Replicas
path: webhook.replicas
path: event_stream.replicas
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:podCount
- displayName: Node Selector
path: webhook.node_selector
path: event_stream.node_selector
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:advanced
- description: The deployment strategy to use to replace existing pods with
new ones.
displayName: Strategy
path: webhook.strategy
path: event_stream.strategy
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:updateStrategy
- urn:alm:descriptor:com.tectonic.ui:advanced
- description: Node tolerations for the webhook pods.
- description: Node tolerations for the event_stream pods.
displayName: Tolerations
path: webhook.tolerations
path: event_stream.tolerations
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:advanced
- description: Topology rule(s) for the pods.
displayName: Topology Spread Constraints
path: webhook.topology_spread_constraints
path: event_stream.topology_spread_constraints
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:advanced
- description: Defines desired state of eda-ui deployment resources
Expand Down
6 changes: 3 additions & 3 deletions roles/eda/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ _scheduler:
node_selector: {}
tolerations: []

webhook: {}
_webhook:
prefix: /eda-webhook
event_stream: {}
_event_stream:
prefix: /event-streams
gunicorn_workers: 2
replicas: 1
resource_requirements:
Expand Down
6 changes: 3 additions & 3 deletions roles/eda/tasks/combine_defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
combined_api: "{{ _api | combine(api, recursive=True) }}"
combined_ui: "{{ _ui | combine(ui, recursive=True) }}"
combined_scheduler: "{{ _scheduler | combine(scheduler, recursive=True) }}"
combined_webhook: "{{ _webhook | combine(webhook, recursive=True) }}"
combined_event_stream: "{{ _event_stream | combine(event_stream, recursive=True) }}"

# Backwards compatibility support for worker parameters
- name: Set defaults for workers # (overridden by worker, default_worker, and activation_worker)
Expand All @@ -15,8 +15,8 @@

- name: Combine worker params
set_fact:
combined_default_worker: "{{ _worker | combine (worker, recursive=True) }}"
combined_activation_worker: "{{ _worker | combine (worker, recursive=True) }}"
combined_default_worker: "{{ _worker | combine(worker, recursive=True) }}"
combined_activation_worker: "{{ _worker | combine(worker, recursive=True) }}"
when: worker is defined

- name: Set default worker parameters when worker is not defined
Expand Down
12 changes: 6 additions & 6 deletions roles/eda/tasks/deploy_eda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@
- 'eda-default-worker.deployment'
- 'eda-activation-worker.deployment'
- 'eda-scheduler.deployment'
- 'eda-webhook.configmap'
- 'eda-webhook.service'
- 'eda-webhook.deployment'
- 'eda-event-stream.configmap'
- 'eda-event-stream.service'
- 'eda-event-stream.deployment'

- name: Apply webhook ingress resources
- name: Apply event-stream ingress resources
k8s:
apply: yes
definition: "{{ lookup('template', item + '.yaml.j2') }}"
wait: no
loop:
- 'eda-webhook.ingress'
- 'eda-event-stream.ingress'
when:
- (service_type | lower) == 'route' or ((service_type | lower) == 'ingress' and ui_disabled)
# Always runs if service_type: Route
# If service_type: Ingress, only run if UI is disabled
# If UI is enabled, the webhook ingress is handled by the UI ingress via multiple pathes
# If UI is enabled, the event-stream ingress is handled by the UI ingress via multiple pathes

- name: Apply UI deployment resources if UI is enabled
k8s:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: '{{ ansible_operator_meta.name }}-nginx-webhook-configmap'
name: '{{ ansible_operator_meta.name }}-nginx-event-stream-configmap'
namespace: '{{ ansible_operator_meta.namespace }}'
data:
nginx_webhook_default_conf_template: |
nginx_event_stream_default_conf_template: |
events {
worker_connections 1024;
}
Expand All @@ -19,15 +19,15 @@ data:
application/manifest+json webmanifest;
}

upstream eda-api-webhook-backend {
server 127.0.0.1:{{ webhook_django_port }};
upstream eda-api-event-stream-backend {
server 127.0.0.1:{{ event_stream_django_port }};
}

server {
listen {{ webhook_nginx_port }};
listen {{ event_stream_nginx_port }};

location / {
proxy_pass http://eda-api-webhook-backend/;
proxy_pass http://eda-api-event-stream-backend/;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,37 @@ metadata:
labels:
{{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=4) | trim }}
{{ lookup("template", "../common/templates/labels/version.yaml.j2") | indent(width=4) | trim }}
app.kubernetes.io/component: '{{ deployment_type }}-webhook'
name: '{{ webhook_server_name }}'
app.kubernetes.io/component: '{{ deployment_type }}-event-stream'
name: '{{ event_stream_server_name }}'
namespace: '{{ ansible_operator_meta.namespace }}'
spec:
replicas: {{ combined_webhook.replicas }}
{% if combined_webhook.strategy is defined %}
replicas: {{ combined_event_stream.replicas }}
{% if combined_event_stream.strategy is defined %}
strategy:
type: {{ combined_webhook.strategy.type }}
{% if combined_webhook.strategy.type == "Recreate" %}
type: {{ combined_event_stream.strategy.type }}
{% if combined_event_stream.strategy.type == "Recreate" %}
rollingUpdate: null
{% elif combined_webhook.strategy.type == "RollingUpdate" %}
{% elif combined_event_stream.strategy.type == "RollingUpdate" %}
rollingUpdate:
maxSurge: {{ combined_webhook.strategy.rollingUpdate.maxSurge | default("25%")}}
maxUnavailable: {{ combined_webhook.strategy.rollingUpdate.maxUnavailable | default("25%")}}
maxSurge: {{ combined_event_stream.strategy.rollingUpdate.maxSurge | default("25%")}}
maxUnavailable: {{ combined_event_stream.strategy.rollingUpdate.maxUnavailable | default("25%")}}
{% endif %}
{% endif %}
selector:
matchLabels:
app.kubernetes.io/name: '{{ ansible_operator_meta.name }}'
app.kubernetes.io/managed-by: '{{ deployment_type }}-operator'
app.kubernetes.io/component: '{{ deployment_type }}-webhook'
app.kubernetes.io/component: '{{ deployment_type }}-event-stream'
template:
metadata:
labels:
{{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=8) | trim }}
{{ lookup("template", "../common/templates/labels/version.yaml.j2") | indent(width=8) | trim }}
app.kubernetes.io/component: '{{ deployment_type }}-webhook'
app.kubernetes.io/component: '{{ deployment_type }}-event-stream'
annotations:
kubectl.kubernetes.io/default-container: 'eda-webhook'
kubectl.kubernetes.io/default-container: 'eda-event-stream'
{% for template in [
"eda-webhook.configmap",
"eda-event-stream.configmap",
] %}
checksum-{{ template | replace('/', '-') }}: "{{ lookup('template', template + '.yaml.j2') | sha1 }}"
{% endfor %}
Expand All @@ -52,17 +52,17 @@ spec:
- name: {{ secret }}
{% endfor %}
{% endif %}
{% if combined_webhook.node_selector is defined %}
{% if combined_event_stream.node_selector is defined %}
nodeSelector:
{{ combined_webhook.node_selector | to_nice_yaml | indent(width=8) }}
{{ combined_event_stream.node_selector | to_nice_yaml | indent(width=8) }}
{% endif %}
{% if combined_webhook.tolerations is defined %}
{% if combined_event_stream.tolerations is defined %}
tolerations:
{{ combined_webhook.tolerations | to_nice_yaml | indent(width=8) }}
{{ combined_event_stream.tolerations | to_nice_yaml | indent(width=8) }}
{% endif %}
{% if combined_webhook.topology_spread_constraints is defined %}
{% if combined_event_stream.topology_spread_constraints is defined %}
topologySpreadConstraints:
{{ combined_webhook.topology_spread_constraints | indent(width=8) }}
{{ combined_event_stream.topology_spread_constraints | indent(width=8) }}
{% endif %}
initContainers:
- name: wait-for-migrations
Expand Down Expand Up @@ -124,8 +124,8 @@ spec:
- |
mkdir -p /etc/pki/ca-trust/extracted/{java,pem,openssl,edk2}
update-ca-trust
{% if combined_webhook.resource_requirements is defined %}
resources: {{ combined_webhook.resource_requirements }}
{% if combined_event_stream.resource_requirements is defined %}
resources: {{ combined_event_stream.resource_requirements }}
{% endif %}
volumeMounts:
- name: "ca-trust-extracted"
Expand All @@ -136,13 +136,13 @@ spec:
readOnly: true
{% endif %}
containers:
- name: eda-webhook
- name: eda-event-stream
image: {{ _image }}
imagePullPolicy: '{{ image_pull_policy }}'
args:
- /bin/bash
- -c
- gunicorn --bind 0.0.0.0:{{ webhook_django_port }} --workers {{ combined_webhook.gunicorn_workers }} aap_eda.wsgi:application
- gunicorn --bind 0.0.0.0:{{ event_stream_django_port }} --workers {{ combined_event_stream.gunicorn_workers }} aap_eda.wsgi:application
envFrom:
- configMapRef:
name: '{{ ansible_operator_meta.name }}-{{ deployment_type }}-env-properties'
Expand Down Expand Up @@ -183,23 +183,23 @@ spec:
name: '{{ db_fields_encryption_secret_name }}'
key: secret_key
ports:
- containerPort: {{ webhook_django_port }}
- containerPort: {{ event_stream_django_port }}
readinessProbe:
httpGet:
path: /_healthz
port: {{ webhook_django_port }}
port: {{ event_stream_django_port }}
failureThreshold: 10
periodSeconds: 10
initialDelaySeconds: 20
livenessProbe:
httpGet:
path: /_healthz
port: {{ webhook_django_port }}
port: {{ event_stream_django_port }}
failureThreshold: 10
periodSeconds: 10
initialDelaySeconds: 20
{% if combined_webhook.resource_requirements is defined %}
resources: {{ combined_webhook.resource_requirements }}
{% if combined_event_stream.resource_requirements is defined %}
resources: {{ combined_event_stream.resource_requirements }}
{% endif %}
{% if bundle_ca_crt %}
volumeMounts:
Expand All @@ -213,9 +213,9 @@ spec:
- name: nginx
image: {{ _image_web }}
ports:
- containerPort: {{ webhook_nginx_port }}
- containerPort: {{ event_stream_nginx_port }}
volumeMounts:
- name: '{{ ansible_operator_meta.name }}-nginx-webhook-conf'
- name: '{{ ansible_operator_meta.name }}-nginx-event-stream-conf'
mountPath: /etc/nginx/nginx.conf
subPath: nginx.conf
readOnly: true
Expand All @@ -225,11 +225,11 @@ spec:
mountPath: /var/run
restartPolicy: Always
volumes:
- name: '{{ ansible_operator_meta.name }}-nginx-webhook-conf'
- name: '{{ ansible_operator_meta.name }}-nginx-event-stream-conf'
configMap:
name: '{{ ansible_operator_meta.name }}-nginx-webhook-configmap'
name: '{{ ansible_operator_meta.name }}-nginx-event-stream-configmap'
items:
- key: nginx_webhook_default_conf_template
- key: nginx_event_stream_default_conf_template
path: nginx.conf
- name: nginx-cache
emptyDir: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ apiVersion: '{{ ingress_api_version }}'
{% endif %}
kind: Ingress
metadata:
name: '{{ ansible_operator_meta.name }}-webhook-ingress'
name: '{{ ansible_operator_meta.name }}-event-stream-ingress'
namespace: '{{ ansible_operator_meta.namespace }}'
labels:
{{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=4) | trim }}
Expand All @@ -24,7 +24,7 @@ spec:
pathType: '{{ ingress_path_type }}'
backend:
service:
name: '{{ ansible_operator_meta.name }}-webhook'
name: '{{ ansible_operator_meta.name }}-event-stream'
port:
number: 8000
{% if hostname %}
Expand All @@ -45,7 +45,7 @@ apiVersion: '{{ route_api_version }}'
{% endif %}
kind: Route
metadata:
name: '{{ ansible_operator_meta.name }}-webhook'
name: '{{ ansible_operator_meta.name }}-event-stream'
namespace: '{{ ansible_operator_meta.namespace }}'
labels:
{{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=4) | trim }}
Expand All @@ -70,7 +70,7 @@ spec:
{% endif %}
to:
kind: Service
name: {{ ansible_operator_meta.name }}-webhook
name: {{ ansible_operator_meta.name }}-event-stream
weight: 100
wildcardPolicy: None
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
apiVersion: v1
kind: Service
metadata:
name: "{{ webhook_server_name }}"
name: "{{ event_stream_server_name }}"
namespace: "{{ ansible_operator_meta.namespace }}"
labels:
{{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=4) | trim }}
app.kubernetes.io/component: '{{ deployment_type }}-webhook'
app.kubernetes.io/component: '{{ deployment_type }}-event-stream'
spec:
ports:
- port: {{ webhook_nginx_port }}
- port: {{ event_stream_nginx_port }}
protocol: TCP
targetPort: {{ webhook_nginx_port }}
targetPort: {{ event_stream_nginx_port }}
selector:
{{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=4) | trim }}
app.kubernetes.io/component: '{{ deployment_type }}-webhook'
app.kubernetes.io/component: '{{ deployment_type }}-event-stream'
Loading