SERVER: updated k8s manifests

Martin Gerhardy 2020-03-08 11:08:53 +01:00
parent 3cf77cf961
commit d2cb768bc4
11 changed files with 68 additions and 24 deletions

View File

@ -67,9 +67,11 @@ option(USE_CPPCHECK "Enable cppcheck" OFF)
option(USE_CLANG_TIDY "Enable Clang Tidy" OFF)
set(PKGDATADIR "" CACHE STRING "System directory to search for data files")
set(DB_PW "engine" CACHE STRING "The database password")
set(SERVER_HOST "server-${FQDN}" CACHE STRING "Host where the server is running on")
set(SERVER_DOMAIN "localdomain")
set(SERVER_HOST "localhost.${SERVER_DOMAIN}" CACHE STRING "Host where the server is running on")
set(SERVER_PORT "11337" CACHE STRING "Port where the server is listening on")
set(BASE_URL "http://localhost/" CACHE STRING "Base url of the http endpoints")
set(HTTP_SERVER_HOST "${SERVER_HOST}" CACHE STRING "Host where the http server is running on")
set(HTTP_SERVER_PORT "8080" CACHE STRING "Port where the http server is listening on")
set(DOCKER_REGISTRY "" CACHE STRING "Docker registry")
if (VOXEDIT_ONLY)

View File

@ -117,7 +117,6 @@ core::AppState Client::onConstruct() {
core::Var::get(cfg::ClientPassword, "");
_chunkUrl = core::Var::get(cfg::ServerChunkBaseUrl, "");
_seed = core::Var::get(cfg::ServerSeed, "");
core::Var::get(cfg::HTTPBaseURL, BASE_URL);
_rotationSpeed = core::Var::getSafe(cfg::ClientMouseRotationSpeed);
core::Var::get(cfg::VoxelMeshSize, "16", core::CV_READONLY);
_worldRenderer.construct();

View File

@ -9,6 +9,8 @@
#define PROJECT_VERSION_MINOR "@PROJECT_VERSION_MINOR@"
#define PROJECT_VERSION_PATCH "@PROJECT_VERSION_PATCH@"
#define HTTP_SERVER_HOST "@HTTP_SERVER_HOST@"
#define HTTP_SERVER_PORT "@HTTP_SERVER_PORT@"
#define SERVER_HOST "@SERVER_HOST@"
#define SERVER_PORT "@SERVER_PORT@"
@ -25,7 +27,6 @@
#cmakedefine CURSES_HAVE_NCURSES_H 1
#cmakedefine OPENCL_LIBRARY "@OPENCL_LIBRARY@"
#cmakedefine BASE_URL "@BASE_URL@"
#cmakedefine DB_PW "@DB_PW@"
#cmakedefine POSTGRESQL_LIBS "@POSTGRESQL_LIBS@"

View File

@ -222,6 +222,11 @@ bool ServerLoop::init() {
response->setText("Server info");
});
_httpServer->registerRoute(http::HttpMethod::GET, "/health", [] (const http::RequestParser& request, http::HttpResponse* response) {
response->headers.put(http::header::CONTENT_TYPE, "application/json");
response->setText("{status: up}");
});
if (!_metricMgr->init()) {
Log::warn("Failed to init metric sender");
}

View File

@ -71,8 +71,6 @@ constexpr const char *DatabaseMaxConnections = "db_maxconnections";
constexpr const char *AppHomePath = "app_homepath";
constexpr const char *AppBasePath = "app_basepath";
constexpr const char *HTTPBaseURL = "http_baseurl";
constexpr const char *MetricPort = "metric_port";
constexpr const char *MetricHost = "metric_host";
constexpr const char *MetricFlavor = "metric_flavor";

View File

