forked from lbovet/contador
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6aa174
commit f3454cd
Showing
10 changed files
with
311 additions
and
134 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,39 @@ | ||
# contador | ||
A 12-factor counter microservice | ||
|
||
## Services | ||
|
||
### Telegraf | ||
|
||
Run somewhere | ||
|
||
nc -l 2003 | ||
|
||
### Redis | ||
|
||
Run somewhere | ||
|
||
docker run --name gontador-redis -p 6379:6379 -d redis | ||
|
||
|
||
## Test local | ||
|
||
go build -o gontador src/*.go | ||
REDIS_URL=192.168.1.2:6379 METRIC_HOST=192.168.1.2 METRIC_PORT=2003 ./gontador | ||
|
||
### HTTP Interface | ||
|
||
curl http://localhost:3000/counter | ||
|
||
## Test on Openshift | ||
|
||
bash -xe deploy/deploy.sh | ||
|
||
URL=`oc get route.route.openshift.io/gontador -o go-template --template={{.spec.host}}` | ||
|
||
curl -v $URL/counter | ||
|
||
## Undeploy | ||
|
||
oc delete all -l app=gontador | ||
oc delete template gontador-template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
apiVersion: build.openshift.io/v1 | ||
kind: BuildConfig | ||
metadata: | ||
# annotations: | ||
# description: Defines how to build the application | ||
# template.alpha.openshift.io/wait-for-ready: 'true' | ||
# labels: | ||
# app: gontador | ||
# template: gontador | ||
name: gontador-build | ||
# namespace: gontador | ||
spec: | ||
# failedBuildsHistoryLimit: 5 | ||
# nodeSelector: null | ||
output: | ||
to: | ||
kind: ImageStreamTag | ||
name: 'gontador:latest' | ||
# postCommit: | ||
# script: ./manage.py test | ||
# resources: {} | ||
# runPolicy: Serial | ||
source: | ||
git: | ||
uri: 'https://github.com/philipsahli/gontador.git' | ||
ref: 'go-implementation' | ||
type: Git | ||
strategy: | ||
type: Docker | ||
dockerStrategy: | ||
dockerfilePath: Dockerfile | ||
|
||
# env: | ||
# - name: PIP_INDEX_URL | ||
# from: | ||
# kind: ImageStreamTag | ||
# name: 'python:3.6' | ||
# namespace: openshift | ||
|
||
# successfulBuildsHistoryLimit: 5 | ||
triggers: | ||
- imageChange: | ||
type: ImageChange | ||
- type: ConfigChange | ||
- github: | ||
secret: 4tqgB6gCvDQBoWBiKtNcm3NsT37MM602KhLGKrCR | ||
type: GitHub | ||
# status: | ||
# lastVersion: 1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash -xe | ||
|
||
# Build docker image in openshift | ||
# oc apply -f imagestream.yaml | ||
|
||
# Deploy app | ||
oc create -f template.yaml | ||
oc new-app --template=gontador-template --name gontador | ||
oc apply -f build.yaml | ||
oc start-build gontador-build -n gontador | ||
|
||
# Publish service | ||
# oc apply -f service.yaml | ||
oc apply -f route.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
apiVersion: image.openshift.io/v1 | ||
kind: ImageStream | ||
metadata: | ||
annotations: | ||
description: Keeps track of changes in the application image | ||
name: gontador | ||
namespace: gontador | ||
spec: | ||
lookupPolicy: | ||
local: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apiVersion: route.openshift.io/v1 | ||
kind: Route | ||
metadata: | ||
annotations: | ||
openshift.io/host.generated: 'true' | ||
creationTimestamp: '2018-12-31T10:24:53Z' | ||
labels: | ||
app: gontador | ||
name: gontador | ||
namespace: gontador | ||
resourceVersion: '58060' | ||
selfLink: /apis/route.openshift.io/v1/namespaces/gontador/routes/gontador | ||
uid: 50250017-0ce6-11e9-8918-2215dd3699dc | ||
spec: | ||
host: gontador-gontador.192.168.64.7.nip.io | ||
port: | ||
targetPort: gontador | ||
to: | ||
kind: Service | ||
name: gontador | ||
weight: 100 | ||
wildcardPolicy: None | ||
status: | ||
ingress: | ||
- conditions: | ||
- lastTransitionTime: '2018-12-31T10:24:54Z' | ||
status: 'True' | ||
type: Admitted | ||
host: gontador-gontador.192.168.64.7.nip.io | ||
routerName: router | ||
wildcardPolicy: None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
description: Exposes the gontador service | ||
creationTimestamp: '2018-12-31T06:50:19Z' | ||
labels: | ||
app: gontador | ||
name: gontador | ||
namespace: gontador | ||
resourceVersion: '3000' | ||
spec: | ||
ports: | ||
- name: gontador | ||
port: 3000 | ||
protocol: TCP | ||
targetPort: 3000 | ||
selector: | ||
app: gontador | ||
sessionAffinity: None | ||
type: ClusterIP | ||
status: | ||
loadBalancer: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
apiVersion: v1 | ||
kind: Template | ||
metadata: | ||
creationTimestamp: null | ||
name: gontador-template | ||
objects: | ||
- apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
annotations: | ||
description: Exposes the gontador service | ||
creationTimestamp: '2018-12-31T06:50:19Z' | ||
labels: | ||
app: gontador | ||
name: gontador | ||
namespace: gontador | ||
spec: | ||
ports: | ||
- name: gontador | ||
port: 3000 | ||
protocol: TCP | ||
targetPort: 3000 | ||
selector: | ||
app: gontador | ||
sessionAffinity: None | ||
type: ClusterIP | ||
status: | ||
loadBalancer: {} | ||
|
||
- apiVersion: v1 | ||
kind: ImageStream | ||
metadata: | ||
annotations: | ||
description: Keeps track of changes in the application image | ||
name: gontador | ||
namespace: gontador | ||
spec: | ||
lookupPolicy: | ||
local: false | ||
|
||
|
||
- apiVersion: v1 | ||
kind: DeploymentConfig | ||
metadata: | ||
labels: | ||
app: gontador | ||
name: gontador | ||
namespace: gontador | ||
spec: | ||
replicas: 2 | ||
selector: | ||
app: gontador | ||
deploymentconfig: gontador | ||
# strategy: | ||
# activeDeadlineSeconds: 21600 | ||
# resources: {} | ||
# rollingParams: | ||
# intervalSeconds: 1d | ||
# maxSurge: 25% | ||
# maxUnavailable: 25% | ||
# timeoutSeconds: 600 | ||
# updatePeriodSeconds: 1 | ||
# type: Rolling | ||
template: | ||
metadata: | ||
labels: | ||
app: gontador | ||
deploymentconfig: gontador | ||
spec: | ||
containers: | ||
- image: >- | ||
172.30.1.1:5000/gontador/gontador@sha256:9fd64c947842884d6def85ca5ee907efefb2c636960ca5069a06eb89adeda1ec | ||
imagePullPolicy: Always | ||
livenessProbe: | ||
failureThreshold: 3 | ||
httpGet: | ||
path: /health/live | ||
port: 3000 | ||
scheme: HTTP | ||
initialDelaySeconds: 2 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 10 | ||
name: gontador | ||
ports: | ||
- containerPort: 3000 | ||
protocol: TCP | ||
readinessProbe: | ||
failureThreshold: 3 | ||
httpGet: | ||
path: /health/ready | ||
port: 3000 | ||
scheme: HTTP | ||
initialDelaySeconds: 2 | ||
periodSeconds: 10 | ||
successThreshold: 1 | ||
timeoutSeconds: 10 | ||
resources: {} | ||
terminationMessagePath: /dev/termination-log | ||
terminationMessagePolicy: File | ||
env: | ||
- name: SYSTEM_ENV | ||
value: dev | ||
- name: SYSTEM_INSTANCE | ||
value: demo-stao | ||
- name: SERVICE_HOST | ||
valueFrom: | ||
fieldRef: | ||
# apiVersion: v1 | ||
fieldPath: spec.nodeName | ||
- name: SERVICE_PORT | ||
value: '3000' | ||
- name: SERVICE_INSTANCE | ||
valueFrom: | ||
fieldRef: | ||
# apiVersion: v1 | ||
fieldPath: metadata.name | ||
- name: METRIC_HOST | ||
value: 192.168.1.2 | ||
- name: METRIC_PORT | ||
value: '2003' | ||
- name: REDIS_URL | ||
value: '192.168.1.2:6379' | ||
dnsPolicy: ClusterFirst | ||
restartPolicy: Always | ||
securityContext: {} | ||
terminationGracePeriodSeconds: 30 | ||
test: false | ||
triggers: | ||
- imageChangeParams: | ||
automatic: true | ||
containerNames: | ||
- gontador | ||
from: | ||
kind: ImageStreamTag | ||
name: 'gontador:latest' | ||
namespace: gontador | ||
lastTriggeredImage: >- | ||
172.30.1.1:5000/gontador/gontador@sha256:9fd64c947842884d6def85ca5ee907efefb2c636960ca5069a06eb89adeda1ec | ||
type: ImageChange | ||
- type: ConfigChange | ||
status: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.