Add liveness and readiness probe

This commit is contained in:
Michal Fojtik 2016-02-29 16:19:42 +01:00
parent 36f7972ce9
commit dfc399fe95
4 changed files with 57 additions and 6 deletions

View file

@ -164,6 +164,22 @@
"containerPort": 8080 "containerPort": 8080
} }
], ],
"readinessProbe": {
"timeoutSeconds": 3,
"initialDelaySeconds": 3,
"httpGet": {
"path": "/health",
"port": 8080
}
},
"livenessProbe": {
"timeoutSeconds": 3,
"initialDelaySeconds": 30,
"httpGet": {
"path": "/health",
"port": 8080
}
},
"env": [ "env": [
{ {
"name": "DATABASE_SERVICE_NAME", "name": "DATABASE_SERVICE_NAME",
@ -294,6 +310,20 @@
"value": "${DATABASE_NAME}" "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": { "resources": {
"limits": { "limits": {
"memory": "${MEMORY_POSTGRESQL_LIMIT}" "memory": "${MEMORY_POSTGRESQL_LIMIT}"

View file

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

View file

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

View file

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