{"id":6203,"date":"2022-08-24T22:53:08","date_gmt":"2022-08-24T13:53:08","guid":{"rendered":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=6203"},"modified":"2022-08-24T16:38:49","modified_gmt":"2022-08-24T07:38:49","slug":"hello-world-2","status":"publish","type":"post","link":"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=6203","title":{"rendered":"Hello World"},"content":{"rendered":"<h1>Hello World<\/h1>\n<p>Job \uc744 \ud14c\uc2a4\ud2b8\ud558\uace0,<br \/>\nLoad Balancing \uc758 health check point \ub97c \uc81c\uacf5\ud558\uae30 \uc704\ud574,<br \/>\nhello_world job \uc744 \uc0dd\uc131\ud569\ub2c8\ub2e4.<\/p>\n<pre><code class=\"language-bash\">vi hello_world.nomad\n-----------------------------\njob &quot;hello_world&quot; {\n  datacenters = [&quot;dc1&quot;]\n\n  group &quot;hello_world&quot; {\n    count = 1\n\n    network {\n      port &quot;http&quot; { to = 80 }\n    }\n\n    task &quot;hello_world&quot; {\n      driver = &quot;docker&quot;\n\n      config {\n        image = &quot;nginxdemos\/hello&quot;\n        ports = [&quot;http&quot;]\n\n        auth_soft_fail = true\n      }\n\n      resources {\n        cpu    = 500\n        memory = 128\n      }\n\n      service {\n        name = &quot;hello-world&quot;\n        port = &quot;http&quot;\n\n        check {\n          type     = &quot;http&quot;\n          path     = &quot;\/health&quot;\n          interval = &quot;10s&quot;\n          timeout  = &quot;2s&quot;\n        }\n      }\n    }\n  }\n}\n-----------------------------<\/code><\/pre>\n<h2>haproxy \uc5f0\ub3d9<\/h2>\n<ul>\n<li>\n<p>\uace0\uc815 \ud3ec\ud2b8 \ud560\ub2f9 :<\/p>\n<p><code class=\"kb-btn\">port &quot;hello_world&quot; { static = 2390 }<\/code><\/p>\n<\/li>\n<li>\n<p>frontend \uc124\uc815 :<\/p>\n<p><code>NOMAD_PORT_\ud3ec\ud2b8\uba85<\/code><\/p>\n<\/li>\n<li>\n<p>backend \uc124\uc815 :<\/p>\n<p><code>_hello-world._tcp.service.consul<\/code> \uc5d0\uc11c <code>hello-world<\/code> \uac00 job \uc11c\ube44\uc2a4\uba85<br \/>\n<code class=\"kb-btn\">service { name = &quot;hello-world&quot; }<\/code><\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"language-nomad\">job &quot;haproxy&quot; {\n  datacenters = [&quot;dc1&quot;]\n  type = &quot;system&quot;         # \ubaa8\ub4e0 \ub178\ub4dc\uc5d0 \uc790\ub3d9\uc124\uce58\n\n  group &quot;haproxy&quot; {\n    count = 1\n\n    network {\n      port &quot;haproxy_ui&quot; {\n        static = 4936\n      }\n\n      port &quot;prometheus_ui&quot; {\n        static = 9090\n      }\n\n      port &quot;hello_world&quot; {\n        static = 2390\n      }\n\n      port &quot;haproxy_exporter&quot; {}\n    }\n\n    task &quot;haproxy&quot; {\n      driver = &quot;docker&quot;\n\n      config {\n        image = &quot;haproxy:2.4.4&quot;\n        ports = [&quot;haproxy_ui&quot;]\n\n        auth_soft_fail = true\n\n        # host \ub85c \uc124\uc815\ud588\uc73c\ubbc0\ub85c 127.0.0.1 \ub294 \ud638\uc2a4\ud2b8\ub97c \uac00\ub974\ud0a8\ub2e4.\n        network_mode = &quot;host&quot;\n\n        volumes = [\n          &quot;local\/haproxy.cfg:\/usr\/local\/etc\/haproxy\/haproxy.cfg&quot;,\n          &quot;\/ssl\/:\/ssl\/&quot;,\n        ]\n      }\n\n      template {\n        data = &lt;&lt;EOF\nglobal\n   maxconn 8192\ndefaults\n   mode http\n   timeout client 10s\n   timeout connect 5s\n   timeout server 10s\n   timeout http-request 10s\n   option forwardfor\n\nfrontend stats\n   bind *:{{ env &quot;NOMAD_PORT_haproxy_ui&quot; }}\n   stats uri \/\n   stats show-legends\n   no log\n\nfrontend prometheus_ui_front\n   bind *:{{ env &quot;NOMAD_PORT_prometheus_ui&quot; }}\n   default_backend prometheus_ui_back\n\nbackend prometheus_ui_back\n   balance roundrobin\n   server-template prometheus_ui 5 _prometheus._tcp.service.consul resolvers consul resolve-opts allow-dup-ip resolve-prefer ipv4 check\n\nfrontend hello_world_front\n   bind *:{{ env &quot;NOMAD_PORT_hello_world&quot; }}\n   default_backend hello_world_back\n\nbackend hello_world_back\n   balance roundrobin\n   server-template hello_world 5 _hello-world._tcp.service.consul resolvers consul resolve-opts allow-dup-ip resolve-prefer ipv4 check\n\nresolvers consul\n   nameserver consul 127.0.0.1:8600\n   accepted_payload_size 8192\n   hold valid 5s\nEOF\n\n        destination   = &quot;local\/haproxy.cfg&quot;\n        change_mode   = &quot;signal&quot;\n        change_signal = &quot;SIGUSR1&quot;\n      }\n\n      resources {\n        cpu    = 500\n        memory = 128\n      }\n\n      service {\n        name = &quot;haproxy-ui&quot;\n        port = &quot;haproxy_ui&quot;\n\n        check {\n          type     = &quot;http&quot;\n          path     = &quot;\/&quot;\n          interval = &quot;10s&quot;\n          timeout  = &quot;2s&quot;\n        }\n      }\n    }\n\n    task &quot;haproxy-exporter&quot; {\n      driver = &quot;docker&quot;\n\n      lifecycle {\n        hook    = &quot;prestart&quot;\n        sidecar = true\n      }\n\n      config {\n        image = &quot;prom\/haproxy-exporter:v0.10.0&quot;\n        ports = [&quot;haproxy_exporter&quot;]\n\n        network_mode = &quot;host&quot;\n        auth_soft_fail = true\n\n        args = [\n          &quot;--web.listen-address&quot;,\n          &quot;:${NOMAD_PORT_haproxy_exporter}&quot;,\n          &quot;--haproxy.scrape-uri&quot;,\n          &quot;http:\/\/${NOMAD_ADDR_haproxy_ui}\/?stats;csv&quot;,\n        ]\n      }\n\n      resources {\n        cpu    = 100\n        memory = 32\n      }\n\n      service {\n        name = &quot;haproxy-exporter&quot;\n        port = &quot;haproxy_exporter&quot;\n\n        check {\n          type     = &quot;http&quot;\n          path     = &quot;\/metrics&quot;\n          interval = &quot;10s&quot;\n          timeout  = &quot;2s&quot;\n        }\n      }\n    }\n  }\n}<\/code><\/pre>\n<p>http:\/\/&lt;\ub178\ub9c8\ub4dc \ud074\ub77c\uc774\uc5b8\ud2b8 \uc544\uc774\ud53c&gt;:2390\/ \uc5d0 \uc811\uc18d\ud558\uba74,<br \/>\nhello_world \uac00 \uc2e4\ud589\ub418\uace0 \uc788\ub294 \uac83\uc744 \ubcfc \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello World Job \uc744 \ud14c\uc2a4\ud2b8\ud558\uace0, Load Balancing \uc758 health check point \ub97c \uc81c\uacf5\ud558\uae30 \uc704\ud574, hello_world job \uc744 \uc0dd\uc131\ud569\ub2c8\ub2e4. vi hello_world.nomad &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; job &quot;hello_world&quot; { datacenters = [&quot;dc1&quot;] group &quot;hello_world&quot; { count = 1 network { port &quot;http&quot; { to = 80 } } task &quot;hello_world&quot; { driver = &quot;docker&quot; config { image = &quot;nginxdemos\/hello&quot; ports\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.skyer9.pe.kr\/wordpress\/?p=6203\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-6203","post","type-post","status-publish","format-standard","hentry","category-nomad"],"_links":{"self":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6203","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6203"}],"version-history":[{"count":6,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6203\/revisions"}],"predecessor-version":[{"id":6211,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/6203\/revisions\/6211"}],"wp:attachment":[{"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6203"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6203"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyer9.pe.kr\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6203"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}