<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Zachary Fowler</title>
    <description>The latest articles on DEV Community by Zachary Fowler (@zaxharperdb).</description>
    <link>https://dev.to/zaxharperdb</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F407768%2Fbd51adc6-95f5-4c91-a028-411b8f13c81d.jpeg</url>
      <title>DEV Community: Zachary Fowler</title>
      <link>https://dev.to/zaxharperdb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zaxharperdb"/>
    <language>en</language>
    <item>
      <title>HarperDB Containerization Journey</title>
      <dc:creator>Zachary Fowler</dc:creator>
      <pubDate>Thu, 19 Nov 2020 16:00:34 +0000</pubDate>
      <link>https://dev.to/harperfast/harperdb-containerization-journey-369p</link>
      <guid>https://dev.to/harperfast/harperdb-containerization-journey-369p</guid>
      <description>&lt;h3&gt;
  
  
  How I Single-Handedly Containered HarperDB
&lt;/h3&gt;

&lt;p&gt;HarperDB is a simple database that is adequately configured, works as a distributed database verging towards serverless, and is significant for micro-service-oriented architecture. It enables developers to think responsibly about the data they are collecting. Companies can begin to isolate the important data from the noise, and store only the information they need where they need it. This is a possibility now more than ever before, and containers are a significant contributor to the paradigm.&lt;/p&gt;

&lt;p&gt;Explaining containers is out of scope for this blog; the long and the short, a container is an isolated set of applications prerequisites that use the host systems resources.   &lt;/p&gt;

&lt;h3&gt;
  
  
  Docker-ization
&lt;/h3&gt;

&lt;p&gt;At HarperDB, I began ushering things to be organized in a container friendly manner early on. &lt;a href="https://hub.docker.com/r/harperdb/hdb" rel="noopener noreferrer"&gt;HarperDB on Docker hub&lt;/a&gt; was one of our first release channels. Docker created the ability for HarperDB to spawn quickly, persist data on the host, or load data into the container for an ephemeral instance. The HarperDB application and the data store are not tightly coupled; the HarperDB application can point to any HarperDB datastore. Below is a quick Docker example of two HarperDB application instances pointing to the same database.&lt;/p&gt;

&lt;p&gt;Create one container and make port 9925 available on the docker host instance:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run -d -v /tmp/docker1/:/opt/harperdb/hdb -p 9925:9925 harperdb/hdb:latest&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Login to the local HarperDB management Studio at &lt;code&gt;http://localhost:9925&lt;/code&gt; with username: &lt;code&gt;HDB_ADMIN&lt;/code&gt; and password: &lt;code&gt;password&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Create a schema, table and add a few records.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwq9d99fb7249ep23ko45.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwq9d99fb7249ep23ko45.png" alt="After Login Create Schema and Table with hash attribute (primary key) id" width="800" height="192"&gt;&lt;/a&gt;After Login Create Schema and Table with hash attribute (primary key) id &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkx7p365kvjfn2sakmipq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkx7p365kvjfn2sakmipq.png" alt="Created two records with the + button; Rosemerry and Billie" width="800" height="391"&gt;&lt;/a&gt;Created two records with the + button; Rosemerry and Billie&lt;/p&gt;

&lt;p&gt;Now create a second container attached to the same data directory&lt;/p&gt;

&lt;p&gt;&lt;code&gt;docker run -d -v /tmp/docker1/:/opt/harperdb/hdb -p 9926:9925 harperdb/hdb:latest&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Notice the host port 9926 because 9925 is in use.&lt;/p&gt;

&lt;p&gt;Login to a new instance and create a new record! This time at &lt;code&gt;http://localhost:9926&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fepxysztvavigdu5xwtoz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fepxysztvavigdu5xwtoz.png" alt="Created Harper on localhost:9926" width="800" height="328"&gt;&lt;/a&gt;Created Harper on localhost:9926&lt;/p&gt;

&lt;p&gt;Refresh the instance on 9925!&lt;/p&gt;

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

&lt;p&gt;Fun!&lt;/p&gt;

&lt;p&gt;Is this useful in real life? Probably somewhere somehow, this can do something neat!&lt;/p&gt;

