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

feat: Reorganise workflow yamls #262

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
a5807aa
Rename argo workflow files
Sep 9, 2024
09e42cf
Delete example-feature argo-workflows folders
Sep 9, 2024
6ec90ae
Re-organise workflow docker containers into their own folder
Sep 9, 2024
9fa14f8
Fix up the "defined in" metadata in workflows that were renamed
Sep 9, 2024
d18e69a
Add titles to argo workflow templates
Sep 9, 2024
dbf8d82
Fix outdated docstring comment
Sep 9, 2024
4de4d22
Re-organise argo-workflow docs
Sep 9, 2024
95266f0
Rename workflows->workflowtemplates to reflect the Kind of its contents
Sep 10, 2024
f5f4289
Move dnsmasq container to subdirectory
Sep 10, 2024
f950cd4
Move ironiic-nautobot-client container to subdirectory
Sep 10, 2024
76d57ab
Move ironic and neutron containers to subdirectories
Sep 10, 2024
3164ae1
Move argo-workflow containers to central containers directory
Sep 10, 2024
6181c60
Fix up precommit and github jobs paths for YAML tempalte changes
Sep 10, 2024
02a4828
Organise the eventsource nautobot-webhook
Sep 10, 2024
98f8eeb
Merge the workflowtemplates into one place
Sep 10, 2024
f621668
Update appsets configuration to reflect new path to workflows
Sep 10, 2024
42af2f0
Update workflow descriptions to match new paths
Sep 10, 2024
327b223
Update yamllint to reflect changes to workflow paths
Sep 10, 2024
9046c93
Update pre-commit config to reflect changes to workflow paths
Sep 11, 2024
b9b7240
Update workflows.yaml to reflect new workflow paths
Sep 11, 2024
d5a5534
Fix doc link to reflect new path to workflows
Sep 11, 2024
99ceecb
Fix up Dockerfiles to reflect change to container directory structure
Sep 11, 2024
0598ca3
Break workflow role into one yaml file per object for yamllint
Sep 11, 2024
b3935bf
Update docs paths to refelct changes to workflow directory structure
Sep 11, 2024
957b8a7
Use dynamic github repository name instead of hardcoding rackerlabs
Sep 11, 2024
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
38 changes: 20 additions & 18 deletions .github/workflows/build-container-images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ on:
workflow_dispatch:
pull_request:
paths:
- 'argo-workflows/*/containers/*'
- 'argo-workflows/*/code/**'
- '!argo-workflows/example-feature/**'
- "containers/argo_utils/**"
- "containers/obm-utils/**"
- "containers/python311_alpine/**"
- "containers/python312_alpine/**"
push:
branches:
- main
paths:
- 'argo-workflows/*/containers/*'
- 'argo-workflows/*/code/**'
- '!argo-workflows/example-feature/**'
- "containers/argo_utils/**"
- "containers/obm-utils/**"
- "containers/python311_alpine/**"
- "containers/python312_alpine/**"

# bump container versions here, they will be populated to tags and labels
env:
Expand Down Expand Up @@ -46,43 +48,43 @@ jobs:
- name: Build and deploy Python 3.11 image
uses: docker/build-push-action@v5
with:
context: argo-workflows/generic/
file: argo-workflows/generic/containers/Dockerfile.python311_alpine
context: containers/python311_alpine/
file: containers/python311_alpine/Dockerfile.python311_alpine
# push for all main branch commits
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/rackerlabs/understack/argo-python3.11.8-alpine3.19:latest,ghcr.io/rackerlabs/understack/argo-python3.11.8-alpine3.19:${{ env.VERSION_PYTHON311 }}
tags: ghcr.io/${{ github.repository }}/argo-python3.11.8-alpine3.19:latest,ghcr.io/${{ github.repository }}/argo-python3.11.8-alpine3.19:${{ env.VERSION_PYTHON311 }}
labels: |
org.opencontainers.image.version=${{ env.VERSION_PYTHON311 }}

