Skip to content

Commit 4a5606f

Browse files
committed
Merge pull request #4367 from krancour/kube-proxy-health
feat(router): improve healthcheck
2 parents 0bd2471 + 19b06d5 commit 4a5606f

5 files changed

Lines changed: 32 additions & 7 deletions

File tree

contrib/aws/deis.template.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@
300300
"HealthCheck": {
301301
"HealthyThreshold": "4",
302302
"Interval": "15",
303-
"Target": "TCP:80",
303+
"Target": "HTTP:9090/health-check",
304304
"Timeout": "5",
305305
"UnhealthyThreshold": "2"
306306
},
@@ -367,7 +367,8 @@
367367
{"IpProtocol": "tcp", "FromPort" : "22", "ToPort" : "22", "CidrIp" : { "Ref" : "SSHFrom" }},
368368
{"IpProtocol": "tcp", "FromPort": "80", "ToPort": "80", "SourceSecurityGroupId": { "Ref": "DeisWebELBSecurityGroup" } },
369369
{"IpProtocol": "tcp", "FromPort": "443", "ToPort": "443", "SourceSecurityGroupId": { "Ref": "DeisWebELBSecurityGroup" } },
370-
{"IpProtocol": "tcp", "FromPort": "2222", "ToPort": "2222", "SourceSecurityGroupId": { "Ref": "DeisWebELBSecurityGroup" } }
370+
{"IpProtocol": "tcp", "FromPort": "2222", "ToPort": "2222", "SourceSecurityGroupId": { "Ref": "DeisWebELBSecurityGroup" } },
371+
{"IpProtocol": "tcp", "FromPort": "9090", "ToPort": "9090", "SourceSecurityGroupId": { "Ref": "DeisWebELBSecurityGroup" } }
371372
],
372373
"VpcId" : { "Ref" : "VPC" }
373374
}

deisctl/units/deis-kube-proxy.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Documentation=https://github.com/GoogleCloudPlatform/kubernetes
66
EnvironmentFile=/etc/environment
77
ExecStartPre=/bin/bash -c "/opt/bin/download-k8s-binary kube-proxy"
88
ExecStartPre=/bin/bash -c "/opt/bin/wupiao $(/usr/bin/etcdctl get /deis/scheduler/k8s/master):8080"
9-
ExecStart=/bin/bash -c '/opt/bin/kube-proxy --master=`/usr/bin/etcdctl get /deis/scheduler/k8s/master`:8080 --logtostderr=true'
9+
ExecStart=/bin/bash -c '/opt/bin/kube-proxy --master=`/usr/bin/etcdctl get /deis/scheduler/k8s/master`:8080 --logtostderr=true --healthz-bind-address=0.0.0.0'
1010
Restart=always
1111
RestartSec=10
1212
SuccessExitStatus=2

deisctl/units/deis-router.service

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TimeoutStartSec=20m
77
ExecStartPre=-/usr/bin/etcdctl mkdir /registry/services/ >/dev/null 2>&1
88
ExecStartPre=/bin/sh -c "IMAGE=`/run/deis/bin/get_image /deis/router` && docker history $IMAGE >/dev/null 2>&1 || docker pull $IMAGE"
99
ExecStartPre=/bin/sh -c "docker inspect deis-router >/dev/null 2>&1 && docker rm -f deis-router || true"
10-
ExecStart=/bin/sh -c "IMAGE=`/run/deis/bin/get_image /deis/router` && docker run --name deis-router --rm -p 80:80 -p 2222:2222 -p 443:443 -e EXTERNAL_PORT=80 -e HOST=$COREOS_PRIVATE_IPV4 $IMAGE"
10+
ExecStart=/bin/sh -c "IMAGE=`/run/deis/bin/get_image /deis/router` && docker run --name deis-router --rm -p 80:80 -p 2222:2222 -p 443:443 -p 9090:9090 -e EXTERNAL_PORT=80 -e HOST=$COREOS_PRIVATE_IPV4 $IMAGE"
1111
ExecStop=-/usr/bin/docker stop deis-router
1212
Restart=on-failure
1313
RestartSec=5

router/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ COPY rootfs /
2525
RUN build
2626

2727
CMD ["boot"]
28-
EXPOSE 80 2222
28+
EXPOSE 80 2222 9090
2929

3030
ENV DEIS_RELEASE 1.11.0-dev

router/rootfs/etc/confd/templates/nginx.conf

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,19 @@ http {
369369
}{{ end }}
370370
## end service definitions for each application
371371

372-
# healthcheck
372+
{{ $scheduler := or (getv "/deis/controller/schedulerModule") "fleet" }}
373+
374+
# default server, including "classic" healthcheck
373375
server {
374376
listen 80 default_server reuseport{{ if ne $useProxyProtocol "false" }} proxy_protocol{{ end }};
375377
location /health-check {
376-
default_type 'text/plain';
377378
access_log off;
379+
{{ if eq $scheduler "k8s" }}
380+
proxy_pass http://{{ getenv "HOST" }}:10249/healthz;
381+
{{ else }}
382+
default_type 'text/plain';
378383
return 200;
384+
{{ end }}
379385
}
380386
location /router-nginx-status {
381387
vhost_traffic_status_display;
@@ -385,6 +391,24 @@ http {
385391
return 404;
386392
}
387393
}
394+
395+
# healthcheck on 9090 -- never uses proxy_protocol
396+
server {
397+
listen 9090 default_server;
398+
location /health-check {
399+
access_log off;
400+
{{ if eq $scheduler "k8s" }}
401+
proxy_pass http://{{ getenv "HOST" }}:10249/healthz;
402+
{{ else }}
403+
default_type 'text/plain';
404+
return 200;
405+
{{ end }}
406+
}
407+
location / {
408+
return 404;
409+
}
410+
}
411+
388412
#start k8s apps
389413
{{ range $k8namespace := lsdir "/registry/services/specs/" }}
390414
{{ $k8appdir := printf "/registry/services/specs/%s" $k8namespace}}{{ range $kapp := ls $k8appdir }}

0 commit comments

Comments
 (0)