Skip to content

Conversation

@raphaelauv
Copy link
Contributor

@raphaelauv raphaelauv commented Mar 5, 2023

Add an abstract KubernetesResourceOperator

and two concrete operators : KubernetesDeleteResourceOperator and KubernetesCreateResourceOperator

missing documentation and tests

example of use

dag = DAG(
    dag_id="resource_dag",
    schedule_interval="0 0 * * *",
    start_date=today("UTC").add(days=-1)
)

pvc_conf = """
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: {pvc_name}
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: standard
  resources:
    requests:
      storage: 5Gi
"""
pvc_conf_all = """
apiVersion: v1
kind: List
items:
- apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    name: toto
- apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    name: tata
"""

with dag:
    a = KubernetesCreateResourceOperator(
        task_id="create_pvc_1",
        yaml_conf=pvc_conf.format(pvc_name="toto"),
    )
    b = KubernetesCreateResourceOperator(
        task_id="create_pvc_2",
        yaml_conf=pvc_conf.format(pvc_name="tata"),
    )

    c = KubernetesDeleteResourceOperator(
        task_id="delete_pvc",
        yaml_conf=pvc_conf_all,
    )

    a >> b >> c

@boring-cyborg boring-cyborg bot added provider:cncf-kubernetes Kubernetes (k8s) provider related issues area:providers labels Mar 5, 2023
@jedcunningham
Copy link
Member

I'm hesitant to build create/deletes for every single resource type... Especially if you are going to ask them to give you it all via yaml anyways.

Check out create_from_yaml instead. We could probably use this to build a generic create/delete?

@raphaelauv raphaelauv force-pushed the feature/k8s_pvc_operators branch from 877ca52 to a38400f Compare March 7, 2023 02:46
@raphaelauv raphaelauv changed the title KubernetesResourceOperator - create PVC & delete PVC KubernetesResourceOperator - KubernetesDeleteOperator & KubernetesCreateOperator Mar 7, 2023
@raphaelauv
Copy link
Contributor Author

missing delete_from_yaml : kubernetes-client/python#940

@raphaelauv
Copy link
Contributor Author

inspired from tomplus/kubernetes_asyncio#239

@potiuk
Copy link
Member

potiuk commented Mar 21, 2023

errors to fix :(

@raphaelauv raphaelauv force-pushed the feature/k8s_pvc_operators branch 2 times, most recently from 5941a59 to 67ff8ba Compare March 26, 2023 21:48
@potiuk potiuk force-pushed the feature/k8s_pvc_operators branch from 67ff8ba to 54369fe Compare March 27, 2023 00:29
@raphaelauv raphaelauv force-pushed the feature/k8s_pvc_operators branch from 54369fe to 6dd9f56 Compare March 27, 2023 08:07
@raphaelauv raphaelauv changed the title KubernetesResourceOperator - KubernetesDeleteOperator & KubernetesCreateOperator KubernetesResourceOperator - KubernetesDeleteResourceOperator & KubernetesCreateResourceOperator Mar 27, 2023
@raphaelauv
Copy link
Contributor Author

hey @potiuk I think I fixed the issues related to the PR , could you have a second look , thanks 👍

@raphaelauv raphaelauv force-pushed the feature/k8s_pvc_operators branch from 6dd9f56 to 0c5ee37 Compare March 28, 2023 07:39
@raphaelauv
Copy link
Contributor Author

@jedcunningham thanks for your first review , could you have a second look to the PR , thanks

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

That one looks good to me. @jedcunningham ?

@raphaelauv raphaelauv force-pushed the feature/k8s_pvc_operators branch from 0c5ee37 to b4b173e Compare April 11, 2023 14:43
@raphaelauv
Copy link
Contributor Author

just rebased on main branch

@potiuk
Copy link
Member

potiuk commented Apr 22, 2023

Tests failing :(

@raphaelauv raphaelauv force-pushed the feature/k8s_pvc_operators branch from 122770a to b08e010 Compare April 23, 2023 23:19
@raphaelauv
Copy link
Contributor Author

flaky test related to #30831

@raphaelauv raphaelauv force-pushed the feature/k8s_pvc_operators branch 3 times, most recently from 3e29034 to f48fb68 Compare April 24, 2023 10:46
Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

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

LGTM - @jedcunningham ?

@raphaelauv raphaelauv force-pushed the feature/k8s_pvc_operators branch from f48fb68 to 5c051a6 Compare May 5, 2023 00:38
@raphaelauv
Copy link
Contributor Author

@eladkal thank again for your review , I adressed all your remarks , could you please re-review , thanks

@raphaelauv raphaelauv force-pushed the feature/k8s_pvc_operators branch 2 times, most recently from d0da0c1 to c483970 Compare May 9, 2023 07:38
@raphaelauv
Copy link
Contributor Author

@jedcunningham could you review again , thank you

@raphaelauv raphaelauv force-pushed the feature/k8s_pvc_operators branch from 127361f to 9d64713 Compare May 26, 2023 00:06
@raphaelauv raphaelauv force-pushed the feature/k8s_pvc_operators branch from 9d64713 to ace319f Compare May 26, 2023 07:08
Copy link
Member

@hussein-awala hussein-awala left a comment

Choose a reason for hiding this comment

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

Looks good! LGTM

@eladkal
Copy link
Contributor

eladkal commented Jun 2, 2023

@jedcunningham any further comments?

@raphaelauv
Copy link
Contributor Author

@potiuk could we merge ? Thanks

@hussein-awala hussein-awala merged commit 0fa8c44 into apache:main Jun 4, 2023
@hussein-awala hussein-awala added the type:new-feature Changelog: New Features label Jun 4, 2023
@raphaelauv raphaelauv deleted the feature/k8s_pvc_operators branch June 4, 2023 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:providers provider:cncf-kubernetes Kubernetes (k8s) provider related issues type:new-feature Changelog: New Features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants