<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Brent Eiler on Medium]]></title>
        <description><![CDATA[Stories by Brent Eiler on Medium]]></description>
        <link>https://medium.com/@brent.m.eiler?source=rss-d96a116a80ab------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*VkywMYXEA-AepVq_</url>
            <title>Stories by Brent Eiler on Medium</title>
            <link>https://medium.com/@brent.m.eiler?source=rss-d96a116a80ab------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 18:57:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@brent.m.eiler/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automating Certificates for the Akamai Cloud Nodebalancer]]></title>
            <link>https://medium.com/@brent.m.eiler/automating-certificates-for-the-akamai-cloud-nodebalancer-2f85c053e56e?source=rss-d96a116a80ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f85c053e56e</guid>
            <category><![CDATA[tls-certificate]]></category>
            <category><![CDATA[linode]]></category>
            <category><![CDATA[akamai-connected-cloud]]></category>
            <category><![CDATA[akamai]]></category>
            <category><![CDATA[nodebalancer]]></category>
            <dc:creator><![CDATA[Brent Eiler]]></dc:creator>
            <pubDate>Mon, 01 Jul 2024 19:02:40 GMT</pubDate>
            <atom:updated>2024-07-01T19:02:40.775Z</atom:updated>
            <content:encoded><![CDATA[<p>A couple weeks back I was posed a question about the Load Balancer function of our cloud — the Nodebalancer. The question seemed simple on the surface, but unfortunately, there was not a good or straight forward answer. The question? ‘Can I automate certificates for my Nodebalancer?’ And the answer is: Of course you <em>can</em>… But unfortunately there is no easy button that will allow you to plug your domain in and have those certs created/renewed for you and applied to your Nodebalancer, as there is with a service like the AWS ACM. So I decided to tackle the problem in this tutorial by automating certificate rotation on Nodebalancers using Certbot’s DNS validation and a script to update renewed certificates. To complete this tutorial you will need the following:</p><ul><li>A load balanced HTTP service in the Akamai Connected Cloud</li><li>A registered domain or sub-domain running in Linode Domains</li><li>(Optional) A secured Linode Nanode running in a VPC with access to the Internet — This Linode does not need to be in the same region as your service.</li></ul><p>Your eventual architecture will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*Q5qVAEOaOytQb0HKOmy2cw.png" /></figure><p>Let’s build!</p><h4>Automating Cert Renewals for an Existing Nodebalancer Service</h4><p>Since you have already built the systems, have set up the load balancing and DNS, the structure is already created and this should be a simple process.</p><ol><li>Validate and prepare.</li><li>Install and run certbot with the Linode DNS validation script on a single node if it is not already running.</li><li>Modify the Certbot service for auto renewal by changing the command to run our new script in succession to the auto renewal command.</li></ol><h4>Step 1</h4><p>The first thing you will want to do is validate your infrastructure and document some items:</p><ol><li>Which single Linode will be designated as your certificate moderator (The Linode that will run your Certbot instance)? Certbot should run on just a single instance, although, if you are super paranoid, you can run it on more than one and it should not hurt anything. This node does not have to be part of the load balanced solution since this will use DNS based validation. And for security purposes, should not. In this tutorial we will do certificate management on a small dedicated Ubuntu instance within a VPC.</li></ol><p>2. Do you have your Linode Personal Access Token? You can use the Web UI as well, as we will actually be creating 2 limited purpose tokens for this process.</p><p>If you do not have a token created, go into the Akamai Cloud portal at <a href="https://www.linode.com/">https://www.linode.com</a> and create the two new limited purpose tokens. Click on your username in the top right corner and click ‘API Tokens.’ Give your first token a name, I use NB_Updater, select an expiration, again I use a limited time of 30 days. Then give it Read Write access to only Nodebalancers. Repeat this process to create the second token. This time, name your token DNS_Updater and give it only Domains Read Write permissions. Document these two tokens.</p><p>Alternatively, if you already have a personal access token with Account level Read/Write privileges, you can run this command from your host instance to to generate the limited rights tokens from the API. Just adjust the variable TOKEN to whatever you are using to access your existing Personal Access Token.</p><pre>apt update -qq &amp;&amp; apt install jq -qqy<br>exp_date=$(date -u -d &quot;30 days&quot; +&quot;%Y-%m-%dT%H:%M:%S&quot;)<br>NB_TOKEN=$(curl --request POST \<br>  https://api.linode.com/v4/profile/tokens \<br>  -H &#39;accept: application/json&#39; \<br>  -H &quot;authorization: Bearer $TOKEN&quot; \<br>  -H &#39;content-type: application/json&#39; \<br>  --data &#39;{<br>    &quot;label&quot;: &quot;NB-Updater-&#39;&quot;$exp_date&quot;&#39;&quot;,<br>    &quot;expiry&quot;: &quot;&#39;&quot;$exp_date&quot;&#39;&quot;,<br>    &quot;scopes&quot;: &quot;nodebalancers:read_write&quot;<br>}&#39; | jq -r .token)<br>echo $NB_TOKEN<br>DNS_TOKEN=$(curl --request POST \<br>  https://api.linode.com/v4/profile/tokens \<br>  -H &#39;accept: application/json&#39; \<br>  -H &quot;authorization: Bearer $TOKEN&quot; \<br>  -H &#39;content-type: application/json&#39; \<br>  --data &#39;{<br>    &quot;label&quot;: &quot;DNS-Updater-&#39;&quot;$exp_date&quot;&#39;&quot;,<br>    &quot;expiry&quot;: &quot;&#39;&quot;$exp_date&quot;&#39;&quot;,<br>    &quot;scopes&quot;: &quot;domains:read_write&quot;<br>}&#39; | jq -r .token)<br>echo $DNS_TOKEN</pre><p>3. Do you have a load balanced service in Nodebalancer using HTTP? Hopefully this already exists and we can quickly grab the ID. You will need to document the Nodebalancer ID you are using. To do so, you can use the Web UI, Click Nodebalancers and then click on the Nodebalancer that holds your HTTPS (or HTTP) configuration. The Nodebalancer ID is the numeric indicator in the resulting URL that should now be in your address bar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*tVBtsSWGN-va9hY-6wet1w.png" /></figure><p>Conversely, if you know the IP Address of your Nodebalancer, and have used the API to create your new tokens, you can use one of your newly created tokens to pull this ID from the API using this command:</p><pre>curl --request GET https://api.linode.com/v4/nodebalancers -H ‘accept: application/json’ -H “authorization: Bearer $NB_TOKEN” -H ‘content-type: application/json’ | jq -r &#39;.data[] | select (.ipv4 == “1.1.1.1”) | .id&#39;</pre><p>Of course you will want to replace the IP Address with a real one from your Nodebalancer.</p><p>Last, make sure you have a DNS name tied to the IP Address of your load balancer. If you have not done this yet, do so now.</p><p>Now that you have created your token, and documented your Nodebalancer ID, you should be ready to roll with either modifying your existing Certbot implementation or creating a new one.</p><h4>Step 2 — Implement Certbot.</h4><p>If you already have a Certbot implementation running, and it is already auto-renewing the certificate using the DNS validation. Skip to step 3. If not, continue on. You will need your DNS_TOKEN and the fully qualified domain name you have set up in Linode DNS (and pointing to your Nodebalancer IP Address) to complete these tasks.</p><p>Step 1 of this process is to install Certbot and some related packages. This is very simple on Linux based systems using apt or your favorite package manager.</p><p>sudo apt update -qq &amp;&amp; apt install -qqy certbot python3 python3-certbot-dns-linode jq</p><p>Next you will configure your Certbot install with your Linode credentials to allow Certbot to create the necessary txt records for DNS based validation. This is a simple process. Create the following file <em>~/.secrets/certbot/linode.ini </em>with sudo mkdir -p ~/.secrets/certbot and then sudo vi ~/.secrets/certbot/linode.ini<em> </em>and populate it with information like this:</p><pre>dns_linode_key = yourDNS_Tokenshouldbeinputhere...<br>dns_linode_version = 4</pre><p>chmod the file as 600 using chmod 600 ~/.secrets/certbot/linode.ini The last step here is to kickoff the initial Certbot run for the DNS name tied to your Nodebalancer. If you have previously deployed Certbot on this host, you will do this by issuing the following command (replacing the last argument with your fqdn):</p><pre>certbot certonly --dns-linode --dns-linode-credentials ~/.secrets/certbot/linode.ini --dns-linode-propagation 90 -d that.fqdn.tied.to.your.nodebalancer</pre><p>If this is a new Certbot implementation, you will need a few more arguments:</p><pre>certbot certonly --agree-tos --email cert.admin@email.com --non-interactive --quiet --dns-linode --dns-linode-credentials ~/.secrets/certbot/linode.ini --dns-linode-propagation 90 -d that.fqdn.tied.to.your.nodebalancer</pre><p>This will keep Certbot from bugging you for information. The email address is very important to be an accurate one, as this is where you will get notifications of potential problems (like certificate expirations). And again, you will also replace the last argument with your fqdn.</p><h4>Step 3— Download the Script and Modify the Certbot Service</h4><p>Now that you have a functional Certbot DNS validation implementation, you can simply download the script, prepare your host and replace the variables in the script for execution. If you have an HTTPS based configuration tied to your Nodebalancer ID, this script will continually update the certificate with the latest renewed cert from Certbot. If you only have an HTTP based configuration, this script will replace that HTTP configuration with an HTTPS configuration, terminating the TLS on the Nodebalancer while continuing to send traffic from your Nodebalancer back to your nodes using regular HTTP. Once replaced, it will only update the certificate as needed.</p><pre>apt update -qq &amp;&amp; apt install -qqy jq<br>git clone https://github.com/eilerb1011/nb_cert<br>chmod +x nb_cert/nb-cert.sh<br>chmod +x nb_cert/post-install.sh<br>cp nb_cert/nb-cert.sh /etc<br>vi /etc/nb-cert.sh<br>  #!/bin/bash<br>  #####################<br>  #if https_config exists, update with new cert<br>  #else if http exists, update to https<br>  #if neither, exit<br>  # Fully Qualified Domain Name (FQDN) ie www.mydomain.com - how it looks on your cert<br>  FQDN=&quot;&quot;<br>  # Linode API details - the limited access token you created<br>  TOKEN=&quot;&quot;<br>  # The Nodebalancer ID you pulled from the Web UI or API<br>  NB_ID=&quot;&quot;</pre><p>Then run the scripts cloned from Github</p><pre>/etc/nb-cert.sh<br>/nb_cert/post-install.sh</pre><p>post-install.sh will add the nb-cert.sh to be executed after each run of certbot -q renew. This will ensure you will always have the most up to date certificate on your Nodebalancer.</p><p>To clean things up, remember to rotate these tokens every 30 days. You can use the same API calls outlined above to create the new tokens and then script the replacement of those tokens in your Linode credentials file and the nb_cert.sh.</p><p>And voila! You should now have TLS certificate rotation on your Nodebalancer and a load balanced HTTPS service.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f85c053e56e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Akamai Object Storage as a Backup Target for TrueNAS]]></title>
            <link>https://medium.com/@brent.m.eiler/using-akamai-object-storage-as-a-backup-target-for-truenas-eb862db2b3bd?source=rss-d96a116a80ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/eb862db2b3bd</guid>
            <category><![CDATA[object-storage]]></category>
            <category><![CDATA[backup]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[akamai-connected-cloud]]></category>
            <category><![CDATA[truenas]]></category>
            <dc:creator><![CDATA[Brent Eiler]]></dc:creator>
            <pubDate>Fri, 15 Dec 2023 09:37:53 GMT</pubDate>
            <atom:updated>2023-12-15T09:37:53.181Z</atom:updated>
            <content:encoded><![CDATA[<p>If you have viewed my other TrueNAS and Linode write ups, you may see the value in having Encrypted Shared File Storage in an Open Source Cloud. And Maybe you also see the value in having offsite backup of your data, if for nothing more than compliance reasons. But maybe you only need one Cloud region at a time serving active data. For just this reason, you can securely leverage a less expensive Linode Object Storage bucket to back up your massive amounts of file storage data.</p><p>If you have not followed along with my previous tutorials on shared file storage for Linodes, don’t worry, you can catch up quickly. For the purpose of this exercise, building <a href="https://medium.com/@brent.m.eiler/shared-storage-in-akamai-connected-cloud-140fb597b15a">this tutorial</a>, will give you a base TrueNAS environment from which to work. In the end you will have an architecture that looks like this. Once you finish the previous tutorial, move on to step 1 below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/533/1*vt6P6v1M0U9wVN6shlCM7w.png" /></figure><h4>Step 1 — Create an Object Storage Bucket</h4><p>To get started, you will need to enable Object Storage on your Linode Account. You can do this in your “<em>Billing and Contract Information</em>” and going to “<em>Settings</em>.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*3p_PATiQBeaGU_U9Ej-4ig.png" /></figure><p>Once enabled, click “<em>Object Storage</em>” from the left hand menu in the Akamai Connected Cloud Console. Click any one of the blue “<em>Create Bucket</em>” buttons to get started. Give your bucket a unique name, these names must be unique across customers. I will name mine <em>eiler-trunas-test. </em>Next decide on the region where you want your bucket to reside. I would suggest sending your backups to a different area altogether. If your NAS is in the eastern USA, create a bucket in Chicago. My NAS is in Chicago. So I will put my bucket in Los Angeles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*e7OQW5RXdBCOmwb4B6KZPw.png" /></figure><h4>Step 2 — Create Access Keys</h4><p>Once you have your bucket created, you need to create keys. Within the same console screen, click “<em>Access Keys</em>” at the top and then “<em>Create Keys</em>.” Give your keys a name. And in the spirit of least privilege, make sure you only give read/write access to the one bucket TrueNAS will need to access. Click the blue “<em>Create Access Key</em>” button.</p><p>Download your keys, because that is the last time you will see the Secret Key. Click “<em>I Have Saved My Secret Key</em>.” Now click back on buckets and take note of the hostname your bucket resides on. My bucket below in LA is on us-lax-1.linodeobjects.com and the bucketname is the first part of the full fqdn upto the first dot. Make note of yours. You will need it to set up TrueNAS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r-0hzGkRnHJZtFRcYxmHmw.png" /></figure><h4>Step 3 — Configure your Cloud Credentials in TrueNAS</h4><p>Now, you are ready to configure TrueNAS for Akamai Object Storage backup. Open a web browser and enter the IP Address of your TRUENAS_1 instance into the address bar, then hit Enter. Log in using ‘admin’ and your super secret password from the install. Click “<em>Credentials</em>” from the left hand menu, and then “<em>Backup Credentials</em>.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*8eBWVTKg7mamuwRUTlu7ZQ.png" /></figure><p>Click “<em>Add</em>” next to “<em>Cloud Credentials</em>.”<br><strong>Use the following settings:</strong><br>Provider = Amazon S3<br>Name = I call mine Akamai — LAX<br>Access Key ID = Your key from the Console<br>Secret Access Key = Your secret from the Console<br>Endpoint URL = the Akamai host part of the fqdn<br>Disable Endpoint Region = checked (yes)<br>Click “<em>Save</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*paFNNcMj_iIATJgozh4VEA.png" /></figure><h4>Step 4 — Set Up Cloud Sync</h4><p>Click on “<em>Data Protection</em>” on the left side menu. Under “<em>Cloud Sync </em>Tasks,” click “<em>Add</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*tuUL6le5vgxiBdY0YwDiig.png" /></figure><p><strong>Use the following settings:</strong><br>Description = Give it a name, like nightly backup<br>Direction = Push<br>Transfer Mode = Copy<br>Directory/Files = /mnt/NAS_POOL<br>Credential = This is what you just created, there should only be one here<br>Bucket = Pick the bucket you just created<br>Folder = /<br>Advanced Remote Options<br>Remote Encryption = checked (yes)<br>Filename Encryption = checked (yes)<br>Encryption Password = more super secret passwords<br>Storage Class = Leave this blank, as today Akamai only has 1 class.<br>Bandwidth = crank it up to High, we have plenty!</p><h4>Step 5 — Send Some Data!</h4><p>Now to test this, you will need to load some data to the NFS mount from another Linode. If you followed one of my tutorials, you should have one. And all of them mounted the NFS share at /var/www/html. So pick a Linode. Go to the Akamai Connected Cloud console, click on that Linode and click “<em>Launch LISH Console.</em>” To test this, you will curl a large file from the Internet directly into the NFS mount. And then kick off the backup job manually. At a prompt in the LISH console issue this command: curl -o /var/www/html/1GB.zip <a href="http://ipv4.download.thinkbroadband.com/1GB.zip">http://ipv4.download.thinkbroadband.com/1GB.zip</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*6w3mXO-HAtEvPtlXFMhDDw.png" /></figure><p>When the file completes, go back to your TrueNAS management interface and click on “<em>Data Protection</em>.” Then click the “play” button (triangle) in your “<em>Cloud Sync Tasks.</em>” When the job completes, go back in to your Akamai Connected Cloud Console, and click “<em>Object Storage</em>” from the navigation menu on the left. Click your bucket name to see what the replication elves have left you. You should see some encrypted folder names and an encrypted file name or two.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XjVT0ZYT2baQgDrOlR23OQ.png" /></figure><p>Success! I hope this tutorial helps you to find some piece of mind, resting assured that your files are safely encrypted and backed up on a regular basis in the Akamai Connected Cloud.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eb862db2b3bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Geo-Replicated Encrypted File Storage in Akamai Connected Cloud]]></title>
            <link>https://medium.com/@brent.m.eiler/geo-replicated-encrypted-file-storage-in-akamai-connected-cloud-936d9905caa5?source=rss-d96a116a80ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/936d9905caa5</guid>
            <category><![CDATA[replication]]></category>
            <category><![CDATA[truenas]]></category>
            <category><![CDATA[akamai-connected-cloud]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[nfs-server]]></category>
            <dc:creator><![CDATA[Brent Eiler]]></dc:creator>
            <pubDate>Fri, 15 Dec 2023 07:58:16 GMT</pubDate>
            <atom:updated>2023-12-15T07:58:16.017Z</atom:updated>
            <content:encoded><![CDATA[<p>Whether for Business Continuity and Disaster Recover purposes or just to have consistency in distributed application configuration, a secure, replicated file store is necessary to have in any computing environment. Today I am going to show you how to create one in Akamai Connected Cloud — using the TrueNAS virtual appliance. If you have followed my previous tutorials, you should be all set for this one. If not, go back and do <a href="https://medium.com/@brent.m.eiler/shared-storage-in-akamai-connected-cloud-140fb597b15a">this</a> and <a href="https://medium.com/@brent.m.eiler/creating-and-deploying-golden-images-for-non-standard-linodes-in-the-akamai-connected-cloud-d1de6e9505b0">this</a>. These 2 tutorials should leave you with 2 TrueNAS images in 2 Cloud regions.</p><p>In this tutorial, you will create a TrueNAS appliance in 2 Akamai Connected Cloud regions. In each region, you will create an Ubuntu server and mount /var/www/html to the local TrueNAS vAppliance over a private VLAN. You will then populate a file on 1 server which will replicate to the second region and display on the NFS mount on the second server. Now this is just for demo purposes, whether for web content back-ending your CMS, or something else, the sky is the limit with. You could use this to back-end your own container registry, or your own golden image repo, or just for general files that need to be accessed regularly, globally. Whatever the case, you can simply adapt this to your use case. In the end, you will have something that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*RuX23t9neakhhcIa0Wme8Q.png" /></figure><p>Let’s get started.</p><h4>Step 1 — Storage Volumes</h4><p>Make sure you have storage volumes created in the regions. If you have followed the tutorials, you should have three 20 GB volumes in the first region, and they should be attached to the TRUENAS_1 Linode. You will need to create three 20 GB volumes in the second region. Go in to your Akamai Connected Cloud Console and click the blue “<em>Create</em>” and select “<em>Volumes</em>” Create a Volume with the following settings:<br>Label TRUENAS_2_VOL_1<br>Region = Wherever you build TRUENAS_2<br>Linode = TRUENAS_2 and Config TRUENAS_SYSTEM<br>Size=20 GB<br>Click “<em>Create Volume</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dFH_RUAvtFgQc-KsijcHgw.png" /></figure><p>Close out of the Volume Configuration screen and then clone this volume 2 times by clicking … at the end of the new volume and “Clone”<br>Create 1 with Label = TRUENAS_2_VOL_2<br>Create 1 with Label = TRUENAS_2_VOL_3<br>You will have to attach these clones to the Instance. Click “<em>Linodes</em>” from the menu on the left. And then click on your Linode TRUENAS_2.<br>Click “<em>Storage</em>” and “<em>Create Volume</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yyjrhKbQn2CgCRVPO8Uc6A.png" /></figure><p>Select “<em>Attach an Existing Volume</em>” and then your VOL_2 from the drop down. Click “<em>Attach Volume</em>”<br>Repeat this process for VOL_3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*lWCUqeIfFKs7lAFW5V4eIw.png" /></figure><p>Now you should have disks that can be used to create the dataset on the second NAS.</p><h4>Step2 — Open the Firewall</h4><p>The next step is to open the firewall to allow SSH traffic between TRUENAS_1 and TRUENAS_2. This is required for the replication. Click “<em>Firewalls</em>” in the menu to the left.<br>Click on your HTTP_ONLY rule from the previous exercises. Click “<em>Add An Inbound Rule</em>” and create a rule with the following settings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*NZmEUbdi9MKjR03WuRZaQQ.png" /></figure><p>Preset = SSH<br>Sources = IP / Netmask<br>IP / Netmask = type the public IP of TRUENAS_1<br>Click “<em>Add Rule</em>”<br>Click “<em>Add An Inbound Rule</em>” again<br>Repeat these settings, but substitute the IP Address for TRUENAS_2<br>Click “<em>Add Rule</em>”<br>Scroll down and click “<em>Save Changes</em>”</p><p>Now you should be ready to set up the TrueNAS Appliances.</p><h4>Step 3— Create the Datasets</h4><p>Before you can create Datasets, visit the Linode overview page and make sure each TrueNAS Linode is running.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FrADqg-PujJyPAhvbOjEIg.png" /></figure><p>If you need to start one, click the Linode and then Click “<em>Power On.</em>” Once all Linodes are in a running state, enter the IP Address of TRUENAS_1 in your browser and hit Enter. Login to the TrueNAS console with ‘admin’ and your super secret password. Click “<em>Storage</em>” on the menu to the left and then click the “<em>Create Pool</em>” button.<br><strong>Use the following settings:</strong><br>Name = NAS_POOL<br>Encryption = checked (Yes)<br>Click “<em>Next</em>”<br>Layout = RAIDZ1 (This means you will stripe with 1 disk for parity)<br>Size = 20 GiB (SSD)<br>Width = 3<br>Number of VDEVs = 1<br>Click “<em>Save And Go To Review</em>”<br>In the review, click “<em>Create Pool</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*HF6aF_IAoG-xa5TpiSNdnA.png" /></figure><p>Download your encryption keys and click “<em>Done</em>.”</p><p>After the Dataset completes, click “<em>Datasets</em>” from the menu on the left and click the “<em>Add Dataset</em>” button on the far right.<br><strong>Use the following settings:<br></strong>Name = web<br>Encryption Options = Check “<em>Inherit (encrypted)</em>”<br>Leave all other options at default and click “<em>Save</em>.”</p><p>Now open a new browser window and type the IP Address of TRUENAS_2. Follow this same process to create the same 36 GiB pool on the second NAS.</p><h4>Step 3— Validate the Network Settings</h4><p>Before proceeding, set the VLAN interface to an IP Address. While still in the TRUENAS_2 management console. Click “<em>Network</em>” from the menu to the left. And then click the pencil icon next to the second network interface.<br><strong>Using the following settings:</strong><br>DHCP = unchecked (no)<br>Click “<em>Add</em>” next to Aliases<br>Enter 192.168.1.100 and /24<br>Click “<em>Save</em>” and the click “<em>Skip</em>” twice</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*Dr_AKiIY763AZDBX4Jphow.png" /></figure><p>Edit the Public Interface by clicking the pencil icon next to the first network interface and re-enable DHCP on that one by checking the DHCP box. Click “<em>Save</em>” and then “<em>Skip</em>” twice.</p><p>Click “<em>Test Changes</em>” then “<em>Save Changes</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*EPvBD-jqXzLfRMVoDssfuA.png" /></figure><p>Now repeat this process on TRUENAS_1</p><h4>Step 4— Create A User and Share</h4><p>In this tutorial we will not be using MapAll = root, just in case you want to use this going forward. You will create an unprivileged user called web that will own the web Dataset and the replication between TRUENAS_1 and TRUENAS_2 web Datasets. Create the user on each TRUENAS appliance. From within the management interface of TRUENAS_1, click “<em>Credentials</em>” from the menu on the left and select “<em>Local Users</em>.” Click “<em>Add</em>” to add a new user:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rKMJzTU9KVihGad8dyDZ3w.png" /></figure><p><strong>Use the following settings:</strong><br>Full Name = web<br>Username = web<br>Disable Password = checked (yes)<br>Home Directory = /mnt/NAS_POOL<br>Create Home Directory = checked (yes)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*tCtEWJfbJAFYQcInfE6mlA.png" /></figure><p>Click “<em>Save”</em> and then Create the Share by clicking “Shares” on the left side and “<em>Add</em>” in the NFS line.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JGzJOeB13A8YTG-Fn6L6rw.png" /></figure><p>Click “<em>Advanced Options</em>” <br><strong>Use the following settings:<br></strong>Path = /mnt/NAS_POOL/web<br>Mapall User = web<br>Mapall Group = web<br>Click “<em>Add</em>” next to Networks:<br>Network = 192.168.1.0 / 24<br>Click “<em>Save</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*2IhSXoe5o0rCSREDRAjpNg.png" /></figure><p>If you are prompted to enable NFS, click “<em>Enable Service</em>” to make sure NFS starts at boot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*1JHLTVTq-vU8CPHBM_duVg.png" /></figure><p>Then repeat this process of adding a user and share on TRUENAS_2.</p><h4>Step 5 — Set Permissions</h4><p>Starting in TRUENAS_2, click on “<em>Datasets</em>” from the left hand navigation, and then click your Dataset “<em>web.</em>” Then scroll down in the far right menu set until you get to “<em>Permissions</em>.” Click “<em>Edit</em>.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hJU9om4s7kBilt8qVD7cHA.png" /></figure><p><strong>Use the following settings:</strong><br>User = web<br>Apply User = checked (yes)<br>Group = web<br>Apply Group = checked (yes)<br>Apply permissions recursively = checked (yes)<br>Apply permissions to child datasets = checked (yes)<br>Click “<em>Save</em>”</p><p>Now repeat this on TRUENAS_1.</p><h4>Step 6 — Add Public Keys</h4><p>The next step will enable the web user to replicate its own files. So that all files replicated will still be owned by the web user that interacts with the mounted shares. For this exercise you will need both TRUENAS_1 and TRUENAS_2 up at the same time. Starting in TRUENAS_1, select “<em>Credentials</em>” from the left hand navigation and click “<em>Add</em>” next to “<em>SSH Keypairs</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*G8d_AY1TFySW3IVd0MZ4yA.png" /></figure><p>Give it a name, say web-replication. Then click “<em>Generate Keypair.</em>” Copy the Public Key before clicking “<em>Save.</em>” Now go to TRUENAS_2 and click “Credentials” in the left hand navigation, but go to “<em>Local Users.</em>” Click your web username and click “<em>Edit.</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*ZCXgMNKccr3-NH2qSV2svA.png" /></figure><p>Scroll down to “<em>Authentication</em>” on the right side, and paste your Public Key from TRUENAS_1 into the “<em>Authorized Keys</em>” field for web user on TRUENAS_2. Then click “<em>Save</em>.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/495/1*Ci1P3Yc2MbF-0yvDlfouWQ.png" /></figure><p>Now, within TRUENAS_2, you will repeat the process. Click “<em>Credentials</em>” and then “<em>Backup Credentials</em>.” On “<em>SSH Keypairs</em>,” click “<em>Add</em>.” Give it the same name, web-replication, and click the “<em>Generate Keypair</em>.” Now copy the Public Key, and then click “<em>Save</em>.” Go back to TRUENAS_1, click “<em>Credentials</em>” once again, and then click “<em>Local Users.</em>” Click your web user and select “<em>Edit</em>.” Paste the newly generated Public Key into the “<em>Authorized Keys</em>” field, and click “<em>Save</em>.”</p><h4>Step 7 — Set Up The Replication</h4><p>This is the last step of setup before creating a couple test VMs. Starting in TRUENAS_1, click “<em>Data Protection</em>” on the left hand navigation. Click “<em>Add</em>” in “<em>Rsync Tasks</em>.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*8MkYvOfD6jc1mO4FlUxOKw.png" /></figure><p>Use the following settings:<br>Path = /mnt/NAS_POOL/web<br>Rsync Mode = SSH<br>Connect using: SSH connection from the keychain<br>User: web<br>Direction: Push<br>Schedule: Hourly<br>SSH Connection: Create New<br>Remote Path = /mnt/NAS_POOL <strong>**NOTE DO NOT ADD WEB TO THIS**<br></strong>Validate Remote Path = checked (yes)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*Em829SHGkOahKLtW9SFpxw.png" /></figure><p><strong>Use the following settings for the new SSH Connection:<br></strong>Name = web-repl <strong>**This name must be different than the Key name you created in Step 6.</strong><br>Setup Method = Semi-Automatic<br>Authentication = <a href="http://ip/">http://IP</a> Address of your TRUENAS_2<br>Admin user = admin<br>Admin password = your super secret password from the initial setup<br>Username = web<br>Private Key = Should only be the one your created in step 6<br>Click “<em>Save</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*5WtjbSdZ7Zl22S3Ci8it1w.png" /></figure><p>After you have created the new SSH connection, click “<em>Save</em>” on the Rsync Task. You can test your sync immediately by clicking the “<em>Play</em>” button on the Rsync task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*U_u2Jta-htJ56s8tKjIukw.png" /></figure><p>Then repeat this process on TRUENAS_2.</p><h4>Step 8 — Setup Test VMs</h4><p>To test the replication, we need to mount NFS filesystems at both ends. To do this, you will need a small Ubuntu Nanode in each of the regions you have TRUENAS_1 and TRUENAS_2. Got back to your Akamai Connected Cloud Console and click the blue “<em>Create</em>.” Select “<em>Linode</em>.”<br><strong>Use the following settings:</strong><br>Images = Ubuntu 23.10<br>Region = The same region as TRUENAS_1<br>Plan = Shared, Nanode<br>Linode Label = TEST_1<br>Root Password = give it a complex pass<br>VLAN = BACKEND<br>IPAM Address = 192.168.1.10/24<br>Click “<em>Create Linode</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bfxsUtsvA1l4f3KKGhT1fg.png" /></figure><p>Do the same thing for the second Linode, but place it in the same region as TRUENAS_2 and call it TEST_2.</p><p>When TEST_1 boots, use the LISH console to run the following commands. Click the “<em>Launch LISH Console</em>” button from the Linode TEST_1 overview page.</p><pre>apt update &amp;&amp; apt install -y nfs-common<br>vi /etc/fstab</pre><p>In fstab, arrow to the bottom and click ‘o’ then paste the following line:</p><p>192.168.1.100:/mnt/NAS_POOL/web /var/www/html</p><p>Click Esc, then type :x and hit Enter. Type reboot and hit Enter. Now repeat this process on TEST_2.</p><p>After completing the task on TEST_2, wait for TEST_2 to return to a running state. Reopen your LISH Console. In the prompt, type:</p><pre>cd /var/www/html<br>touch my-cool-file.html<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*bLrkvcZjSa7_OHf59zGQ0Q.png" /></figure><p>Close the LISH Console and return to your TRUENAS_2 management interface. Login with admin and your super secret password. Click “<em>Data Protection</em>” and then click the “<em>Play</em>” button on your Rsync Task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*WP_cd4YYefZnUCU-5QNHGw.png" /></figure><p>You should see a success message. Now go back to your Akamai Connected Cloud Console. Click “<em>Linodes</em>” on the left hand pane. Click on TEST_1. Click “<em>Launch LISH Console</em>.” Type:</p><pre>cd /var/www/html<br>ls -l</pre><p>You should see the file you created in your other Cloud region. And this replication will continue every hour, per your replication schedule.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*bLGVYGNbpePXmTUl18krmA.png" /></figure><p>I hope you enjoyed this tutorial. Check back soon for more fun tips and tricks with Akamai Connected Cloud.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=936d9905caa5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating and Deploying Golden Images for  Non-Standard Linodes in the Akamai Connected Cloud]]></title>
            <link>https://medium.com/@brent.m.eiler/creating-and-deploying-golden-images-for-non-standard-linodes-in-the-akamai-connected-cloud-d1de6e9505b0?source=rss-d96a116a80ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/d1de6e9505b0</guid>
            <category><![CDATA[linode]]></category>
            <category><![CDATA[truenas]]></category>
            <category><![CDATA[vm]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[akamai-connected-cloud]]></category>
            <dc:creator><![CDATA[Brent Eiler]]></dc:creator>
            <pubDate>Thu, 14 Dec 2023 01:12:19 GMT</pubDate>
            <atom:updated>2023-12-14T19:51:24.276Z</atom:updated>
            <content:encoded><![CDATA[<h3>Creating and Deploying Golden Images for Non-Standard Linodes in the Akamai Connected Cloud</h3><p>In my last few posts, I have covered a couple ways you can create non-standard Linodes in the Akamai Connected Cloud — both from KVM images and from ISO. But, what if you want to make your own? Maybe you have standard software that every RHEL VM must have. Or maybe you have certain configurations like LVM. Or maybe you just do not feel like installing from ISO 50 times. Or potentially you want to avoid billing for VMs that are not often used and do not need to be up on-demand within seconds, but do hold state and are used semi-regularly. Regardless of the why, the process for doing this is quite simple and uses the same basic tooling you should already be familiar with if you have created a non-standard Linode. Unfortunately, the answer is not using the Clone option, as you may have done with standard Linodes. Fortunately, it really isn’t much more involved than that. To demonstrate this procedure, I will clone the TrueNAS VM built in my last post. And then deploy it to a different Cloud region. There are many reasons why I chose this specific VM for this post, but I will cover those in a subsequent tutorial.</p><h4>Part 1 — Create the Golden Image</h4><p>To start, if you have not already, read <a href="https://medium.com/@brent.m.eiler/shared-storage-in-akamai-connected-cloud-140fb597b15a">Shared Storage in the Akamai Connected Cloud</a>. When you have your TrueNAS VM built, you are almost ready to go. Go back in to your TrueNAS console and delete the Dataset so your image is clean. To do this, delete the Share, by clicking “<em>Shares</em>” on the menu to the left, and then the trash can icon on the share. Then click “<em>Storage</em>” from the left hand menu, and the “<em>Export/Disconnect</em>” button. Check all the boxes and enter the Pool Name. Click “<em>Export/Disconnect</em>” and the Pool is gone.<br>Now from the Akamai Connected Cloud console, click “<em>Linodes</em>” from the menu on the left and then click on your TRUENAS_1 VM. Power off your NAS using the “<em>Power Off</em>” button. Click the … and select “<em>Rescue</em>.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*JHD96Nxml0-JSse-VEytsw.png" /></figure><p>In the next step, you will again make use of the TEMP disk, from the previous exercise. Select TEMP under “<em>/dev/sda</em>” and TRUENAS_1_SYSTEM under “<em>/dev/sdb.</em>” Then click “<em>Reboot Into Rescue Mode.</em>” And then click the “<em>Launch LISH console</em>” button from the TRUENAS_1 overview page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*08s1ULLALKTudwOWGm2Qfw.png" /></figure><p>When the console reaches a prompt, do an lsblk and verify you see your 5 GB disk at /dev/sda and 75 GB disk at /dev/sdb. If you do not, look to see if they are listed under another /dev/sdX and adjust the steps below to account for that. If you use another Linode plan in your initial install, just find the disk size of your TRUENAS_1_SYSTEM disk. It should have 4 partitions like /dev/sdb below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*uS7Vw9cBUyCQM7Qe3-UPEg.png" /><figcaption>lsblk</figcaption></figure><p>If your /dev/sda has partitions under it (ie /dev/sda1, /dev/sda2, etc…) you will need to fdisk this and delete the partitions.<strong> **WARNING — This is only for the 5 GB Disk. Do not do this on the larger disk.**</strong> You can do this by issuing fdisk /dev/sda and once inside type d for delete, then hit Enter. Do this 1 time for each /dev/sdX. After deleting all partitions, type w to write the table and exit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*rsVk6azHgtw-QYsPGYfFcg.png" /><figcaption>fdisk</figcaption></figure><p>Next, and regardless of whether you needed to fdisk /dev/sda, make sure you have a filesystem in place by using mkfs.ext4 /dev/sda and accept any prompts. Then mount the disk at /mnt by issuing mount /dev/sda /mnt</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/494/1*k-L4QYvNV0EJ5Nr32zYHlQ.png" /></figure><p>The next part is the sneaky magic — shoving a 75 GB disk into a 5 GB disk. To do so, you will stream the blocks from /dev/sdb, compressing them in transit to a zip file on /mnt. Use this command: <br>dd if=/dev/sdb bs=4M status=progress | zip –q &gt; /mnt/nas_image.zip<br>The process of making the golden image can take 10+ minutes due to the inline compression. So go get a coffee now, at a local coffee shop. You have time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/683/1*NaX5ji6EWYB3S1matAXsPw.png" /></figure><p>Once it completes, the resulting file should be about 3.5 GB — much smaller than the 75 GB disk. Now upload it to your favorite Internet facing file storage. Linode Object Storage is great for this! You now have a golden image for TrueNAS.</p><h4>Part 2- Deploy Your Golden Image</h4><p>Now, deploying a golden image is a similar process to deploying a KVM image or building from an ISO. The TLDR; is this:</p><ol><li>Create a shell VM with 2 disks, 5 GB and 75+ GB and a config that boots the larger disk, along with any network interfaces you need.</li><li>Boot to Rescue Mode, obtain the image and image the disk.</li><li>Reboot.</li></ol><h4>Part 2.1 — Prepare the VM Environment</h4><p>To prepare the VM environment, create a Linode via the blue “<em>Create” </em>button. Select “<em>Linode</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*-Tp8fPlUszlP7fu8lMjhwA.png" /></figure><p>As per the last exercise, click the “<em>x</em>” under “<em>Images</em>”. Since you already have a NAS in one region, select a new region to deploy your golden image. If you are staying on the cheaper side and just using this for learning, use the Linode 4GB Shared Plan like in the previous exercise. However, you must use at least this plan size to accommodate the 75 GB disk.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JIK41CViWOQIJHYBmWvoIw.png" /></figure><p>Give your Linode a label — maybe TRUENAS_2. And assign your HTTP_ONLY firewall to the Linode. Then click “<em>Create Linode.</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ikGnIkmp_6mofSKnFmfiA.png" /></figure><p>While your new Linode provisions, create your disks by clicking “<em>Storage</em>” and then “<em>Add A Disk.</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b5ACkO1QxDsKQyR3WJvf5w.png" /></figure><p><strong>Use the following settings:</strong><br>“<em>Create Empty Disk”</em><br>“<em>Label</em>” = TEMP<br>“<em>Filesystem</em>” = ext4<br>“<em>Size</em>” = 5120<br>Then click “<em>Create</em>”</p><p>When that disk is created, click “<em>Add A Disk</em>” again.<br><strong>Use the following settings:<br></strong>“<em>Create Empty Disk”</em><br>“<em>Label</em>” = TRUENAS_2_SYSTEM<br>“<em>Filesystem</em>” = raw<br>“<em>Size</em>” = 76800<br>Then click “<em>Create</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*IorCIZarkovt0uLGNpF3kA.png" /></figure><p>Now create the boot configuration for the VM. Click “<em>Configurations</em>” and then “<em>Add Configuration.</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h8VKUC_495jNB8cKFDyTgw.png" /></figure><p><strong>Use the following settings:<br>“</strong><em>Label</em>” = TRUENAS_SYSTEM<br>“<em>VM Mode</em>” = Paravirtualization<br>Under Boot Settings:<br>“<em>Kernel</em>” = Direct Disk<br>Under Block Device Assignment:<br>“/dev/sda” = TRUENAS_2_SYSTEM<br>**This is the only disk you will need to mount in the standard boot configuration.<br>Under Network Interfaces:<br>leave “<em>eth0</em>” at “<em>Public Internet</em>”<br>You can select “<em>VLAN</em>” under “<em>eth1</em>” and create a VLAN so that VMs can access your file shares on a private RFC1918 address space. Do this by typing a VLAN name into the box and clicking “<em>Create ‘vlan-name’</em>”<br>Finally, click the blue “<em>Add Configuration</em>” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xi5wy1Kfl6o4IVjQIxD1dg.png" /></figure><h4>Part 2.2 — Get the Image</h4><p>The next step is to boot into Rescue Mode with both /dev/sda as TEMP and /dev/sdb as TRUENAS_2_SYSTEM. Click the … and select “<em>Rescue</em>.”<br><strong>Use the following settings:<br>“</strong><em>/dev/sda”</em> = TEMP<br>“<em>/dev/sdb</em>” = TRUENAS_2_SYSTEM<br>Click “<em>Reboot Into Rescue Mode.</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*o3vKwXrFC2ZO0BbNjM2h4Q.png" /></figure><p>Click “<em>Launch LISH Console</em>” and wait for the prompt. Again, run lsblk to ensure your disks are attached and the correct size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*xDbHUD6KzS6lH8QgYjPKvA.png" /></figure><p>Mount the 5 GB device on /mnt. It should already have an ext4 filesystem from the creation settings. cd /mnt and then run a curl command to the location of your golden image file, like this: curl -o nas_image.zip https://my.bucket-object.storageplatform.com/nas_image.zip or wherever you have the file stored. If the file completes within a second, check your permissions and make sure you can actually access the file. Then delete it from /mnt using the rm command. Once it completes successfully — within a minute or two, issue the last command:</p><p>unzip -p nas_image.zip | dd of=/dev/sdb bs=4M status=progress</p><p>Replace nas_image.zip with the filename of your golden image if you have used something else.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*cvkRhMv-s8H-oBqXUAPPwA.png" /></figure><p>This will take about 7 minutes to stream the decompression of the file into dd and blast the larger disk with those blocks. When it completes, close the LISH console and click the “<em>Reboot</em>” button on your TRUENAS_2 Linode overview page. Confirm the reboot. When the Linode reaches the “<em>Running</em>” status, click on the Public IP Address to copy it to your clipboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*JtnRwPL5dOJnxvwouEFaPQ.png" /></figure><p>Open your favorite web browser, paste the IP into the address bar and hit Enter. You should now be prompted with a TrueNAS login page in your new Linode region. And if you use your username ‘admin’ and super secret password from the initial TrueNAS install, it will grant you access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*5OIJpD1nl0vGk-6tvMaXlA.png" /></figure><p>You now have a golden image of a TrueNAS deployment that you can deploy to any region. Stay tuned for my next tutorial on using your these 2 TrueNAS deployments for replicated golden image storage and streamlined image deployment over NFS.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d1de6e9505b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shared Storage in Akamai Connected Cloud]]></title>
            <link>https://medium.com/@brent.m.eiler/shared-storage-in-akamai-connected-cloud-140fb597b15a?source=rss-d96a116a80ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/140fb597b15a</guid>
            <category><![CDATA[truenas]]></category>
            <category><![CDATA[linode]]></category>
            <category><![CDATA[akamai-connected-cloud]]></category>
            <dc:creator><![CDATA[Brent Eiler]]></dc:creator>
            <pubDate>Fri, 08 Dec 2023 16:21:04 GMT</pubDate>
            <atom:updated>2023-12-08T16:21:04.344Z</atom:updated>
            <content:encoded><![CDATA[<p>A common request from customers is to have a fault tolerant, file-based storage service where common configurations and shared files can be stored easily and mounted to their instances without having to make local copies of these files. Unfortunately today, the Akamai Connected Cloud does not have such a service like the AWS EFS or FSx. Fortunately, I can make this easy for you. The file storage platform you will build today can serve files over both NFS, SMB and iSCSI. The platform can create a RAID protected (and encrypted if you want) array over multiple Linode Volumes, reaching a capacity of 40TB per array, or more. The system also has a simple graphical interface to guide you through all sorts of advanced features and functionality. This build will make use of the Linode VLAN network to securely serve files to instances, Cloud Firewall to protect the web interface on the Public Internet and 2 Apache servers sharing a common filesystem. Both Apache servers will serve the same php page from behind a NodeBalancer. Your final architecture will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*KiIRdCxn6O_ovae0AuM0VA.png" /><figcaption>Simple Web with Shared Backend</figcaption></figure><p>Now, to not break the bank, the following components should be used. Keep in mind this is a PoC level deployment and not for production. In production, proper instance RAM sizing and filesystem sizing should be taken into account. But for this purpose, cost is king.</p><ul><li>1 NodeBalancer</li><li>2 Nanodes connected to the Public Internet and VLAN</li><li>1 Linode 4GB connected to the Public Internet and VLAN</li><li>3 Linode Volumes of 20GB each</li><li>1 Firewall policy to only allow HTTP to the management interface of the filer</li><li>1 Firewall policy to only allow HTTP to the web tier from NodeBalancer</li></ul><p>It goes without saying, you will need an Akamai Connected Cloud account to build this architecture. And, as always, if you do not have one, you can <a href="https://www.linode.com/lp/free-credit-100/">SIGN UP HERE</a> and receive a $100 credit. Let’s get this built.</p><h4>Step 1 — Create the Storage Volumes for the Filer Array</h4><p>To start, build the filer using TrueNAS. This is a fairly simple process. But it does require some back end trickery in the Akamai Connected Cloud console. The first thing you will need to do is create the 3 Linode Volumes. Click the blue “<em>Create</em>” button and select “<em>Volume.</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*w1iyw4QYM6_yTTbvrhCVWA.png" /></figure><p><strong>Use the following settings:</strong><br>Label: NAS_VOL_1<br>Region: Pick any Region Close EXCEPT Fremont, CA or Tokyo, JP<br>Do not attach any Linodes<br>Size: 20 GB</p><p>Then click “<em>Create Volume.</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*4g46anQ4wueMaPSIX2H4iw.png" /></figure><p>Back at the Volumes overview page, click the … at the end of the line for the Volume you just created. Select “<em>Clone.</em>” Use this to create Volumes with labels NAS_VOL_2 and NAS_VOL_3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vgupQjrrmFxXmojz-Wfs7Q.png" /></figure><h4>Step 2 — Create the Filer Firewall Policy</h4><p>The next step is to create a firewall policy to protect the filer you are creating. At the top of the page, click the blue “<em>Create</em>” and select “<em>Firewall.</em>” <strong>Use the following settings:</strong><br>Label: HTTP_ONLY<br>Linodes: Leave this blank for now</p><p>Click “<em>Create Firewall</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*-pgDLjk2IM24I-Kf3nFVEQ.png" /></figure><p>When you are returned the the Firewall Policy overview screen, click the name of the firewall policy you just created (HTTP_ONLY). In the policy, click “<em>Add An Inbound Rule.</em>” Select “<em>HTTP</em>” from the “<em>Preset</em>” drop down menu. At the bottom, click “<em>Add Rule.</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*UN_KzGtSIt4PnKdHh2qdGw.png" /></figure><p>Change the “<em>Default Inbound Policy</em>” to “<em>Drop</em>” and click “<em>Save Changes.</em>”</p><h4>Step 3 — Create the Filer Shell Linode</h4><p>Use the same blue “<em>Create</em>” button at the top of the page to create your Linode shell instance that will hold the filer. This time select “<em>Linode</em>” from the menu.</p><p>Click the “x” on the Distro to clear the “<em>Images</em>” selection.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*LPoPUkk_UdmNe4wjcS_3wA.png" /><figcaption>This clears the image</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*Hao8k_TIf3MJHFqiekbJeg.png" /><figcaption>You want it to stay this way</figcaption></figure><p>Next select the same region you created the 3 Volumes in: I used Chicago.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/1*2P8VAHkCWuvaZZR7QWdv2Q.png" /></figure><p>Now select a “<em>Linode Plan</em>.” For testing only, you can use the Shared CPU 4 x 8 (Linode 4GB). However, if this will be for production, I would recommend using the 2 x 24 High Memory instance (or greater) due to the way ZFS works.<br>Give it a label of “<em>TRUENAS_1</em>”<br>Select your “<em>HTTP_ONLY</em>” Firewall policy from the drop down menu under “<em>Firewall</em>”<br>Click “<em>Create Linode</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XasfrmcrMsyzgOx77EHhvQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2o4kC2JhPsk_O-dmRipsrg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n-NHUuciM-SrxEOcbpiVaQ.png" /></figure><p>This will take you to the overview page of your new Linode.</p><h4>Step 4 — Configure the Shell Linode for Installation</h4><p>Next you will create a TEMP disk to hold the TrueNAS ISO file by clicking on “<em>Storage</em>” and then “<em>Add A Disk</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I3Nsz9OGa5_wGuUYLKaMdA.png" /></figure><p><strong>Use the following settings:<br></strong>Label: TEMP<br>Filesystem: raw<br>Size: 5120 MB</p><p>And then click “<em>Create</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*nE6Yke06o9NR2xY39fdWwQ.png" /></figure><p>Next you will use this TEMP disk and a Volume to pull in the ISO and image the TEMP disk with the ISO to act as a virtual DVD. To do so, click the three dots in the top right of the page:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/467/1*IIKGWNgmeF3HtM9iQmtdnA.png" /><figcaption>Select Rescue and use the following settings:</figcaption></figure><p>/dev/sda=TEMP<br>/dev/sdb=NAS_VOL_1</p><p>Click “<em>Reboot Into Rescue Mode</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*eXqCfNXcw0w2lBbLdRqq0g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/249/1*NntVptHo8IPYuhmcc7fFGg.png" /></figure><p>Once your Linode is in the Running state, Click the “<em>Launch LISH Console</em>” from the upper right. Once you have a Finnix prompt up, do an lsblk and make sure you see both your 5GB disk on /dev/sda and your 20GB vol on /dev/sdb. Run the following commands:</p><pre>mkfs.ext4 /dev/sdb<br>mount /dev/sdb /mnt<br>cd /dev/mnt<br>curl -o truenas.iso https://download.sys.truenas.net/TrueNAS-SCALE-Cobia/23.10.0.1/TrueNAS-SCALE-23.10.0.1.iso</pre><p>If this link fails, you will need to go out to the TrueNAS scale downloads page and get a updated link. When the ISO finishes downloading, use dd to image TEMP by typing:<br>dd if=/mnt/truenas.iso of=/dev/sda bs=4M status=progress</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QkTG3R-EGyJzU2aRfX9tAA.png" /></figure><p>When this completes, close the LISH Console window. Then click “<em>Power Off</em>” from the Linode overview page for TRUENAS_1.</p><p>Now you will need to create a Disk for which to install the TrueNAS software to. This will be your system boot disk after install time. To do this, create the “<em>TRUENAS_1_SYSTEM</em>” disk by clicking on “<em>Storage</em>” and then click “<em>Add A Disk</em>” just like you previously did to create the “TEMP” disk.<br><strong>Use the following settings:<br></strong>Label: TRUENAS_1_SYSTEM<br>Filesystem: raw<br>Size: 76800 or the maximum for your Linode</p><p>Click “<em>Create</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*uMFi7-3oBl4jEBBDrkx-UQ.png" /></figure><p>The last step to prep for the installation is to create a boot config. This tells the Linode which disks to use, which one is the boot disk, and which network interfaces to install. To create your boot config — click “<em>Configurations</em>” and then “<em>Add Configuration</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ekTT0hkVREuV0psbGBdP-Q.png" /></figure><p><strong>Modify the following settings:<br></strong>Label: NAS_SYSTEM<br><em>Boot Settings:</em><br>Kernel: Direct Disk<br><em>Block Device Assignments:<br></em>/dev/sda = TEMP<br>/dev/sdb = TRUENAS_1_SYSTEM</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*4UjMe8iC7x7YkybVL3A21g.png" /></figure><p>Leave eth0 as Public Internet and select VLAN for eth1. Type BACKEND in the VLAN entry box and click <em>Create “BACKEND”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ruV5dmtjprdxjLI1V4PtQ.png" /></figure><p>Then click “<em>Add Configuration</em>” at the very bottom.</p><h4>Step 5 — Install TrueNAS into the Shell Linode</h4><p>Click “<em>Boot</em>” on your new config.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SUG8tMAm7IJoRwKypn54WQ.png" /></figure><p>Confirm the Boot and then open the LISH Console again by clicking on the “<em>Launch LISH Console</em>” button from the top right.</p><p>When you see this screen, arrow down and then up again to stop the timer. Select the “<em>Start TrueNAS SCALE Installation</em>” and hit Enter. <strong>**This is a very important step, as the installer may hang if you let it auto select the installation.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/851/1*ss0YOdb9CYr1rKFNB2UjMg.png" /></figure><p>After selecting the installation starter, click “<em>Glish</em>” in bar above to switch to the graphical console. Yes this is hokey — but it works. You should now see the installation menu:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/983/1*2KfCL7r0bnRJyveXluAtXA.png" /></figure><p>Place your cursor over the “<em>OK</em>” and left click. Then hit Enter.</p><p>You will be presented with a warning because the Demo system does not have sufficient RAM for a production installation. But this is not for PROD. So arrow left to “<em>Yes</em>” and click Enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*ECCh3XIcXkwj5h_QJNsODQ.png" /></figure><p>Hit your space bar to select the only disk available at this time, and hit Enter. You will add the Volumes after installation of the main system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*p3M6kTEpf7O1g6zQ7sGSqQ.png" /></figure><p>Accept the warning and hit Enter again. Next leave the WebUI user at the default of admin and hit Enter. Then give admin a cool password. I’m using ‘password’ so you can’t use that one. Hit Enter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*Kyo712KUGOYXUEXtTNyHag.png" /></figure><p>Now accept the default 16GB for swap and hit Enter once again to create swap.</p><p>You want to allow EFI boot. So leave this at the default “<em>Yes</em>”, and hit Enter. Then sit back and let the install run for the next few minutes. You should soon see a success message. This should take no more than 5 minutes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*dbkMWs4BIkleOVdNyP9FHw.png" /></figure><p>Now close the LISH console window and power down the Linode from the Linode overview screen using the “<em>Power Off</em>” button. Confirm the power off.</p><p>And now the last step before you have a functional NAS is to modify the boot config. Edit the configuration by clicking “<em>Edit</em>” next to your config.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xI0Dg0fi8KVCzWlVFMamrw.png" /></figure><p><strong>Change the following settings:<br></strong><em>Under Block Device Assignments change</em><br>/dev/sda should reflect TRUENAS_1_SYSTEM<br>/dev/sdb should reflect NAS_VOL_1</p><p>Now Click the “<em>Add A Device</em>” 2 times to add /dev/sdc and /dev/sdd<br>/dev/sdc can be set to NAS_VOL_2<br>/dev/sdd should be set to NAS_VOL_3</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*54HDvWhQViF-8pvzRBaKlA.png" /></figure><p>Scroll to the bottom and click “<em>Save Changes</em>”</p><p>Now click “<em>Boot</em>” again to the right of your config. And confirm the boot.</p><h4>Step 6 — Configure TrueNAS</h4><p>Once the Linode is Running, click the IP Address to copy it to your clipboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*Bfm-1sgz9uflkLBt1ZJzqw.png" /></figure><p>Open a new tab in your browser and paste the IP. It may take a minute for the system to fully come up. So be patient. Then enter your username of ‘admin’ and your super secret password into the login screen and click “<em>Log In</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*x87-7pP4NN4HB_lJpLjhWg.png" /></figure><p>Now you need to make the system available on the VLAN you set up. To do so, click “<em>Network</em>” from the menu on the left. You should see two interfaces. One will have the public IP you pasted in your browser, The other will only have IPv6. Click the pencil icon on that second interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*BH8p5Gn1rouumiw4POxmLQ.png" /></figure><p>Uncheck “<em>DHCP</em>” and then click “<em>Add</em>” down at the bottom next to “<em>Aliases</em>.”<br><strong>Use the following settings:<br></strong>IP Address: 192.168.1.100 / 24</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*yMBNlwjFwAvnGVLaYyzpTw.png" /></figure><p>You can click skip when it prompts for a new Default Gateway. However, <strong>you will need to click the pencil icon on the first Network Connection, and re-enable DHCP, as it removes it from both Interfaces. **This is a very important step.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/755/1*0vsZ_yhofe809K1loNksMg.png" /></figure><p>Click “<em>Test Changes</em>” and then click “<em>Save Changes</em>.”</p><p>Now the network should be setup properly on the virtual appliance. The next step is to create the pool. To do so, click “<em>Datasets</em>” from the left side. Then click “<em>Create Pool</em>”</p><p><strong>Use the following settings:<br></strong>Name: NAS_POOL<br>leave encryption off for this exercise and click “Next”<br><em>Data<br></em>Layout: RAIDZ1 — If you create a NAS for production with much larger drives, dRAID may be better for you.<br>Disk Size: 20 GiB (This should match the size of 1 Linode Volume that you created in step 1).<br>Width: 3 — This is the number of Disks to use in the set.<br>Number of VDEVs: 1</p><p>We are not going to enable any other features here. ZFS uses RAM for read and write caching. So unless you have a specific situation where it would warrant this, do not enable it. So click “<em>Save And Go To Review</em>” And then “<em>Create Pool</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*n_qAZjQUtUrARRN1_snEmQ.png" /></figure><p>Confirm the pool.</p><p>The last item for a basic setup is to create an NFS Share. Accomplishing this is simple. Click “<em>Shares</em>” from the menu on the left. On the line “<em>UNIX (NFS) Shares</em>” click “<em>Add</em>” and use the following settings:<br>Path: /mnt/NAS_POOL<br>Description: Whatever you want to put here<br>Network — click “<em>Add</em>” and enter 192.168.1.0 and /24</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*DA_xQ4CyNOsP6HylaQRYgw.png" /></figure><p>Scroll to the very bottom and click “<em>Advanced Options</em>” Just for demo purposes, set “<em>MapAll User</em>” to root and “<em>MapAll Group</em>” to root. In a real world scenario you will want to place proper controls. So do not do this in production. Click “<em>Save</em>” and you will be prompted to enable the NFS service on boot, click “<em>Enable Service</em>”</p><p>Now Restart from the Power menu in the upper right. Confirm the Restart. And if all goes well, the NAS should come back up. This is to test that the network Interfaces are properly set and the NFS service automagically starts.</p><p>When the NAS comes back up, it will take you right back to where you left off. So you can easily validate that NFS is running and your share is created. Your NAS is now officially created, online and serving a data share. Now you need to create the Ubuntu Linodes to run your Apache site that will be mounted from your new NAS.</p><h4>Step 7 — Create the Web Servers</h4><p>Go back to the Akamai Connected Cloud console and click the blue “<em>Create</em>” and select “<em>Linode</em>.”<br><strong>Use the following settings:<br></strong>Images: Ubuntu 23.10<br>Region: Use the same region you used for Volumes and the NAS.<br>Linode Plans: Click Shared CPU and select the Nanode 1 GB.<br>Linode Label: APACHE_1<br>Root Password: Give it a good root pass<br>Firewall: leave this blank<br>VLAN: Select BACKEND<br>IPAM Address: 192.168.1.10/24</p><p>Scroll to the bottom and click “<em>Create Linode</em>”</p><p>After the instance provisions, you will need to configure it. You can do this via the LISH console or SSH. Once the instance is in a running state, click “<em>Launch LISH Console</em>” and login using root and your root password. Run the following commands:</p><pre>apt update &amp;&amp; apt instal -y apache2 nfs-common php<br>hostnamectl hostname APACHE1<br>vi /etc/fstab</pre><p>Go to the last line and type ‘o’ and then enter the following line</p><p>192.168.1.100:/mnt/NAS_POOL /var/www/html nfs defaults 0 0</p><p>Hit Esc and then type <em>:x</em> (colon x) to save the file.</p><p>These commands did the following: They installed the nfs binaries required to mount an NFS share, installed Apache2 and installed PHP. Then opened the fstab file and entered the mount point information so the NFS share mounts at boot on to the default html directory for Apache. This will allow Apache to use a shared webpage across multiple servers. The next step is to reboot the instance to mount the NFS share. Then clone this instance so you have 2. In your Akamai Connected Cloud console, click “<em>Reboot</em>.” Confirm the reboot. And when the instance comes back to a running state, click the … and select “<em>Clone</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*uqL59l5tCsI72hJ3dyIEdg.png" /></figure><p>In the resulting Window, select APACHE_1. Then select the same region you have been working in. Keep the “<em>Linode Plan</em>” at Nanode 1GB. Change the label to APACHE_2. And then click “<em>Create Linode</em>”</p><p>In the new APACHE_2 Linode overview screen, click “<em>Configurations</em>” and “<em>Edit</em>”</p><p>Scroll to the bottom and change the IPAM Address associated to the VLAN to reflect 192.168.1.11/24. Click “<em>Save Changes</em>”. And then power up your Linode with the “Power On” button. Click “<em>Launch LISH Console</em>” and login using your root user and previously set root password.<br>Run the following commands:</p><pre>hostnamectl hostname APACHE2<br>cd /var/www/html<br>curl -o index.php https://php-mysql-demo.us-iad-1.linodeobjects.com/index.php</pre><p>These commands set the system variable for hostname to a unique hostname that will be pulled into your webpage. The curl command pulls in a php page from a bucket and places it in the NFS share now mounted by both Apache servers.</p><p>Now the last thing to do to verify this installation is to check both Apache servers via http to ensure both have the new page. Enter the Public IP listed on each Apache server’s Linode overview page into a web browser. You should get a colorful message back that tells you which server you are using. The very last thing to do is to add a NodeBalancer to this and firewall off the Webservers.</p><h4><strong>Step 8 — Load Balance Web Servers</strong></h4><p>First off we have to add Private IPs to the Instances — Yeah I know, A VLAN is private. But these private IPs talk to the Load Balancers on a special subnet. So in each of the Apache servers’ Linode Overview page, click “<em>Network</em>” and scroll to the bottom. Click “<em>Add and IP Address</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ESk9l7iJkmwkLmk8CMBfqw.png" /></figure><p>In the resulting window, select “<em>Private</em>” under IPv4 and click “<em>Allocate</em>”. Repeat this process for the other Apache server.</p><p>Now, to create the NodeBalancer, select the blue “<em>Create</em>” at the top of the screen and click “<em>NodeBalancer.</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/443/1*T8mvbRybEtaXAZzq5BIOQw.png" /></figure><p>Use the following settings:<br>NodeBalancer Label: WEBSERVERS<br>Region: Select the same region you have placed all your other assets in<br>Configuration: Change “<em>Protocol</em>” to “<em>TCP</em>” and “<em>Session Stickiness</em>” to “<em>None</em>”<br> **This is to more effectively show the change from 1 Apache Server to another.<br>Add your APACHE_1 and APACHE_2 nodes as “<em>Backend Nodes”</em> — Give each a label of its name</p><p>Finally click “<em>Create NodeBalancer</em>”</p><p>Make a note of the IP Address of your new NodeBalancer.</p><h4><strong>Step 9 — Firewall the Web Servers</strong></h4><p>The last step is to move the Apache servers to a firewall policy that will only allow traffic from the NodeBalancers. Again click the blue “<em>Create</em>” and this time select “<em>Firewall</em>” Make your new policy label WEBSERVERS and click “<em>Create Firewall</em>” Add APACHE_1 and APACHE_2.</p><p>Click your new WEBSERVERS policy. Change the “<em>Default Inbound Policy</em>” to “<em>Drop</em>” and click “<em>Add An Inbound Rule</em>.”</p><p>Select the “<em>HTTP</em>” preset, but change “<em>Sources</em>” to reflect “<em>IPv4 / Netmask</em>.” Add 192.168.128.0/17, then click “<em>Add Rule</em>”</p><p>Click “<em>Save Changes</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*ZwU8vkxzSLhymSyv0PmTkg.png" /></figure><h4>Step 10 — Test</h4><p>You should now no longer be able to reach your Apache servers on their individual Public IPs, and only now through the NodeBalancer IP. Enter the NodeBalancer IP in your browser and hit Enter. You should see the PHP page from one of your Apache servers. Click refresh a bunch of times or check from another web browser. You should get responses from both APACHE1 and APACHE2.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vCiYY1ZHAnA9Yekur8xQhg.png" /></figure><p>Hopefully you have learned something here that you can use in the real world. Stay tuned for future Akamai Connected Cloud tutorials where I will explore additional considerations such as clustering, auto-scaling, geographical distribution and replication.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=140fb597b15a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Custom Operating Systems in Akamai Connected Cloud]]></title>
            <link>https://medium.com/@brent.m.eiler/custom-operating-systems-in-akamai-connected-cloud-dca8f523895b?source=rss-d96a116a80ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/dca8f523895b</guid>
            <category><![CDATA[akamai-connected-cloud]]></category>
            <category><![CDATA[linode]]></category>
            <category><![CDATA[linux-tutorial]]></category>
            <category><![CDATA[rhel]]></category>
            <category><![CDATA[red-hat-enterprise-linux]]></category>
            <dc:creator><![CDATA[Brent Eiler]]></dc:creator>
            <pubDate>Thu, 07 Dec 2023 02:24:26 GMT</pubDate>
            <atom:updated>2023-12-07T02:24:26.921Z</atom:updated>
            <content:encoded><![CDATA[<p>As anyone who has used the platform can tell you, the artist formerly known as Linode — the Akamai Connected Cloud — is built for the Open Source community. To that end, licensed products are nowhere to be found in the platform. However, due to the Open Source nature of the platform, this by no means excludes licensed products from running here. And this includes Operating Systems and virtual appliances. Today, I will show you how to load your own Red Hat 8 dev system in the Akamai Connected Cloud using the official Red Hat KVM image. This process can be followed for virtually any OS out there that has a KVM image.<br><strong>**DISCLAIMER — THIS IS FOR DEMONSTRATION PURPOSE ONLY. SOFTWARE LICENSING IS BETWEEN YOU AND A SOFTWARE VENDOR. AKAMAI MAKES NO WARRANTIES AS TO YOUR COMPLIANCE WITH SOFTWARE VENDORS. AKAMAI CONNECTED CLOUD IS NOT A RED HAT CERTIFIED CLOUD. THIS IS ONLY AN EXAMPLE AND SHOULD NOT BE RUN IN PRODUCTION WITHOUT THE EXPRESS CONSENT OF RED HAT.<br></strong>That said, here is what you will need to build along.</p><ul><li>A Redhat Trial KVM Image</li><li>An Akamai Connected Cloud account</li><li>A linux terminal to work from</li><li>20-30 minutes from your busy schedule</li></ul><h4>Step 1</h4><p>The first order of business is to obtain a Red Hat trial image. This can be done via the Red Hat site.</p><h4>Step 2</h4><p>One you have the qcow2 image, it will need to be manipulated to work in the Akamai Connected Cloud environment. You must make 3 keys changes to load the image:</p><ol><li>Remove Cloud Init. This does not work with the Linode Cloud Init</li><li>Set a root password within the image</li><li>Convert the image to a raw format</li></ol><p>To do this, it is best to work from a Linux workstation. You will need to get the following packages: qemu-utils and libguestfs-tools. Once installed you can use virt-customize to remove Cloud Init and set a root password with the following command:</p><p>sudo virt-customize -a rhel-8.1-x86_64-kvm.qcow2 — root-password password:linode — uninstall cloud-init</p><p>This command assumes your image name is rhel-8.1-x86_64-kvm.qcow2 and you are setting a root password of linode</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-BZu8X9JPyGD1aT8JEcb1Q.png" /></figure><p>Once that is done, you can start packaging this up for deployment. Using qemu-img, you will convert the qcow2 image format to an output raw format. And then zip the file to save bandwidth in transfer.</p><pre>qemu-img convert -f qcow2 -O raw rhel-8.1-x86_64-kvm.qcow2 rhel81-image.raw<br><br>zip rhel81-image.raw.zip rhel81-image.raw</pre><h4>Step 3</h4><p>Now, that the image is zipped up it can be uploaded to anywhere on the Internet capable of serving up a file of roughly 700MB. I recommend Akamai Connected Cloud Object Storage within the same region you will create your VM. Once you have uploaded your image, move on.</p><h4>Step 4</h4><p>Now that you have the image file uploaded. The next step is to create a shell VM from which to work, along with a swing volume to hold the image during “install.” This is a very simple process and can be accomplished via the API or the Cloud Manager UI. I would suggest using the Cloud Manager UI for this task, as you will have to use the Cloud Manager to do the install anyway. So, in the UI, click “<em>Create</em>” and select “<em>Linode</em>” from the drop down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*lN67tzWelVZ8R4ddcYQeXw.png" /></figure><p>In the next screen, this is very key. Click the ‘x’ next to the selected image name. The result should be a blank space under “<em>Images</em>.” Leave it that way. Then select a region to install your VM into.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*BgZMNP-2JtJ8V2CnNb0yfQ.png" /></figure><p>Select whatever <em>Linode Plan</em> makes you happy. A simple 1x2 or a 2x4. It does not really matter. You can go create another one when you are done here if you want.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*Ga1AE2qZ7D20I-C7fEaRsg.png" /></figure><p>Give your Linode a label and then click “<em>Create</em>.”</p><h4>Step 5</h4><p>Now, click the blue “<em>Create</em>” at the top of the screen again. This time, select “<em>Volume</em>.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*NTHqKLxg1MHAw3h0UPtOtA.png" /></figure><p>Give it a label, maybe “<em>SWING</em>” and select the same “<em>Region</em>” the new Linode was created in. In the size, use 13GB. This will be enough to hold the 700MB image and the unzipped version. Click “<em>Create Volume</em>” and you are ready to start loading the VM.</p><h4>Step 6</h4><p>Go back to your newly created Linode by clicking “<em>Linodes” </em>on the left hand menu and the selecting your Linode. Next you will create a disk. Click the “<em>Storage”</em> group and then “<em>Add A Disk</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tgM4gCX11JbiUc79RuJuYQ.png" /></figure><p>Select “<em>Create Empty Disk</em>” and give the disk a label, maybe ‘<em>INSTALL</em>’. Choose “<em>raw</em>” for the filesystem. Give the disk the maximum size and click “<em>Create.</em>”</p><h4>Step 7</h4><p>The next step involves booting the shell of a VM into a rescue disk so you can image the new boot disk using your uploaded image file. To do so, click the <em>…</em> in the upper right of the Linode page and click “<em>Rescue</em>.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*XbQPkC3_zsJh9_EmCmoC_g.png" /></figure><p>In the resulting menu, select the disk label you just created as /dev/sda (hopefully this is ‘INSTALL”) and in the drop down for /dev/sdb select the label for the Volume you created above (hopefully this is “<em>SWING”</em>). Click “<em>Reboot Into Rescue Mode</em>”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*DBL14s_UqGQsS_gZIWa09g.png" /></figure><p>Right next to the … Is a button for “<em>Launch LISH Console”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*tcogSeo3CysBZE_Danubfw.png" /></figure><p>Click this button and it will open up a magical terminal window that will eventually land you on a finnix prompt. Here you will format the swing volume, download the image, uncompress the image and load it to the install disk. To start, create a filesystem on that swing volume by entering the following command: mkfs.ext4 /dev/sdb Then mount /dev/sdb with mount /dev/sdb /mnt and enter the disk by doing a cd /dev/mnt<br>Now, download your image from wherever you placed it using curl. Example: curl -o rhel81-img.raw.zip <a href="http://pathto/">http://pathto</a>yourfile</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HA7z1n4Q6gtm2ng2Kr-U4Q.png" /></figure><p>Once downloaded, issue an unzip command: unzip rhel81-img.raw.zip And finally block copy the .raw file to /dev/sda using dd: dd if=rhel81-img.raw of=/dev/sda bs=4M status=progress</p><p>Once this completes, close the LISH console window. And in the Linode page, click “<em>Power Off</em>”</p><h4>Step 8</h4><p>The last step before you have a functional VM is to create the Boot Configuration. Under the “<em>Configurations”</em> menu, click “<em>Add Configuration</em>.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZRXtiWeEpAVQZehOPiE4dA.png" /></figure><p>Give the config a label like with everything in Akamai Connected Cloud. Under “<em>Boot Settings”</em> select “<em>Direct Disk</em>.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/1*_pyu10ScrblBNxBCtiZAHQ.png" /></figure><p>Then finally under “<em>Block Device Assignment</em>,” assign /dev/sda to the disk you just imaged. If you used my suggested label, this will say “<em>INSTALL</em>.” Scroll all the way to the bottom and click “<em>Add Configuration</em>”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*b6uyi1gBlfGi5Icpyc56DQ.png" /></figure><h4>Step 9</h4><p>The last thing to do is boot this new configuration and log in. To do so, click “<em>Boot</em>” next to your new Configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mv7aDxwjKHUbIpkK55r2vw.png" /></figure><p>Wait for the Linode status to show as “<em>Running</em>” and then click the SSH Access to copy to it the clipboard. Then paste into your terminal window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*XFTr_IAzfujmjHQ3Bep-UA.png" /></figure><p>Accept the key and then enter your password at the prompt (mine was linode). You should now be in your RHEL system running on the Akamai Connected Cloud.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*c-pMfUxEI4HuuOEjBi121w.png" /></figure><h4>Step 10</h4><p>To make the most of your system, you should expand your partition and filesystem to cover the whole disk. This is easily accomplished by doing the following:</p><p>fdisk /dev/sda and type p to print the current partition table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*XF7YImEgoXQKIRRCdJc1GA.png" /></figure><p>Type d to delete the existing partition. Then type n to create a new partition. Use the default partition 1, then give your new partition the same start sector as the old. And finally accept the default for the end sector. When done, type w to write the new table and exit.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*We3WSf00iauVCxD0PA-etg.png" /></figure><p>Type sudo partprobe to update the system. Then expand your root filesystem to the maximum by typing sudo xfs_growfs / Finally type df -H to view the new root filesystem size.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*QNOWth9tJgcOWfaQ4sv1vg.png" /></figure><p>And you are done. You have a new RHEL system running on a Linode using the official KVM image from Red Hat. If you are going to test with this system for more than a few minutes, add a the instance to a cloud firewall in the Akamai Connected Cloud Manager to keep it secure. You can now delete the Volume created to support this install, under “<em>Volumes</em>.” And be sure to delete this instance prior to your RHEL trial license expiration.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dca8f523895b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enhancing LKE with the Zeet IDP]]></title>
            <link>https://medium.com/@brent.m.eiler/enhancing-lke-with-the-zeet-idp-2c2e8be5cb6a?source=rss-d96a116a80ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c2e8be5cb6a</guid>
            <category><![CDATA[lke]]></category>
            <category><![CDATA[zeet]]></category>
            <category><![CDATA[linode]]></category>
            <category><![CDATA[akamai-connected-cloud]]></category>
            <category><![CDATA[internaldeveloperplatform]]></category>
            <dc:creator><![CDATA[Brent Eiler]]></dc:creator>
            <pubDate>Wed, 06 Dec 2023 00:54:28 GMT</pubDate>
            <atom:updated>2023-12-06T00:54:28.356Z</atom:updated>
            <content:encoded><![CDATA[<p>In my latest LKE productivity article I will explore a really cool topic, using a tool developed by a former engineer at AWS. This tool is called Zeet. And it is an Internal Developer Platform run as a Service. But before I dig into the what and the how, let’s talk about the why. Why do you need an Internal Developer Platform? Well, maybe you do not. Maybe you have an army of really smart developers and really smart cloud engineers as well as a gaggle of super smart Infrastructure engineers. And maybe they all get along harmoniously and everyone is super productive. And in general everything is awesome. But in reality, there are competing priorities and developers, cloud engineers and infrastructure engineers all report to different teams and quite frankly speak completely different languages. Or maybe they just speak different dialects of nerd. Whatever the case may be, a self service platform where everyone can do their own parts without having to rely on the others is a great way to boost efficiency in resources. And through this workflow automation, you can provide a consistent level of service, provide standardization leading to better scaling, and enforce security across all applications in the same manner. Sounds great right? Where do I sign up? Well, if you want to follow along you can signup up for Zeet at their website — <a href="http://www.zeet.co./">www.zeet.co.</a> Their free account should be enough for this specific purpose. Now this is not an advertisement for Zeet. So I will not be going in to all their cool capabilities. You can learn all that on your own once you have an account. What I will focus on specifically here, is how easy this makes deploying an application in the Linode Kubernetes Engine.</p><p>However, I will give a brief overview of the Zeet platform. Zeet was developed by Johnny Dallas and his team. It helps you to manage your deployments using Teams, Projects, Blueprints, Clusters and Clouds. Teams, of course, are the people power interfacing with the system. Projects are the deployments themselves. Blueprints are repeatable processes defined to execute your deployments. Clusters are your Kubernetes clusters. And Clouds are where your clusters live. Devs can use the system to deploy their apps. Cloud and Infra guys can use the system to define Blueprints for use by the devs and manage the Cloud accounts. And our good friends at Zeet have common Blueprints for everyone to use — in the event you do not have access to those Cloud and Infra guys. Simple yet elegant, right?</p><p>Ok, lets dive in to how you can use Zeet to deploy a containerized application into LKE with very little knowledge of Kubernetes or infrastructure in general. You will need the following to complete this tutorial:</p><ul><li>A registered domain name</li><li>An Akamai Connected Cloud LKE Cluster*</li><li>An Akamai Connected Cloud personal access token</li><li>Access to a shell (preferably Linux)*</li><li>A Zeet account</li></ul><p>*At the time of this writing, Zeet has not fully integrated LKE into the platform. The two marked activities will go away once the provisioning integration is completed. At that point, you will only need the domain, Akamai token and Zeet account. You can also tie a Github account to your Zeet account for even better continuous deployment integration. But that is a topic for a later date. And just like all my tutorials, if you do not have an Akamai Connected Cloud account, <a href="https://www.linode.com/lp/free-credit-100/">sign up here</a> for a $100 credit.</p><h4>Your Domain</h4><p>The first thing we need to accomplish is ensuring we have a subdomain we can use. And that subdomain should be delegated to Linode if the domain is not already pointed at the Linode Name Servers. This is a very simple process. Whereas the full process is not in scope for this document, the high level is this: Using whatever DNS provider you use (Linode or otherwise), go to your DNS Management console and create a new NS type record in your current domain. Give the record name the new subdomain you want to use (e.g. zeet.mydomain.com) and add ns1.linode.com through ns5.linode.com to the record. Using some providers (like AWS Route53) you can do this in 1 action. In others, such as Linode, you must create a new NS record per Linode nameserver. Next add this new subdomain as a zone in your Linode DNS Manager. In the Akamai Connected Cloud Manager (a.k.a Linode) UI click the “<em>Create</em>” blue drop down button and select “<em>Domain</em>.” Select “<em>Primary</em>” and fill in the domain name you have delegated (e.g. zeet.mydomain.com) and click “<em>Create Domain</em>.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*TP2LPkTjeNHZvtRJ0w1ZwA.png" /></figure><h4>Create Your Cluster</h4><p>If you are familiar with the Akamai Connected Cloud a.k.a. Linode, you will know this is a very simple process. For the purpose of this exercise we are going to keep it very small. So if you don’t have credits to use, don’t fret, this should cost less than a dollar. In your Cloud Manager console:</p><ol><li>Click “<em>Create</em>” and Select “<em>Kubernetes</em>.”</li><li>Give the cluster a label, maybe Zeet.</li><li>Pick a region close to you from the drop down</li><li>Under HA Control Plane, select “<em>No</em>”</li><li>Click the “<em>Shared CPU</em>” instances in the “<em>Add Node Pools</em>” section.</li><li>Click the “<em>-</em>” at the end of the “<em>Linode 4GB</em>” line until it reads “<em>1</em>” then click “<em>Add.</em>”</li><li>Click “<em>Create Cluster</em>” and we are just about done.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rBCFoRlukitr3FyBpVLBxg.png" /></figure><p>It will take a couple minutes to build the cluster. And when done will take you to the cluster overview screen. After the node is provisioned, its status will change to “Running” and you can download the kubeconfig.yaml. Save the kubeconfig to use when provisioning Zeet to the cluster.</p><h4>Create a Token</h4><p>As with every external system you connect to your cloud accounts, you want to create a least privilege token to be used only by that system and for a limited time. Since Zeet currently does not do the provisioning of LKE, that privilege should be contained to only DNS management. In the future the token will need access to Kubernetes and potentially other IAM resources. Zeet will also infer privileges from LKE itself through the Cloud Controller Manager once Zeet assumes management of the LKE Cluster. So, when creating your token for this exercise, open your main user menu in the upper right corner and select “<em>API Tokens</em>.” Click “<em>Create A Personal Access Token</em>” and give it a label — maybe Zeet. Select an expiration, I suggest 1 month. Then kill all privileges by selecting “<em>None</em>” on the “<em>Select All</em>” line. Give your token only DNS privileges by selecting “<em>Read/Write</em>” from the “<em>Domains</em>” line. Then click “<em>Create Token</em>” at the very bottom. **Note: This represents the Akamai Connected Cloud IAM at the time of writing. The IAM is under further development to better suit the needs of customers. And the resources and actions listed will likely change greatly in the next 12 months.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*hh50RIQFXOSmRHDkDqD01Q.png" /></figure><p>CCick this button to save your Access Token — you will need it to onboard the LKE cluster to Zeet.</p><h4>Onboard the Cloud Account and LKE Cluster to Zeet</h4><p>This next step can be tricky. So luckily it will be going away and soon replaced by a click to provision LKE cluster within the Zeet software that will deploy the cluster within Akamai Connected Cloud and onboard the resulting Kubernetes cluster to the Zeet IDP using nothing more than your Akamai Connected Cloud account in Zeet. But for now, we will walk through the manually onboarding process that must be done for each Linode LKE Cluster used within the Zeet IDP.</p><p><strong>Step 1: </strong>Sign up for a Zeet account if you have not already.</p><p><strong>Step 2:</strong> Add your Cloud Personal Access Token to the Zeet platform by selecting “<em>Clouds</em>” from the navigation menu on the left. Click “<em>New Cloud</em>” and then “<em>Linode</em>.” Paste in your personal access token created in the previous step. Then click “<em>Connect</em>.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*yBRDVggRJKj6Ta9c8sjhWQ.png" /></figure><p><strong>Step 3: </strong>Add your cluster by selecting “<em>Clusters</em>” from the menu on the left. Click “<em>Connect Cluster</em>.” And then select “<em>Connect LKE Cluster</em>” from under “<em>Connect self-managed cluster</em>.” Your cloud account created in step 2 should be listed at the top, along with a name and a region. Select the region you used to deploy the LKE Cluster in the Akamai Connected Cloud portal. Then, upload the kubeconfig you downloaded when creating the cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*MZ7WDrXPv_29cq9SM8xWEQ.png" /></figure><p>In the next screen you can also tie Github credentials and a repo to this cluster. This is out of scope for this exercise. Click “<em>Back to Clusters</em>.”</p><p><strong>Step 4:</strong> The next step is to load software to the cluster that allows Zeet to automate things for you. This step uses helmfiles and a Kubernetes manifest to get all our affairs in order. We will use a repo from the Zeet team: <a href="https://github.com/zeet-dev/zeet-cloud-linode/tree/main/lke-byok/k8s">https://github.com/zeet-dev/zeet-cloud-linode/tree/main/lke-byok/k8s</a>. To accomplish this, you will need to have the following installed on your terminal:</p><ol><li>helm — installable via snap or other package managers — sudo snap install helm <a href="https://helm.sh/docs/intro/install/">https://helm.sh/docs/intro/install/</a></li><li>helmfile (yes this is different) — download the binary via <a href="https://github.com/helmfile/helmfile/releases/tag/v0.159.0">https://github.com/helmfile/helmfile/releases/tag/v0.159.0</a></li><li>kubectl — standard ole kubectl — if you need it, you can get it here: <a href="https://kubernetes.io/docs/tasks/tools/">https://kubernetes.io/docs/tasks/tools/</a></li></ol><p>helmfile may (or may not) give you an error regarding your version of helm when you initialize the binary sudo helmfile init If so, update your version of helm. Once you have these utilities in place, you are ready to roll. If you use git, you can go into your working directory for this project and clone the repo from Zeet — git clone <a href="https://github.com/zeet-dev/zeet-cloud-linod">https://github.com/zeet-dev/zeet-cloud-linod</a>e. Otherwise just open the repo in a web browser and copy the contents of the 3 files we will be working with down to your local machine:</p><ul><li>helmfile.yaml</li><li>cert-manager-linode.yaml</li><li>manifests.yaml</li></ul><p>These files rely on 3 environmental variables to be set on your system</p><ul><li>LINODE_TOKEN</li><li>LINODE_TOKEN_B64</li><li>CLUSTER_DOMAIN</li></ul><p>To do this you will need the subdomain that you set up in DNS and your Linode Access Token that was created earlier.</p><pre>export CLUSTER_DOMAIN=zeet.mydomain.com<br>--replace the domain with your subdomain from the above DNS actions<br>export LINODE_TOKEN=thisiswhereyouputthetokeninthefile<br>export LINODE_TOKEN_B64=$(echo $LINODE_TOKEN | base64 -w0)<br>export KUBECONFIG=zeet-kubeconfig.yaml<br>  --replace this file name with your kubeconfig filename and path if not in the same dir</pre><p>And now, from the working directory where you have the yamls and kubeconfig, run the following commands:</p><pre>helmfile init<br>helmfile apply -f helmfile.yaml<br>helmfile apply -f cert-manager-linode.yaml<br>kubectl apply -f manifest.yaml<br>--If you receive any base64 errors run the command below<br>kubectl create secret generic -n cert-manager linode-credentials --from-literal=token=&quot;$LINODE_TOKEN_B64&quot;</pre><h4>Deploy a Container to Kubernetes</h4><p>In this exercise we are going to use a pre-made container that runs nginx on port 80 and echos back a specific environmental variable that gets passed to the container through a manifest. Zeet will deploy the container to our cluster, create the DNS, create a certificate and expose the container to the Internet via the ingress.</p><p>To accomplish this, go back to your <a href="https://www.zeet.co/">Zeet dashboard</a>:</p><ul><li>Click on “<em>Projects</em>.”</li><li>Select “<em>Deploy my own repo</em>.”</li><li>Then click “<em>Next: Configure project</em>”</li><li>Type “<em>Docker</em>” in the search</li><li>Select “<em>Docker Image</em>”</li><li>Leave the Source as “<em>Docker Hub</em>”</li><li>In the Docker Image field type: <em>eilerb101/nginx_akamai</em>.</li><li>Click “<em>Continue</em>”</li><li>Click “<em>Continue</em>” on the target (you should have only 1 cluster there).</li><li>Change the CPU value to 0.5 and the Memory to 0.5</li><li>Change the “<em>Listen on Port</em>” in networking to 80</li><li>Open the “<em>Environment Variables”</em> and enter a “<em>Key” </em>of <strong>LINODE_ID</strong> and <strong>Awesome </strong>in the “<em>Value</em>.”</li><li>Click “<em>Continue”</em></li><li>Create a group name, subgroup name and a project name (the project name must be all lowercase and have no special characters).</li><li>Click “<em>Deploy”</em></li></ul><p>Now sit back and watch the status and the Runtime logs on the screen. When you receive your success message, it will send you to the Project Overview page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_2Y0vS7tOcXEyNx3dRiUow.png" /></figure><p>Now you need to give it a custom domain name so you can access the page. This will expose it on the Internet using TLS and your DNS. To do this, click “<em>Settings” </em>and “<em>Networking</em>.” Type in a custom hostname and the subdomain as you set up in Linode DNS (e.g. test.zeet.mydomain.com). Click “<em>Add</em>.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jDx4_i6GXUc_Nri6hCG0Cg.png" /></figure><p>Once the Certificate Status changes to ready — you should be all set. Open a web browser and point it to your new url. If you see this page, it was a success!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/766/1*8DKc8Ge2DXu9jFYKrBBkwA.png" /></figure><p>And if you click on the “<em>Logs” </em>tab in your Zeet console, you should see some activity. There are a lot of additional cool features you can play with before tearing the environment down, like the Terminal functionality, which takes the place of kubectl exec -it podname /bin/sh.</p><p>Now, you can clean up and turn down your environment by doing the following tasks:</p><p>In your Zeet Project, go to “<em>Settings”</em> and “<em>Danger Zone</em>.” Click the “<em>Delete”</em> button.</p><p>The click “<em>Clusters</em>” from the left side. At the bottom, click “<em>Unlink Cluster</em>”</p><p>Finally click “<em>Clouds</em>” from the left, Click on your (hopefully) only Cloud, then click “<em>Unlink cloud</em>”</p><p>And now, in the Akamai Connected Cloud console, click “<em>Kubernetes”</em> in the left hand menu. And click “<em>Delete Cluster”</em> in the upper right.</p><p>Then select “<em>Nodebalancers”</em> from the left hand menu, find the Nodebalancer that was attached to your cluster. If you have more than 1 listed there, it is usually a safe bet to delete anything with 0 up — 0 down under backend status.</p><p>I hope you have enjoyed this tutorial on using Zeet with LKE. There are many more features you can use Zeet for to get the most out of your LKE Clusters (including the Github integration). I will post a tutorial soon on using this feature and more.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c2e8be5cb6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Public TLS Certificate Automation in LKE using Certbot & KIC]]></title>
            <link>https://medium.com/@brent.m.eiler/public-tls-certificate-automation-in-lke-using-certbot-kic-fc883300974c?source=rss-d96a116a80ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc883300974c</guid>
            <category><![CDATA[certbot]]></category>
            <category><![CDATA[linode]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kong]]></category>
            <category><![CDATA[akamai-connected-cloud]]></category>
            <dc:creator><![CDATA[Brent Eiler]]></dc:creator>
            <pubDate>Sat, 09 Sep 2023 19:16:41 GMT</pubDate>
            <atom:updated>2023-09-09T19:16:41.813Z</atom:updated>
            <content:encoded><![CDATA[<p>Certificates on the Internet are a very important part of everyday life in this day and age. When certificates stop working, and my browser can not authenticate that you are who you say you are, all Hell tends to break loose. And probably for the best. This keeps us from giving sensitive information to people who should not have it. But from a backend administration perspective, certificates can be a real pain in the backend — pun intended. In this post, I am going to outline a great process that I like to use to automate this certificate handling through the use of a special container, a configmap, Kubernetes secrets and my good friend Certbot. And best of all, this process is FREE and makes use of FREE TLS certificates validated by a public Certificate Authority. I will also show you how to use this with Kong Ingress Controller for Kubernetes (in Akamai Connected Cloud using the Linode Kubernetes Engine). If you would like to build along and do not already have a Akamai Connected Cloud account —<a href="https://www.linode.com/lp/free-credit-100/?promo=sitelin100-02162023&amp;promo_value=100&amp;promo_length=60"> Sign up here for $100 free credit.</a> <strong>You will need a registered domain name to build along.</strong></p><h4>Getting Started</h4><p>I am going to assume that you have the basic knowledge to deploy an LKE cluster in the Akamai Connected Cloud. As well, I am going to assume you have kubectl and helm on your local machine (or a bastion you use). If you have a Docker environment at your disposal, feel free to steal my Docker files and make your own container to store in your Docker Hub repo and use with the Kubernetes manifests provided — otherwise just skip step 2.</p><h4>Step 1 — Prepare your environment.</h4><p>Clone the <a href="https://github.com/eilerb1011/k8s-autocert">repo</a>! This will make everything easier. git clone <a href="https://github.com/eilerb1011/k8s-autocert">https://github.com/eilerb1011/k8s-autocert</a></p><p>If you do not already have an LKE Cluster, create one and download the kubeconfig to your working directory. You only need the smallest cluster possible to complete this — a single 1x2 node on a non-HA LKE cluster will suffice.</p><h4>Step 2 — Build theContainer (You can skip this)</h4><p>Using the Docker folder in the repo, build your container using your Docker environment. Unless you want to make some changes to the container, you can leave everything as is — just be sure to change the below commands to your Dockerhub username and the container name you want to use.</p><pre>docker build -t myDockeruser/my-cool-certbot:latest .<br>docker login<br>docker push myDockeruser/my-cool-certbot:latest</pre><h4>Step 3— Prepare the Cluster</h4><p>Now that you have the repo and your cluster, you will need to do a few things to prep by creating a secret that contains the kubeconfig as well as a configmap that contains information needed by Certbot to create the TLS cert. For the purpose of this exercise, we are going to create a secret from the default kubeconfig file — However, it is recommended to lock things down by creating a role that will only be able to delete and create certs through the use of roles, bindings and a custom kubeconfig.</p><p>Last, in this exercise we will use Kong Ingress Controller to direct traffic inbound from the Internet to our intermittent Certbot container. This will allow us to keep the webroot open for other services, while creating a certificate for a hostname that can be applied to many different webservices in the LKE cluster. So we will install Kong and apply a basic ingress that sends traffic to certbot as well as sends traffic from our webroot to a special container that echos back a node name. And once the Kong Ingress is in place, we will need to tie the fully qualified domain name, as we have documented in our configmap, to the IP Address of the Kong Ingress in our authoritative DNS.</p><p>Before creating the configmap, decide on the hostname in your domain that will be used for your cluster. Mine will be myhost.linode.eiler.rocks. Edit the config.yaml provided in the repo and change the clusterfqdn variable to match your chosen name. Then edit the email address to match the email address you want to be notified on with certificate issues. Save the file. Now we can deploy the secret, the configmap, install Kong (if not already installed) and create the DNS entry.</p><pre>kubectl create secret generic kcon --from-file=config=kubeconfig.yaml<br>kubectl apply -f config.yaml<br>#If Kong is already installed, skip this step<br>helm repo add kong https://charts.konghq.com<br>helm repo update<br>helm install kong/kong --generate-name --set ingressController.installCRDs=false --create-namespace --namespace kong</pre><p>In the commands above, replace kubeconfig.yaml with the name of your own kubeconfig. And now you should have a Kong ingress running in the Kong namespace. You should also have your kubeconfig exposed as a secret named kcon. And you should have a configmap named cert-vars that holds the variables for our Certbot process. The next step is to retrieve your IP Address using kubectl get svc -n kong. This will output something similar to below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2frDvFmUjAwAcweLXnlJ9g.png" /><figcaption>kubectl output</figcaption></figure><p>Use the External IP listed in the kong-proxy line and create an A record in your authoritative DNS server using the host name from the fqdn you have decided to use. <strong>**You must do this or else your TLS cert will not be issued.</strong></p><h4>Step 4 — Deploy Containers &amp; Services</h4><p>The next step will deploy 2 services and a container. The 2 services will allow for ingress from the Internet and direct traffic to our pods — both for Certbot and for NGINX as our main web service.</p><pre>kubectl apply -f certbot-svc.yaml<br>kubectl apply -f nginx.yaml</pre><p>Now run kubectl get pods and kubectl get svc to make sure you have an NGINX deployment running as well as a service for each NGINX and Certbot</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*fVeQSPzj0n_7kYuX-2aWEw.png" /><figcaption>kubectl get svc</figcaption></figure><h4>Step 5 — Configure Ingress</h4><p>Before we unleash Certbot to give us the authority to say we are who we say we are, we need to let Kong know where everything is at. In in the ingress.yaml from the repo, replace both entries <em>replace.with.your.fqdn</em> with your actual fqdn as listed in your authoritative DNS. Everything else can be left alone.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*ZppsBmo75CjqqGh5Usq6kg.png" /></figure><p>But, to provide insight on the rest of the ingress configuration. These entries tell Kong which hosts to accept on which services. Here we allow our fqdn on HTTP and HTTPS. The secret name is the name of the Kubernetes secret where we will store our TLS certificate. (This happens automagically using the certbot container.) The rules simply provide Kong a mechanism to direct traffic. The magic here is that we direct /.well-known/acme-challenge to the Kubernetes service named <em>certbot</em>. This allows for the certbot challenge-repsponse mechanism to work without disrupting traffic on /, which is mapped to the Kubernets service <em>nginx</em>.</p><h4>Step 6 — Apply Cert Creation Jobs &amp; Test</h4><p>The last step will be to deploy Certbot itself. If you have built your own container — change the image in the cert-cron.yaml and cert-job.yaml files to reflect your repo and image. Else, leave them alone and deploy:</p><pre>kubectl apply -f cert-job.yaml<br>kubectl apply -f cert-cron.yaml</pre><p>This will deploy the certbot container that we built in step 2. This container, stands up an Apache server to accept the Certbot challenge-response. It then runs Certbot in silent mode using the configmap created in our preparation. Last, it takes the created TLS cert and stores it in the Kubernetes secret, <em>sitecert</em>, leveraging the config stored in the kcon secret. And then Kong references <em>sitecert </em>to apply TLS to connections.</p><p>Now, run kubectl get secrets --watch</p><p>When you see the new secret named <em>sitecert</em> pop up, open a web browser and go to <a href="https://your.fqdn./">https://your.fqdn.</a> You should see a page with the node name that is running NGINX. And that is it. Your cron job will run every 30 days, create a new cert for your fqdn and place it in the <em>sitecert </em>secret pulled by Kong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hrrFmopMib7jk7N6RsgaDg.png" /><figcaption>Response from NGINX</figcaption></figure><p>You will now have automagic TLS certs for any services on paths in your main fqdn. Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc883300974c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kong Ingress Controller Custom Plugins —Routing by Query String]]></title>
            <link>https://medium.com/@brent.m.eiler/kong-ingress-controller-custom-plugins-routing-by-query-string-1442c8cb02c7?source=rss-d96a116a80ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/1442c8cb02c7</guid>
            <category><![CDATA[lke]]></category>
            <category><![CDATA[kong]]></category>
            <category><![CDATA[kic]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[akamai-connected-cloud]]></category>
            <dc:creator><![CDATA[Brent Eiler]]></dc:creator>
            <pubDate>Thu, 07 Sep 2023 00:30:03 GMT</pubDate>
            <atom:updated>2023-09-07T00:30:03.777Z</atom:updated>
            <content:encoded><![CDATA[<p>In my last post we explored using plugins in Kong Ingress Controller for Kubernetes on LKE. That provided a baseline for this post. Here, we will explore how to create a custom plugin that will do routing by query string. When will you ever need this? I cannot answer that. Honestly, I never thought I would need it, until I did. To get started, you can use the same LKE cluster, with the same Kong implementation as in the previous posts. If you are on a fresh cluster, you can get up to speed by using the values file from the <a href="https://github.com/eilerb1011/kong-query-route">repo</a> and running these commands (assuming you have Helm installed):</p><pre>helm repo add kong https://charts.konghq.com<br>helm repo update<br>helm install kong/kong --generate-name --set ingressController.installCRDs=false -n kong --create-namespace --values=values.yaml</pre><h4>Intro to Custom Plugins</h4><p>Before we dig in, let’s define what a custom plugin is, what options we have and the high level process of implementing one. So what is a Kong custom plugin? A Kong custom plugin a a small piece of software that adds additional custom functionality to Kong Ingress Controller, outside of the officially posted and supported plugins. Like standard plugins, a custom plugin can be inserted at many different steps of the connection, from init_worker to log and everything in between (as defined here: <a href="https://docs.konghq.com/gateway/3.3.x/plugin-development/custom-logic/">https://docs.konghq.com/gateway/3.3.x/plugin-development/custom-logic/</a>). Also like standard plugins, custom plugins are primarily written in Lua — although you can use other languages. Now, a big differentiator is how we implement a custom plugin. For starters, custom plugins must be enabled in your Kong implementation. At a bare minimum, your custom plugin should have a handler and a schema file defined. The handler is where your functions will live. Your schema will define any variables or end user configurations that can occur. Another difference is that we must upload and store our custom plugin to the cluster. In this example, we will use a Configmap to store the plugin. This part can be tricky. Below I will take you through the whole process. If you want to save time typing, clone the repo at <a href="https://gitbub.com/eilerb1011/kong-query-routing">https://gitbub.com/eilerb1011/kong-query-routing</a></p><h3>Building the Custom Plugin</h3><h4>Architecture</h4><p>Before we build, lets take a look at the end result we are shooting for in this exercise. The below depiction shows multiple requests coming in from the Internet. As you can see, we have multiple requests coming to the webroot of our hostname — but going to different webservices. The query string parameter of sys with a value of test, needs to route to the same service as the path /system/test, which both terminate to our NGINX server. But all other requests on the webroot need to route to our Apache server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*jG6mx1FcZYxIXyGpCkhjpQ.png" /></figure><h4>Preparation</h4><p>It may seem a little cart before the horse, however before we enable custom plugins (and define a custom plugin in our Kong configuration), we are going to document our names and values to be used and then create the plugin itself. This will be helpful in ensuring we have everything in place.</p><p><strong>Kong Plugin Name: </strong>queryrouting</p><p><em>— We define this name in our handler, schema and the folder that holds them.</em></p><p><strong>Configmap name:</strong> my-custom-routing</p><p><em>— This holds our actual plugin data and we will reference both this name and the name we gave our plugin within Kong in our Kong reconfiguration values yaml.</em></p><p><strong>Kubernetes Plugin Name (if different):</strong> kong-custom-query-routing</p><p><em>— This name is referenced in our Kong plugin file as well as the annotation in the Ingress configuration.</em></p><p><strong>Ingress Paths and Services:</strong></p><ul><li>/ = apache.default.svc.cluster.local</li><li>/system/test = nginx.default.svc.cluster.local</li></ul><p><strong>Kong Services: TBD</strong></p><p>— This one is tricky. And without it properly formatted, our plugin will fail gloriously. This will be the Kong service name we target when conditions are met. We will discover these later.</p><p>One very major item to note when working with custom routing for Kubernetes services in KIC is that the service name used in the path for purpose of Ingress setup will be different from the naming convention used in the custom routing. This is because the custom routing uses Kong service names that are loosely based on the Kuebrnetes service name. A very important step we will take in our Kong configuration, is to enable the Admin API so that we can view the Kong services in our Ingress configuration. The Admin API is disabled by default for KIC, as everything can typically be done through the Kubernetes mechanisms. And you should not use the Admin API for anything other than viewing specific configuration entries if you are using KIC in Kubernetes. So let’s build our plugin!</p><h4>The Structure</h4><p>In a basic plugin the structure is just a handler and a schema file (both .lua files) placed in a folder with the name of the Kong plugin. In this case, our files will reside in a folder called queryrouting. So create your files in your own queryrouting folder using your favorite text editor: handler.lua and schema.lua. Or just <a href="https://github.com/eilerb1011/kong-query-route">clone the repo</a>.</p><pre>mkdir queryrouting &amp;&amp; cd queryrouting &amp;&amp; touch handler.lua &amp;&amp; touch schema.lua</pre><h4>The Handler</h4><p>The handler is where all your magic happens. Here you must define any imported modules, a priority, version and your custom logic. Before we define our logic, we should define priority. What does this mean? Essentially priority defines when your custom plugin will be executed. The higher the number, the sooner the execution. This is important in ensuring your plugin works properly. For example, if you have created 2 custom plugins, 1 that handles authentication and 1 that handles routing of authenticated traffic, you would want to give the second plugin a lower priority number than the first. In this case, we use a high number, as we are routing first thing when this comes in the door. You will notice, we have given our function a name of query-routing and we are using the Kong module to parse out the query string in the url. If the parameter sys exists, it gets set to a var called sys_param. Its value is then checked against a value that can be user defined.</p><pre>-- handler.lua for queryrouting<br>-- Import modules<br>local kong = kong<br><br>-- Define plugin<br>local queryrouting = {}<br><br>-- Define Priority<br>queryrouting.PRIORITY = 1000<br>queryrouting.VERSION = &quot;1.0&quot;<br><br>-- Define the function<br>function queryrouting:access(conf)<br>  local customparam = conf.param<br>  local customvalue = conf.value<br>  local customservice = conf.service<br>  local sys_param = kong.request.get_query_arg(customparam)<br>  ngx.log(ngx.INFO, &quot;Custom plugin - attemting to use param=&quot;, conf.param)<br>  ngx.log(ngx.INFO, &quot;Custom plugin - param value=&quot;, conf.value)<br>  -- match statement<br>  if sys_param == customvalue then<br>   -- set the target svc<br>    kong.service.set_upstream(customservice)<br>  end<br>end<br>return queryrouting</pre><h4>The Schema</h4><p>This is the configuration for your handler and where you define the variable fields and their defaults. We will leave the defaults blank and define then later in our plugin yaml. You will see below that for out plugin to work, we will need to define values for param, value and service.</p><pre>return {<br>  name = &quot;queryrouting&quot;,<br>  fields = {<br>    { config = {<br>        type = &quot;record&quot;,<br>        fields = {<br>          { service = { type = &quot;string&quot;, default = &quot;nginx-service.default.80.svc&quot;, }, },<br>          { param = { type = &quot;string&quot;, default = &quot;system&quot;, }, },<br>          { value = { type = &quot;string&quot;, default = &quot;test&quot;, }, },<br>        },<br>    }, },<br>  }<br>}</pre><h4>The Configmap</h4><p>The Configmap will be built from the Handler and Schema files; and it will provide the data storage for your custom plugin. We will use the configmap name we have defined above to store this data using the following command from OUTSIDE the folder queryrouting. This assumes you are using a namespace called kong to house your kong services. If you are not, modify the -n parameter.</p><pre><br>kubectl create configmap my-custom-routing --from-file=queryrouting -n kong</pre><p>A very important step comes next — validate the data in the configmap and make sure it looks right. This was a pitfall I hit as I tend to work back in forth in multiple O/S. You should NOT see any wacky \r or \n characters in the configmap. So give it a look with: kubectl describe configmap my-custom-routing -n kong If you see these characters, make sure you are not using a DOS format imported in to Linux. As well make sure all your spaces are accounted for!</p><h4>Create Test Systems</h4><p>The test systems for this exercise are simple and will just be defaul nginx and apache containers — each with super creative service and pod names of nginx and apache. These will get defined in 1 big yaml called kong-systems.yaml</p><pre>#kong-systems.yaml<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: apache-deployment<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: apache<br>  template:<br>    metadata:<br>      labels:<br>        app: apache<br>    spec:<br>      containers:<br>      - name: apache-container<br>        image: httpd:2.4<br>        ports:<br>        - containerPort: 80</pre><pre>---<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: apache-service<br>spec:<br>  selector:<br>    app: apache<br>  ports:<br>    - protocol: TCP<br>      port: 80<br>      targetPort: 80<br>  type: ClusterIP</pre><pre>---<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: nginx-deployment<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: nginx<br>  template:<br>    metadata:<br>      labels:<br>        app: nginx<br>    spec:<br>      containers:<br>      - name: nginx-container<br>        image: nginx:latest<br>        ports:<br>        - containerPort: 80</pre><pre>---<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: nginx-service<br>spec:<br>  selector:<br>    app: nginx<br>  ports:<br>    - protocol: TCP<br>      port: 80<br>      targetPort: 80<br>  type: ClusterIP</pre><p>Apply this with kubectl apply -f kong-systems.yaml</p><h3>Enabling the Custom Plugin</h3><h4>Enable Custom Plugins &amp; The Kong Admin API</h4><p>This next part is very important and requires us to change the Kong configuration to:</p><ul><li>Allow for custom plugins globally</li><li>Define our custom plugin using our Configmap values</li><li>Enable the Admin API so that we can validate Kong service names</li></ul><p>The last bullet is extremely important in keeping you from banging your head on the wall. If the Kong service name set in the set_upstream directive is incorrect, your plugin will fail with no meaningful error message. Further, as mentioned previously, these service names are not quite the same as the Kubernetes service you are sending to, unlike in the path definitions of your ingress.yaml. This assumes you have used the Helm install for Kong, as has been done in all previous posts. In the values.yaml file, we need to make the following modifications:</p><pre># values.yaml<br># Specify Kong admin API service and listener configuration<br>admin:<br>  # Enable creating a Kubernetes service for the admin API<br>  # Disabling this is recommended for most ingress controller configurations<br>  # Enterprise users that wish to use Kong Manager with the controller should enable this<br>#CHANGE ENABLED FROM false TO true<br>  enabled: false<br><br>###DOWN A FEW MORE LINES IS A TLS CONFIG WITHIN ADMIN API<br>  tls:<br>    # Enable HTTPS listen for the admin API<br>#CHANGE THE BELOW VALUE FROM false TO true<br>    enabled: false<br><br>-----<br>#FIND THE PLUGINS SECTION WAY DOWN IN THE VALUES FILE<br>#REMOVE {}<br>#THEN ADD A configmap like the following below:<br>#WHERE - name: IS THE CONFIGMAP NAME AND THE pluginName IS THE NAME OF YOUR FOLDER<br>plugins: {}<br>  configMaps:<br>  - name: my-custom-routing<br>    pluginName: queryrouting</pre><p>It is VERY important that if you have implemented Kong with Helm, you only update Kong configurations with Helm. To do so, start by getting the release name with helm list -n kong which should return something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O1mmtvsZCf5TCTtDw2c5_Q.png" /></figure><p>Then upgrade Kong with the new values.yaml with helm upgrade kong-1693946606 kong/kong -n kong --values values.yaml where you replace my kong-… with your own release name from the output. Once successful, you should see a messaging stating Kong has been upgraded. And it is now time to deploy some test systems, create the plugin in Kubernetes, create the Ingress and tie it to the plugin. Do not worry if your new Kong pods do not come up immediately, there is still configuration to do.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*ML23K5Su0QfAFgAEd6erOg.png" /></figure><h4>Configure The Ingress</h4><p>We are going to configure the Ingress now so that we can see the services listed in Kong. As mentioned before, these are differently addressed than they would be in Kubernetes. So it is important to take careful note of what they are. If you are not working on the same cluster used to implement syslog for Kong, this does remove that plugin. And as always kubectl apply -f ingress.yaml</p><pre>#Ingress.yaml<br>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  name: ingress<br>  annotations:<br>    konghq.com/https-status-redirect-code: &quot;301&quot;<br>    konghq.com/strip-path: &quot;false&quot;<br>    konghq.com/preserve-host: &quot;true&quot;<br>    konghq.com/protocols: http,https<br>    konghq.com/http-forwarded: &quot;preserve&quot;<br>spec:<br>  tls:<br>    - hosts:<br>  ingressClassName: kong<br>  rules:<br>    - host: <br>      http:<br>        paths:<br>          - path: /system/test<br>            pathType: ImplementationSpecific<br>            backend:<br>              service:<br>                name: nginx-service<br>                port:<br>                  number: 80<br>          - path: /<br>            pathType: ImplementationSpecific<br>            backend:<br>              service:<br>                name: apache-service<br>                port:<br>                  number: 80</pre><p>The Admin API</p><p>After we apply the YAML, we should be able to see valid upstreams to place as targets (services) in our plugin configuration. To accomplish this, we need to map the 8001 port of our Kong pod to port 8001 of localhost by: kubectl get pods -n kong and copying the name of our running Kong pod. Then: kubectl port-forward -n kong [THE NAME OF YOUR POD] 8001:8001 If successful you should see something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/469/1*67pdU6upMlQPnWKX9jY4jw.png" /></figure><p>Next, from another terminal window: curl -i localhost:8001/upstreams This output is is JSON so I suggest putting it through a JSON interpereter. However you should see the following services in the output:</p><pre><br>&quot;name&quot;:&quot;apache-service.default.80.svc&quot;<br>&quot;name&quot;:&quot;nginx-service.default.80.svc&quot;</pre><p>As you can see, they are similar, but not the same as what we have defined in our Ingress.yaml. These however are the service names that can be referenced by the plugin as valid targets for which to send /?sys=test (or whatever you decide to call your paramter and value). You can kill the port forward with a ctrl+c and move on to configuring the Plugin.</p><h4>The Plugin YAML</h4><p>The plugin YAML is what Kubernetes uses to intermediate between Kong and the Kong plugin held in the configmap. Here we can also define the data we want to use in our plugin: ie the parameter, value and Kong service. This can drive you absolutely nuts chasing your tail if you are not very careful with the input of that Kong service. So pay attention to your API output. Give your param and value new names (or leave them alone). And leave the service as it is. If you create your own service down the road to test with, here is where you would change it (after updating the ingress configuration and polling the API to validate the name).</p><pre>apiVersion: configuration.konghq.com/v1<br>kind: KongPlugin<br>metadata:<br>  name: kong-custom-query-routing<br>config:<br>  param: sys<br>  value: new<br>  service: nginx-service.default.80.svc<br>plugin: queryrouting</pre><p>As usual kubectl apply -f kong-custom-plugin.yaml</p><h4>The Ingress Annotation:</h4><p>This is the easiest step. We now need to go back to our ingress.yaml file and modify the custom plugin annotation to include the name listed in the metadata of our kong-custom-plugin.yaml. So open the ingress.yaml and add the following line to your annotations:</p><p>konghq.com/plugins: kong-custom-query-routing Save the file and kubectl apply -f ingress.yaml</p><p>Now Test!</p><h4>Test Procedure</h4><p>Testing is simple. Just get the IP Address of your ingress via kubectl get ingress</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*Fvyai3RIY_RioKZeYW6lcQ.png" /></figure><p>Then paste the IP Address into your browser. At the root, you should get the default message from Apache. If you go to /system/test you should the default page for nginx. And if you go to ?sys=new (or whatever you changed the parameter and value to), you should get the same.</p><p>I hope you found this as fun and informative as I did.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1442c8cb02c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Working with Kong Ingress Controller Plugins — A Simple Example]]></title>
            <link>https://medium.com/@brent.m.eiler/working-with-kong-ingress-controller-plugins-a-simple-example-f525a826aba4?source=rss-d96a116a80ab------2</link>
            <guid isPermaLink="false">https://medium.com/p/f525a826aba4</guid>
            <category><![CDATA[kong-api-gateway]]></category>
            <category><![CDATA[kic]]></category>
            <category><![CDATA[linode]]></category>
            <category><![CDATA[lke]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Brent Eiler]]></dc:creator>
            <pubDate>Wed, 06 Sep 2023 13:01:38 GMT</pubDate>
            <atom:updated>2023-09-06T13:01:38.875Z</atom:updated>
            <content:encoded><![CDATA[<h3>Working with Kong Ingress Controller Plugins — A Simple Example</h3><p>Kong can work in multiple ways, one of which is as an Ingress Controller for Kubernetes. This is a great way to get the benefits of Kong integrated into your Kubernetes environment to provide a very robust API gateway functionality. In this environment Kong supports a multitude of plugins to do things from the very simple to custom complex operations. Recently I had the need to do such a non-standard operation and had the pleasure of writing my own plugin. In my case, I needed to leave / open on my hostname to support an automated public cert management process. However, I needed requests from both a specific path and a query string off of / to go to that specific path. So I figure this is a great place to document my journey to help others who may also have the need to write custom KIC plugins for their Kubernetes environments.</p><p>First off though, lets cover basic plugins for Kong. I will also provide an example of integrating a syslog to Kong using the syslog plugin (this was very important in my troubleshooting process). So what is a Kong plugin? A Kong plugin a small piece of software that is used to provide customization in Kong. This can be used to provide custom routing, header or path manipulation or to enable external systems (such as a syslog or authentication). The plugin can be inserted into different places in the workflow, like access (before the request touches anything) or at the log phase (after the last bytes have been sent to the client). Kong plugins can be written in many languages, but primarily are written in Lua. Whereas the plugin architecture is very well documented for Kong Gateway, how it is documented in regards to Kurbenetes may leave a bit to be desired. So I will provide some tips and tricks there. As always with my tutorials — you will need an Akamai Connected Cloud (aka Linode) account to build along. If you have one, great! If not, you can receive a $100 credit to try Akamai Connected Cloud, <a href="https://www.linode.com/lp/free-credit-100/?promo=sitelin100-02162023&amp;promo_value=100&amp;promo_length=60">just click here.</a></p><h4>Syslogging with KIC</h4><p>If you do not have an LKE cluster with Kong running as Ingress, see my tutorial on <a href="https://medium.com/@brent.m.eiler/using-kong-ingress-with-linode-kubernetes-engine-in-akamai-connected-cloud-fb6b5f9564f5">Kong for LKE</a> before continuing. Now, one of the first things to address after building any system is visibility — what good is the system if I cannot see what is going on? How do I know it is working? Yes, you could follow Kubernetes logs all day. But unless you have endless amounts of time to watch 99.9% of things work as expected, this is not a good use of time. This is why we have logs servers. And Kong, like many other systems, supports external syslog servers, through a Kong plugin. This is great for me, because I get to setup syslog to watch my system while explaining Kong plugins. In this example, we will keep the syslog local to our cluster and leave it as an ephemeral system. You could very easily create this as a statefulset or on an external VM. But since our focus here is really just the use of plugins, a simple pod deployment is just fine. To accomplish this, we will use a Kubernetes manifest to define the Kong plugin, one to define a rsyslog server and one to define the Kubernetes service to intermediate between Kong and the rSyslog server. Then we can enable this plugin within the Ingress configuration using an annotation and we should see events flow. From the perspective of Kong the real requirement is the plugin manifest (and config yaml for more complex or reusable plugins) and the annotation within the Ingress. In the end, our architecture will look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*w-kX3mmyb3jBx7T6Li8p7g.png" /></figure><h4>rSyslog setup</h4><p>Step 1 here will be to setup Rsyslog. This is a very simple process that I have made simpler through the manifest. Simply copy this text into your own file — call it whatever you want .yaml.</p><pre>#rsyslog.yaml below<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: rsyslog-pod<br>  labels:<br>    app: rsyslog<br>spec:<br>  containers:<br>  - name: ubuntu-rsyslog<br>    image: ubuntu:latest<br>    command: [&quot;/bin/bash&quot;, &quot;-c&quot;]<br>    args:<br>    - apt update &amp;&amp; apt install -y rsyslog &amp;&amp; echo &#39;module(load=&quot;imtcp&quot;)&#39; &gt;&gt; /etc/rsyslog.conf &amp;&amp; echo &#39;input(type=&quot;imtcp&quot; port=&quot;514&quot;)&#39; &gt;&gt; /etc/rsyslog.conf &amp;&amp; /usr/sbin/rsyslogd -n</pre><p>Then create another file called, again whatever you want. But this time end with -svc.yaml and add the below text:</p><pre>#rsyslog-svc.yaml<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: rsyslog<br>spec:<br>  ports:<br>    - port: 514<br>      targetPort: 514<br>  selector:<br>    app: rsyslog</pre><p>And finally, make a third file called rsyslog-plugin.yaml with the following data:</p><pre>#rsyslog-plugin.yaml<br>apiVersion: configuration.konghq.com/v1<br>kind: KongPlugin<br>metadata:<br>  name: tcp-log-plugin<br>config:<br>  host: syslog.default.svc.cluster.local<br>  port: 514<br>plugin: tcp-log</pre><p>Now, before applying these manifests to our Kubernetes deployment, let’s break down what they do. The first file is the pod manifest. It is deploying an ubuntu pod, installing rsyslog, adding a couple lines to the configuration to enable a TCP/514 listener and finally running the rsyslogd binary. The second file creates a Kubernetes service that exposes TCP 514 from our pod to the rest of the cluster as service name rsyslog.default.svc.cluster.local. And finally the last file is the Kong plugin definition. Now since this is a standard definition, Kong already knows the data and scripts it needs to run to enable this function based on the Kong plugin name at the very bottom (tcp-log). However, it does not know the configuration. So, this is where we plug in that service name (under the host) and the port number used for syslog. We also give it a name in the metadata that will be used in the ingress annotation.</p><p>And now that we know what these files do, it is time to apply them to the cluster:</p><pre>kubectl apply -f rsyslog.yaml<br>kubectl apply -f rsyslog-svc.yaml<br>kubectl apply -f rsyslog-plugin.yaml</pre><h4>Enable The Plugin and Test</h4><p>Next comes the simple part, enabling the new plugin to start sending traffic to our syslog server. To do so, we add the following annotation to the current ingress configuration konghq.com/plugins:tcp-log-plugin You might notice this uses the name we define in the plugin metadata. If you have not yet set up an ingress. Here is a sample ingress with a sample nginx pod and service to demonstrate the test:</p><pre>#Sample NGINX Pod<br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: nginx<br>  labels:<br>    k8s-app: nginx  <br>  annotations:<br>    deployment.kubernetes.io/revision: &quot;1&quot;<br>    kubectl.kubernetes.io/last-applied-configuration: |<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: nginx<br>  template:<br>    metadata:<br>      creationTimestamp: null<br>      labels:<br>        app: nginx<br>    spec:<br>      containers:<br>      - image: eilerb101/nginx_akamai<br>        imagePullPolicy: Always<br>        name: nginx<br>        ports:<br>        - containerPort: 80<br>          protocol: TCP<br>        env:<br>        - name: LINODE_ID<br>          valueFrom:<br>            fieldRef:<br>              apiVersion: v1<br>              fieldPath: spec.nodeName<br>      restartPolicy: Always<br></pre><pre>#Sample NGINX service definition<br>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: nginx<br>spec:<br>  selector:<br>    app: nginx<br>  ports:<br>    - protocol: TCP<br>      port: 80<br>      targetPort: 80</pre><pre>#Sample Ingress YAML<br>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  name: ingress<br>  annotations:<br>    konghq.com/plugins: tcp-log-plugin<br>    konghq.com/strip-path: &quot;false&quot;<br>    konghq.com/preserve-host: &quot;true&quot;<br>    konghq.com/protocols: http<br>    konghq.com/http-forwarded: &quot;preserve&quot;<br>spec:<br>  ingressClassName: kong<br>  rules:<br>    - host: <br>      http:<br>        paths:<br>          - path: /<br>            pathType: ImplementationSpecific<br>            backend:<br>              service:<br>                name: nginx<br>                port:<br>                  number: 80</pre><p>After either applying these new manifests to your cluster or adding the annotation to your existing ingress YAML and applying it to the cluster, you should see entries in the syslog when you attempt to access entities behind Kong. To test this out, you can tail the syslog on the system we created and then enter the IP Address of your Kong Ingress Controller service into your browser.</p><p>You can get the IP Address of Kong by entering a kubectl get svc -n kong This assumes you have installed Kong into a namespace called kong. And you should receive the following back:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FleijK6TtzNLQtDBGXpOrw.png" /></figure><p>You can tail the syslog entries by entering the rsyslog container using kubectl exec -it --tty rsyslog /bin/bash and then using tail -f /var/log/syslog</p><p>If everything is set up correctly, you should see an output like the following when you attempt to access the IP Address of your Kong Proxy service:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F0faUTtMTF7fS7csD4lJJg.png" /></figure><p>And that is it. You have successfully set up a Kong plugin as well as given yourself valuable visibility into your Kong Ingress Controller. Next time, we will explore building a custom plugin for Kong.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f525a826aba4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>