<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged acl</title>
<link>https://coderlegion.com/tag/acl</link>
<description>Powered by Question2Answer</description>
<item>
<title>How to Secure Nomad?</title>
<link>https://coderlegion.com/16115/how-to-secure-nomad</link>
<description>
&lt;p&gt;Hello, I'm Ganesh. I'm building &lt;em&gt;git-lrc&lt;/em&gt;, an AI code reviewer that runs on every commit. It is free, unlimited, and source-available on Github. &lt;a href=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;Star Us&lt;/a&gt; to help devs discover the project. Do give it a try and share your feedback for improving the product.&lt;/p&gt;

&lt;p&gt;Nomad is a flexible workload orchestrator that enables an organization to easily deploy and manage any containerized or legacy application using a single, unified workflow. &lt;/p&gt;

&lt;p&gt;Nomad can run a diverse workload of Docker, non-containerized, microservice, and batch applications.&lt;/p&gt;

&lt;p&gt;With powerful features, it becomes very important to secure the Nomad cluster.&lt;/p&gt;

&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F278yl2e31bd4t34mn94y.png&quot; class=&quot;article-body-image-wrapper&quot;&gt;&lt;img src=&quot;https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F278yl2e31bd4t34mn94y.png&quot; alt=&quot;&quot; width=&quot;302&quot; height=&quot;167&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If anyone gets access to the cluster, it can lead to a big security risk.&lt;/p&gt;

&lt;p&gt;In this article I will explain how to secure the Nomad cluster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enable ACL in Nomad
&lt;/h2&gt;

&lt;p&gt;ACL is a feature in Nomad that allows you to control access to the cluster.&lt;/p&gt;

&lt;p&gt;It is a way to implement the principle of least privilege, which means that users should only have access to the resources that they need to do their job.&lt;/p&gt;

&lt;p&gt;To enable ACL in Nomad, you need to add the following lines to your Nomad server configuration file:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/etc/nomad.d/nomad.hcl&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight hcl&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;acl&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;enabled&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kc&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once it is enabled, you need to restart the Nomad server to apply the changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;sudo &lt;/span&gt;systemctl restart nomad
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Generate Security Token for Nomad
&lt;/h2&gt;

&lt;p&gt;Once ACL is enabled, you need to generate a security token for Nomad.&lt;/p&gt;

&lt;p&gt;You need to bootstrap the ACL system to generate the initial security token.&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;nomad acl bootstrap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will return something like this&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;Accessor ID  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &amp;lt;ACCESSOR_ID&amp;gt;
Secret ID    &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &amp;lt;SECRET_ID&amp;gt;
Name         &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; Bootstrap Token
Type         &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; management
Global       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;true
&lt;/span&gt;Create Time  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &amp;lt;timestamp&amp;gt;
Expiry Time  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &amp;lt;none&amp;gt;
Create Index &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &amp;lt;create_index&amp;gt;
Modify Index &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &amp;lt;modify_index&amp;gt;
Policies     &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; n/a
Roles        &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; n/a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Copy and  to a secure location. You will need this token to access the Nomad UI and API.&lt;/p&gt;

&lt;p&gt;Once this is done if we try to access the Nomad UI or API without the token, it will return 403 Forbidden.&lt;/p&gt;

&lt;p&gt;Which means ACL is enabled and working.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create Policy for Users
&lt;/h2&gt;

&lt;p&gt;As it is recommended not to use bootstrap token directly, we should create policies for users based on their roles.&lt;/p&gt;

&lt;p&gt;Based on requirements you can create policies for users.&lt;/p&gt;

&lt;p&gt;For example, let's create a policy for a user who can only read the jobs and node information.&lt;/p&gt;

&lt;p&gt;Readonly access policy for a user.&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight hcl&quot;&gt;&lt;code&gt;&lt;span class=&quot;nx&quot;&gt;namespace&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;default&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;policy&lt;/span&gt;       &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;read&quot;&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;capabilities&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;list-jobs&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;read-job&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;agent&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;policy&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;read&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;operator&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;policy&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;read&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;quota&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;policy&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;read&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;node&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;policy&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;read&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;host_volume&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;*&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;policy&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;read&quot;&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will make sure only read access for the users. This may be given to monitoring tools to monitor the cluster.&lt;/p&gt;

&lt;p&gt;Create this file in &lt;code&gt;./nomad/policies/readonly.hcl&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Once done create a token for this policy.&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;nomad acl policy apply &lt;span class=&quot;nt&quot;&gt;-description&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Readonly policy&quot;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;readonly&lt;/span&gt; ./nomad/policies/readonly.hcl
Successfully wrote &lt;span class=&quot;s2&quot;&gt;&quot;readonly&quot;&lt;/span&gt; ACL policy!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create Keys for Selected Policy&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;nomad acl token create &lt;span class=&quot;nt&quot;&gt;-name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Read Only Token&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-policy&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;readonly&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will return&lt;br&gt;
&lt;/p&gt;

&lt;div class=&quot;highlight js-code-highlight&quot;&gt;
&lt;pre class=&quot;highlight shell&quot;&gt;&lt;code&gt;Accessor ID  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &amp;lt;ACCESSOR_ID&amp;gt;
Secret ID    &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &amp;lt;SECRET_ID&amp;gt;
Name         &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; Read Only Token
Type         &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; client
Global       &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;false
&lt;/span&gt;Create Time  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &amp;lt;timestamp&amp;gt;
Expiry Time  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &amp;lt;none&amp;gt;
Create Index &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &amp;lt;create_index&amp;gt;
Modify Index &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &amp;lt;modify_index&amp;gt;
Policies     &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;readonly&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;

Roles
&amp;lt;none&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now with this token we can access the Nomad UI and API with read only access.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Nomad is very powerful tool for orchestrating containers and other workloads. &lt;br&gt;
But if we leave it unsecured it can be a security risk. &lt;br&gt;
It is very important to secure the Nomad cluster.&lt;/p&gt;

&lt;p&gt;So, I hope you understood how to secure the Nomad cluster. &lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;&lt;img src=&quot;https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fabn6nl3iehrohehnxgje.png&quot; alt=&quot;git-lrc&quot; width=&quot;800&quot; height=&quot;373&quot;&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback or contributors are welcome! It&amp;rsquo;s online, source-available, and ready for anyone to use. &lt;br&gt;
&amp;#11088; Star it on GitHub: &lt;a href=&quot;https://github.com/HexmosTech/git-lrc&quot; rel=&quot;noopener noreferrer nofollow&quot;&gt;https://github.com/HexmosTech/git-lrc&lt;/a&gt;&lt;/p&gt;


</description>
<category>Other</category>
<guid isPermaLink="true">https://coderlegion.com/16115/how-to-secure-nomad</guid>
<pubDate>Fri, 01 May 2026 03:45:38 +0000</pubDate>
</item>
</channel>
</rss>