<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>kubernetes Archives - Tech Chronicles</title>
	<atom:link href="http://kostacipo.stream/tag/kubernetes/feed/" rel="self" type="application/rss+xml" />
	<link>http://kostacipo.stream/tag/kubernetes/</link>
	<description>Ramblings of a Tech Dude</description>
	<lastBuildDate>Fri, 21 Feb 2020 13:13:56 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.2</generator>

<image>
	<url>https://kostacipo.stream/wp-content/uploads/2019/12/cropped-profile-32x32.jpg</url>
	<title>kubernetes Archives - Tech Chronicles</title>
	<link>http://kostacipo.stream/tag/kubernetes/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Kubernetes 101: Pods, Nodes, Containers, and Clusters</title>
		<link>http://kostacipo.stream/kubernetes-101-pods-nodes-containers-and-clusters/</link>
					<comments>http://kostacipo.stream/kubernetes-101-pods-nodes-containers-and-clusters/#respond</comments>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Fri, 21 Feb 2020 13:13:56 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[devops]]></category>
		<category><![CDATA[kubernetes]]></category>
		<guid isPermaLink="false">http://www.kostacipo.stream/?p=1753</guid>

					<description><![CDATA[<p>&#160; Kubernetes is quickly becoming the new standard for deploying and managing software in the cloud. With all the power Kubernetes provides, however, comes a steep learning curve. As a newcomer, trying to parse the&#160;official documentation&#160;can be overwhelming. There are many different pieces that make up the system, and it can be hard to tell [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/kubernetes-101-pods-nodes-containers-and-clusters/">Kubernetes 101: Pods, Nodes, Containers, and Clusters</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<p id="5e66" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm">Kubernetes is quickly becoming the new standard for deploying and managing software in the cloud. With all the power Kubernetes provides, however, comes a steep learning curve. As a newcomer, trying to parse the&nbsp;<a class="cq fw gv gw gx gy" href="https://kubernetes.io/docs/concepts/" target="_blank" rel="noopener nofollow noreferrer">official documentation&nbsp;</a>can be overwhelming. There are many different pieces that make up the system, and it can be hard to tell which ones are relevant for your use case. This blog post will provide a simplified view of Kubernetes, but it will attempt to give a high-level overview of the most important components and how they fit together.</p>
<p id="2c24" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm">First, lets look at how hardware is represented</p>
<h1 id="baff" class="gz ha du at as hb dw hc dy hd he hf hg hh hi hj hk">Hardware</h1>
<h2 id="6b4c" class="hl ha du at as hb hm hn ho hp hq hr hs ht hu hv hw">Nodes</h2>
<p id="34b1" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm"><img decoding="async" src="https://miro.medium.com/max/6930/1*uyMd-QxYaOk_APwtuScsOg.png">A&nbsp;<a class="cq fw gv gw gx gy" href="https://kubernetes.io/docs/concepts/architecture/nodes/" target="_blank" rel="noopener nofollow noreferrer">node</a>&nbsp;is the smallest unit of computing hardware in Kubernetes. It is a representation of a single machine in your cluster. In most production systems, a node will likely be either a physical machine in a datacenter, or virtual machine hosted on a cloud provider like&nbsp;<a class="cq fw gv gw gx gy" href="https://cloud.google.com/" target="_blank" rel="noopener nofollow noreferrer">Google Cloud Platform</a>. Don’t let conventions limit you, however; in theory, you can make a node out of&nbsp;almost&nbsp;anything.</p>
<p id="dea0" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm">Thinking of a machine as a “node” allows us to insert a layer of abstraction. Now, instead of worrying about the unique characteristics of any individual machine, we can instead simply view each machine as a set of CPU and RAM resources that can be utilized. In this way, any machine can substitute any other machine in a Kubernetes cluster.</p>
<h2 id="8eb5" class="hl ha du at as hb hm hn ho hp hq hr hs ht hu hv hw">The Cluster</h2>
<p id="60fa" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm"><img decoding="async" src="https://miro.medium.com/max/6540/1*KoMzLETQeN-c63x7xzSKPw.png">Although working with individual nodes can be useful, it’s not the Kubernetes way. In general, you should think about the cluster as a whole, instead of worrying about the state of individual nodes.</p>
<p id="82aa" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm">In Kubernetes, nodes pool together their resources to form a more powerful machine. When you deploy programs onto the cluster, it intelligently handles distributing work to the individual nodes for you. If any nodes are added or removed, the cluster will shift around work as necessary. It shouldn’t matter to the program, or the programmer, which individual machines are actually running the code.</p>
<p id="ed84" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm">If this kind of hivemind-like system reminds you of the&nbsp;<a class="cq fw gv gw gx gy" href="http://memory-alpha.wikia.com/wiki/Borg" target="_blank" rel="noopener nofollow noreferrer">Borg from Star Trek</a>, you’re not alone; “Borg” is the name for the&nbsp;<a class="cq fw gv gw gx gy" href="http://blog.kubernetes.io/2015/04/borg-predecessor-to-kubernetes.html" target="_blank" rel="noopener nofollow noreferrer">internal Google project</a>&nbsp;Kubernetes was based on.</p>
<h2 id="bfa3" class="hl ha du at as hb hm hn ho hp hq hr hs ht hu hv hw">Persistent Volumes</h2>
<p id="3b4c" class="gh gi du at gj b gk iw gm ix go iy gq iz gs ja gu dm">Because programs running on your cluster aren’t guaranteed to run on a specific node, data can’t be saved to any arbitrary place in the file system. If a program tries to save data to a file for later, but is then relocated onto a new node, the file will no longer be where the program expects it to be. For this reason, the traditional local storage associated to each node is treated as a temporary cache to hold programs, but any data saved locally can not be expected to persist.</p>
<p id="6784" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm"><img decoding="async" src="https://miro.medium.com/max/6874/1*kF57zE9a5YCzhILHdmuRvQ.png">To store data permanently, Kubernetes uses&nbsp;<a class="cq fw gv gw gx gy" href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" target="_blank" rel="noopener nofollow noreferrer">Persistent Volumes</a>. While the CPU and RAM resources of all nodes are effectively pooled and managed by the cluster, persistent file storage is not. Instead, local or cloud drives can be attached to the cluster as a Persistent Volume. This can be thought of as plugging an external hard drive in to the cluster. Persistent Volumes provide a file system that can be mounted to the cluster, without being associated with any particular node.</p>
<h1 id="9af2" class="gz ha du at as hb dw hc dy hd he hf hg hh hi hj hk">Software</h1>
<h2 id="8ca8" class="hl ha du at as hb hm hn ho hp hq hr hs ht hu hv hw">Containers</h2>
<p id="0f71" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm"><img decoding="async" src="https://miro.medium.com/max/10000/1*ILinzzMdnD5oQ6Tu2bfBgQ.png">Programs running on Kubernetes are packaged as&nbsp;<a class="cq fw gv gw gx gy" href="https://www.docker.com/what-container" target="_blank" rel="noopener nofollow noreferrer">Linux containers</a>. Containers are a widely accepted standard, so there are already many&nbsp;<a class="cq fw gv gw gx gy" href="https://hub.docker.com/explore/" target="_blank" rel="noopener nofollow noreferrer">pre-built images</a>&nbsp;that can be deployed on Kubernetes.</p>
<p id="6c91" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm">Containerization allows you to create self-contained Linux execution environments. Any program and all its dependencies can be bundled up into a single file and then shared on the internet. Anyone can download the container and deploy it on their infrastructure with very little setup required. Creating a container can be done programmatically, allowing powerful&nbsp;CI and CD&nbsp;pipelines to be formed.</p>
<p id="b764" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm">Multiple programs can be added into a single container, but you should limit yourself to one process per container if at all possible. It’s better to have many small containers than one large one. If each container has a tight focus, updates are easier to deploy and issues are easier to diagnose.</p>
<h2 id="2bd6" class="hl ha du at as hb hm hn ho hp hq hr hs ht hu hv hw">Pods</h2>
<p id="efba" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm"><img decoding="async" src="https://miro.medium.com/max/12000/1*8OD0MgDNu3Csq0tGpS8Obg.png">Unlike other systems you may have used in the past, Kubernetes doesn’t run containers directly; instead it wraps one or more containers into a higher-level structure called a&nbsp;<a class="cq fw gv gw gx gy" href="https://kubernetes.io/docs/concepts/workloads/pods/pod/" target="_blank" rel="noopener nofollow noreferrer">pod</a>. Any containers in the same pod will share the same resources and local network. Containers can easily communicate with other containers in the same pod as though they were on the same machine while maintaining a degree of isolation from others.</p>
<p id="64c4" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm">Pods are used as the unit of replication in Kubernetes. If your application becomes too popular and a single pod instance can’t carry the load, Kubernetes can be configured to deploy new replicas of your pod to the cluster as necessary. Even when not under heavy load, it is standard to have multiple copies of a pod running at any time in a production system to allow load balancing and failure resistance.</p>
<p id="3fb7" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm">Pods can hold multiple containers, but you should limit yourself when possible. Because pods are scaled up and down as a unit, all containers in a pod must scale together, regardless of their individual needs. This leads to wasted resources and an expensive bill. To resolve this, pods should remain as small as possible, typically holding only a main process and its tightly-coupled helper containers (these helper containers are typically referred to as “side-cars”).</p>
<h2 id="f5c6" class="hl ha du at as hb hm hn ho hp hq hr hs ht hu hv hw">Deployments</h2>
<p id="54b8" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm"><img decoding="async" src="https://miro.medium.com/max/8068/1*iTAVk3glVD95hb-X3HiCKg.png">Although pods are the basic unit of computation in Kubernetes, they are not typically directly launched on a cluster. Instead, pods are usually managed by one more layer of abstraction: the&nbsp;<a class="cq fw gv gw gx gy" href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" target="_blank" rel="noopener nofollow noreferrer">deployment</a>.</p>
<p id="aeef" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm">A deployment’s primary purpose is to declare how many replicas of a pod should be running at a time. When a deployment is added to the cluster, it will automatically spin up the requested number of pods, and then monitor them. If a pod dies, the deployment will automatically re-create it.</p>
<p id="2bb1" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm">Using a deployment, you don’t have to deal with pods manually. You can just declare the desired state of the system, and it will be managed for you automatically.</p>
<h2 id="4a14" class="hl ha du at as hb hm hn ho hp hq hr hs ht hu hv hw">Ingress</h2>
<p id="85af" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm"><img decoding="async" src="https://miro.medium.com/max/6564/1*tBJ-_g4Mk5OkfzLEHrRsRw.png">Using the concepts described above, you can create a cluster of nodes, and launch deployments of pods onto the cluster. There is one last problem to solve, however: allowing external traffic to your application.</p>
<p id="d52a" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm">By default, Kubernetes provides isolation between pods and the outside world. If you want to communicate with a service running in a pod, you have to open up a channel for communication. This is referred to as ingress.</p>
<p id="727e" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm">There are multiple ways to add ingress to your cluster. The most common ways are by adding either an&nbsp;<a class="cq fw gv gw gx gy" href="https://kubernetes.io/docs/concepts/services-networking/ingress/" target="_blank" rel="noopener nofollow noreferrer">Ingress</a>&nbsp;controller, or a&nbsp;<a class="cq fw gv gw gx gy" href="https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/" target="_blank" rel="noopener nofollow noreferrer">LoadBalancer</a>. The exact tradeoffs between these two options are out of scope for this post, but you must be aware that ingress is something you need to handle before you can experiment with Kubernetes.</p>
<h2 id="ef85" class="hl ha du at as hb hm hn ho hp hq hr hs ht hu hv hw">What’s Next</h2>
<p id="3a4d" class="gh gi du at gj b gk iw gm ix go iy gq iz gs ja gu dm">What’s described above is an oversimplified version of Kubernetes, but it should give you the basics you need to start experimenting. </p>
<p id="55de" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm">To experiment with Kubernetes locally,&nbsp;<a class="cq fw gv gw gx gy" href="https://kubernetes.io/docs/getting-started-guides/minikube/" target="_blank" rel="noopener nofollow noreferrer">Minikube</a> will create a virtual cluster on your personal hardware. If you’re ready to try out a cloud service, <a class="cq fw gv gw gx gy" href="https://cloud.google.com/kubernetes-engine/" target="_blank" rel="noopener nofollow noreferrer">Google Kubernetes Engine</a>&nbsp;has a collection of&nbsp;<a class="cq fw gv gw gx gy" href="https://cloud.google.com/kubernetes-engine/docs/tutorials/" target="_blank" rel="noopener nofollow noreferrer">tutorials</a>&nbsp;to get you started.</p>
<p id="9358" class="gh gi du at gj b gk gl gm gn go gp gq gr gs gt gu dm">If you are new to the world of containers and web infrastructure, I suggest reading up on the<a class="cq fw gv gw gx gy" href="https://12factor.net/" target="_blank" rel="noopener nofollow noreferrer">&nbsp;12 Factor App methodology</a>. This describes some of the best practices to keep in mind when designing software to run in an environment like Kubernetes.</p>
<p>The post <a href="http://kostacipo.stream/kubernetes-101-pods-nodes-containers-and-clusters/">Kubernetes 101: Pods, Nodes, Containers, and Clusters</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://kostacipo.stream/kubernetes-101-pods-nodes-containers-and-clusters/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How To Setup Grafana On Kubernetes</title>
		<link>http://kostacipo.stream/how-to-setup-grafana-on-kubernetes/</link>
		
		<dc:creator><![CDATA[Majordomo]]></dc:creator>
		<pubDate>Tue, 26 Nov 2019 10:19:47 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[grafana]]></category>
		<category><![CDATA[kubernetes]]></category>
		<guid isPermaLink="false">http://www.kostacipo.stream/?p=1374</guid>

					<description><![CDATA[<p>&#160; Grafana is an open-source lightweight dashboard tool. It can be integrated with many data sources like Prometheus, AWS cloud watch, Stackdriver, etc. This tutorial explains the Grafana setup on a Kubernetes cluster. You can create dashboards on Grafana for all the Kubernetes metrics through prometheus. Lets get started with the setup. Step 1: Create [&#8230;]</p>
<p>The post <a href="http://kostacipo.stream/how-to-setup-grafana-on-kubernetes/">How To Setup Grafana On Kubernetes</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>&nbsp;</p>
<p>Grafana is an open-source lightweight dashboard tool. It can be integrated with many data sources like Prometheus, AWS cloud watch, Stackdriver, etc.</p>
<p>This tutorial explains the Grafana setup on a Kubernetes cluster. You can create dashboards on Grafana for all the Kubernetes metrics through prometheus.</p>
<p>Lets get started with the setup.</p>
<p><strong>Step 1:</strong> Create file named <code>grafana-datasource-config.yaml</code></p>
<div id="crayon-5ddcf8c93636a260095640" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">vi grafana-datasource-config.yaml</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf8c93636a260095640-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf8c93636a260095640-1" class="crayon-line"><span class="crayon-r">vi</span> <span class="crayon-v">grafana</span><span class="crayon-o">&#8211;</span><span class="crayon-v">datasource</span><span class="crayon-o">&#8211;</span><span class="crayon-v">config</span><span class="crayon-e">.yaml</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Copy the following contents.</p>
<blockquote class="wp-block-quote"><p><strong>Note:</strong> The following datasource configuration is for prometheus. If you have more data sources, you can add more data sources with different YAMLs under data section.</p></blockquote>
<div id="crayon-5ddcf8c936372637115472" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">apiVersion: v1&lt;br /&gt;<br />
kind: ConfigMap&lt;br /&gt;<br />
metadata:&lt;br /&gt;<br />
  name: grafana-datasources&lt;br /&gt;<br />
  namespace: monitoring&lt;br /&gt;<br />
data:&lt;br /&gt;<br />
  prometheus.yaml: |-&lt;br /&gt;<br />
    {&lt;br /&gt;<br />
        &#8220;apiVersion&#8221;: 1,&lt;br /&gt;<br />
        &#8220;datasources&#8221;: [&lt;br /&gt;<br />
            {&lt;br /&gt;<br />
               &#8220;access&#8221;:&#8221;proxy&#8221;,&lt;br /&gt;<br />
                &#8220;editable&#8221;: true,&lt;br /&gt;<br />
                &#8220;name&#8221;: &#8220;prometheus&#8221;,&lt;br /&gt;<br />
                &#8220;orgId&#8221;: 1,&lt;br /&gt;<br />
                &#8220;type&#8221;: &#8220;prometheus&#8221;,&lt;br /&gt;<br />
                &#8220;url&#8221;: &#8220;http://prometheus-service.monitoring.svc:8080&#8221;,&lt;br /&gt;<br />
                &#8220;version&#8221;: 1&lt;br /&gt;<br />
            }&lt;br /&gt;<br />
        ]&lt;br /&gt;<br />
    }</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf8c936372637115472-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936372637115472-2">2</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936372637115472-3">3</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936372637115472-4">4</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936372637115472-5">5</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936372637115472-6">6</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936372637115472-7">7</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936372637115472-8">8</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936372637115472-9">9</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936372637115472-10">10</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936372637115472-11">11</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936372637115472-12">12</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936372637115472-13">13</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936372637115472-14">14</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936372637115472-15">15</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936372637115472-16">16</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936372637115472-17">17</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936372637115472-18">18</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936372637115472-19">19</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936372637115472-20">20</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936372637115472-21">21</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf8c936372637115472-1" class="crayon-line"><span class="crayon-v">apiVersion</span><span class="crayon-o">:</span> <span class="crayon-e">v1</span></div>
<div id="crayon-5ddcf8c936372637115472-2" class="crayon-line crayon-striped-line"><span class="crayon-v">kind</span><span class="crayon-o">:</span> <span class="crayon-e">ConfigMap</span></div>
<div id="crayon-5ddcf8c936372637115472-3" class="crayon-line"><span class="crayon-v">metadata</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c936372637115472-4" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-v">name</span><span class="crayon-o">:</span> <span class="crayon-v">grafana</span><span class="crayon-o">&#8211;</span><span class="crayon-e">datasources</span></div>
<div id="crayon-5ddcf8c936372637115472-5" class="crayon-line"><span class="crayon-e">&nbsp;&nbsp;</span><span class="crayon-t">namespace</span><span class="crayon-o">:</span> <span class="crayon-e">monitoring</span></div>
<div id="crayon-5ddcf8c936372637115472-6" class="crayon-line crayon-striped-line"><span class="crayon-v">data</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c936372637115472-7" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-v">prometheus</span><span class="crayon-e">.yaml</span><span class="crayon-o">:</span> <span class="crayon-o">|</span><span class="crayon-o">&#8211;</span></div>
<div id="crayon-5ddcf8c936372637115472-8" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-sy">{</span></div>
<div id="crayon-5ddcf8c936372637115472-9" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-s">&#8220;apiVersion&#8221;</span><span class="crayon-o">:</span> <span class="crayon-cn">1</span><span class="crayon-sy">,</span></div>
<div id="crayon-5ddcf8c936372637115472-10" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-s">&#8220;datasources&#8221;</span><span class="crayon-o">:</span> <span class="crayon-sy">[</span></div>
<div id="crayon-5ddcf8c936372637115472-11" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-sy">{</span></div>
<div id="crayon-5ddcf8c936372637115472-12" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span class="crayon-s">&#8220;access&#8221;</span><span class="crayon-o">:</span><span class="crayon-s">&#8220;proxy&#8221;</span><span class="crayon-sy">,</span></div>
<div id="crayon-5ddcf8c936372637115472-13" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-s">&#8220;editable&#8221;</span><span class="crayon-o">:</span> <span class="crayon-t">true</span><span class="crayon-sy">,</span></div>
<div id="crayon-5ddcf8c936372637115472-14" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-s">&#8220;name&#8221;</span><span class="crayon-o">:</span> <span class="crayon-s">&#8220;prometheus&#8221;</span><span class="crayon-sy">,</span></div>
<div id="crayon-5ddcf8c936372637115472-15" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-s">&#8220;orgId&#8221;</span><span class="crayon-o">:</span> <span class="crayon-cn">1</span><span class="crayon-sy">,</span></div>
<div id="crayon-5ddcf8c936372637115472-16" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-s">&#8220;type&#8221;</span><span class="crayon-o">:</span> <span class="crayon-s">&#8220;prometheus&#8221;</span><span class="crayon-sy">,</span></div>
<div id="crayon-5ddcf8c936372637115472-17" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-s">&#8220;url&#8221;</span><span class="crayon-o">:</span> <span class="crayon-s">&#8220;http://prometheus-service.monitoring.svc:8080&#8221;</span><span class="crayon-sy">,</span></div>
<div id="crayon-5ddcf8c936372637115472-18" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-s">&#8220;version&#8221;</span><span class="crayon-o">:</span> <span class="crayon-cn">1</span></div>
<div id="crayon-5ddcf8c936372637115472-19" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-sy">}</span></div>
<div id="crayon-5ddcf8c936372637115472-20" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-sy">]</span></div>
<div id="crayon-5ddcf8c936372637115472-21" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-sy">}</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 2:</strong> Create the configmap using the following command.</p>
<div id="crayon-5ddcf8c936375958298718" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">kubectl create -f grafana-datasource-config.yaml</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf8c936375958298718-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf8c936375958298718-1" class="crayon-line"><span class="crayon-e">kubectl </span><span class="crayon-v">create</span> <span class="crayon-o">&#8211;</span><span class="crayon-i">f</span> <span class="crayon-v">grafana</span><span class="crayon-o">&#8211;</span><span class="crayon-v">datasource</span><span class="crayon-o">&#8211;</span><span class="crayon-v">config</span><span class="crayon-e">.yaml</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 3: </strong>Create a file named <code>deployment.yaml</code></p>
<div id="crayon-5ddcf8c936377083564107" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">vi deployment.yaml</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf8c936377083564107-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf8c936377083564107-1" class="crayon-line"><span class="crayon-r">vi</span> <span class="crayon-v">deployment</span><span class="crayon-e">.yaml</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Copy the following contents</p>
<div id="crayon-5ddcf8c93637a536782978" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">apiVersion: apps/v1&lt;br /&gt;<br />
kind: Deployment&lt;br /&gt;<br />
metadata:&lt;br /&gt;<br />
  name: grafana&lt;br /&gt;<br />
  namespace: monitoring&lt;br /&gt;<br />
spec:&lt;br /&gt;<br />
  replicas: 1&lt;br /&gt;<br />
  selector:&lt;br /&gt;<br />
    matchLabels:&lt;br /&gt;<br />
      app: grafana&lt;br /&gt;<br />
  template:&lt;br /&gt;<br />
    metadata:&lt;br /&gt;<br />
      name: grafana&lt;br /&gt;<br />
      labels:&lt;br /&gt;<br />
        app: grafana&lt;br /&gt;<br />
    spec:&lt;br /&gt;<br />
      containers:&lt;br /&gt;<br />
      &#8211; name: grafana&lt;br /&gt;<br />
        image: grafana/grafana:latest&lt;br /&gt;<br />
        ports:&lt;br /&gt;<br />
        &#8211; name: grafana&lt;br /&gt;<br />
          containerPort: 3000&lt;br /&gt;<br />
        resources:&lt;br /&gt;<br />
          limits:&lt;br /&gt;<br />
            memory: &#8220;2Gi&#8221;&lt;br /&gt;<br />
            cpu: &#8220;1000m&#8221;&lt;br /&gt;<br />
          requests:&lt;br /&gt;<br />
            memory: &#8220;1Gi&#8221;&lt;br /&gt;<br />
            cpu: &#8220;500m&#8221;&lt;br /&gt;<br />
        volumeMounts:&lt;br /&gt;<br />
          &#8211; mountPath: /var/lib/grafana&lt;br /&gt;<br />
            name: grafana-storage&lt;br /&gt;<br />
          &#8211; mountPath: /etc/grafana/provisioning/datasources&lt;br /&gt;<br />
            name: grafana-datasources&lt;br /&gt;<br />
            readOnly: false&lt;br /&gt;<br />
      volumes:&lt;br /&gt;<br />
        &#8211; name: grafana-storage&lt;br /&gt;<br />
          emptyDir: {}&lt;br /&gt;<br />
        &#8211; name: grafana-datasources&lt;br /&gt;<br />
          configMap:&lt;br /&gt;<br />
              defaultMode: 420&lt;br /&gt;<br />
              name: grafana-datasources</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-2">2</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-3">3</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-4">4</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-5">5</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-6">6</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-7">7</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-8">8</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-9">9</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-10">10</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-11">11</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-12">12</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-13">13</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-14">14</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-15">15</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-16">16</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-17">17</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-18">18</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-19">19</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-20">20</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-21">21</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-22">22</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-23">23</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-24">24</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-25">25</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-26">26</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-27">27</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-28">28</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-29">29</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-30">30</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-31">31</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-32">32</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-33">33</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-34">34</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-35">35</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-36">36</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-37">37</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-38">38</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-39">39</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-40">40</div>
<div class="crayon-num" data-line="crayon-5ddcf8c93637a536782978-41">41</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c93637a536782978-42">42</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf8c93637a536782978-1" class="crayon-line"><span class="crayon-v">apiVersion</span><span class="crayon-o">:</span> <span class="crayon-v">apps</span><span class="crayon-o">/</span><span class="crayon-e">v1</span></div>
<div id="crayon-5ddcf8c93637a536782978-2" class="crayon-line crayon-striped-line"><span class="crayon-v">kind</span><span class="crayon-o">:</span> <span class="crayon-e">Deployment</span></div>
<div id="crayon-5ddcf8c93637a536782978-3" class="crayon-line"><span class="crayon-v">metadata</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-4" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-v">name</span><span class="crayon-o">:</span> <span class="crayon-e">grafana</span></div>
<div id="crayon-5ddcf8c93637a536782978-5" class="crayon-line"><span class="crayon-e">&nbsp;&nbsp;</span><span class="crayon-t">namespace</span><span class="crayon-o">:</span> <span class="crayon-e">monitoring</span></div>
<div id="crayon-5ddcf8c93637a536782978-6" class="crayon-line crayon-striped-line"><span class="crayon-v">spec</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-7" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-v">replicas</span><span class="crayon-o">:</span> <span class="crayon-cn">1</span></div>
<div id="crayon-5ddcf8c93637a536782978-8" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-v">selector</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-9" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">matchLabels</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-10" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">app</span><span class="crayon-o">:</span> <span class="crayon-e">grafana</span></div>
<div id="crayon-5ddcf8c93637a536782978-11" class="crayon-line"><span class="crayon-e">&nbsp;&nbsp;</span><span class="crayon-v">template</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-12" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">metadata</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-13" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">name</span><span class="crayon-o">:</span> <span class="crayon-e">grafana</span></div>
<div id="crayon-5ddcf8c93637a536782978-14" class="crayon-line crayon-striped-line"><span class="crayon-e">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">labels</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-15" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">app</span><span class="crayon-o">:</span> <span class="crayon-e">grafana</span></div>
<div id="crayon-5ddcf8c93637a536782978-16" class="crayon-line crayon-striped-line"><span class="crayon-e">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">spec</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-17" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">containers</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-18" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-o">&#8211;</span> <span class="crayon-v">name</span><span class="crayon-o">:</span> <span class="crayon-e">grafana</span></div>
<div id="crayon-5ddcf8c93637a536782978-19" class="crayon-line"><span class="crayon-e">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">image</span><span class="crayon-o">:</span> <span class="crayon-v">grafana</span><span class="crayon-o">/</span><span class="crayon-v">grafana</span><span class="crayon-o">:</span><span class="crayon-e">latest</span></div>
<div id="crayon-5ddcf8c93637a536782978-20" class="crayon-line crayon-striped-line"><span class="crayon-e">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">ports</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-21" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-o">&#8211;</span> <span class="crayon-v">name</span><span class="crayon-o">:</span> <span class="crayon-e">grafana</span></div>
<div id="crayon-5ddcf8c93637a536782978-22" class="crayon-line crayon-striped-line"><span class="crayon-e">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">containerPort</span><span class="crayon-o">:</span> <span class="crayon-cn">3000</span></div>
<div id="crayon-5ddcf8c93637a536782978-23" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">resources</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-24" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">limits</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-25" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">memory</span><span class="crayon-o">:</span> <span class="crayon-s">&#8220;2Gi&#8221;</span></div>
<div id="crayon-5ddcf8c93637a536782978-26" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">cpu</span><span class="crayon-o">:</span> <span class="crayon-s">&#8220;1000m&#8221;</span></div>
<div id="crayon-5ddcf8c93637a536782978-27" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">requests</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-28" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">memory</span><span class="crayon-o">:</span> <span class="crayon-s">&#8220;1Gi&#8221;</span></div>
<div id="crayon-5ddcf8c93637a536782978-29" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">cpu</span><span class="crayon-o">:</span> <span class="crayon-s">&#8220;500m&#8221;</span></div>
<div id="crayon-5ddcf8c93637a536782978-30" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">volumeMounts</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-31" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-o">&#8211;</span> <span class="crayon-v">mountPath</span><span class="crayon-o">:</span> <span class="crayon-o">/</span><span class="crayon-t">var</span><span class="crayon-o">/</span><span class="crayon-v">lib</span><span class="crayon-o">/</span><span class="crayon-e">grafana</span></div>
<div id="crayon-5ddcf8c93637a536782978-32" class="crayon-line crayon-striped-line"><span class="crayon-e">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">name</span><span class="crayon-o">:</span> <span class="crayon-v">grafana</span><span class="crayon-o">&#8211;</span><span class="crayon-v">storage</span></div>
<div id="crayon-5ddcf8c93637a536782978-33" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-o">&#8211;</span> <span class="crayon-v">mountPath</span><span class="crayon-o">:</span> <span class="crayon-o">/</span><span class="crayon-v">etc</span><span class="crayon-o">/</span><span class="crayon-v">grafana</span><span class="crayon-o">/</span><span class="crayon-v">provisioning</span><span class="crayon-o">/</span><span class="crayon-e">datasources</span></div>
<div id="crayon-5ddcf8c93637a536782978-34" class="crayon-line crayon-striped-line"><span class="crayon-e">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">name</span><span class="crayon-o">:</span> <span class="crayon-v">grafana</span><span class="crayon-o">&#8211;</span><span class="crayon-e">datasources</span></div>
<div id="crayon-5ddcf8c93637a536782978-35" class="crayon-line"><span class="crayon-e">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">readOnly</span><span class="crayon-o">:</span> <span class="crayon-t">false</span></div>
<div id="crayon-5ddcf8c93637a536782978-36" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">volumes</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-37" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-o">&#8211;</span> <span class="crayon-v">name</span><span class="crayon-o">:</span> <span class="crayon-v">grafana</span><span class="crayon-o">&#8211;</span><span class="crayon-e">storage</span></div>
<div id="crayon-5ddcf8c93637a536782978-38" class="crayon-line crayon-striped-line"><span class="crayon-e">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">emptyDir</span><span class="crayon-o">:</span> <span class="crayon-sy">{</span><span class="crayon-sy">}</span></div>
<div id="crayon-5ddcf8c93637a536782978-39" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-o">&#8211;</span> <span class="crayon-v">name</span><span class="crayon-o">:</span> <span class="crayon-v">grafana</span><span class="crayon-o">&#8211;</span><span class="crayon-e">datasources</span></div>
<div id="crayon-5ddcf8c93637a536782978-40" class="crayon-line crayon-striped-line"><span class="crayon-e">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">configMap</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c93637a536782978-41" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">defaultMode</span><span class="crayon-o">:</span> <span class="crayon-cn">420</span></div>
<div id="crayon-5ddcf8c93637a536782978-42" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">name</span><span class="crayon-o">:</span> <span class="crayon-v">grafana</span><span class="crayon-o">&#8211;</span><span class="crayon-v">datasources</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 4:</strong> Create the deployment</p>
<div id="crayon-5ddcf8c93637c348737385" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">kubectl create -f deployment.yaml</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf8c93637c348737385-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf8c93637c348737385-1" class="crayon-line"><span class="crayon-e">kubectl </span><span class="crayon-v">create</span> <span class="crayon-o">&#8211;</span><span class="crayon-i">f</span> <span class="crayon-v">deployment</span><span class="crayon-e">.yaml</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 5: </strong>Create a service file named <code>service.yaml</code></p>
<div id="crayon-5ddcf8c93637e272299395" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">vi service.yaml</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf8c93637e272299395-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf8c93637e272299395-1" class="crayon-line"><span class="crayon-r">vi</span> <span class="crayon-v">service</span><span class="crayon-e">.yaml</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Copy the following contents. This will expose Grafana on <code>NodePort</code> 32000. You can also expose it <a href="https://devopscube.com/setup-ingress-kubernetes-nginx-controller/" target="_blank" rel="noreferrer noopener" aria-label="using ingress (opens in a new tab)">using ingress </a>or a Loadbalancer based on your requirement.</p>
<div id="crayon-5ddcf8c936380960905825" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">apiVersion: v1&lt;br /&gt;<br />
kind: Service&lt;br /&gt;<br />
metadata:&lt;br /&gt;<br />
  name: grafana&lt;br /&gt;<br />
  namespace: monitoring&lt;br /&gt;<br />
  annotations:&lt;br /&gt;<br />
      prometheus.io/scrape: &#8216;true'&lt;br /&gt;<br />
      prometheus.io/port:   &#8216;3000&#8217;&lt;br /&gt;<br />
spec:&lt;br /&gt;<br />
  selector:&lt;br /&gt;<br />
    app: grafana&lt;br /&gt;<br />
  type: NodePort&lt;br /&gt;<br />
  ports:&lt;br /&gt;<br />
    &#8211; port: 3000&lt;br /&gt;<br />
      targetPort: 3000&lt;br /&gt;<br />
      nodePort: 32000</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf8c936380960905825-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936380960905825-2">2</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936380960905825-3">3</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936380960905825-4">4</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936380960905825-5">5</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936380960905825-6">6</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936380960905825-7">7</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936380960905825-8">8</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936380960905825-9">9</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936380960905825-10">10</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936380960905825-11">11</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936380960905825-12">12</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936380960905825-13">13</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936380960905825-14">14</div>
<div class="crayon-num" data-line="crayon-5ddcf8c936380960905825-15">15</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936380960905825-16">16</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf8c936380960905825-1" class="crayon-line"><span class="crayon-v">apiVersion</span><span class="crayon-o">:</span> <span class="crayon-e">v1</span></div>
<div id="crayon-5ddcf8c936380960905825-2" class="crayon-line crayon-striped-line"><span class="crayon-v">kind</span><span class="crayon-o">:</span> <span class="crayon-e">Service</span></div>
<div id="crayon-5ddcf8c936380960905825-3" class="crayon-line"><span class="crayon-v">metadata</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c936380960905825-4" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-v">name</span><span class="crayon-o">:</span> <span class="crayon-e">grafana</span></div>
<div id="crayon-5ddcf8c936380960905825-5" class="crayon-line"><span class="crayon-e">&nbsp;&nbsp;</span><span class="crayon-t">namespace</span><span class="crayon-o">:</span> <span class="crayon-e">monitoring</span></div>
<div id="crayon-5ddcf8c936380960905825-6" class="crayon-line crayon-striped-line"><span class="crayon-e">&nbsp;&nbsp;</span><span class="crayon-v">annotations</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c936380960905825-7" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">prometheus</span><span class="crayon-e">.io</span><span class="crayon-o">/</span><span class="crayon-v">scrape</span><span class="crayon-o">:</span> <span class="crayon-s">&#8216;true&#8217;</span></div>
<div id="crayon-5ddcf8c936380960905825-8" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">prometheus</span><span class="crayon-e">.io</span><span class="crayon-o">/</span><span class="crayon-v">port</span><span class="crayon-o">:</span><span class="crayon-h">&nbsp;&nbsp; </span><span class="crayon-s">&#8216;3000&#8217;</span></div>
<div id="crayon-5ddcf8c936380960905825-9" class="crayon-line"><span class="crayon-v">spec</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c936380960905825-10" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;</span><span class="crayon-v">selector</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c936380960905825-11" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">app</span><span class="crayon-o">:</span> <span class="crayon-e">grafana</span></div>
<div id="crayon-5ddcf8c936380960905825-12" class="crayon-line crayon-striped-line"><span class="crayon-e">&nbsp;&nbsp;</span><span class="crayon-r">type</span><span class="crayon-o">:</span> <span class="crayon-e">NodePort&nbsp;&nbsp;</span></div>
<div id="crayon-5ddcf8c936380960905825-13" class="crayon-line"><span class="crayon-e">&nbsp;&nbsp;</span><span class="crayon-v">ports</span><span class="crayon-o">:</span></div>
<div id="crayon-5ddcf8c936380960905825-14" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-o">&#8211;</span> <span class="crayon-v">port</span><span class="crayon-o">:</span> <span class="crayon-cn">3000</span></div>
<div id="crayon-5ddcf8c936380960905825-15" class="crayon-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">targetPort</span><span class="crayon-o">:</span> <span class="crayon-cn">3000</span></div>
<div id="crayon-5ddcf8c936380960905825-16" class="crayon-line crayon-striped-line"><span class="crayon-h">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="crayon-v">nodePort</span><span class="crayon-o">:</span> <span class="crayon-cn">32000</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p><strong>Step 6:</strong> Create the service.</p>
<div id="crayon-5ddcf8c936382626031286" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">kubectl create -f service.yaml</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf8c936382626031286-1">1</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf8c936382626031286-1" class="crayon-line"><span class="crayon-e">kubectl </span><span class="crayon-v">create</span> <span class="crayon-o">&#8211;</span><span class="crayon-i">f</span> <span class="crayon-v">service</span><span class="crayon-e">.yaml</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Now you should be able to access the Grafana dashboard using any node IP on port 3200. Use the following default username and password to login. Once you login with default credentials, it will prompt to change the default password.</p>
<div id="crayon-5ddcf8c936383190727083" class="crayon-syntax crayon-theme-prism-like crayon-font-monaco crayon-os-pc print-yes notranslate crayon-wrapped" data-settings=" minimize scroll-mouseover wrap">
<div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" readonly="readonly" data-settings="dblclick">User: admin&lt;br /&gt;<br />
Pass: admin</textarea></div>
<div class="crayon-main">
<table class="crayon-table">
<tbody>
<tr class="crayon-row">
<td class="crayon-nums " data-settings="hide">
<div class="crayon-nums-content">
<div class="crayon-num" data-line="crayon-5ddcf8c936383190727083-1">1</div>
<div class="crayon-num crayon-striped-num" data-line="crayon-5ddcf8c936383190727083-2">2</div>
</div>
</td>
<td class="crayon-code">
<div class="crayon-pre">
<div id="crayon-5ddcf8c936383190727083-1" class="crayon-line"><span class="crayon-v">User</span><span class="crayon-o">:</span> <span class="crayon-e">admin</span></div>
<div id="crayon-5ddcf8c936383190727083-2" class="crayon-line crayon-striped-line"><span class="crayon-v">Pass</span><span class="crayon-o">:</span> <span class="crayon-v">admin</span></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<h3>Setup Kubernetes Dashbaords</h3>
<p>There are many prebuilt Grafana templates available for various data sources. You can <a href="https://grafana.com/grafana/dashboards?search=kubernetes" target="_blank" rel="noreferrer noopener" aria-label="check out the templates here (opens in a new tab)">check out the templates from here</a>.</p>
<p>Setting up a dashboard from a template is pretty easy. Follow the steps given below to setup a dashboard to monitor kubernetes deployments.</p>
<p><strong>Step 1:</strong> Get the template ID from <a href="https://grafana.com/grafana/dashboards/8588" target="_blank" rel="noreferrer noopener" aria-label="grafana public template. (opens in a new tab)">grafana public template.</a> as shown below.</p>
<figure class="wp-block-image"><img decoding="async" class="wp-image-4728" src="https://devopscube.com/wp-content/uploads/2019/11/image-1024x472.png" sizes="(max-width: 1024px) 100vw, 1024px" srcset="https://devopscube.com/wp-content/uploads/2019/11/image-1024x472.png 1024w, https://devopscube.com/wp-content/uploads/2019/11/image-300x138.png 300w, https://devopscube.com/wp-content/uploads/2019/11/image-768x354.png 768w, https://devopscube.com/wp-content/uploads/2019/11/image.png 1277w" alt=""></figure>
<p><strong>Step 2: </strong>Head over to grafana and select the import option.</p>
<figure class="wp-block-image"><img decoding="async" class="wp-image-4729" src="https://devopscube.com/wp-content/uploads/2019/11/image-1.png" sizes="(max-width: 856px) 100vw, 856px" srcset="https://devopscube.com/wp-content/uploads/2019/11/image-1.png 856w, https://devopscube.com/wp-content/uploads/2019/11/image-1-300x113.png 300w, https://devopscube.com/wp-content/uploads/2019/11/image-1-768x289.png 768w" alt=""></figure>
<p><strong>Step 3:</strong> Enter the dashboard ID you got it step 1</p>
<figure class="wp-block-image"><img decoding="async" class="wp-image-4730" src="https://devopscube.com/wp-content/uploads/2019/11/image-2-1024x494.png" sizes="(max-width: 1024px) 100vw, 1024px" srcset="https://devopscube.com/wp-content/uploads/2019/11/image-2-1024x494.png 1024w, https://devopscube.com/wp-content/uploads/2019/11/image-2-300x145.png 300w, https://devopscube.com/wp-content/uploads/2019/11/image-2-768x370.png 768w, https://devopscube.com/wp-content/uploads/2019/11/image-2.png 1191w" alt=""></figure>
<p><strong>Step 4:</strong> Grafana will automatically fetch the template from Grafana website. You can change the values as shown in the image below and click import.</p>
<figure class="wp-block-image"><img decoding="async" class="wp-image-4731" src="https://devopscube.com/wp-content/uploads/2019/11/image-3-1024x470.png" sizes="(max-width: 1024px) 100vw, 1024px" srcset="https://devopscube.com/wp-content/uploads/2019/11/image-3-1024x470.png 1024w, https://devopscube.com/wp-content/uploads/2019/11/image-3-300x138.png 300w, https://devopscube.com/wp-content/uploads/2019/11/image-3-768x353.png 768w, https://devopscube.com/wp-content/uploads/2019/11/image-3.png 1211w" alt=""></figure>
<p>You should see the dashboard immediately.</p>
<figure class="wp-block-image alignwide"><img decoding="async" class="wp-image-4732" src="https://devopscube.com/wp-content/uploads/2019/11/image-4-1024x324.png" sizes="(max-width: 1024px) 100vw, 1024px" srcset="https://devopscube.com/wp-content/uploads/2019/11/image-4-1024x324.png 1024w, https://devopscube.com/wp-content/uploads/2019/11/image-4-300x95.png 300w, https://devopscube.com/wp-content/uploads/2019/11/image-4-768x243.png 768w, https://devopscube.com/wp-content/uploads/2019/11/image-4.png 1349w" alt=""></figure>
<h2>Conclusion</h2>
<p>Grafana is a very powerful tool when it comes to dashboards. It is used by many organisations to monitor their workloads.</p>
<p>The post <a href="http://kostacipo.stream/how-to-setup-grafana-on-kubernetes/">How To Setup Grafana On Kubernetes</a> appeared first on <a href="http://kostacipo.stream">Tech Chronicles</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
