blob: 6429b83db89d3bdc3847a7b4b17dacb6fa916056 [file] [log] [blame]
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sidcar-injector Deployment and Usage &mdash; go-chassis documentation</title>
<script type="text/javascript" src="_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="prev" title="Egress" href="istio/egress.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> go-chassis
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">User Documentations</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="intro.html">Introductions</a></li>
<li class="toctree-l1"><a class="reference internal" href="get-started.html">Get started</a></li>
<li class="toctree-l1"><a class="reference internal" href="configuration.html">User guides</a></li>
<li class="toctree-l1"><a class="reference internal" href="development.html">Development guides</a></li>
<li class="toctree-l1"><a class="reference internal" href="protocols.html">Protocols</a></li>
<li class="toctree-l1"><a class="reference internal" href="istio-guides.html">Use Istio as control plane</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Sidcar-injector Deployment and Usage</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#introduction">Introduction</a></li>
<li class="toctree-l2"><a class="reference internal" href="#injection">Injection</a></li>
<li class="toctree-l2"><a class="reference internal" href="#manual-sidecar-injection">Manual sidecar injection</a></li>
<li class="toctree-l2"><a class="reference internal" href="#automatic-sidecar-injection">Automatic sidecar injection</a></li>
<li class="toctree-l2"><a class="reference internal" href="#how-it-works">How it works</a></li>
<li class="toctree-l2"><a class="reference internal" href="#deployment-of-sidecar-injector">Deployment Of Sidecar-Injector</a></li>
<li class="toctree-l2"><a class="reference internal" href="#annotations">Annotations</a></li>
<li class="toctree-l2"><a class="reference internal" href="#deployment-of-application">Deployment of application</a></li>
<li class="toctree-l2"><a class="reference internal" href="#prerequisites-before-deploying-application">Prerequisites before deploying application</a></li>
<li class="toctree-l2"><a class="reference internal" href="#usage-of-istio">Usage of istio</a></li>
<li class="toctree-l2"><a class="reference internal" href="#usage-of-servicecomb">Usage of serviceComb</a></li>
<li class="toctree-l2"><a class="reference internal" href="#verification">Verification</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">go-chassis</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> &raquo;</li>
<li>Sidcar-injector Deployment and Usage</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/sidecar.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="sidcar-injector-deployment-and-usage">
<h1>Sidcar-injector Deployment and Usage<a class="headerlink" href="#sidcar-injector-deployment-and-usage" title="Permalink to this headline"></a></h1>
<div class="section" id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline"></a></h2>
<p>Sidecar is a way to run alongside your service as a second process.
The role of the sidecar is to augment and improve the application container, often without the application container’s knowledge.</p>
<p>sidecar is a pattern of “Single-node, multi container application”.</p>
<p>This pattern is particularly useful when using kubernetes as container orchestration platform.
Kubernetes uses pods. A pod is composed of one or more application containers. A sidecar is a utility container in the pod and its purpose is to support the main container. It is important to note that standalone sidecar doesnot serve any purpose, it must be paired with one or more main containers.
Generally, sidecar container is reusable and can be paired with numerous type of main containers.</p>
<p>For design pattern please refer</p>
<p><a class="reference external" href="https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/45406.pdf">Container Design Pattern</a></p>
<p>Example:
The main container might be a web server, and it might be paired with a “logsaver” sidecar container that collects the web server’s logs from local disk and streams them to a cluster.</p>
</div>
<div class="section" id="injection">
<h2>Injection<a class="headerlink" href="#injection" title="Permalink to this headline"></a></h2>
<p>Two types</p>
<ol class="arabic simple">
<li><p>Manual sidecar injection</p></li>
<li><p>Automatic sidecar injection</p></li>
</ol>
</div>
<div class="section" id="manual-sidecar-injection">
<h2>Manual sidecar injection<a class="headerlink" href="#manual-sidecar-injection" title="Permalink to this headline"></a></h2>
<p>In manual sidecar injection user has to provide sidecar information in deployment.</p>
<blockquote>
<div><img alt="communication" src="_images/pod.png" />
</div></blockquote>
</div>
<div class="section" id="automatic-sidecar-injection">
<h2>Automatic sidecar injection<a class="headerlink" href="#automatic-sidecar-injection" title="Permalink to this headline"></a></h2>
<p>Sidecars can be automatically added to applicable Kubernetes pods using</p>
<p><a class="reference external" href="https://kubernetes.io/docs/reference/access-authn-authz/admission-controllers/">mutating webhook admission controller</a>
Note that unlike manual injection, automatic injection occurs at the pod-level.
You won’t see any change to the deployment itself.</p>
<p><a class="reference external" href="https://github.com/go-chassis/sidecar-injector#verification">Verify</a></p>
</div>
<div class="section" id="how-it-works">
<h2>How it works<a class="headerlink" href="#how-it-works" title="Permalink to this headline"></a></h2>
<p>sidecar will deploy along side with main container as shown below</p>
<p>The figure shows the client and server communication using mesher as a sidecar.</p>
<blockquote>
<div><img alt="communication" src="_images/mesher.png" />
</div></blockquote>
<p>Explanation:</p>
<p>Mesher is deployed as a sidecar along with main container of server and client in a pod.</p>
<p>client and server will implement some rest api’s
and functionalities like
loadbalance, circuit-breaker, fault-injection, routerule, discovery etc… will be provided by mesher(sidecar).</p>
<p>workflow:</p>
<p>user/curl—–&gt;client(main container)—–&gt;mesher(sidecar container)—–&gt;mesher(sidecar container)—–&gt;server(main container).</p>
</div>
<div class="section" id="deployment-of-sidecar-injector">
<h2>Deployment Of Sidecar-Injector<a class="headerlink" href="#deployment-of-sidecar-injector" title="Permalink to this headline"></a></h2>
<p><a class="reference external" href="https://github.com/go-chassis/sidecar-injector#prerequisites">Prerequisites</a></p>
<p><a class="reference external" href="https://github.com/go-chassis/sidecar-injector#quick-start">Quick start</a></p>
<p>Use below links to build and Install sidecar</p>
<p><a class="reference external" href="https://github.com/go-chassis/sidecar-injector#build">build</a>
<a class="reference external" href="https://github.com/go-chassis/sidecar-injector#install">install</a></p>
</div>
<div class="section" id="annotations">
<h2>Annotations<a class="headerlink" href="#annotations" title="Permalink to this headline"></a></h2>
<p>Refer k8s document</p>
<p><a class="reference external" href="https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/">Annotation</a></p>
</div>
<div class="section" id="deployment-of-application">
<h2>Deployment of application<a class="headerlink" href="#deployment-of-application" title="Permalink to this headline"></a></h2>
<p>The Sidecar-injector will automatically inject mesher containers into your application pods.</p>
<p>Following are the annotations used to inject mesher sidecar into the user pod</p>
<ol class="arabic">
<li><p>sidecar.mesher.io/inject:</p>
<blockquote>
<div><p>The allowed values are “yes” or “y”</p>
<p>If “yes” or “y” provided the sidecar will inject in the main container.
If not, sidecar will not inject in the main container.</p>
</div></blockquote>
</li>
<li><p>sidecar.mesher.io/discoveryType:</p>
<blockquote>
<div><p>The allowed values are “sc” and “pilot”</p>
<p>If value is “sc” it will use serviecComb service-center as a registry and discovery.
If value is “pilot” it will use the istio pilot as a discovery.</p>
</div></blockquote>
</li>
<li><p>sidecar.mesher.io/servicePorts:</p>
<blockquote>
<div><p>serviceports are the port values of actual main server container append with “rest or grps”</p>
<p>ex: sidecar.mesher.io/servicePorts: rest:9999</p>
</div></blockquote>
</li>
</ol>
<dl class="simple">
<dt>Required annotation for client and server</dt><dd><p>sidecar.mesher.io/inject:</p>
</dd>
<dt>Optional annotation for client and server</dt><dd><p>sidecar.mesher.io/discoveryType:</p>
</dd>
<dt>Optional annotation for server</dt><dd><p>sidecar.mesher.io/servicePorts:</p>
</dd>
</dl>
</div>
<div class="section" id="prerequisites-before-deploying-application">
<h2>Prerequisites before deploying application<a class="headerlink" href="#prerequisites-before-deploying-application" title="Permalink to this headline"></a></h2>
<p>Label the chassis namespace with sidecar-injector=enabled</p>
<p><strong>kubectl label namespace chassis sidecar-injector=enabled</strong></p>
<p><strong>kubectl get namespace -L sidecar-injector</strong></p>
<blockquote>
<div><img alt="communication" src="_images/label.png" />
</div></blockquote>
</div>
<div class="section" id="usage-of-istio">
<h2>Usage of istio<a class="headerlink" href="#usage-of-istio" title="Permalink to this headline"></a></h2>
<p>To use istio following are the required annotation to be given in client and server yaml file
sidecar.mesher.io/inject: “yes” and sidecar.mesher.io/discoveryType:”pilot”</p>
<p><a class="reference external" href="https://github.com/go-chassis/sidecar-injector/tree/master/example/WithoutServicePort/pilot">Example to use pilot registry</a></p>
<p>deploy the examples using kubectl command line</p>
<p><cite>kubectl create -f &lt;filename.yaml&gt; -n chassis</cite></p>
</div>
<div class="section" id="usage-of-servicecomb">
<h2>Usage of serviceComb<a class="headerlink" href="#usage-of-servicecomb" title="Permalink to this headline"></a></h2>
<p>To use service-center following are the required annotation to be given in client and server yaml file
sidecar.mesher.io/inject: “yes” and sidecar.mesher.io/discoveryType:”sc”</p>
<p><a class="reference external" href="https://github.com/go-chassis/sidecar-injector/tree/master/example/WithoutServicePort/sc">Example to use sc registry</a></p>
<p>deploy the examples using kubectl command line</p>
<p><cite>kubectl create -f &lt;filename.yaml&gt; -n chassis</cite></p>
</div>
<div class="section" id="verification">
<h2>Verification<a class="headerlink" href="#verification" title="Permalink to this headline"></a></h2>
<p><a class="reference external" href="https://github.com/go-chassis/sidecar-injector#verification">Follow</a></p>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="istio/egress.html" class="btn btn-neutral float-left" title="Egress" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright 2018, xiaoliang
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>