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

docs: Add StatefulSet and Service doc #3008

Merged
merged 2 commits into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
40 changes: 40 additions & 0 deletions docs/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Workflow is the definition of a workflow resource

- [`daemon-step.yaml`](../examples/daemon-step.yaml)

- [`daemoned-stateful-set-with-service.yaml`](../examples/daemoned-stateful-set-with-service.yaml)

- [`dag-coinflip.yaml`](../examples/dag-coinflip.yaml)

- [`dag-continue-on-fail.yaml`](../examples/dag-continue-on-fail.yaml)
Expand Down Expand Up @@ -327,6 +329,8 @@ WorkflowSpec is the specification of a Workflow.

- [`daemon-step.yaml`](../examples/daemon-step.yaml)

- [`daemoned-stateful-set-with-service.yaml`](../examples/daemoned-stateful-set-with-service.yaml)

- [`dag-coinflip.yaml`](../examples/dag-coinflip.yaml)

- [`dag-continue-on-fail.yaml`](../examples/dag-continue-on-fail.yaml)
Expand Down Expand Up @@ -621,6 +625,8 @@ CronWorkflowSpec is the specification of a CronWorkflow

- [`daemon-step.yaml`](../examples/daemon-step.yaml)

- [`daemoned-stateful-set-with-service.yaml`](../examples/daemoned-stateful-set-with-service.yaml)

- [`dag-coinflip.yaml`](../examples/dag-coinflip.yaml)

- [`dag-continue-on-fail.yaml`](../examples/dag-continue-on-fail.yaml)
Expand Down Expand Up @@ -881,6 +887,8 @@ WorkflowTemplateSpec is a spec of WorkflowTemplate.

- [`daemon-step.yaml`](../examples/daemon-step.yaml)

- [`daemoned-stateful-set-with-service.yaml`](../examples/daemoned-stateful-set-with-service.yaml)

- [`dag-coinflip.yaml`](../examples/dag-coinflip.yaml)

- [`dag-continue-on-fail.yaml`](../examples/dag-continue-on-fail.yaml)
Expand Down Expand Up @@ -1335,6 +1343,8 @@ Template is a reusable and composable unit of execution in a workflow

- [`daemon-step.yaml`](../examples/daemon-step.yaml)

- [`daemoned-stateful-set-with-service.yaml`](../examples/daemoned-stateful-set-with-service.yaml)

- [`dag-coinflip.yaml`](../examples/dag-coinflip.yaml)

- [`dag-continue-on-fail.yaml`](../examples/dag-continue-on-fail.yaml)
Expand Down Expand Up @@ -2179,6 +2189,8 @@ Pod metdata

- [`daemon-step.yaml`](../examples/daemon-step.yaml)

- [`daemoned-stateful-set-with-service.yaml`](../examples/daemoned-stateful-set-with-service.yaml)

- [`dag-coinflip.yaml`](../examples/dag-coinflip.yaml)

- [`dag-continue-on-fail.yaml`](../examples/dag-continue-on-fail.yaml)
Expand Down Expand Up @@ -2380,6 +2392,8 @@ ResourceTemplate is a template subtype to manipulate kubernetes resources
<summary>Examples with this field (click to open)</summary>
<br>

- [`daemoned-stateful-set-with-service.yaml`](../examples/daemoned-stateful-set-with-service.yaml)

- [`k8s-jobs.yaml`](../examples/k8s-jobs.yaml)

- [`k8s-orchestration.yaml`](../examples/k8s-orchestration.yaml)
Expand Down Expand Up @@ -2544,6 +2558,8 @@ WorkflowStep is a reference to a template to execute in a series of step

- [`daemon-step.yaml`](../examples/daemon-step.yaml)

- [`daemoned-stateful-set-with-service.yaml`](../examples/daemoned-stateful-set-with-service.yaml)

- [`dag-coinflip.yaml`](../examples/dag-coinflip.yaml)

- [`dag-diamond-steps.yaml`](../examples/dag-diamond-steps.yaml)
Expand Down Expand Up @@ -3002,6 +3018,8 @@ MetricLabel is a single label for a prometheus metric

- [`custom-metrics.yaml`](../examples/custom-metrics.yaml)

- [`daemoned-stateful-set-with-service.yaml`](../examples/daemoned-stateful-set-with-service.yaml)

- [`pod-metadata.yaml`](../examples/pod-metadata.yaml)

- [`resource-delete-with-flags.yaml`](../examples/resource-delete-with-flags.yaml)
Expand Down Expand Up @@ -3250,6 +3268,8 @@ ObjectMeta is metadata that all persisted resources must have, which includes al

- [`daemon-step.yaml`](../examples/daemon-step.yaml)

