391 lines
16 KiB
HTML
391 lines
16 KiB
HTML
<!Doctype html>
|
||
<html id="docs">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<link href='https://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'>
|
||
<link rel="stylesheet" href="/css/styles.css"/>
|
||
<script src="/js/script.js"></script>
|
||
<script src="/js/jquery-2.2.0.min.js"></script>
|
||
<script src="/js/non-mini.js"></script>
|
||
<title>Kubernetes - Node</title>
|
||
</head>
|
||
<body>
|
||
<div id="cellophane" onclick="kub.toggleMenu()"></div>
|
||
<header>
|
||
<a href="/" class="logo"></a>
|
||
<div class="nav-buttons" data-auto-burger="primary">
|
||
<a href="/docs" class="button" id="viewDocs">View Documentation</a>
|
||
<a href="/get-started" class="button" id="tryKubernetes">Try Kubernetes</a>
|
||
<button id="hamburger" onclick="kub.toggleMenu()" data-auto-burger-exclude><div></div></button>
|
||
</div>
|
||
|
||
<nav id="mainNav">
|
||
<main data-auto-burger="primary">
|
||
<div class="nav-box">
|
||
<h3><a href="">Get Started</a></h3>
|
||
<p>Built for a multi-cloud world, public, private or hybrid. Seamlessly roll out new features.</p>
|
||
</div>
|
||
<div class="nav-box">
|
||
<h3><a href="">Documentation</a></h3>
|
||
<p>Pellentesque in ipsum id orci porta dapibus. Nulla porttitor accumsan tincidunt. </p>
|
||
</div>
|
||
<div class="nav-box">
|
||
<h3><a href="">Community</a></h3>
|
||
<p>Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. </p>
|
||
</div>
|
||
<div class="nav-box">
|
||
<h3><a href="">Blog</a></h3>
|
||
<p>Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Quisque velit nisi, pretium ut lacinia in. </p>
|
||
</div>
|
||
</main>
|
||
<main data-auto-burger="primary">
|
||
<div class="left">
|
||
<h5 class="github-invite">Interested in hacking on the core Kubernetes code base?</h5>
|
||
<a href="" class="button">View On Github</a>
|
||
</div>
|
||
|
||
<div class="right">
|
||
<h5 class="github-invite">Explore the community</h5>
|
||
<div class="social">
|
||
<a href="https://twitter.com/kubernetesio" class="Twitter"><span>twitter</span></a>
|
||
<a href="https://github.com/kubernetes/kubernetes" class="github"><span>Github</span></a>
|
||
<a href="http://slack.k8s.io/" class="slack"><span>Slack</span></a>
|
||
<a href="http://stackoverflow.com/questions/tagged/kubernetes" class="stack-overflow"><span>stackoverflow</span></a>
|
||
<a href="https://groups.google.com/forum/#!forum/google-containers" class="mailing-list"><span>Mailing List</span></a>
|
||
</div>
|
||
</div>
|
||
<div class="clear" style="clear: both"></div>
|
||
</main>
|
||
</nav>
|
||
</header>
|
||
|
||
<!-- HERO -->
|
||
<section id="hero" class="light-text">
|
||
<h1></h1>
|
||
<h5></h5>
|
||
<div id="vendorStrip" class="light-text">
|
||
<ul>
|
||
<li><a href="/v1.1/">GUIDES</a></li>
|
||
<li><a href="/v1.1/reference">REFERENCE</a></li>
|
||
<li><a href="/v1.1/samples">SAMPLES</a></li>
|
||
<li><a href="/v1.1/support">SUPPORT</a></li>
|
||
</ul>
|
||
<div class="dropdown">
|
||
<div class="readout"></div>
|
||
<a href="/v1.1">Version 1.1</a>
|
||
<a href="/v1.0">Version 1.0</a>
|
||
</div>
|
||
<input type="text" id="search" placeholder="Search the docs">
|
||
</div>
|
||
</section>
|
||
|
||
<section id="encyclopedia">
|
||
<div id="docsToc">
|
||
<div class="pi-accordion">
|
||
|
||
|
||
|
||
</div> <!-- /pi-accordion -->
|
||
</div> <!-- /docsToc -->
|
||
<div id="docsContent">
|
||
<h1>Node</h1>
|
||
<!-- BEGIN MUNGE: UNVERSIONED_WARNING -->
|
||
|
||
<!-- END MUNGE: UNVERSIONED_WARNING -->
|
||
|
||
<h1 id="node">Node</h1>
|
||
|
||
<p><strong>Table of Contents</strong>
|
||
<!-- BEGIN MUNGE: GENERATED_TOC --></p>
|
||
|
||
<ul>
|
||
<li><a href="#node">Node</a>
|
||
<ul>
|
||
<li><a href="#what-is-a-node">What is a node?</a></li>
|
||
<li><a href="#node-status">Node Status</a>
|
||
<ul>
|
||
<li><a href="#node-addresses">Node Addresses</a></li>
|
||
<li><a href="#node-phase">Node Phase</a></li>
|
||
<li><a href="#node-condition">Node Condition</a></li>
|
||
<li><a href="#node-capacity">Node Capacity</a></li>
|
||
<li><a href="#node-info">Node Info</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#node-management">Node Management</a>
|
||
<ul>
|
||
<li><a href="#node-controller">Node Controller</a></li>
|
||
<li><a href="#self-registration-of-nodes">Self-Registration of Nodes</a>
|
||
<ul>
|
||
<li><a href="#manual-node-administration">Manual Node Administration</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#node-capacity">Node capacity</a></li>
|
||
</ul>
|
||
</li>
|
||
<li><a href="#api-object">API Object</a></li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
|
||
<!-- END MUNGE: GENERATED_TOC -->
|
||
|
||
<h2 id="what-is-a-node">What is a node?</h2>
|
||
|
||
<p><code>Node</code> is a worker machine in Kubernetes, previously known as <code>Minion</code>. Node
|
||
may be a VM or physical machine, depending on the cluster. Each node has
|
||
the services necessary to run <a href="../user-guide/pods.html">Pods</a> and is managed by the master
|
||
components. The services on a node include docker, kubelet and network proxy. See
|
||
<a href="../design/architecture.html#the-kubernetes-node">The Kubernetes Node</a> section in the
|
||
architecture design doc for more details.</p>
|
||
|
||
<h2 id="node-status">Node Status</h2>
|
||
|
||
<p>Node status describes current status of a node. For now, there are the following
|
||
pieces of information:</p>
|
||
|
||
<h3 id="node-addresses">Node Addresses</h3>
|
||
|
||
<p>The usage of these fields varies depending on your cloud provider or bare metal configuration.</p>
|
||
|
||
<ul>
|
||
<li>
|
||
<p>HostName: Generally not used</p>
|
||
</li>
|
||
<li>
|
||
<p>ExternalIP: Generally the IP address of the node that is externally routable (available from outside the cluster)</p>
|
||
</li>
|
||
<li>
|
||
<p>InternalIP: Generally the IP address of the node that is routable only within the cluster</p>
|
||
</li>
|
||
</ul>
|
||
|
||
<h3 id="node-phase">Node Phase</h3>
|
||
|
||
<p>Node Phase is the current lifecycle phase of node, one of <code>Pending</code>,
|
||
<code>Running</code> and <code>Terminated</code>.</p>
|
||
|
||
<ul>
|
||
<li>
|
||
<p>Pending: New nodes are created in this state. A node stays in this state until it is configured.</p>
|
||
</li>
|
||
<li>
|
||
<p>Running: Node has been configured and the Kubernetes components are running</p>
|
||
</li>
|
||
<li>
|
||
<p>Terminated: Node has been removed from the cluster. It will not receive any scheduling requests,
|
||
and any running pods will be removed from the node.</p>
|
||
</li>
|
||
</ul>
|
||
|
||
<p>Node with <code>Running</code> phase is necessary but not sufficient requirement for
|
||
scheduling Pods. For a node to be considered a scheduling candidate, it
|
||
must have appropriate conditions, see below.</p>
|
||
|
||
<h3 id="node-condition">Node Condition</h3>
|
||
|
||
<p>Node Condition describes the conditions of <code>Running</code> nodes. Currently the only
|
||
node condition is Ready. The Status of this condition can be True, False, or
|
||
Unknown. True means the Kubelet is healthy and ready to accept pods.
|
||
False means the Kubelet is not healthy and is not accepting pods. Unknown
|
||
means the Node Controller, which manages node lifecycle and is responsible for
|
||
setting the Status of the condition, has not heard from the
|
||
node recently (currently 40 seconds).
|
||
Node condition is represented as a json object. For example,
|
||
the following conditions mean the node is in sane state:</p>
|
||
|
||
<div class="highlight">
|
||
<pre><code class="language-json">"conditions": [
|
||
{
|
||
"kind": "Ready",
|
||
"status": "True",
|
||
},
|
||
]
|
||
</code></pre>
|
||
</div>
|
||
|
||
<p>If the Status of the Ready condition
|
||
is Unknown or False for more than five minutes, then all of the Pods on the node are terminated by the Node Controller.</p>
|
||
|
||
<h3 id="node-capacity">Node Capacity</h3>
|
||
|
||
<p>Describes the resources available on the node: CPUs, memory and the maximum
|
||
number of pods that can be scheduled onto the node.</p>
|
||
|
||
<h3 id="node-info">Node Info</h3>
|
||
|
||
<p>General information about the node, for instance kernel version, Kubernetes version
|
||
(kubelet version, kube-proxy version), docker version (if used), OS name.
|
||
The information is gathered by Kubelet from the node.</p>
|
||
|
||
<h2 id="node-management">Node Management</h2>
|
||
|
||
<p>Unlike <a href="../user-guide/pods.html">Pods</a> and <a href="../user-guide/services.html">Services</a>, a Node is not inherently
|
||
created by Kubernetes: it is either taken from cloud providers like Google Compute Engine,
|
||
or from your pool of physical or virtual machines. What this means is that when
|
||
Kubernetes creates a node, it is really just creating an object that represents the node in its internal state.
|
||
After creation, Kubernetes will check whether the node is valid or not.
|
||
For example, if you try to create a node from the following content:</p>
|
||
|
||
<div class="highlight">
|
||
<pre><code class="language-json">{
|
||
"kind": "Node",
|
||
"apiVersion": "v1",
|
||
"metadata": {
|
||
"name": "10.240.79.157",
|
||
"labels": {
|
||
"name": "my-first-k8s-node"
|
||
}
|
||
}
|
||
}
|
||
</code></pre>
|
||
</div>
|
||
|
||
<p>Kubernetes will create a Node object internally (the representation), and
|
||
validate the node by health checking based on the <code>metadata.name</code> field: we
|
||
assume <code>metadata.name</code> can be resolved. If the node is valid, i.e. all necessary
|
||
services are running, it is eligible to run a Pod; otherwise, it will be
|
||
ignored for any cluster activity, until it becomes valid. Note that Kubernetes
|
||
will keep the object for the invalid node unless it is explicitly deleted by the client, and it will keep
|
||
checking to see if it becomes valid.</p>
|
||
|
||
<p>Currently, there are three components that interact with the Kubernetes node interface: Node Controller, Kubelet, and kubectl.</p>
|
||
|
||
<h3 id="node-controller">Node Controller</h3>
|
||
|
||
<p>Node controller is a component in Kubernetes master which manages Node
|
||
objects. It performs two major functions: cluster-wide node synchronization
|
||
and single node life-cycle management.</p>
|
||
|
||
<p>Node controller has a sync loop that creates/deletes Nodes from Kubernetes
|
||
based on all matching VM instances listed from the cloud provider. The sync period
|
||
can be controlled via flag <code>--node-sync-period</code>. If a new VM instance
|
||
gets created, Node Controller creates a representation for it. If an existing
|
||
instance gets deleted, Node Controller deletes the representation. Note however,
|
||
that Node Controller is unable to provision the node for you, i.e. it won’t install
|
||
any binary; therefore, to
|
||
join a node to a Kubernetes cluster, you as an admin need to make sure proper services are
|
||
running in the node. In the future, we plan to automatically provision some node
|
||
services.</p>
|
||
|
||
<h3 id="self-registration-of-nodes">Self-Registration of Nodes</h3>
|
||
|
||
<p>When kubelet flag <code>--register-node</code> is true (the default), the kubelet will attempt to
|
||
register itself with the API server. This is the preferred pattern, used by most distros.</p>
|
||
|
||
<p>For self-registration, the kubelet is started with the following options:
|
||
- <code>--api-servers=</code> tells the kubelet the location of the apiserver.
|
||
- <code>--kubeconfig</code> tells kubelet where to find credentials to authenticate itself to the apiserver.
|
||
- <code>--cloud-provider=</code> tells the kubelet how to talk to a cloud provider to read metadata about itself.
|
||
- <code>--register-node</code> tells the kubelet to create its own node resource.</p>
|
||
|
||
<p>Currently, any kubelet is authorized to create/modify any node resource, but in practice it only creates/modifies
|
||
its own. (In the future, we plan to limit authorization to only allow a kubelet to modify its own Node resource.)</p>
|
||
|
||
<h4 id="manual-node-administration">Manual Node Administration</h4>
|
||
|
||
<p>A cluster administrator can create and modify Node objects.</p>
|
||
|
||
<p>If the administrator wishes to create node objects manually, set kubelet flag
|
||
<code>--register-node=false</code>.</p>
|
||
|
||
<p>The administrator can modify Node resources (regardless of the setting of <code>--register-node</code>).
|
||
Modifications include setting labels on the Node, and marking it unschedulable.</p>
|
||
|
||
<p>Labels on nodes can be used in conjunction with node selectors on pods to control scheduling,
|
||
e.g. to constrain a Pod to only be eligible to run on a subset of the nodes.</p>
|
||
|
||
<p>Making a node unscheduleable will prevent new pods from being scheduled to that
|
||
node, but will not affect any existing pods on the node. This is useful as a
|
||
preparatory step before a node reboot, etc. For example, to mark a node
|
||
unschedulable, run this command:</p>
|
||
|
||
<div class="highlight">
|
||
<pre><code class="language-sh">kubectl replace nodes 10.1.2.3 --patch='{"apiVersion": "v1", "unschedulable": true}'
|
||
</code></pre>
|
||
</div>
|
||
|
||
<p>Note that pods which are created by a daemonSet controller bypass the Kubernetes scheduler,
|
||
and do not respect the unschedulable attribute on a node. The assumption is that daemons belong on
|
||
the machine even if it is being drained of applications in preparation for a reboot.</p>
|
||
|
||
<h3 id="node-capacity-1">Node capacity</h3>
|
||
|
||
<p>The capacity of the node (number of cpus and amount of memory) is part of the node resource.
|
||
Normally, nodes register themselves and report their capacity when creating the node resource. If
|
||
you are doing <a href="#manual-node-administration">manual node administration</a>, then you need to set node
|
||
capacity when adding a node.</p>
|
||
|
||
<p>The Kubernetes scheduler ensures that there are enough resources for all the pods on a node. It
|
||
checks that the sum of the limits of containers on the node is no greater than the node capacity. It
|
||
includes all containers started by kubelet, but not containers started directly by docker, nor
|
||
processes not in containers.</p>
|
||
|
||
<p>If you want to explicitly reserve resources for non-Pod processes, you can create a placeholder
|
||
pod. Use the following template:</p>
|
||
|
||
<div class="highlight">
|
||
<pre><code class="language-yaml">apiVersion: v1
|
||
kind: Pod
|
||
metadata:
|
||
name: resource-reserver
|
||
spec:
|
||
containers:
|
||
- name: sleep-forever
|
||
image: gcr.io/google_containers/pause:0.8.0
|
||
resources:
|
||
limits:
|
||
cpu: 100m
|
||
memory: 100Mi
|
||
</code></pre>
|
||
</div>
|
||
|
||
<p>Set the <code>cpu</code> and <code>memory</code> values to the amount of resources you want to reserve.
|
||
Place the file in the manifest directory (<code>--config=DIR</code> flag of kubelet). Do this
|
||
on each kubelet where you want to reserve resources.</p>
|
||
|
||
<h2 id="api-object">API Object</h2>
|
||
|
||
<p>Node is a top-level resource in the kubernetes REST API. More details about the
|
||
API object can be found at: <a href="http://kubernetes.io/v1.1/docs/api-reference/v1/definitions.html#_v1_node">Node API
|
||
object</a>.</p>
|
||
|
||
<!-- BEGIN MUNGE: IS_VERSIONED -->
|
||
<!-- TAG IS_VERSIONED -->
|
||
<!-- END MUNGE: IS_VERSIONED -->
|
||
|
||
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
|
||
<p><a href=""><img src="https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/admin/node.md?pixel" alt="Analytics" /></a>
|
||
<!-- END MUNGE: GENERATED_ANALYTICS --></p>
|
||
|
||
|
||
</div>
|
||
</section>
|
||
|
||
|
||
<footer>
|
||
<main class="light-text">
|
||
<nav>
|
||
<a href="/getting-started.html">Getting Started</a>
|
||
<a href="/docs.html">Documentation</a>
|
||
<a href="http://blog.kubernetes.io/">Blog</a>
|
||
<a href="/foobang.html">Community</a>
|
||
</nav>
|
||
<div class="social">
|
||
<a href="https://twitter.com/kubernetesio" class="twitter"><span>twitter</span></a>
|
||
<a href="https://github.com/kubernetes/kubernetes" class="github"><span>Github</span></a>
|
||
<a href="http://slack.k8s.io/" class="slack"><span>Slack</span></a>
|
||
<a href="http://stackoverflow.com/questions/tagged/kubernetes" class="stack-overflow"><span>stackoverflow</span></a>
|
||
<a href="https://groups.google.com/forum/#!forum/google-containers" class="mailing-list"><span>Mailing List</span></a>
|
||
<label for="wishField">I wish this page <input type="text" id="wishField" name="wishField" placeholder="made better textfield suggestions"></label>
|
||
</div>
|
||
<div class="center">© 2016 Kubernetes</div>
|
||
</main>
|
||
</footer>
|
||
|
||
</body>
|
||
</html>
|
||
|
||
|
||
|