docs/ee/ucp/admin/configure/_site/view-namespace-resources.html

122 lines
6.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>With Docker Enterprise Edition, administrators can filter the view of
Kubernetes objects by the namespace the objects are assigned to. You can
specify a single namespace, or you can specify all available namespaces.</p>
<h2 id="create-two-namespaces">Create two namespaces</h2>
<p>In this example, you create two Kubernetes namespaces and deploy a service
to both of them.</p>
<ol>
<li>Log in to the UCP web UI with an administrator account.</li>
<li>In the left pane, click <strong>Kubernetes</strong>.</li>
<li>Click <strong>Create</strong> to open the <strong>Create Kubernetes Object</strong> page.</li>
<li>
<p>In the <strong>Object YAML</strong> editor, paste the following YAML.</p>
<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">apiVersion</span><span class="pi">:</span> <span class="s">v1</span>
<span class="na">kind</span><span class="pi">:</span> <span class="s">Namespace</span>
<span class="na">metadata</span><span class="pi">:</span>
<span class="na">name</span><span class="pi">:</span> <span class="s">blue</span>
<span class="nn">---</span>
<span class="na">apiVersion</span><span class="pi">:</span> <span class="s">v1</span>
<span class="na">kind</span><span class="pi">:</span> <span class="s">Namespace</span>
<span class="na">metadata</span><span class="pi">:</span>
<span class="na">name</span><span class="pi">:</span> <span class="s">green</span>
</code></pre></div> </div>
</li>
<li>Click <strong>Create</strong> to create the <code class="highlighter-rouge">blue</code> and <code class="highlighter-rouge">green</code> namespaces.</li>
</ol>
<p><img src="../../images/view-namespace-resources-1.png" alt="" class="with-border" /></p>
<h2 id="deploy-services">Deploy services</h2>
<p>Create a <code class="highlighter-rouge">NodePort</code> service in the <code class="highlighter-rouge">blue</code> namespace.</p>
<ol>
<li>Navigate to the <strong>Create Kubernetes Object</strong> page.</li>
<li>In the <strong>Namespace</strong> dropdown, select <strong>blue</strong>.</li>
<li>
<p>In the <strong>Object YAML</strong> editor, paste the following YAML.</p>
<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">apiVersion</span><span class="pi">:</span> <span class="s">v1</span>
<span class="na">kind</span><span class="pi">:</span> <span class="s">Service</span>
<span class="na">metadata</span><span class="pi">:</span>
<span class="na">name</span><span class="pi">:</span> <span class="s">app-service-blue</span>
<span class="na">labels</span><span class="pi">:</span>
<span class="na">app</span><span class="pi">:</span> <span class="s">app-blue</span>
<span class="na">spec</span><span class="pi">:</span>
<span class="na">type</span><span class="pi">:</span> <span class="s">NodePort</span>
<span class="na">ports</span><span class="pi">:</span>
<span class="pi">-</span> <span class="na">port</span><span class="pi">:</span> <span class="s">80</span>
<span class="na">nodePort</span><span class="pi">:</span> <span class="s">32768</span>
<span class="na">selector</span><span class="pi">:</span>
<span class="na">app</span><span class="pi">:</span> <span class="s">app-blue</span>
</code></pre></div> </div>
</li>
<li>
<p>Click <strong>Create</strong> to deploy the service in the <code class="highlighter-rouge">blue</code> namespace.</p>
</li>
<li>
<p>Repeat the previous steps with the following YAML, but this time,
select <code class="highlighter-rouge">green</code> from the <strong>Namespace</strong> dropdown.</p>
<div class="language-yaml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="na">apiVersion</span><span class="pi">:</span> <span class="s">v1</span>
<span class="na">kind</span><span class="pi">:</span> <span class="s">Service</span>
<span class="na">metadata</span><span class="pi">:</span>
<span class="na">name</span><span class="pi">:</span> <span class="s">app-service-green</span>
<span class="na">labels</span><span class="pi">:</span>
<span class="na">app</span><span class="pi">:</span> <span class="s">app-green</span>
<span class="na">spec</span><span class="pi">:</span>
<span class="na">type</span><span class="pi">:</span> <span class="s">NodePort</span>
<span class="na">ports</span><span class="pi">:</span>
<span class="pi">-</span> <span class="na">port</span><span class="pi">:</span> <span class="s">80</span>
<span class="na">nodePort</span><span class="pi">:</span> <span class="s">32769</span>
<span class="na">selector</span><span class="pi">:</span>
<span class="na">app</span><span class="pi">:</span> <span class="s">app-green</span>
</code></pre></div> </div>
</li>
</ol>
<h2 id="view-services">View services</h2>
<p>Currently, the <strong>Namespaces</strong> view is set to the <strong>default</strong> namespace, so the
<strong>Load Balancers</strong> page doesnt show your services.</p>
<ol>
<li>In the left pane, click <strong>Namespaces</strong> to open the list of namespaces.</li>
<li>In the upper-right corner, click the <strong>Set context for all namespaces</strong>
toggle and click <strong>Confirm</strong>. The indicator in the left pane changes to <strong>All Namespaces</strong>.</li>
<li>Click <strong>Load Balancers</strong> to view your services.</li>
</ol>
<p><img src="../../images/view-namespace-resources-2.png" alt="" class="with-border" /></p>
<h2 id="filter-the-view-by-namespace">Filter the view by namespace</h2>
<p>With the <strong>Set context for all namespaces</strong> toggle set, you see all of the
Kubernetes objects in every namespace. Now filter the view to show only
objects in one namespace.</p>
<ol>
<li>In the left pane, click <strong>Namespaces</strong> to open the list of namespaces.</li>
<li>
<p>In the <strong>green</strong> namespace, click the <strong>More options</strong> icon and in the
context menu, select <strong>Set Context</strong>.</p>
<p><img src="../../images/view-namespace-resources-3.png" alt="" class="with-border" /></p>
</li>
<li>Click <strong>Confirm</strong> to set the context to the <code class="highlighter-rouge">green</code> namespace.
The indicator in the left pane changes to <strong>green</strong>.</li>
<li>Click <strong>Load Balancers</strong> to view your <code class="highlighter-rouge">app-service-green</code> service.
The <code class="highlighter-rouge">app-service-blue</code> service doesnt appear.</li>
</ol>
<p><img src="../../images/view-namespace-resources-4.png" alt="" class="with-border" /></p>
<p>To view the <code class="highlighter-rouge">app-service-blue</code> service, repeat the previous steps, but this
time, select <strong>Set Context</strong> on the <strong>blue</strong> namespace.</p>
<p><img src="../../images/view-namespace-resources-5.png" alt="" class="with-border" /></p>