-
Notifications
You must be signed in to change notification settings - Fork 7
feat: PUC-529 : create provisioning network on successful deployment of neutron-server #598
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
workflows/openstack/eventsources/eventsource-openstack-neutron.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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
69
workflows/openstack/sensors/sensor-neutron-deployment.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
|
||
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 |
39 changes: 39 additions & 0 deletions
39
workflows/openstack/serviceaccounts/serviceaccount-openstack-events.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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.