Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: argoproj.io/v1alpha1
kind: EventSource
metadata:
name: openstack-neutron
namespace: openstack
spec:
template:
serviceAccountName: openstack-events
# Kubernetes resource event sources
resource:
neutron-deployment:
# monitor deployment resources under openstack namespace
namespace: openstack
resource: deployments
group: apps
version: v1
# Event types to listen for (e.g., ADD, UPDATE, DELETE). Here we want only when deployment is created.
eventTypes:
- ADD
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is this only when the deployment is created? Can we add some descriptions / comments in these to tell the user this is how it works? We could also make this happen on update as well if we check first if the provisioning network exists?

Copy link
Contributor Author

@haseebsyed12 haseebsyed12 Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments. sure I will add logic for UPDATE too. what I noticed was 4 jobs are executing simultaneously on UPDATE event. We need to have some lock to ensure only one job runs.

filter:
# filter based these labels to match neutron-server deployment
labels:
- key: application
value: neutron
- key: component
value: server
69 changes: 69 additions & 0 deletions workflows/openstack/sensors/sensor-neutron-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
name: neutron-deployment
namespace: openstack
spec:
template:
serviceAccountName: openstack-events
# events the Sensor listens for
dependencies:
- eventName: neutron-deployment
eventSourceName: openstack-neutron
name: openstack-neutron-server-deployment
# actions executed when dependencies are satisfied (StandardK8STrigger designed to create or update a generic Kubernetes resource.)
triggers:
- template:
name: create-provisioning-network
k8s:
operation: create
source:
resource:
apiVersion: batch/v1
kind: Job # Resource type to be created

Check warning on line 24 in workflows/openstack/sensors/sensor-neutron-deployment.yaml

View workflow job for this annotation

GitHub Actions / lint-yaml

24:25 [comments] too few spaces before comment

Check warning on line 24 in workflows/openstack/sensors/sensor-neutron-deployment.yaml

View workflow job for this annotation

GitHub Actions / lint-yaml

24:25 [comments] too few spaces before comment
metadata:
generateName: create-provision-network
spec:
template:
spec:
containers:
- name: create-network
image: docker.io/openstackhelm/openstack-client:2024.2
command:
- /bin/bash
- '-c'
- >-
openstack network create --description "${PROVISIONING_NETWORK_DESCRIPTION}" \
--no-share --provider-network-type "${PROVISIONING_NETWORK_TYPE}" \
--provider-physical-network "${PROVISIONING_PHYSICAL_NETWORK}" \
--tag "${PROVISIONING_NETWORK_TAGS}" \
"${PROVISIONING_NETWORK_NAME}"
env:
- name: PROVISIONING_NETWORK_NAME
valueFrom:
configMapKeyRef:
name: provisioning-network-config
key: network_name
- name: PROVISIONING_NETWORK_TYPE
valueFrom:
configMapKeyRef:
name: provisioning-network-config
key: network_type
- name: PROVISIONING_PHYSICAL_NETWORK
valueFrom:
configMapKeyRef:
name: provisioning-network-config
key: physical_network
- name: PROVISIONING_NETWORK_TAGS
valueFrom:
configMapKeyRef:
name: provisioning-network-config
key: tags
- name: PROVISIONING_NETWORK_DESCRIPTION
valueFrom:
configMapKeyRef:
name: provisioning-network-config
key: description
imagePullPolicy: IfNotPresent
restartPolicy: OnFailure
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
namespace: openstack
name: openstack-events

---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: openstack
name: openstack-events-role
rules:
- apiGroups:
- ""
- apps
- batch
resources:
- pods
- deployments
- jobs
verbs:
- '*'

---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
namespace: openstack
name: openstack-events-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: openstack-events-role
subjects:
- kind: ServiceAccount
name: openstack-events
namespace: openstack
Loading