1<!DOCTYPE html> 2<html lang="en-US"> 3 <head> 4 <meta charset="utf-8"> 5 <meta name="viewport" content="width=device-width,initial-scale=1"> 6 <meta name="generator" content="VuePress 2.0.0-beta.24"> 7 <link rel="icon" type="image/png" sizes="16x16" href="/images/icons/favicon.png"><link rel="icon" type="image/png" sizes="32x32" href="/images/icons/favicon.png"><title>Hybrid Proxy | EdgeMesh</title><meta name="description" content="Cross LANs, Light Container Network Fabric for KubeEdge"> 8 <link rel="preload" href="/assets/js/runtime~app.d96a3814.js" as="script"><link rel="preload" href="/assets/css/styles.53fc1d55.css" as="style"><link rel="preload" href="/assets/js/968.9ffd55de.js" as="script"><link rel="preload" href="/assets/js/app.f0cab5c3.js" as="script"> 9 <link rel="stylesheet" href="/assets/css/styles.53fc1d55.css"> 10 </head> 11 <body> 12 <div id="app"><!--[--><div class="theme-container"><header class="navbar"><div class="toggle-sidebar-button" title="toggle sidebar" aria-expanded="false" role="button" tabindex="0"><div class="icon" aria-hidden="true"><span></span><span></span><span></span></div></div><span><a href="/" class=""><!----><span class="site-name">EdgeMesh</span></a></span><div class="navbar-links-wrapper" style=""><!--[--><!--]--><nav class="navbar-links can-hide"><!--[--><div class="navbar-links-item"><a href="/guide/" class="nav-link" aria-label="Guide"><!--[--><!--]--> Guide <!--[--><!--]--></a></div><div class="navbar-links-item"><div class="dropdown-wrapper"><button class="dropdown-title" type="button" aria-label="Learn More"><span class="title">Learn More</span><span class="arrow down"></span></button><button class="mobile-dropdown-title" type="button" aria-label="Learn More"><span class="title">Learn More</span><span class="right arrow"></span></button><!--[--><ul style="display:none;" class="nav-dropdown"><!--[--><li class="dropdown-item"><!--[--><h4 class="dropdown-subtitle"><span>Advanced</span></h4><ul class="dropdown-subitem-wrapper"><!--[--><li class="dropdown-subitem"><a aria-current='page' aria-label='Hybrid Proxy' class='router-link-active router-link-exact-active nav-link router-link-active' href='/advanced/hybird-proxy'><!--[--><!--]--> Hybrid Proxy <!--[--><!--]--></a></li><!--]--></ul><!--]--></li><!--]--></ul><!--]--></div></div><div class="navbar-links-item"><div class="dropdown-wrapper"><button class="dropdown-title" type="button" aria-label="Select language"><span class="title">Languages</span><span class="arrow down"></span></button><button class="mobile-dropdown-title" type="button" aria-label="Select language"><span class="title">Languages</span><span class="right arrow"></span></button><!--[--><ul style="display:none;" class="nav-dropdown"><!--[--><li class="dropdown-item"><a aria-current='page' aria-label='English' class='router-link-active router-link-exact-active nav-link router-link-active' href='/advanced/hybird-proxy'><!--[--><!--]--> English <!--[--><!--]--></a></li><li class="dropdown-item"><a aria-label='ç®ä½ä¸æ' class='nav-link' href='/zh/advanced/hybird-proxy'><!--[--><!--]--> ç®ä½ä¸æ <!--[--><!--]--></a></li><!--]--></ul><!--]--></div></div><div class="navbar-links-item"><a class="nav-link external" href="https://github.com/kubeedge/edgemesh" rel="noopener noreferrer" target="_blank" aria-label="GitHub"><!--[--><!--]--> GitHub <span><svg class="icon outbound" xmlns="http://www.w3.org/2000/svg" ariahidden="true" focusable="false" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><!--[--><span class="sr-only">open in new window</span><!--]--></span><!--[--><!--]--></a></div><!--]--></nav><!--[--><!--]--><button class="toggle-dark-button" title="toggle dark mode"><svg style="" class="icon" focusable="false" viewBox="0 0 32 32"><path d="M16 12.005a4 4 0 1 1-4 4a4.005 4.005 0 0 1 4-4m0-2a6 6 0 1 0 6 6a6 6 0 0 0-6-6z" fill="currentColor"></path><path d="M5.394 6.813l1.414-1.415l3.506 3.506L8.9 10.318z" fill="currentColor"></path><path d="M2 15.005h5v2H2z" fill="currentColor"></path><path d="M5.394 25.197L8.9 21.691l1.414 1.415l-3.506 3.505z" fill="currentColor"></path><path d="M15 25.005h2v5h-2z" fill="currentColor"></path><path d="M21.687 23.106l1.414-1.415l3.506 3.506l-1.414 1.414z" fill="currentColor"></path><path d="M25 15.005h5v2h-5z" fill="currentColor"></path><path d="M21.687 8.904l3.506-3.506l1.414 1.415l-3.506 3.505z" fill="currentColor"></path><path d="M15 2.005h2v5h-2z" fill="currentColor"></path></svg><svg style="display:none;" class="icon" focusable="false" viewBox="0 0 32 32">
12<path d="M13.502 5.414a15.075 15.075 0 0 0 11.594 18.194a11.113 11.113 0 0 1-7.975 3.39c-.138 0-.278.005-.418 0a11.094 11.094 0 0 1-3.2-21.584M14.98 3a1.002 1.002 0 0 0-.175.016a13.096 13.096 0 0 0 1.825 25.981c.164.006.328 0 .49 0a13.072 13.072 0 0 0 10.703-5.555a1.01 1.01 0 0 0-.783-1.565A13.08 13.08 0 0 1 15.89 4.38A1.015 1.015 0 0 0 14.98 3z" fill="currentColor"></path></svg></button><div id="docsearch-container"></div></div></header><div class="sidebar-mask"></div><aside class="sidebar"><nav class="navbar-links"><!--[--><div class="navbar-links-item"><a href="/guide/" class="nav-link" aria-label="Guide"><!--[--><!--]--> Guide <!--[--><!--]--></a></div><div class="navbar-links-item"><div class="dropdown-wrapper"><button class="dropdown-title" type="button" aria-label="Learn More"><span class="title">Learn More</span><span class="arrow down"></span></button><button class="mobile-dropdown-title" type="button" aria-label="Learn More"><span class="title">Learn More</span><span class="right arrow"></span></button><!--[--><ul style="display:none;" class="nav-dropdown"><!--[--><li class="dropdown-item"><!--[--><h4 class="dropdown-subtitle"><span>Advanced</span></h4><ul class="dropdown-subitem-wrapper"><!--[--><li class="dropdown-subitem"><a aria-current='page' aria-label='Hybrid Proxy' class='router-link-active router-link-exact-active nav-link router-link-active' href='/advanced/hybird-proxy'><!--[--><!--]--> Hybrid Proxy <!--[--><!--]--></a></li><!--]--></ul><!--]--></li><!--]--></ul><!--]--></div></div><div class="navbar-links-item"><div class="dropdown-wrapper"><button class="dropdown-title" type="button" aria-label="Select language"><span class="title">Languages</span><span class="arrow down"></span></button><button class="mobile-dropdown-title" type="button" aria-label="Select language"><span class="title">Languages</span><span class="right arrow"></span></button><!--[--><ul style="display:none;" class="nav-dropdown"><!--[--><li class="dropdown-item"><a aria-current='page' aria-label='English' class='router-link-active router-link-exact-active nav-link router-link-active' href='/advanced/hybird-proxy'><!--[--><!--]--> English <!--[--><!--]--></a></li><li class="dropdown-item"><a aria-label='ç®ä½ä¸æ' class='nav-link' href='/zh/advanced/hybird-proxy'><!--[--><!--]--> ç®ä½ä¸æ <!--[--><!--]--></a></li><!--]--></ul><!--]--></div></div><div class="navbar-links-item"><a class="nav-link external" href="https://github.com/kubeedge/edgemesh" rel="noopener noreferrer" target="_blank" aria-label="GitHub"><!--[--><!--]--> GitHub <span><svg class="icon outbound" xmlns="http://www.w3.org/2000/svg" ariahidden="true" focusable="false" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><!--[--><span class="sr-only">open in new window</span><!--]--></span><!--[--><!--]--></a></div><!--]--></nav><!--[--><!--]--><ul class="sidebar-links"><!--[--><!--[--><p class="sidebar-heading sidebar-item active">Advanced</p><ul class=""><li><!--[--><a aria-current='page' aria-label='Hybrid Proxy' class='router-link-active router-link-exact-active nav-link router-link-active sidebar-item active' href='/advanced/hybird-proxy'><!--[--><!--]--> Hybrid Proxy <!--[--><!--]--></a><ul class="sidebar-sub-items"><li><!--[--><a aria-current='page' aria-label='Principle' class='router-link-active router-link-exact-active nav-link sidebar-item' href='/advanced/hybird-proxy#principle'><!--[--><!--]--> Principle <!--[--><!--]--></a><!----><!--]--></li><li><!--[--><a aria-current='page' aria-label='Service Filter' class='router-link-active router-link-exact-active nav-link sidebar-item' href='/advanced/hybird-proxy#service-filter'><!--[--><!--]--> Service Filter <!--[--><!--]--></a><!----><!--]--></li></ul><!--]--></li></ul><!--]--><!--]--></ul><!--[--><!--]--></aside><!--[--><main class="page"><!--[--><!--]--><div class="theme-default-content"><!--[--><h1 id="hybrid-proxy" tabindex="-1"><a class="header-anchor" href="#hybrid-proxy" aria-hidden="true">
12#</a> Hybrid Proxy</h1><p>When kube-proxy and edgemesh are deployed in a K8s cluster at the same time, the compatibility of the two is ensured by hybrid proxy.</p><h2 id="principle" tabindex="-1"><a class="header-anchor" href="#principle" aria-hidden="true">#</a> Principle</h2><p>When edgemesh-agent is started after kube-proxy, the <code>KUBE-PORTALS-CONTAINER</code> chain will be inserted into the PREROUTING and OUTPUT chains in the nat table of the host iptables, and it will be in front of the <code>KUBE-SERVICES</code> chain, so It can hijack the traffic of the service in preference to kube-proxy, and realize the traffic forwarding of cloud edge communication.</p><div class="language-bash ext-sh line-numbers-mode"><pre class="language-bash"><code>$ iptables -t nat -nvL 13Chain PREROUTING <span class="token punctuation">(</span>policy ACCEPT 1379K packets, 395M bytes<span class="token punctuation">)</span> 14 pkts bytes target prot opt <span class="token keyword">in</span> out <span class="token builtin class-name">source</span> destination 15 <span class="token number">52</span> <span class="token number">13980</span> KUBE-PORTALS-CONTAINER all -- * * <span class="token number">0.0</span>.0.0/0 <span class="token number">0.0</span>.0.0/0 /* handle ClusterIPs<span class="token punctuation">;</span> NOTE: this must be before the NodePort rules */ 161375K 394M KUBE-SERVICES all -- * * <span class="token number">0.0</span>.0.0/0 <span class="token number">0.0</span>.0.0/0 /* kubernetes <span class="token function">service</span> portals */ 17<span class="token punctuation">..</span>. 18 19Chain OUTPUT <span class="token punctuation">(</span>policy ACCEPT 1317K packets, 79M bytes<span class="token punctuation">)</span> 20 pkts bytes target prot opt <span class="token keyword">in</span> out <span class="token builtin class-name">source</span> destination 21 <span class="token number">51</span> <span class="token number">3086</span> KUBE-PORTALS-HOST all -- * * <span class="token number">0.0</span>.0.0/0 <span class="token number">0.0</span>.0.0/0 /* handle ClusterIPs<span class="token punctuation">;</span> NOTE: this must be before the NodePort rules */ 221314K 79M KUBE-SERVICES all -- * * <span class="token number">0.0</span>.0.0/0 <span class="token number">0.0</span>.0.0/0 /* kubernetes <span class="token function">service</span> portals */ 23<span class="token punctuation">..</span>. 24</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br></div></div><div class="custom-container tip"><p class="custom-container-title">TIP</p><p>If there is an error such as <code>No route to host</code> when accessing the service, it may be because the startup of edgemesh-agent precedes the startup of kube-proxy, resulting in the chain of <code>KUBE-PORTALS-CONTAINER</code> located behind <code>KUBE-SERVICES</code>, which cannot be prioritized Because kube-proxy hijacks the service's traffic. This problem can be circumvented by redeploying edgemesh to re-establish the order of the chain.</p></div><h2 id="service-filter" tabindex="-1"><a class="header-anchor" href="#service-filter" aria-hidden="true">#</a> Service Filter</h2><p>edgemesh-agent intercepts and forwards all services accessed through Cluster IP by default, but the traffic forwarding process of edgemesh-agent will bring a little performance loss in user mode. Therefore, you may have some services that you don't want to be proxied by edgemesh-agent, we provide a label for service filtering: <code>service.edgemesh.kubeedge.io/service-proxy-name</code>.</p><p>To enable more fine-tuned settings you can set the service filter mode by setting the <code>serviceFilterMode</code> option in the edgemesh-agent configuration file (<code>modules.edgeProxy.serviceFilterMode</code>) to either "FilterIfLabelExists" or "FilterIfLabelDoesNotExists". The default value is "FilterIfLabelExists". If the value is "FilterIfLabelExists", the service will be filtered if the label <code>service.edgemesh.kubeedge.io/service-proxy-name</code> exists and vice versa if the label does not exist.</p><p>For example: If you want to deploy prometheus + grafana monitoring services in the cloud, these services do not require edge access, so you do not want them to be proxied by edgemesh-agent, then you can do this:</p><div class="language-yaml ext-yml line-numbers-mode"><pre class="language-yaml"><code><span class="token key atrule">apiVersion</span><span class="token punctuation">:</span> v1 25<span class="token key atrule">kind</span><span class="token punctuation">:</span> Service 26<span class="token key atrule">metadata</span><span class="token punctuation">:</span> 27 <span class="token key atrule">labels</span><span class="token punctuation">:</span> 28 <span class="token key atrule">service.edgemesh.kubeedge.io/service-proxy-name</span><span class="token punctuation">:</span> <span class="token string">""</span> <span class="token comment">#<---- add this label to ignored by edgemesh-agent</span> 29 <span class="token key atrule">app.kubernetes.io/name</span><span class="token punctuation">:</span> node<span class="token punctuation">-</span>exporter 30 <span class="token key atrule">app.kubernetes.io/version</span><span class="token punctuation">:</span> v1.0.1 31 <span class="token key atrule">name</span><span class="token punctuation">:</span> node<span class="token punctuation">-</span>exporter 32 <span class="token key atrule">namespace</span><span class="token punctuation">:</span> monitoring 33<span class="token key atrule">spec</span><span class="token punctuation">:</span> 34 <span class="token key atrule">clusterIP</span><span class="token punctuation">:</span> None 35 <span class="token key atrule">ports</span><span class="token punctuation">:</span> 36 <span class="token punctuation">-</span> <span class="token key atrule">name</span><span class="token punctuation">:</span> https 37 <span class="token key atrule">port</span><span class="token punctuation">:</span> <span class="token number">9100</span> 38 <span class="token key atrule">targetPort</span><span class="token punctuation">:</span> https 39 <span class="token key atrule">selector</span><span class="token punctuation">:</span> 40 <span class="token key atrule">app.kubernetes.io/name</span><span class="token punctuation">:</span> node<span class="token punctuation">-</span>exporter 41</code></pre><div class="line-numbers"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div><p>After saving the configuration, you will not see the iptables rules for this service in the <code>KUBE-PORTALS-CONTAINER</code> chain, meaning edgemesh will not process this service.</p><!--]--></div><footer class="page-meta"><div class="meta-item edit-link"><a class="nav-link external meta-item-label" href="https://github.com/kubeedge/edgemesh/edit/main/docs/advanced/hybird-proxy.md" rel="noopener noreferrer" target="_blank" aria-label="Edit this page on GitHub"><!--[--><!--]--> Edit this page on GitHub <span><svg class="icon outbound" xmlns="http://www.w3.org/2000/svg" ariahidden="true" focusable="false" x="0px" y="0px" viewbox="0 0 100 100" width="15" height="15">
41<path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><!--[--><span class="sr-only">open in new window</span><!--]--></span><!--[--><!--]--></a></div><div class="meta-item last-updated"><span class="meta-item-label">Last Updated: </span><span class="meta-item-info">10/25/2022, 5:21:05 AM</span></div><!----></footer><!----><!--[--><!--]--></main><!--]--></div><!----><!--]--></div> 42
42<script src="/assets/js/runtime~app.d96a3814.js" defer></script>
42<script src="/assets/js/968.9ffd55de.js" defer></script>
42<script src="/assets/js/app.f0cab5c3.js" defer></script>
42 43 </body> 44</html>
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.