Skip to content

Instantly share code, notes, and snippets.

@davidc-donorschoose
Created January 10, 2019 20:32
Show Gist options
  • Save davidc-donorschoose/79bb22c203000d4ecea702618923e709 to your computer and use it in GitHub Desktop.
Save davidc-donorschoose/79bb22c203000d4ecea702618923e709 to your computer and use it in GitHub Desktop.
Sample CronWorkflow manifest
apiVersion: "workflow.k8s.io/v1"
kind: CronWorkflow
metadata:
name: qa-nightly-batch
labels:
workflow: nightly-batch
spec:
# Some fields are identical to CronJob
schedule: "05 20 * * *"
startingDeadlineSeconds: 60
concurrencyPolicy: Forbid
suspend: false
# These fields correspond to Cronjob fields with similar names
successfulWorkflowsHistoryLimit: 3
failedWorkflowsHistoryLimit: 3
# Define the Workflow that should execute
workflowTemplate:
metadata:
name: qa-nightly-batch
labels:
workflow: nightly-batch
spec:
metadata:
name: qa-nightly-batch
selector:
matchLabels:
workflow: nightly-batch
steps:
- name: 1-process-late-projects
jobTemplate:
spec:
template:
metadata:
name: process-late-projects
labels:
workflow: nightly-batch
app: processLateProjects
spec:
restartPolicy: OnFailure
dnsPolicy: Default
nodeSelector:
batch: "true"
volumes:
- name: batch-logs
emptyDir: {}
containers:
- name: process-late-projects
image: 310136549168.dkr.ecr.us-east-1.amazonaws.com/batch:batch-qa
imagePullPolicy: Always
ports:
- name: jmx-monitoring
containerPort: 1101
volumeMounts:
- mountPath: /var/log/batch
name: batch-logs
env:
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: USER
value: donorschoose
- name: PROPERTIES_DIR
valueFrom:
secretKeyRef:
name: properties-dir
key: PROPERTIES_DIR
- name: ACCOUNT
valueFrom:
secretKeyRef:
name: account
key: ACCOUNT
- name: BOX_NAME
value: qa
- name: DEPLOY_TIME
value: Thu Jan 10 12:54:00 EST 2019
- name: NAMESPACE
value: qa
- name: RANCHER
value: eks-dev
- name: DB_HOST
valueFrom:
secretKeyRef:
name: db-config
key: DB_HOST
- name: DB_NAME
valueFrom:
secretKeyRef:
name: db-config
key: DB_NAME
- name: DB_USER
valueFrom:
secretKeyRef:
name: db-config
key: DB_USER
- name: DB_PW
valueFrom:
secretKeyRef:
name: db-config
key: DB_PW
- name: DB_OWNER
valueFrom:
secretKeyRef:
name: db-config
key: DB_OWNER
- name: DB_OWNER_PW
valueFrom:
secretKeyRef:
name: db-config
key: DB_OWNER_PW
- name: DB2_HOST
valueFrom:
secretKeyRef:
name: db-config
key: DB2_HOST
- name: DB2_NAME
valueFrom:
secretKeyRef:
name: db-config
key: DB2_NAME
- name: DB2_USER
valueFrom:
secretKeyRef:
name: db-config
key: DB2_USER
- name: DB2_PW
valueFrom:
secretKeyRef:
name: db-config
key: DB2_PW
- name: DB_DIR
value: /donorschoose-web/web/db/
- name: PRIMARY_DEV_CLUSTER
value: false
- name: SWU_GITHUB_KEY
valueFrom:
secretKeyRef:
name: swu-key
key: SWU_KEY
command: ["bin/bash", "-c"]
args:
- |
# Call bootstrap to configure things,
# run the command,
# then signal awslogs sidecar with the shutdown file
source /usr/local/bin/bootstrap
echo '***********************************'
date
processLateProjects.sh 2>&1 \
| tee /var/log/batch/processLateProjects.out
date
echo '***********************************'
touch /var/log/batch/shutdown
- name: awslogs
# logging sidecar
image: 310136549168.dkr.ecr.us-east-1.amazonaws.com/awslogs:v1.4.3-dc1.4
imagePullPolicy: Always
command: ["bin/bash", "-c"]
args:
- |
/usr/local/bin/generateBatchLogMonitoring.sh qa processLateProjects
/usr/local/bin/startAgent.sh
volumeMounts:
- mountPath: /var/log/batch
name: batch-logs
lifecycle:
# Make sure awslogs agent exits gracefully
preStop:
exec:
command: ["/usr/sbin/service","awslogs","stop"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment