<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: dwelch-spike</title>
    <description>The latest articles on Forem by dwelch-spike (@dwelchspike).</description>
    <link>https://forem.com/dwelchspike</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1117867%2F6cf2cccb-d6e9-4b60-8a7c-072a1aea0ee2.png</url>
      <title>Forem: dwelch-spike</title>
      <link>https://forem.com/dwelchspike</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/dwelchspike"/>
    <language>en</language>
    <item>
      <title>Unlock new workflows with YAML based config for Aerospike.</title>
      <dc:creator>dwelch-spike</dc:creator>
      <pubDate>Thu, 17 Aug 2023 02:07:46 +0000</pubDate>
      <link>https://forem.com/aerospike/unlock-new-workflows-with-yaml-based-config-for-aerospike-m5h</link>
      <guid>https://forem.com/aerospike/unlock-new-workflows-with-yaml-based-config-for-aerospike-m5h</guid>
      <description>&lt;p&gt;Aerospike's configuration format can be difficult to learn and lacks the ecosystem of more standard configuration formats.&lt;br&gt;
Using the &lt;a href="https://docs.aerospike.com/tools/asconfig"&gt;asconfig&lt;/a&gt; tool, new in &lt;a href="https://download.aerospike.com/download/tools/notes.html#8.3.0"&gt;Aerospike tools 8.3.0&lt;/a&gt;, you can write an Aerospike configuration in a standard YAML format with schema validation and IDE suggestions.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In this article we:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Setup an IDE for Aerospike configuration suggestions.&lt;/li&gt;
&lt;li&gt;Write an Aerospike configuration file in YAML.&lt;/li&gt;
&lt;li&gt;Run an Aerospike cluster using the YAML configuration.&lt;/li&gt;
&lt;li&gt;Convert an existing Aerospike configuration to YAML.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  IDE Setup
&lt;/h2&gt;

&lt;p&gt;Many IDEs support YAML schema files.  We use VS Code in this example.&lt;/p&gt;

&lt;p&gt;The JSON schema files used by &lt;code&gt;asconfig&lt;/code&gt;, and in this example, are stored in the &lt;a href="https://github.com/aerospike/schemas/tree/main"&gt;Aerospike schemas Github repository&lt;/a&gt;. To write your own YAML configuration file, clone the repository and use the following example below for VS Code.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install the Red Hat YAML VS Code extension.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tMZNGKYS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://developer-hub.s3.us-west-1.amazonaws.com/2122467609/install-yaml-extension_1689122848860.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tMZNGKYS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://developer-hub.s3.us-west-1.amazonaws.com/2122467609/install-yaml-extension_1689122848860.gif" alt="gif" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In VS Code, go to Code-&amp;gt;Preferences-&amp;gt;Settings. Search for "YAML schema" and click "edit in settings.json".&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QRJcvhJC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://developer-hub.s3.us-west-1.amazonaws.com/2122467609/schema-json-settings_1689122946560.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QRJcvhJC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://developer-hub.s3.us-west-1.amazonaws.com/2122467609/schema-json-settings_1689122946560.gif" alt="gif" width="800" height="539"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use the following example to add a yaml.schemas mapping to your settings.json. Replace "/absolute/path/to/schemas/repo" with the path to your local clone of the Aerospike schemas repo.
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="s2"&gt;"yaml.schemas"&lt;/span&gt;: &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"/absolute/path/to/schemas/repo/json/aerospike/6.3.0.json"&lt;/span&gt;: &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/*aerospike.yaml"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This associates all files ending in "aerospike.yaml" with the 6.3.0 Aerospike YAML schema.&lt;/p&gt;

&lt;p&gt;Now you can use the code suggestions from the 6.3.0 Aerospike YAML schema to write your YAML configuration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U0tr4PvR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://developer-hub.s3.us-west-1.amazonaws.com/2122467609/paste-settings-see-suggestions_1689123001708.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U0tr4PvR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://developer-hub.s3.us-west-1.amazonaws.com/2122467609/paste-settings-see-suggestions_1689123001708.gif" alt="gif" width="800" height="370"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Write Aerospike Configuration in YAML
&lt;/h2&gt;

&lt;p&gt;Now that your IDE is using the Aerospike YAML schemas, you can write a yaml configuration with suggestions.&lt;br&gt;
Aerospike configuration sections like 'service' will be suggested and possible fields and default values will be inserted.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5zbRJee8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://developer-hub.s3.us-west-1.amazonaws.com/2122467609/suggestions-snippet_1689123049467.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5zbRJee8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://developer-hub.s3.us-west-1.amazonaws.com/2122467609/suggestions-snippet_1689123049467.gif" alt="gif" width="800" height="499"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;YAML Schema Suggestions!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Invalid fields and incorrect values will be highlighted in red.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ykmftULv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://developer-hub.s3.us-west-1.amazonaws.com/2122467609/suggestions-errors_1689123145868.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ykmftULv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://developer-hub.s3.us-west-1.amazonaws.com/2122467609/suggestions-errors_1689123145868.gif" alt="gif" width="800" height="370"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;YAML Schema error highlighting.&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Convert an existing Aerospike Configuration to YAML
&lt;/h2&gt;

&lt;p&gt;Another way to get started with configuring Aerospike in yaml is to use the asconfig tool to convert&lt;br&gt;
an existing configuration file. Make sure to supply the version of the Aerospike database the &lt;br&gt;
configuration will be used with via the -a or --aerospike-version option.&lt;/p&gt;

&lt;p&gt;Here we convert the default &lt;a href="https://docs.aerospike.com/server/operations/configure"&gt;Aerospike configuration to YAML&lt;/a&gt; .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;asconfig convert --aerospike-version 6.3.0 aerospike.conf
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;output&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;logging:
    - any: info
      name: /var/log/aerospike/aerospike.log
namespaces:
    - memory-size: 4294967296
      name: test
      replication-factor: 2
      storage-engine:
        type: memory
    - memory-size: 4294967296
      name: bar
      replication-factor: 2
      storage-engine:
        type: memory
network:
    fabric:
        port: 3001
    heartbeat:
        interval: 150
        mode: multicast
        multicast-groups:
            - 239.1.99.222
        port: 9918
        timeout: 10
    info:
        port: 3003
    service:
        addresses:
            - any
        port: 3000
service:
    group: root
    pidfile: /var/run/aerospike/asd.pid
    proto-fd-max: 15000
    user: root

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Launch an Aerospike cluster with YAML configuration
&lt;/h2&gt;

&lt;p&gt;Launching an Aerospike cluster in Docker using the YAML configuration is easy with asconfig.&lt;/p&gt;

&lt;p&gt;The Aerospike server only understands configuration files in its .conf format for now, so we need to use asconfig to&lt;br&gt;
convert the YAML file we wrote into Aerospike .conf format.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="go"&gt;asconfig convert -a 6.3.0 aerospike.yaml -o aerospike.conf
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we map the converted configuration file into an Aerospike Docker container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;docker run -d -v $&lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;PWD&lt;span class="o"&gt;}&lt;/span&gt;:/opt/aerospike/etc/ &lt;span class="nt"&gt;--name&lt;/span&gt; aerospike &lt;span class="nt"&gt;-p&lt;/span&gt; 3000-3002:3000-3002 aerospike:ce-6.3.0.5 &lt;span class="nt"&gt;--config-file&lt;/span&gt; /opt/aerospike/etc/aerospike.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we have an Aerospike node running in Docker using the configuration file we wrote in YAML.&lt;/p&gt;

&lt;p&gt;Putting it all together, the one line command to convert the YAML configuration and run Aerospike using it is below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight console"&gt;&lt;code&gt;&lt;span class="gp"&gt;asconfig convert -a 6.3.0 aerospike.yaml -o aerospike.conf;&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PWD&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;:/opt/aerospike/etc/ &lt;span class="nt"&gt;--name&lt;/span&gt; aerospike &lt;span class="nt"&gt;-p&lt;/span&gt; 3000-3002:3000-3002 aerospike:ce-6.3.0.5 &lt;span class="nt"&gt;--config-file&lt;/span&gt; /opt/aerospike/etc/aerospike.conf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Docker portion of the command launches the Aerospike server container, maps the current working directory as a volume, and points it to the custom configuration file that we converted.&lt;/p&gt;

&lt;h2&gt;
  
  
  Learn more about Aerospike Observability &amp;amp; Management
&lt;/h2&gt;

&lt;p&gt;Learn how Aerospike is adopting open standards like YAML, Open Telemetry and how to find clarity in complex systems in our &lt;a href="https://aerospike.zoom.us/webinar/register/5116909188905/WN_ZZLrBxBcT3WyJZTEXSwtIw#/registration"&gt;upcoming Webinar - September 6th, 2023&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  More Information
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://docs.aerospike.com/tools/asconfig"&gt;Asconfig documentation&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/aerospike/asconfig"&gt;Asconfig Github repository&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aerospike.com/server/operations/configure"&gt;Aerospike configuration documentation&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://hub.docker.com/_/aerospike"&gt;Aerospike Docker images&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.aerospike.com/reference/configuration"&gt;Aerospike configuration reference&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>yaml</category>
      <category>yml</category>
      <category>asconfig</category>
      <category>aerospike</category>
    </item>
  </channel>
</rss>