&lt;p&gt;The example illustrates that HarperDB application containers are isolated instances that can mount any HarperDB storage.&lt;/p&gt;

&lt;p&gt;Imagine a containers' host syncing data to a remote source like AWS S3, adding S3 data sync to update an S3 bucket periodically. Another container host instance across the planet pulls down the S3 data and starts a HarperDB instance. That is for another blog.&lt;/p&gt;

&lt;p&gt;In real life, Docker is incredible for developers and database administrators. One-off instances are useful, but clusters and application stacks are more relevant for application tiers, and where Docker compose is helpful. However, Docker compose is not as robust as Kubernetes.&lt;/p&gt;

&lt;p&gt;It has been my most recent project to get HarperDB on Helm, the Kubernetes package manager. For updates when that happens, follow HarperDB by joining our &lt;a href="https://harperdbcommunity.slack.com/join/shared_invite/zt-e8w6u1pu-2UFAXl_f4ZHo7F7DVkHIDA#/" rel="noopener noreferrer"&gt;Slack Channel&lt;/a&gt; and/or &lt;a href="https://harperdb.io/contact/" rel="noopener noreferrer"&gt;subscribing to our company updates.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Please go check out &lt;a href="https://hub.docker.com/r/harperdb/hdb" rel="noopener noreferrer"&gt;HarperDB on the Docker hub&lt;/a&gt;; it provides examples to get a lot more out of the Docker image and all the configurations available so far.&lt;/p&gt;

&lt;h3&gt;
  
  
  Kubernetes In A Digital Ocean
&lt;/h3&gt;

&lt;p&gt;Kubernetes is a robust infrastructure that helps orchestrate running containers. Kubernetes allows users to create large-scale deployments of single or multiple containers, the life cycles of containers, and the resources containers rely on, i.e., storage, network configuration, CPU, memory. With the help of a great cloud platform, &lt;a href="https://www.digitalocean.com/" rel="noopener noreferrer"&gt;DigitalOcean&lt;/a&gt;, you can already deploy &lt;a href="https://marketplace.digitalocean.com/apps/harperdb" rel="noopener noreferrer"&gt;HarperDB in their 1-click marketplace&lt;/a&gt;. They also provide &lt;a href="https://marketplace.digitalocean.com/category/kubernetes" rel="noopener noreferrer"&gt;1-click Kubernetes apps; HarperDB&lt;/a&gt; will be available soon; this is a preview of HarperDB deployed on DigitalOcean with &lt;a href="https://helm.sh/" rel="noopener noreferrer"&gt;Helm.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This example assumes that you have following preconfigured: a &lt;a href="https://cloud.digitalocean.com/registrations/new" rel="noopener noreferrer"&gt;DigitalOcean account&lt;/a&gt;, &lt;a href="https://kubernetes.io/docs/setup/" rel="noopener noreferrer"&gt;kubectl,&lt;/a&gt; &lt;a href="https://github.com/digitalocean/doctl" rel="noopener noreferrer"&gt;doctl,&lt;/a&gt; and &lt;a href="https://helm.sh/docs/intro/install/" rel="noopener noreferrer"&gt;helm&lt;/a&gt; installed in your development environment. &lt;/p&gt;

&lt;p&gt;Create a Kubernetes Cluster for simplicity; a two-node cluster is sufficient.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkvnmhv5zl7uqvqmi7er1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkvnmhv5zl7uqvqmi7er1.png" alt="Create two node Kubernetes cluster" width="644" height="924"&gt;&lt;/a&gt;Create two node Kubernetes cluster&lt;/p&gt;

&lt;p&gt;Use &lt;a href="https://www.digitalocean.com/docs/kubernetes/how-to/connect-to-cluster/" rel="noopener noreferrer"&gt;doctl to configure kubectl&lt;/a&gt; context to point to DigitalOcean Kubernetes cluster.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffml85v4tgo3nwqxqmy7n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffml85v4tgo3nwqxqmy7n.png" alt="Configure kubectl context for cluster" width="763" height="79"&gt;&lt;/a&gt;Configure kubectl context for cluster&lt;/p&gt;