- [`daemoned-stateful-set-with-service.yaml`](../examples/daemoned-stateful-set-with-service.yaml)

- [`dag-coinflip.yaml`](../examples/dag-coinflip.yaml)

- [`dag-continue-on-fail.yaml`](../examples/dag-continue-on-fail.yaml)
Expand Down Expand Up @@ -3706,6 +3726,8 @@ A single application container that you want to run within a pod.

- [`daemon-step.yaml`](../examples/daemon-step.yaml)

- [`daemoned-stateful-set-with-service.yaml`](../examples/daemoned-stateful-set-with-service.yaml)

- [`dag-coinflip.yaml`](../examples/dag-coinflip.yaml)

- [`dag-continue-on-fail.yaml`](../examples/dag-continue-on-fail.yaml)
Expand Down Expand Up @@ -3953,6 +3975,13 @@ Probe describes a health check to be performed against a container to determine

ContainerPort represents a network port in a single container.

<details>
<summary>Examples with this field (click to open)</summary>
<br>

- [`daemoned-stateful-set-with-service.yaml`](../examples/daemoned-stateful-set-with-service.yaml)
</details>

### Fields
| Field Name | Field Type | Description |
|:----------:|:----------:|---------------|
Expand Down Expand Up @@ -4202,6 +4231,13 @@ IntOrString is a type that can hold an int32 or a string. When used in JSON or

A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.

<details>
<summary>Examples with this field (click to open)</summary>
<br>

- [`daemoned-stateful-set-with-service.yaml`](../examples/daemoned-stateful-set-with-service.yaml)
</details>

### Fields
| Field Name | Field Type | Description |
|:----------:|:----------:|---------------|
Expand Down Expand Up @@ -4290,6 +4326,8 @@ PersistentVolumeClaimSpec describes the common attributes of storage devices and

- [`daemon-step.yaml`](../examples/daemon-step.yaml)

- [`daemoned-stateful-set-with-service.yaml`](../examples/daemoned-stateful-set-with-service.yaml)

- [`dag-coinflip.yaml`](../examples/dag-coinflip.yaml)

- [`dag-continue-on-fail.yaml`](../examples/dag-continue-on-fail.yaml)
Expand Down Expand Up @@ -5244,6 +5282,8 @@ ListMeta describes metadata that synthetic resources must have, including lists

- [`daemon-step.yaml`](../examples/daemon-step.yaml)

- [`daemoned-stateful-set-with-service.yaml`](../examples/daemoned-stateful-set-with-service.yaml)

- [`dag-coinflip.yaml`](../examples/dag-coinflip.yaml)

- [`dag-continue-on-fail.yaml`](../examples/dag-continue-on-fail.yaml)
Expand Down
112 changes: 112 additions & 0 deletions examples/daemoned-stateful-set-with-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# This example shows how to create a stateful set with an attached service to use as a daemoned server.
# It is complete with a tear-down handler, and a wait step that ensures the stateful set is ready before continuing.
# Note that the service account that Argo uses to run this must have sufficient permissions to create, delte, and get
# the resources.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: daemoned-stateful-set-with-service-
spec:
entrypoint: create-wait-and-test
onExit: delete

templates:
- name: create-wait-and-test
steps:
- - name: create-service
template: create-service
- name: create-stateful-set
template: create-stateful-set

- - name: wait-stateful-set
template: wait-stateful-set

- - name: test
template: test

- name: delete # This is called as an onExit handler
steps:
- - name: delete-service
template: delete-service
- name: delete-stateful-set
template: delete-stateful-set

- name: create-service
resource:
action: create
manifest: |
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: nginx
spec:
ports:
- port: 80
name: web
clusterIP: None
selector:
app: nginx

- name: create-stateful-set
resource:
action: create
manifest: |
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
selector:
matchLabels:
app: nginx # has to match .spec.template.metadata.labels
serviceName: "nginx"
template:
metadata:
labels:
app: nginx # has to match .spec.selector.matchLabels
spec:
terminationGracePeriodSeconds: 10
containers:
- name: nginx
image: k8s.gcr.io/nginx-slim:0.8
ports:
- containerPort: 80
name: web

- name: wait-stateful-set
resource:
action: get
successCondition: status.readyReplicas == 1
manifest: |
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web

- name: test
container:
image: curlimages/curl:latest
command: [sh, -c]
args: ["curl nginx"]

- name: delete-service
resource:
action: delete
flags: ["--ignore-not-found"]
manifest: |
apiVersion: v1
kind: Service
metadata:
name: nginx

- name: delete-stateful-set
resource:
action: delete
flags: ["--ignore-not-found"]
manifest: |
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web