Skip to content

Commit

Permalink
Owner reference example (argoproj#839)
Browse files Browse the repository at this point in the history
* Example using resource that will be GC'd.

* Document owner reference option.
  • Loading branch information
mthx authored and jessesuen committed Apr 26, 2018
1 parent 191f7af commit f3c4171
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,8 @@ spec:
backoffLimit: 4
```

Resources created in this way are independent of the workflow. If you want the resource to be deleted when the workflow is deleted then you can use [Kubernetes garbage collection](https://kubernetes.io/docs/concepts/workloads/controllers/garbage-collection/) with the workflow resource as an owner reference ([example](./k8s-owner-reference.yaml)).

## Docker-in-Docker (aka. DinD) Using Sidecars
An application of sidecars is to implement DinD (Docker-in-Docker).
DinD is useful when you want to run Docker commands from inside a container. For example, you may want to build and push a container image from inside your build container. In the following example, we use the docker:dind container to run a Docker daemon in a sidecar and give the main container access to the daemon.
Expand Down
30 changes: 30 additions & 0 deletions examples/k8s-owner-reference.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This example creates a Kubernetes resource that will be deleted
# when the workflow is deleted via Kubernetes GC.
#
# A configmap is used for this example, but the same approach would apply
# to other more interesting resource types.
#
# https://kubernetes.io/docs/concepts/workloads/controllers/garbage-collection/
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: k8s-owner-reference-
spec:
entrypoint: k8s-owner-reference
templates:
- name: k8s-owner-reference
resource:
action: create
manifest: |
apiVersion: v1
kind: ConfigMap
metadata:
generateName: owned-eg-
ownerReferences:
- apiVersion: argoproj.io/v1alpha1
blockOwnerDeletion: true
kind: Workflow
name: "{{workflow.name}}"
uid: "{{workflow.uid}}"
data:
some: value

0 comments on commit f3c4171

Please sign in to comment.