Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
startxfr committed Mar 9, 2019
2 parents eeaffe4 + 6982142 commit 0139680
Show file tree
Hide file tree
Showing 7 changed files with 960 additions and 185 deletions.
16 changes: 12 additions & 4 deletions docs/guides/USE_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,18 @@ docker-compose up

### Using Openshift

If you're familiar with Openshift PaaS, you will find 3 usefull templates to use in
If you're familiar with Openshift PaaS, you will find 5 usefull templates to use in
your project
- [template with configuration in environement variable](./openshift-template-env.yml)
- [template with configuration in configMap mounted volume](./openshift-template-configMap.yml)
- [template with configuration in mounted volume](./openshift-template-volume.yml)
- [statefulSet template with configuration (embeded in template) embeded in a configMap mounted volume](./openshift-template-cm-embeded.yml)
- [deployConfig template with configuration (template parameter) directly loaded into an environement variable](./openshift-template-env.yml)
- [deployConfig template with configuration (template parameter) embeded in a configMap mounted volume](./openshift-template-cm-defined.yml)
- [deployConfig template with configuration (embeded in template) embeded in a configMap mounted volume](./openshift-template-cm-embeded.yml)
- [deployConfig template with configuration in mounted volume](./openshift-template-volume.yml)

For example you can run
```bash
oc new-project test
oc create -f https://raw.githubusercontent.com/startxfr/sxapi-core/master/docs/guides/openshift-template-cm-defined.yml
oc new-app --template sxapi-cm-defined-template -p APPLICATION_NAME=sxapi-example
```
You can add them in a project using [openshift user guide](https://docs.openshift.org/latest/dev_guide/templates.html#uploading-a-template)
201 changes: 201 additions & 0 deletions docs/guides/openshift-template-cm-defined.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
apiVersion: v1
kind: Template
metadata:
name: sxapi-cm-defined-template
annotations:
openshift.io/display-name: SXAPI (defined configmap)
description: Template for creating an SXAPI microservice where configuration
(defined during templating processing) is stored in a configMap object
for more information see https://hub.docker.com/r/startx/sxapi
iconClass: icon-nodejs
tags: sxapi,api,nodejs,startx,microservice
openshift.io/provider-display-name: STARTX
openshift.io/documentation-url: https://hub.docker.com/r/startx/sxapi
openshift.io/support-url: https://github.com/startxfr/sxapi-core/issues/new
labels:
template: sxapi-cm-defined-template
message: |-
Your application ${APPLICATION_NAME} will be soon deployed in your project.
Monitor the deployement for application availability and
Follow created route to browse your running application
Application : ${APPLICATION_NAME}
sxapi : ${REGISTRY}:${IMAGE_NAME}
config : configmap ${APPLICATION_NAME} (json)
Pods : ${REPLICAS_DATA} (${MEMORY_LIMIT})
objects:
- kind: ImageStream
apiVersion: v1
metadata:
name: "${APPLICATION_NAME}"
annotations:
openshift.io/display-name: Application image stream ${APPLICATION_NAME} based on ${REGISTRY} ${IMAGE_NAME}
openshift.io/generated-by: STARTX
spec:
tags:
- name: ${IMAGE_NAME}
annotations:
openshift.io/display-name: SXAPI container image (${REGISTRY} ${IMAGE_NAME})
description: SXAPI image for the application ${APPLICATION_NAME} based on ${REGISTRY} ${IMAGE_NAME}
iconClass: icon-nodejs
tags: sxapi,api,nodejs,startx,microservice,${APPLICATION_NAME},${REGISTRY}:${IMAGE_NAME}
from:
kind: DockerImage
name: ${REGISTRY}:${IMAGE_NAME}
- kind: ConfigMap
apiVersion: v1
metadata:
name: "${APPLICATION_NAME}"
annotations:
openshift.io/display-name: Sxapi configuration ${APPLICATION_NAME}
openshift.io/generated-by: STARTX
data:
sxapi.yml: "${SXAPI_CONF}"
- kind: DeploymentConfig
apiVersion: v1
metadata:
name: "${APPLICATION_NAME}"
annotations:
openshift.io/display-name: Deployement ${APPLICATION_NAME} application
openshift.io/generated-by: STARTX
spec:
replicas: 2
strategy:
type: Rolling
rollingParams:
updatePeriodSeconds: 1
intervalSeconds: 1
timeoutSeconds: 60
maxUnavailable: 25%
maxSurge: 25%
triggers:
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- "${APPLICATION_NAME}"
from:
kind: ImageStreamTag
name: "${APPLICATION_NAME}:${IMAGE_NAME}"
- type: ConfigChange
test: false
selector:
app: "${APPLICATION_NAME}"
deploymentconfig: "${APPLICATION_NAME}"
template:
metadata:
labels:
app: "${APPLICATION_NAME}"
deploymentconfig: "${APPLICATION_NAME}"
annotations:
openshift.io/generated-by: STARTX
spec:
terminationGracePeriodSeconds: 5
containers:
- name: "${APPLICATION_NAME}"
image: " "
imagePullPolicy: Always
livenessProbe:
initialDelaySeconds: 2
tcpSocket:
port: 8077
timeoutSeconds: 2
periodSeconds: 5
successThreshold: 1
failureThreshold: 2
readinessProbe:
initialDelaySeconds: 2
tcpSocket:
port: 8077
timeoutSeconds: 2
periodSeconds: 5
successThreshold: 1
failureThreshold: 2
env:
- name: SX_VERBOSE
value: 'true'
lifecycle:
preStop:
exec:
command:
- "npm"
- stop
ports:
- name: sxapi
containerPort: 8077
resources:
requests:
cpu: 200m
memory: "${MEMORY_LIMIT}"
limits:
cpu: 2000m
memory: "${MEMORY_LIMIT}"
terminationMessagePath: "/dev/termination-log"
volumeMounts:
- mountPath: "/conf"
name: conf
restartPolicy: Always
volumes:
- name: conf
configMap:
name: "${APPLICATION_NAME}"
items:
- key: sxapi.yml
path: sxapi.yml
- kind: Service
apiVersion: v1
metadata:
name: "${APPLICATION_NAME}"
annotations:
openshift.io/display-name: Service ${APPLICATION_NAME}
openshift.io/generated-by: STARTX
spec:
clusterIP: None
ports:
- name: sxapi
port: 8077
selector:
name: "${APPLICATION_NAME}"
type: application
- kind: Route
apiVersion: v1
metadata:
name: "${APPLICATION_NAME}"
annotations:
openshift.io/display-name: Route ${APPLICATION_NAME}
openshift.io/generated-by: STARTX
spec:
port:
targetPort: sxapi
to:
kind: Service
name: "${APPLICATION_NAME}"
weight: 100
wildcardPolicy: None
parameters:
- name: APPLICATION_NAME
displayName: Application Name
description: The name of the application.
value: sxapi-demo
required: true
- name: IMAGE_NAME
value: 0.3.3
required: true
- name: REGISTRY
value: "startx/sxapi"
required: true
- name: REPLICAS_DATA
displayName: Desired Pod count for data nodes
description: How many data nodes should be provisioned? This value can be changed
later, by scaling up/down.
value: '2'
required: true
- name: MEMORY_LIMIT
displayName: Memory Limit for data nodes
description: Maximum amount of memory data container can use.
value: 128Mi
- name: SXAPI_CONF
displayName: Configuration object (injected into the configMap)
description: Json object string describing the application a see in https://github.com/startx/sxapi-core/blob/master/docs/guides/2.Configure.md
value: "{ \"name\": \"sample-api\",\"description\": \"my desc\", \"version\": \"0.0.0\", \"server\": { \"endpoints\": [ { \"path\": \"/\", \"body\": \"<html><head></head><body><h1>My API</h1></body></html>\" } ] } }"
required: true

0 comments on commit 0139680

Please sign in to comment.