Merge pull request #32 from mfojtik/probe

Add liveness and readiness probe
This commit is contained in:
Michal Fojtik 2016-02-29 17:48:55 +01:00
commit 704ab1dba6
4 changed files with 57 additions and 6 deletions

View file

@ -164,6 +164,22 @@
"containerPort": 8080
}
],
"readinessProbe": {
"timeoutSeconds": 3,
"initialDelaySeconds": 3,
"httpGet": {
"path": "/health",
"port": 8080
}
},
"livenessProbe": {
"timeoutSeconds": 3,
"initialDelaySeconds": 30,
"httpGet": {
"path": "/health",
"port": 8080
}
},
"env": [
{
"name": "DATABASE_SERVICE_NAME",
@ -195,9 +211,9 @@
}
],
"resources": {
"limits": {
"memory": "${MEMORY_LIMIT}"
}
"limits": {
"memory": "${MEMORY_LIMIT}"
}
}
}
]
@ -294,10 +310,24 @@
"value": "${DATABASE_NAME}"
}
],
"readinessProbe": {
"timeoutSeconds": 1,
"initialDelaySeconds": 5,
"exec": {
"command": [ "/bin/sh", "-i", "-c", "psql -h 127.0.0.1 -U ${POSTGRESQL_USER} -q -d ${POSTGRESQL_DATABASE} -c 'SELECT 1'"]
}
},
"livenessProbe": {
"timeoutSeconds": 1,
"initialDelaySeconds": 30,
"tcpSocket": {
"port": 5432
}
},
"resources": {
"limits": {
"memory": "${MEMORY_POSTGRESQL_LIMIT}"
}
"limits": {
"memory": "${MEMORY_POSTGRESQL_LIMIT}"
}
}
}
]

View file

@ -164,6 +164,22 @@
"containerPort": 8080
}
],
"readinessProbe": {
"timeoutSeconds": 3,
"initialDelaySeconds": 3,
"httpGet": {
"path": "/",
"port": 8080
}
},
"livenessProbe": {
"timeoutSeconds": 3,
"initialDelaySeconds": 30,
"httpGet": {
"path": "/",
"port": 8080
}
},
"env": [
{
"name": "DATABASE_SERVICE_NAME",

View file

@ -7,5 +7,6 @@ urlpatterns = [
# url(r'^blog/', include('blog.urls')),
url(r'^$', 'welcome.views.index'),
url(r'^health$', 'welcome.views.health'),
url(r'^admin/', include(admin.site.urls)),
]

View file

@ -1,6 +1,7 @@
import os
from django.shortcuts import render
from django.conf import settings
from django.http import HttpResponse
from . import database
from .models import PageView
@ -16,3 +17,6 @@ def index(request):
'database': database.info(),
'count': PageView.objects.count()
})
def health(request):
return HttpResponse(PageView.objects.count())