- name: Build and deploy Python 3.12 image
uses: docker/build-push-action@v5
with:
context: argo-workflows/generic/
file: argo-workflows/generic/containers/Dockerfile.python312_alpine
context: containers/python312_alpine/
file: containers/python312_alpine/Dockerfile.python312_alpine
# push for all main branch commits
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/rackerlabs/understack/argo-python3.12.2-alpine3.19:latest,ghcr.io/rackerlabs/understack/argo-python3.12.2-alpine3.19:${{ env.VERSION_PYTHON312 }}
tags: ghcr.io/${{ github.repository }}/argo-python3.12.2-alpine3.19:latest,ghcr.io/${{ github.repository }}/argo-python3.12.2-alpine3.19:${{ env.VERSION_PYTHON312 }}
labels: |
org.opencontainers.image.version=${{ env.VERSION_PYTHON312 }}

- name: Build and deploy Argo Utils image
uses: docker/build-push-action@v5
with:
context: argo-workflows/generic/
file: argo-workflows/generic/containers/Dockerfile.argo_utils
context: containers/argo_utils/
file: containers/argo_utils/Dockerfile.argo_utils
# push for all main branch commits
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/rackerlabs/understack/argo-utils-python3.11.8:latest,ghcr.io/rackerlabs/understack/argo-utils-python3.11.8:${{ env.VERSION_ARGO_UTILS }}
tags: ghcr.io/${{ github.repository }}/argo-utils-python3.11.8:latest,ghcr.io/${{ github.repository }}/argo-utils-python3.11.8:${{ env.VERSION_ARGO_UTILS }}
labels: |
org.opencontainers.image.version=${{ env.VERSION_ARGO_UTILS }}

- name: Build and deploy OBM Utils image
uses: docker/build-push-action@v5
with:
context: argo-workflows/obm-utils/
file: argo-workflows/obm-utils/containers/Dockerfile.obm_utils
context: containers/obm-utils/
file: containers/obm-utils/Dockerfile.obm_utils
# push for all main branch commits
push: ${{ github.event_name != 'pull_request' }}
tags: ghcr.io/rackerlabs/understack/argo-obm-utils-python3.11.8:latest,ghcr.io/rackerlabs/understack/argo-obm-utils-python3.11.8:${{ env.VERSION_OBM_UTILS }}
tags: ghcr.io/${{ github.repository }}/argo-obm-utils-python3.11.8:latest,ghcr.io/${{ github.repository }}/argo-obm-utils-python3.11.8:${{ env.VERSION_OBM_UTILS }}
labels: |
org.opencontainers.image.version=${{ env.VERSION_OBM_UTILS }}
9 changes: 5 additions & 4 deletions .github/workflows/containers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ jobs:
# that are arch specific so populate them at the index as well.
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index

- name: build and deploy container image to registry
- name: build and deploy openstack container image to registry
uses: docker/build-push-action@v5
with:
file: containers/Dockerfile.${{ matrix.project }}
file: containers/${{ matrix.project }}/Dockerfile.${{ matrix.project }}
build-args: OPENSTACK_VERSION=${{ matrix.openstack }}
pull: true # ensure we always have an up to date source
push: true
Expand Down Expand Up @@ -98,8 +98,9 @@ jobs:
- name: build and deploy dnsmasq container to registry
uses: docker/build-push-action@v5
with:
context: "{{defaultContext}}:containers/dnsmasq"
file: containers/Dockerfile.dnsmasq
push: true
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