&lt;p&gt;For security reasons, Kubernetes providers implement Role-based access control (RBAC). It is a method of regulating access to a computer or network resources based on individual users' roles within your organization. A dependency of Helm is tiller; the following provides tiller access to resources.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;kubectl -n kube-system create serviceaccount tiller
kubectl create clusterrolebinding tiller --clusterrole cluster-admin --serviceaccount=kube-system:tiller
helm init --service-account=tiller
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpd7bbjfwnhzf137wj55a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpd7bbjfwnhzf137wj55a.png" alt="Configure tiller access control for HELM" width="768" height="259"&gt;&lt;/a&gt;Configure tiller access control for HELM&lt;/p&gt;

&lt;p&gt;Helm charts use a YAML configuration file for resources exposed by the Kubernetes cluster as well as application specific resources. A few import configurations for HarperDB in the values.yaml.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;image:
  repository: harperdb/hdb
  tag: latest
  pullPolicy: IfNotPresent
service:
  type: ClusterIP
  port: 9925
volumes:
  storageClassProvisioner: dobs.csi.digitalocean.com
  storageClassName: do-block-storage
  persistentClaim: harperdb-pvc
  storage: 5Gi
  volumeName: harperdb-ps
harperdb:
  username: HDB_ADMIN
  password: password
  cluster_enabled: true
  cluster_username: clustering
  cluster_password: password
  cluster_port: 1111
  node_name: hdb-cluster-00
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Most options in the "image" and "harperdb" blocks above should be self-explanatory. The volumes block will require an explanation. Each Kubernetes provider will expose specific storage parameters. Provisioner and Class values are available in the Kubernetes dashboard in the DigitalOcean dashboard.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc2pr6erhxus0mdu0xc9t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc2pr6erhxus0mdu0xc9t.png" alt="Storage Provisioner and Class Values for value.yaml" width="800" height="156"&gt;&lt;/a&gt;Storage Provisioner and Class Values for value.yaml&lt;/p&gt;

&lt;p&gt;The Helm chart can now create an instance of HarperDB that persists information on the host and exposes it as a service on port 9925. &lt;/p&gt;

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

&lt;p&gt;The NOTES at the bottom will allow your local development environment to connect to the HarperDB instance management Studio.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F36vd3yc4iaht24wcv9tq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F36vd3yc4iaht24wcv9tq.png" alt="Expose studio through http://localhost:8080" width="753" height="157"&gt;&lt;/a&gt;Expose studio through &lt;a href="http://localhost:8080" rel="noopener noreferrer"&gt;http://localhost:8080&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Connect to the cluster through &lt;code&gt;http://&lt;/code&gt;&lt;code&gt;localhost:8080&lt;/code&gt;, which routes traffic to the Kubernetes HarperDB instance on port 9925.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8wnppkbi35fh2h4vu4a6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8wnppkbi35fh2h4vu4a6.png" alt="Create Schema, Table and Two records" width="800" height="191"&gt;&lt;/a&gt;Create Schema, Table and Two records&lt;/p&gt;

&lt;p&gt;In the real world, HarperDB would not generally be exposed to the world, and deployments would run over HTTPS. Application containers or Pods in Kubernetes would access HarperDB within the Kubernetes network. Again, for another blog, the HarperDB instance could be ephemeral, and the container could get a HarperDB storage copy from a remote source, then sync to the remote source as data is updated. Also, the HarperDB cluster could publish new data to another instance of HarperDB.&lt;/p&gt;

&lt;h3&gt;
  
  
  Q.E.D, What was to be shown
&lt;/h3&gt;

&lt;p&gt;Containers are robust, HarperDB is powerful; their powers combined provide opportunities to think about data storage and data flow in innovative ways. Docker makes it easy to containerize an application. Kubernetes provides a command and control center to build the distributed infrastructure and orchestrate container resources and life cycle. Helm gives software providers better access to Kubernetes with easy to install deployments. HarperDB is working hard to expand its offerings to other deployment channels. If you did not know, HarperDB also offers &lt;a href="https://bit.ly/2KdtsDq" rel="noopener noreferrer"&gt;database as a service&lt;/a&gt;. Your support is appreciated.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>showdev</category>
      <category>kubernetes</category>
      <category>database</category>
    </item>
  </channel>
</rss>
