Skip to content

Instantly share code, notes, and snippets.

@pacroy
Last active July 3, 2018 07:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pacroy/93f534c658b872d13d9411aa20de5b0d to your computer and use it in GitHub Desktop.
Save pacroy/93f534c658b872d13d9411aa20de5b0d to your computer and use it in GitHub Desktop.
apiVersion: v1
kind: Template
metadata:
name: example-voting-app-template
objects:
- apiVersion: v1
data:
database-name: ZGI=
database-password: cG9zdGdyZXNfcGFzc3dvcmQ=
database-user: cG9zdGdyZXNfdXNlcg==
kind: Secret
metadata:
labels:
app: vote
name: db
- apiVersion: v1
data:
database-password: cmVkaXNfcGFzc3dvcmQ=
kind: Secret
metadata:
labels:
app: vote
name: redis
- apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
labels:
app: vote
name: result
spec:
output:
to:
kind: ImageStreamTag
name: 'result:latest'
runPolicy: Serial
source:
contextDir: /result
git:
ref: master
uri: 'https://github.com/mmumshad/example-voting-app.git'
type: Git
strategy:
sourceStrategy:
env:
- name: PORT
value: '8080'
from:
kind: ImageStreamTag
name: 'nodejs:8'
namespace: openshift
type: Source
triggers:
- github:
secret: 248620f1a5d5fa91
type: GitHub
- imageChange: {}
type: ImageChange
- type: ConfigChange
- apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
labels:
app: vote
name: vote
spec:
output:
to:
kind: ImageStreamTag
name: 'vote:latest'
runPolicy: Serial
source:
contextDir: /vote
git:
ref: master
uri: 'https://github.com/mmumshad/example-voting-app.git'
type: Git
strategy:
sourceStrategy:
from:
kind: ImageStreamTag
name: 'python:3.6'
namespace: openshift
type: Source
triggers:
- github:
secret: 248620f1a5d5fa91
type: GitHub
- imageChange: {}
type: ImageChange
- type: ConfigChange
- apiVersion: build.openshift.io/v1
kind: BuildConfig
metadata:
labels:
app: vote
name: worker
spec:
output:
to:
kind: ImageStreamTag
name: 'worker:latest'
runPolicy: Serial
source:
contextDir: /worker
git:
ref: master
uri: 'https://github.com/mmumshad/example-voting-app.git'
type: Git
strategy:
dockerStrategy:
type: Docker
triggers:
- github:
secret: 248620f1a5d5fa91
type: GitHub
- imageChange: {}
type: ImageChange
- type: ConfigChange
- apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
labels:
app: vote
name: worker
spec:
lookupPolicy:
local: false
- apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
labels:
app: vote
name: result
spec:
lookupPolicy:
local: false
- apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
labels:
app: vote
name: vote
spec:
lookupPolicy:
local: false
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
labels:
app: vote
name: db
spec:
replicas: 1
selector:
name: db
strategy:
activeDeadlineSeconds: 21600
recreteParams:
timeoutSeconds: 600
type: Recreate
template:
metadata:
labels:
name: db
spec:
containers:
- image: docker.io/centos/postgresql-96-centos7
imagePullPolicy: IfNotPresent
name: postgresql
ports:
- containerPort: 5432
protocol: TCP
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/lib/pgsql/data
name: db-data
env:
- name: POSTGRESQL_USER
valueFrom:
secretKeyRef:
key: database-user
name: db
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
key: database-password
name: db
- name: POSTGRESQL_DATABASE
valueFrom:
secretKeyRef:
key: database-name
name: db
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
terminationGracePeriodSeconds: 30
volumes:
- name: db-data
persistentVolumeClaim:
claimName: db
test: false
triggers:
- imageChangeParams:
automatic: true
containerNames:
- postgresql
from:
kind: ImageStreamTag
name: 'postgresql:9.6'
namespace: openshift
type: ImageChange
- type: ConfigChange
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
labels:
app: vote
name: redis
spec:
replicas: 1
selector:
name: redis
strategy:
activeDeadlineSeconds: 21600
recreteParams:
timeoutSeconds: 600
type: Recreate
template:
metadata:
labels:
name: redis
spec:
containers:
- image: docker.io/postgres
imagePullPolicy: IfNotPresent
name: postgresql
ports:
- containerPort: 6379
protocol: TCP
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /var/lib/redis/data
name: redis-data
env:
- name: POSTGRESQL_USER
valueFrom:
secretKeyRef:
key: database-user
name: db
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
key: database-password
name: db
- name: POSTGRESQL_DATABASE
valueFrom:
secretKeyRef:
key: database-name
name: db
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
terminationGracePeriodSeconds: 30
volumes:
- name: redis-data
test: false
triggers:
- imageChangeParams:
automatic: true
containerNames:
- redis
from:
kind: ImageStreamTag
name: 'redis:3.2'
namespace: openshift
type: ImageChange
- type: ConfigChange
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
labels:
app: vote
name: result
spec:
replicas: 1
selector:
name: result
strategy:
activeDeadlineSeconds: 21600
rollingParams:
intervalSeconds: 1
maxSurge: 25%
maxUnavailable: 25%
timeoutSeconds: 600
updateperiodSeconds: 1
type: Rolling
template:
metadata:
labels:
name: result
spec:
containers:
- image:
imagePullPolicy: Always
name: result
ports:
- containerPort: 8080
protocol: TCP
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
env:
- name: PORT
value: '8080'
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
terminationGracePeriodSeconds: 30
test: false
triggers:
- imageChangeParams:
automatic: true
containerNames:
- result
from:
kind: ImageStreamTag
name: 'result:latest'
type: ImageChange
- type: ConfigChange
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
labels:
app: vote
name: vote
spec:
replicas: 1
selector:
name: vote
strategy:
activeDeadlineSeconds: 21600
rollingParams:
intervalSeconds: 1
maxSurge: 25%
maxUnavailable: 25%
timeoutSeconds: 600
updateperiodSeconds: 1
type: Rolling
template:
metadata:
labels:
name: vote
spec:
containers:
- env:
- name: REDIS_PASSWORD
value: redis_password
image: 'vote:latest'
imagePullPolicy: Always
name: vote
ports:
- containerPort: 8080
protocol: TCP
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
terminationGracePeriodSeconds: 30
test: false
triggers:
- imageChangeParams:
automatic: true
containerNames:
- vote
from:
kind: ImageStreamTag
name: 'vote:latest'
type: ImageChange
- type: ConfigChange
- apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
labels:
app: vote
name: worker
spec:
replicas: 1
selector:
name: worker
strategy:
activeDeadlineSeconds: 21600
rollingParams:
intervalSeconds: 1
maxSurge: 25%
maxUnavailable: 25%
timeoutSeconds: 600
updateperiodSeconds: 1
type: Rolling
template:
metadata:
labels:
name: worker
spec:
containers:
- env:
- name: REDIS_PASSWORD
value: redis_password
image:
imagePullPolicy: Always
name: worker
ports:
- containerPort: 8080
protocol: TCP
- containerPort: 8443
protocol: TCP
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
terminationGracePeriodSeconds: 30
test: false
triggers:
- imageChangeParams:
automatic: true
containerNames:
- worker
from:
kind: ImageStreamTag
name: 'worker:latest'
type: ImageChange
- type: ConfigChange
- apiVersion: v1
kind: Service
metadata:
labels:
app: vote
name: worker
spec:
ports:
- name: 8080-tcp
port: 8080
protocol: TCP
targetPort: 8080
- name: 8443-tcp
port: 8443
protocol: TCP
targetPort: 8443
selector:
name: worker
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: Service
metadata:
labels:
app: vote
name: result
spec:
ports:
- name: 8080-tcp
port: 8080
protocol: TCP
targetPort: 8080
selector:
name: result
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: Service
metadata:
labels:
app: vote
name: db
spec:
ports:
- name: postgresql
port: 5432
protocol: TCP
targetPort: 5432
selector:
name: db
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: Service
metadata:
labels:
app: vote
name: vote
spec:
ports:
- name: 8080-tcp
port: 8080
protocol: TCP
targetPort: 8080
selector:
name: vote
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: Service
metadata:
labels:
app: vote
name: redis
spec:
ports:
- name: redis
port: 6379
protocol: TCP
targetPort: 6379
selector:
name: redis
sessionAffinity: None
type: ClusterIP
- apiVersion: v1
kind: Route
metadata:
labels:
app: vote
name: worker
spec:
port:
targetPort: 8080-tcp
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
to:
kind: Service
name: worker
weight: 100
wildcardPolicy: None
- apiVersion: v1
kind: Route
metadata:
labels:
app: vote
name: result
spec:
port:
targetPort: 8080-tcp
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
to:
kind: Service
name: result
weight: 100
wildcardPolicy: None
- apiVersion: v1
kind: Route
metadata:
labels:
app: vote
name: vote
spec:
port:
targetPort: 8080-tcp
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
to:
kind: Service
name: vote
weight: 100
wildcardPolicy: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment