ansible / ansible-kubernetes-modules

DEPRECATED Ansible role containing pre-release K8s modules
Apache License 2.0
73 stars 39 forks source link

Ability to add Owner References to Created Resources #31

Open alecmerdler opened 6 years ago

alecmerdler commented 6 years ago

It would be very useful to be able to specify owner references on created Kubernetes resources to enable garbage collection. Something like:

- name: create deployment
  k8s_apps_v1beta1_deployment:
    name: my-test
    namespace: '{{ namespace }}'
    owner_references: {{ owner_references }}
    spec_replicas: '{{ size }}'
    spec_selector_match_labels:
      app: my-test
    spec_template_metadata_labels:
      app: my-test
    spec_template_spec_containers:
    - env:
      image: nginx
      name: nginx
      ports:
      - container_port: 8080
        protocol: TCP

These could then be provided using:

$ ansible-playbook /opt/apb/actions/provision.yml -e owner_references='[{"name":"some-obj","kind":"ExampleApp","uid":"60506c3a-1c08-11e8-a82d-166bfdd9646c","apiVersion":"example.com/v1"}]'