Expand Down Expand Up @@ -142,7 +143,7 @@ jobs:
- name: build and deploy container image to registry
uses: docker/build-push-action@v5
with:
file: containers/Dockerfile.${{ matrix.container.name }}
file: containers/${{ matrix.container.name }}/Dockerfile.${{ matrix.container.name }}
pull: true # ensure we always have an up to date source
push: true
tags: ${{ steps.meta.outputs.tags }}
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/yamllint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ jobs:
- uses: actions/checkout@v4
- uses: thiagodnf/[email protected]
with:
jsonSchemaFile: argo-workflows/.workflow_with_description.schema.json
jsonSchemaFile: workflows/.workflow_with_description.schema.json
yamlFiles: |
argo-workflows/**/workflowtemplates/*.y*ml
argo-workflows/**/sensors/*.y*ml
argo-workflows/**/workflows/*.y*ml
apps/understack-workflows/workflows/workflowtemplates/*.y*ml
workflows/argo-events/secrets/*.y*ml
workflows/argo-events/sensors/*.y*ml
workflows/argo-events/eventsources/*.y*ml
workflows/argo-events/roles/*.y*ml
workflows/argo-events/rolebindings/*.y*ml
workflows/argo-events/workflowtemplates/*.y*ml
workflows/openstack/*.y*ml

shellcheck:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repos:
args:
- --schemafile
- https://raw.githubusercontent.com/argoproj/argo-workflows/master/api/jsonschema/schema.json
files: "argo-workflows/.*/(workflows|workflowtemplates)/.*.(yml|yaml)$"
files: "workflows/argo-events/(sensors|workflowtemplates)/.*.(yml|yaml)$"
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.37.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $(ACTIVATE): requirements-docs.txt

docs/workflows: $(ACTIVATE)
@mkdir -p docs/workflows
@$(PYTHON) scripts/argo-workflows-to-mkdocs.py argo-workflows docs/workflows
@$(PYTHON) scripts/argo-workflows-to-mkdocs.py workflows docs/workflows

.PHONY: docs
docs: $(ACTIVATE) docs/workflows ## Builds the documentation
Expand Down
2 changes: 1 addition & 1 deletion apps/appsets/components.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ spec:
source:
repoURL: '{{index .metadata.annotations "uc_repo_git_url"}}'
targetRevision: '{{index .metadata.annotations "uc_repo_ref"}}'
path: 'apps/understack-workflows'
path: 'workflows'
selector:
# by setting the key in the elements 'skipComponent' to 'true' it will skip installing it
# ArgoCD's templating operates with strings so it's the string "true"
Expand Down
5 changes: 2 additions & 3 deletions apps/appsets/workflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@ spec:
sources:
- repoURL: '{{index .metadata.annotations "uc_repo_git_url"}}'
targetRevision: '{{index .metadata.annotations "uc_repo_ref"}}'
path: 'argo-workflows'
path: 'workflows/argo-events'
directory:
recurse: true
include: '{generic/deps/*.yaml,shared-sensors/*.yaml,*/sensors/*.yaml,*/workflowtemplates/*.yaml}'
exclude: '{example-feature/*,*/*/*example*}'
include: '{roles/*.yaml,rolebindings/*.yaml,secrets/*.yaml,sensors/*yaml,eventsources/*.yaml,workflowtemplates/*.yaml}'
- repoURL: '{{index .metadata.annotations "uc_deploy_git_url"}}'
targetRevision: '{{index .metadata.annotations "uc_deploy_ref"}}'
path: 'argo-workflows'
Expand Down
10 changes: 0 additions & 10 deletions apps/understack-workflows/workflows/kustomization.yaml

This file was deleted.

Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.

This file was deleted.

This file was deleted.

45 changes: 0 additions & 45 deletions components/argo-events/webhook-sensor.yaml

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/*.deb

COPY containers/common/helpers.sh /helpers.sh
COPY containers/dnsmasq/common/helpers.sh /helpers.sh
COPY containers/dnsmasq/entry-point.sh /entry-point.sh
RUN chmod +x /entry-point.sh
COPY containers/dnsmasq/dnsmasq.conf.j2 /etc/dnsmasq.conf.j2
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ARG APP_GROUP=appgroup
ARG APP_USER_UID=1000
ARG APP_GROUP_GID=1000

COPY --chown=${APP_USER}:${APP_GROUP} containers/requirements.txt /app
COPY --chown=${APP_USER}:${APP_GROUP} requirements.txt /app
RUN --mount=type=cache,target=/root/.cache/.pip pip install --no-cache-dir -r /app/requirements.txt

FROM ${BASE} as prod
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/component-argo-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ the Pod's uid can be passed via the `KUBERNETES_POD_UID` environment variable. T
completion of the Workflow `.spec.podGC.strategy` can be set to `OnWorkflowCompletion`.

An example WorkflowTemplate demonstrating argo-python usage can be found
[here](https://github.com/rackerlabs/understack/blob/main/argo-workflows/generic/workflowtemplates/get-obm-creds.yaml).
[here](https://github.com/rackerlabs/understack/blob/main/workflows/argo-events/workflowtemplates/get-obm-creds.yaml).

### Argo CLI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ def argument_parser():


def main():
"""Updates Interface status in Nautobot triggers Undersync.
"""Updates Interface Status in Nautobot and triggers Undersync.

Updates Nautobot Interfaces's status field and follows with request to
Undersync service, requesting sync for all of the uplink_switches that the
device is connected to.
Updates Nautobot Device Interface status field and follows with
request to Undersync service, requesting sync for all of the
uplink_switches that the device is connected to.
"""
args = argument_parser().parse_args()

Expand Down
38 changes: 38 additions & 0 deletions workflows/argo-events/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

# this is where our workflows currently run
namespace: argo-events

resources:
- secrets/openstack-svc-acct.yaml
- secrets/obm-creds.yaml
- secrets/placeholder-obm-creds.yaml
- secrets/operate-workflow-sa.token.yaml
- secrets/production-ironic-for-argo-creds.yaml
- secrets/nautobot-token.yaml
- secrets/placeholder-obm-legacy-passwords.yaml
- sensors/ironic-node-update.yaml
- sensors/debug-sensor.yaml
- sensors/nb-oob-interface-update.yaml
- eventsources/nautobot-webhook.yaml
- roles/sensor-submit-workflow-role.yaml
- rolebindings/openstack-sensor-submit-workflow.yaml
- workflowtemplates/nautobot-api.yaml
- workflowtemplates/get-device-nautobot.yaml
- workflowtemplates/sync-interfaces-to-nautobot.yaml
- workflowtemplates/sync-nb-server-to-ironic.yaml
- workflowtemplates/get-obm-ip.yaml
- workflowtemplates/sync-provision-state-to-nautobot.yaml
- workflowtemplates/node-events.yaml
- workflowtemplates/sync-interfaces-to-ironic.yaml
- workflowtemplates/undersync-device.yaml
- workflowtemplates/sync-server-to-ironic.yaml
- workflowtemplates/undersync-switch.yaml
- workflowtemplates/keystone-event-project.yaml
- workflowtemplates/get-obm-creds.yaml
- workflowtemplates/idrac-enable-network-boot.yaml
- workflowtemplates/obm-sync-creds.yaml
- workflowtemplates/sync-srv-redfish-intfs-to-nb.yaml
- workflowtemplates/obm-firmware-update.yaml
- workflowtemplates/sync-obm-creds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: openstack-sensor-submit-workflow
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: sensor-submit-workflow-role
subjects:
- kind: ServiceAccount
name: sensor-submit-workflow
namespace: openstack
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,3 @@ rules:
- patch
resources:
- workflows
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: openstack-sensor-submit-workflow
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: sensor-submit-workflow-role
subjects:
- kind: ServiceAccount
name: sensor-submit-workflow
namespace: openstack
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
namespace: argo-events
annotations:
workflows.argoproj.io/description: |
Defined in `argo-workflows/sync-nb-server-to-ironic/sensors/debug-sensor.yaml`
Defined in `workflows/argo-events/sensors/debug-sensor.yaml`
spec:
dependencies:
- eventName: interface-update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ metadata:
namespace: argo-events
annotations:
workflows.argoproj.io/description: |
Defined in `argo-workflows/ironic-to-nautobot-sensor/sensors/sync.yaml`
Defined in `workflows/argo-events/sensors/ironic-node-update.yaml`
spec:
dependencies:
- eventName: openstack
Expand Down
Loading
Loading