@ -45,13 +45,13 @@ set(FILES
server/server-autoexec.cfg
)
set(MANIFESTS
deployment/deployment.yaml.in
deployment/postgres-config.yaml.in
deployment/postgres-deployment.yaml.in
deployment/postgres-service.yaml.in
deployment/postgres-storage.yaml.in
deployment/secrets.yaml.in
deployment/service.yaml.in
deployment/postgres-secrets.yaml.in
deployment/server-deployment.yaml.in
deployment/server-service.yaml.in
)
engine_add_executable(TARGET ${PROJECT_NAME} SRCS ${SRCS} FILES ${FILES} LUA_SRCS ${LUA_SRCS})

View File

@ -50,8 +50,8 @@ core::AppState Server::onConstruct() {
core::Var::get(cfg::ServerPort, SERVER_PORT);
core::Var::get(cfg::ServerHost, "0.0.0.0");
core::Var::get(cfg::ServerMaxClients, "1024");
core::Var::get(cfg::ServerHttpPort, "8080", core::CV_REPLICATE);
core::Var::get(cfg::ServerChunkBaseUrl, "http://localhost:8080/chunk", core::CV_REPLICATE);
core::Var::get(cfg::ServerHttpPort, HTTP_SERVER_PORT, core::CV_REPLICATE);
core::Var::get(cfg::ServerChunkBaseUrl, "http://" HTTP_SERVER_HOST ":" HTTP_SERVER_PORT "/chunk", core::CV_REPLICATE);
core::Var::get(cfg::ServerSeed, "1", core::CV_REPLICATE);
core::Var::get(cfg::VoxelMeshSize, "16", core::CV_READONLY);
core::Var::get(cfg::DatabaseMinConnections, "2");

View File

@ -1,4 +1,4 @@
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: @PROJECT_NAME@
@ -15,9 +15,6 @@ spec:
containers:
- name: @PROJECT_NAME@
image: @DOCKER_IMAGE_NAME_TAG@
ports:
- name: service-port
containerPort: @SERVER_PORT@
env:
- name: DB_PW
valueFrom:
@ -26,20 +23,26 @@ spec:
key: POSTGRES_PASSWORD
- name: DB_HOST
value: postgres
- name: SV_PORT
value: "@SERVER_PORT@"
- name: SV_HTTPPORT
value: "@HTTP_SERVER_PORT@"
livenessProbe:
failureThreshold: 3
exec:
command:
- /opt/@ROOT_PROJECT_NAME@/vengi-@PROJECT_NAME@-healthcheck
httpGet:
path: /health
port: @HTTP_SERVER_PORT@
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 5
readinessProbe:
failureThreshold: 3
exec:
command:
- /opt/@ROOT_PROJECT_NAME@/vengi-@PROJECT_NAME@-healthcheck
httpGet:
path: /health
port: @HTTP_SERVER_PORT@
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 30
successThreshold: 1
@ -49,5 +52,5 @@ spec:
memory: 256Mi
cpu: 1000m
limits:
memory: 4096Mi
memory: 8192Mi
cpu: 10000m

View File

@ -0,0 +1,32 @@
---
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
name: @PROJECT_NAME@-cert
spec:
secretName: @PROJECT_NAME@-secret
issuerRef:
name: ca-issuer
kind: ClusterIssuer
commonName: @HTTP_SERVER_HOST@
organization:
- @SERVER_DOMAIN@
dnsNames:
- @HTTP_SERVER_HOST@
---
apiVersion: "networking.k8s.io/v1beta1"
kind: "Ingress"
metadata:
annotations: {}
name: "@PROJECT_NAME@"
spec:
rules:
- host: @HTTP_SERVER_HOST@
http:
paths:
- path: /
backend:
serviceName: "@PROJECT_NAME@"
servicePort: "http"
tls:
- secretName: "@PROJECT_NAME@-secret"

View File

@ -4,9 +4,13 @@ metadata:
name: @PROJECT_NAME@
spec:
ports:
- name: tcp
- name: udp
port: @SERVER_PORT@
protocol: TCP
protocol: UDP
targetPort: @SERVER_PORT@
- name: http
port: @HTTP_SERVER_PORT@
protocol: TCP
targetPort: @HTTP_SERVER_PORT@
selector:
app: @PROJECT_NAME@