{"id":61,"date":"2024-10-11T10:44:52","date_gmt":"2024-10-11T15:44:52","guid":{"rendered":"https:\/\/www.eeinc.us\/homelab\/?p=61"},"modified":"2024-10-11T10:50:23","modified_gmt":"2024-10-11T15:50:23","slug":"deploying-grafana-in-rootless-podman","status":"publish","type":"post","link":"https:\/\/homelab.eeinc.us\/index.php\/2024\/10\/11\/deploying-grafana-in-rootless-podman\/","title":{"rendered":"Deploying Grafana in Rootless Podman"},"content":{"rendered":"\n<p>Per the Grafana <a href=\"https:\/\/grafana.com\/oss\/grafana\/\">web-site<\/a>, Grafana OSS lets you visualize your data and optimize your performance.  You can easily collect, correlate, and visualize data with beautiful dashboards using Grafana \u2014 the open source data visualization and monitoring solution that drives informed decisions, enhances system performance, and streamlines troubleshooting.<\/p>\n\n\n\n<p>The Grafana web-site provides instructions for deploying Grafana in a container on Docker, but nothing for deploying on Podman.  These instructions are how I was finally able to successfully deploy running rootless Podman.<\/p>\n\n\n\n<p><strong>Note:<\/strong> I know, I know, you really should login in as a user account and use sudo for running most of these commands.  However, since this is a lab, I prefer to take a shortcut.  You do you.<\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-110a7263ad62a332fe1bc2bb9b06328d\"><strong>Create the user, user directory, and assign a password<\/strong><\/p>\n\n\n\n<p><code>useradd -c \"Grafana container account\" -m grafana<br>password grafana &lt;-- type your password<br>loginctl enable-linger grafana<\/code><\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-f6e2cf3919ca758692d09d19eb3c6e3d\"><strong>Login, locate and download the container image<\/strong><\/p>\n\n\n\n<p><code>machinectl shell grafana@<br>podman search grafana<br>podman pull grafana\/grafana:latest<br>podman create --name grafana docker.io\/grafana\/grafana:latest<\/code><\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-cca76f010412491629756cddf6f80178\"><strong>Create the directories to save your data and populate the configuration file<\/strong><\/p>\n\n\n\n<p><code>mkdir -p \/home\/grafana\/container\/var\/lib\/grafana<br>mkdir -p \/home\/grafana\/container\/etc\/grafana<br>wget -P \/home\/grafana\/container\/etc\/grafana -O grafana.ini \/<\/code><br><code>https:\/\/github.com\/grafana\/grafana\/blob\/main\/conf\/sample.ini<\/code><\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-9355eb4ef3ece5a506abb1602ff7119e\"><strong>Create the systemd service directory and file<\/strong><\/p>\n\n\n\n<p><code>mkdir -p \/home\/grafana\/.config\/systemd\/user<br>cd \/home\/grafana\/.config\/systemd\/user<br>podman generate systemd --files --new --name --start-timeout=60 grafana<\/code><\/p>\n\n\n\n<p><strong>Note:<\/strong> yes, I know that <code>podman generate systemd<\/code> is deprecated in favor of quadlets.  As soon as podman releases a <code>generate quadlet<\/code> command, or I figure out how to perform a 1:1 mapping of systemd to quadlet files, I will migrate to using quadlets.  Until then, if it ain&#8217;t broken don&#8217;t fix it.<\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-83bdccb9dc84de5f5a487061db4d09d6\"><strong>Edit the systemd service file<\/strong><\/p>\n\n\n\n<p><code>vim container-grafana.service<\/code><\/p>\n\n\n\n<p>The updated file should look like the following:<\/p>\n\n\n\n<p><code>ExecStart=\/usr\/bin\/podman run \\<br>--cidfile=%t\/%n.ctr-id \\<br>--cgroups=no-conmon \\<br>--label \"io.containers.autoupdate=registry\" \\<br>--publish 3000:3000\/tcp \\<br>--volume \/home\/grafana\/container\/var\/lib\/grafana:\/var\/lib\/grafana:Z,U \\<br>--volume \/home\/grafana\/container\/etc\/grafana:\/etc\/grafana:Z,U \\<br>--hostname yourhostname.yourdomain \\<br>--rm \\<br>--sdnotify=conmon \\<br>--detach \\<br>--replace \\<br>--name grafana \\<br>docker.io\/grafana\/grafana<\/code><\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-b7c28e82084a66e445c73c5abd9e3389\"><strong>Configure the service to start automatically<\/strong><\/p>\n\n\n\n<p><code>systemctl --user daemon-reload<br>systemctl --user enable --now container-grafana<br>systemctl --user status container-grafana<\/code><\/p>\n\n\n\n<p class=\"has-vivid-cyan-blue-color has-text-color has-link-color wp-elements-b9cb54ea58581a182a6b027aa0297c97\"><strong>Verify the service started and perform initial login \/ configuration<\/strong><\/p>\n\n\n\n<p><code>podman ps -f name=grafana<\/code><br>You should see output similar to the following:<br><code>0c002eddb710 docker.io\/grafana\/grafana:latest 2 hours ago Up 2 hours 0.0.0.0:3000-&gt;3000\/tcp grafana<\/code><\/p>\n\n\n\n<p>Open a browser to <br><code>http:\/\/hostname:3000<\/code><br>The default credentials are<br><code>ID=admin, PW=admin<\/code><\/p>\n\n\n\n<p>That&#8217;s it. Feel free to leave a comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Per the Grafana web-site, Grafana OSS lets you visualize your data and optimize your performance. You can easily collect, correlate, and visualize data with beautiful dashboards using Grafana \u2014 the open source data visualization and monitoring solution that drives informed decisions, enhances system performance, and streamlines troubleshooting. The Grafana web-site provides instructions for deploying Grafana<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-61","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/posts\/61","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/comments?post=61"}],"version-history":[{"count":4,"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/posts\/61\/revisions"}],"predecessor-version":[{"id":66,"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/posts\/61\/revisions\/66"}],"wp:attachment":[{"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/media?parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/categories?post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/homelab.eeinc.us\/index.php\/wp-json\/wp\/v2\/tags?post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}