Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
66 lines (65 sloc) 3.28 KB
# By Sharon Campbell, Ken Simon, and Joe Beda for Heptio
# one-time Job that executes the /tmp/ script
# from another container copy of our PHP image
# this is how we get initial data for our database
# we use as the database in our demo
apiVersion: batch/v1
kind: Job
name: mysql-data-loader-with-timeout
"": lamp
activeDeadlineSeconds: 100
name: mysql-data-loader
# this creates a temporary container just to run this Job
- name: mysql-data-loader
# deploys this custom PHP image from Docker Hub
# this is the same PHP image we use to create the PHP Deployment in php.yaml
# it could be a completely different image, though, if our script was in its own image
# it's just convenient to have our PHP app and our data loader script packaged together
# make sure the host image for your script has any utilities the script needs
# like curl and mysql-client, in our case
image: heptio/example-php-dbconnect
# env sets environment variables in the container
# exactly like environment variables set from the command line
# The PHP image will configure an environment variable with the value of MYSQL_USER...
- name: MYSQL_USER
# rather than embed sensitive details in this config
# we reference another Kubernetes object
# in this case, the Secret with the name: mysql-credentials
name: mysql-credentials
# references the user key-value pair from the mysql-credentials Secret
key: user
# ... and a password of the value of MYSQL_PASSWORD ...
name: mysql-credentials
key: password
# ... and the MYSQL_HOST mysql.default.svc.cluster.local
# which comes from the Service with the name mysql in the mysql.yaml file
- name: MYSQL_HOST
value: mysql.default.svc.cluster.local
# you can replace /tmp/
# with a link to your own script in your image
command: ["/tmp/"]
# if running /tmp/ returns a non-zero exit status
# the Job will be considered a failure, and this Job will run again
# restartPolicy: OnFailure ensures this Job will keep attempting to load our data
# until it completes successfully
# so if this Job tries to run before the PHP server is up, or before the MySQL server is up
# or before the Secret is created, this Job will keep trying to complete
# the script itself has "set -o errexit"
# so if any commands the script itself launches fail, the whole script returns nonzero
restartPolicy: OnFailure