{"id":313273,"date":"2021-01-19T01:53:10","date_gmt":"2021-01-18T17:53:10","guid":{"rendered":"http:\/\/4563.org\/?p=313273"},"modified":"2021-01-19T01:53:10","modified_gmt":"2021-01-18T17:53:10","slug":"hrproxy-keepalived-for-docker-and-kubernetes","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=313273","title":{"rendered":"HRProxy &amp; Keepalived for Docker and Kubernetes"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  HRProxy &amp; Keepalived for Docker and Kubernetes               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Lpl <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u91cd\u6784\u4e86\u5f88\u4e45\u4ee5\u524d\u5199\u7684\u4e00\u4e2a haproxy-keepalived \u7684\u955c\u50cf\u3002<\/p>\n<p>\u5730\u5740\uff1a https:\/\/github.com\/penglongli\/haproxy-keepalived<\/p>\n<h2>\u4ecb\u7ecd<\/h2>\n<p>\u56e0\u4e3a\u5927\u5bb6\u5728\u505a\u5185\u7f51 LB \u65b9\u6848\u9009\u62e9\u7684\u65f6\u5019\uff0c\u7ecf\u5e38\u4f1a\u8003\u8651 HAProxy + Keepalived \u7684\u65b9\u5f0f\u6765\u505a\u9ad8\u53ef\u7528\u3002\u8fd9\u4e2a\u4ed3\u5e93\u5c06\u8fd9\u4e24\u4e2a\u8fdb\u7a0b\u653e\u5230\u4e86\u5bb9\u5668\u4e2d\u6765\u8dd1\u3002<\/p>\n<p>\u5e76\u5728\u6b64\u57fa\u7840\u4e0a\u505a\u4e86\u4e00\u4e9b\u5305\u88c5\uff0c\u6765\u7b80\u5316\u4f7f\u7528\u65b9\u5f0f\uff1a<\/p>\n<ul>\n<li>\n<p>\u8fdb\u7a0b\u76d1\u63a7\u53ca Graceful Shutdown<\/p>\n<ul>\n<li>\u8be6\u60c5\uff1aHAProxy \u3001Keepalived \u5b50\u8fdb\u7a0b\u6302\u6389\uff0c\u5bb9\u5668\u81ea\u52a8\u9000\u51fa<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>HAProxy \u7684\u65e5\u5fd7<\/p>\n<ul>\n<li>\u8be6\u60c5\uff1a\u4f7f\u7528 rsyslogd\uff0c\u5728\u5bb9\u5668\u7684 \/var\/log\/haproxy.log \u4e2d\u53ef\u4ee5\u770b\u5230\u8bbf\u95ee\u65e5\u5fd7\u6587\u4ef6<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u589e\u52a0\u5bf9 Kubernetes \u7684\u652f\u6301<\/p>\n<ul>\n<li>\u8be6\u60c5\uff1a\u6b64\u9879\u6ca1\u505a\u4ec0\u4e48\u5de5\u4f5c\uff0c\u53ea\u662f\u5c06\u5982\u4f55\u5728 Kubernetes \u4e0a\u90e8\u7f72\u505a\u4e86\u4e00\u4e2a\u793a\u4f8b\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>HAProxy \u52a8\u6001\u5237\u65b0<\/p>\n<ul>\n<li>\u8be6\u60c5\uff1aHAProxy \u5e94\u8be5\u662f\u5728 1.8 \u7248\u672c\u4e4b\u540e\u539f\u751f\u652f\u6301\u4e86\u52a8\u6001\u5237\u65b0\uff0c\u5411\u8fdb\u7a0b\u53d1\u9001 <code>SIGUSR1<\/code> \u5373\u53ef\u52a8\u6001\u5237\u65b0\uff0c\u524d\u63d0\u662f\u542f\u52a8\u7684\u65f6\u5019\u589e\u52a0 <code>-W<\/code> \u53c2\u6570<\/li>\n<li>\u7528\u5904\uff1a\u56e0\u4e3a HAProxy \u7684 LB \u914d\u7f6e\u53ef\u80fd\u4f1a\u7ecf\u5e38\u6027\u66f4\u65b0\uff0c\u901a\u8fc7 ConfigMap \u6216\u8005 Host File \u662f\u53ef\u4ee5\u52a8\u6001\u6620\u5c04\u8fdb\u5bb9\u5668\u7684\uff0c\u901a\u8fc7\u52a8\u6001\u5237\u65b0\u5373\u53ef\u4f7f\u7528\u4e86\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>1<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5161695\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : YouLMAO <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u989d\u5916\u5b9e\u73b0\u5565\u5b50\u529f\u80fd\uff1f<\/p>\n<p>\u4e00\u822c\u4f7f\u7528 4 \u5c42\uff0ccoredns \u670d\u52a1 vip ipvs<br \/>QPS \u79d2\u6740 nginx                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>HRProxy &amp; Kee&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/313273"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=313273"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/313273\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=313273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=313273"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=313273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}