<?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 Vincent Royer on Medium]]></title>
        <description><![CDATA[Stories by Vincent Royer on Medium]]></description>
        <link>https://medium.com/@vroyer?source=rss-1e45494cefee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*OOx33s6OW7rar2Q7UFd-YQ.jpeg</url>
            <title>Stories by Vincent Royer on Medium</title>
            <link>https://medium.com/@vroyer?source=rss-1e45494cefee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 10:37:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vroyer/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[Opendistro SQL plugin for Elassandra]]></title>
            <link>https://medium.com/@vroyer/opendistro-sql-plugin-for-elassandra-50fc07c6430?source=rss-1e45494cefee------2</link>
            <guid isPermaLink="false">https://medium.com/p/50fc07c6430</guid>
            <category><![CDATA[open-distro]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[cassandra]]></category>
            <category><![CDATA[elassandra]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <dc:creator><![CDATA[Vincent Royer]]></dc:creator>
            <pubDate>Mon, 14 Sep 2020 09:52:54 GMT</pubDate>
            <atom:updated>2020-09-14T09:52:54.323Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wnj064hIgEAZcmqSgegiwg.png" /></figure><p><a href="https://strapdata.com/">Elassandra</a> is a distribution of <a href="https://cassandra.apache.org/">Apache Cassandra</a> including an Elasticsearch engine. The SQL plugin for Elasticsearch from <a href="https://opendistro.github.io/for-elasticsearch-docs/docs/sql/">OpenDistro</a> is now running with Elassandra 6.8.4, allowing to query your Cassandra database through regular SQL.</p><h3>Install the SQL plugin</h3><p>On each of your Elassandra 6.8.4.10 nodes, install the SQL Elasticsearch plugin available at <a href="https://github.com/strapdata/sql/releases/tag/v0.10.0.0.0">https://github.com/strapdata/sql</a> and <strong>restart</strong> the nodes.</p><p>bin/elasticsearch-plugin install file:///path/to/opendistro_sql-0.10.0.0.zip</p><h3>Insert some test data</h3><p>Using the Kibana DevTool, insert some sample data</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4cbac30477fdf1abd33ea2689dd23fd7/href">https://medium.com/media/4cbac30477fdf1abd33ea2689dd23fd7/href</a></iframe><p>Once you inserted data through Kibana, you can check the underlying Cassandra table content:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80f385f99ffce93612d016da12d04f80/href">https://medium.com/media/80f385f99ffce93612d016da12d04f80/href</a></iframe><h3>SQL query</h3><p>You can now query your Cassandra table through an SQL query with support for aggregation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s6we0y1fRhPpKli9Wnx0qw.png" /></figure><h3>SQL Cli</h3><p>Install and start the <a href="https://opendistro.github.io/for-elasticsearch-docs/docs/sql/cli/">SQL CLI</a> from OpenDistro, and query you Cassandra:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/621f0e3ae91351044a05b0b9534a0e00/href">https://medium.com/media/621f0e3ae91351044a05b0b9534a0e00/href</a></iframe><p>Have fun with the SQL support for Elassandra and thanks in advance for your feedback !</p><h4>References:</h4><ul><li>Elassandra: <a href="https://github.com/strapdata/elassandra">https://github.com/strapdata/elassandra</a></li><li>SQL plugin for Elassandra : <a href="https://github.com/strapdata/sql">https://github.com/strapdata/sql</a></li><li>OpenDistro for Elasticsearch SQL : <a href="https://opendistro.github.io/for-elasticsearch-docs/docs/sql/">https://opendistro.github.io/for-elasticsearch-docs/docs/sql/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50fc07c6430" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy a multi-cloud Elassandra cluster running on AKS and GKE]]></title>
            <link>https://medium.com/@vroyer/unbreakable-multi-cloud-cassandra-and-elasticsearch-on-kubernetes-with-elassandra-4917c7659dbd?source=rss-1e45494cefee------2</link>
            <guid isPermaLink="false">https://medium.com/p/4917c7659dbd</guid>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[multicloud-management]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[cassandra]]></category>
            <category><![CDATA[elassandra]]></category>
            <dc:creator><![CDATA[Vincent Royer]]></dc:creator>
            <pubDate>Fri, 03 Jul 2020 13:06:43 GMT</pubDate>
            <atom:updated>2020-07-03T13:21:13.148Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X7ZLtFvOSVo_yqY7KR0TTQ.png" /></figure><h3>Elassandra in a Multi-Cloud Kubernetes world — Part One.</h3><p>Kubernetes adoption among IT departments is growing over time and that’s definitely a game changer, and running databases under Kubernetes is the next challenge to run your microservices on any cloud provider. <a href="https://www.elassandra.io/"><strong>Elassandra</strong></a> is providing a nice solution to achieve this as it provides both a distributed database, <a href="https://cassandra.apache.org/"><strong>Apache Cassandra</strong></a>, and an embedded <a href="https://www.elastic.co/elasticsearch/"><strong>Elasticsearch</strong></a>. With the <a href="https://github.com/strapdata/elassandra-operator"><strong>Kubernetes Elassandra Operator</strong></a>, let’s see how to deploy an Elassandra cluster running in many Kubernetes Clusters, with <strong>Azure Kubernetes Service</strong> and <strong>Google Kubernetes Engine</strong>.</p><p>Summary:</p><ul><li>Overview</li><li>Create an AKS cluster</li><li>Create a GKE cluster</li><li>Deploy and configure additional services</li><li>Deploy Elassandra DC1</li><li>Deploy Elassandra DC2</li></ul><h3>Overview</h3><p>The Elassandra Operator creates one Kubernetes statefulset per availability zone mapped to a Cassandra rack. Thus, in case of a zone failure, data is properly distributed across replicas and remains available.</p><p>The Elassandra Operator watches for Kubernetes nodes and identifies availability zones through the node label <strong>failure-domain.beta.kubernetes.io/zone</strong>. Each statefulset is named with its zone index rather than a zone name to keep the naming standard whatever are zone names. Here is a 9 nodes Elassandra datacenter running in 3 availability zones in a Kubernetes cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*72KsdB_XV86SN4NTc7RPSQ.png" /></figure><p>By default, for each Elassandra/Cassandra cluster, you can have only one Elassandra node per Kubernetes node (enforced by an <a href="https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#affinity-and-anti-affinity">anti-affinity rule</a>).</p><p>To ensure data consistency, Persistent Volume Claims are allocated in the zone as of the associated statefulset (or Cassandra rack).</p><p>For the purpose of the demonstration, we are deploying an Elassandra cluster using public IP addresses to connect the datacenter DC1 running on AKS, to another Elassandra datacenter DC2 running on GKE. Of course, for security reasons, it would be better to run such a cluster in a private network interconnected through a VPC or a VPN, but who can do more can do less.</p><h3>AKS Setup</h3><p>We are going to use Azure <a href="https://docs.microsoft.com/fr-fr/azure/virtual-machine-scale-sets/">VMScaleSet</a> with public IP addresses on Kubernetes nodes, and this requires the Azure CLI <a href="https://docs.microsoft.com/en-us/azure/aks/use-multiple-node-pools#assign-a-public-ip-per-node-for-your-node-pools-preview">aks-preview extension</a>:</p><pre>az extension add --name aks-preview<br>az extension update --name aks-preview<br>az feature register --name NodePublicIPPreview --namespace Microsoft.ContainerService</pre><p>Create an Azure resource group and an AKS regional cluster running on 3 zones with public IP addresses on Kubernetes nodes and the Azure network plugin:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f325173db03039bd661919ef99761a2/href">https://medium.com/media/7f325173db03039bd661919ef99761a2/href</a></iframe><h4>Label the k8s nodes</h4><p>Unfortunately, AKS does not map VM’s public IP address to the Kubernetes node external IP address, so the trick is to add these public IP addresses as a kubernetes custom label elassandra.strapdata.com/public-ip to each nodes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e090bc18822b57cdd3e838eeb3bc829b/href">https://medium.com/media/e090bc18822b57cdd3e838eeb3bc829b/href</a></iframe><p>And you should get something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/928711049df82443d3f66379fce1b03c/href">https://medium.com/media/928711049df82443d3f66379fce1b03c/href</a></iframe><h4>Install HELM 2</h4><p>Install HELM 2 and add the <a href="https://github.com/strapdata/helm-charts">strapdata repo</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d805a0506a19e5582bd7421b6bb1c39a/href">https://medium.com/media/d805a0506a19e5582bd7421b6bb1c39a/href</a></iframe><h4>AKS StorageClass</h4><p>Azure persistent volumes are bound to an availability zone, so we need to defined one storageClass per zone in our AKS cluster, and each Elassandra rack or statefulSet will be bound to the corresponding storageClass. This is done here using the HELM chart strapdata/storageclass.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c70709173f6b448c23e2d1eb8c6eec9/href">https://medium.com/media/1c70709173f6b448c23e2d1eb8c6eec9/href</a></iframe><h4>AKS Firewall rules</h4><p>Finally, you may need to authorise inbound Elassandra connections on the following TCP ports:</p><ul><li>Cassandra storage port (usually 7000 or 7001) for internode connections</li><li>Cassandra native CQL port (usually 9042) for client to node connections.</li><li>Elasticsearch HTTP port (usually 9200) for the Elasticsearch REST API.</li></ul><p>Assuming you deploy an Elassandra datacenter respectively using ports 39000, 39001, and 39002 exposed to the internet, with no source IP address restrictions:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9f8fc8a3cf816968bd95829c08aa97be/href">https://medium.com/media/9f8fc8a3cf816968bd95829c08aa97be/href</a></iframe><h3>GKE Setup</h3><p>Create a <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-regional-cluster">Regional Kubernetes cluster</a> on GCP, with RBAC enabled:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6276b8e4213b8e32003ad975cd61186/href">https://medium.com/media/a6276b8e4213b8e32003ad975cd61186/href</a></iframe><p>Install HELM 2 (like on AKS).</p><h4>GKE StorageClass</h4><p>Google cloud persistent volumes are bound to an availability zone, so we need to defined one storageClass per zone in our Kubernetes cluster, and each Elassandra rack or statefulSet will be bound to the corresponding storageClass. This is done here using the HELM chart strapdata/storageclass.</p><pre>for z in europe-west1-b europe-west1-c europe-west1-d; do<br>    helm install --name ssd-$z --namespace kube-system \<br>        --set parameters.type=&quot;pd-ssd&quot; \<br>        --set provisioner=&quot;kubernetes.io/gce-pd&quot; \<br>        --set zone=$z,nameOverride=ssd-$z \<br>        strapdata/storageclass<br>done</pre><h4><strong>GKE Firewall rules</strong></h4><p>Assuming you deploy an Elassandra datacenter respectively using ports 39000, 39001, and 39002 exposed to the internet, with no source IP address restrictions, and Kubernetes nodes are properly tagged with the k8s cluster name, you can create an inbound firewall rule like this:</p><pre>VPC_NETWORK=$(gcloud container clusters describe $K8S_CLUSTER_NAME --region $GCLOUD_REGION --format=&#39;value(network)&#39;)</pre><pre>NODE_POOLS_TARGET_TAGS=$(gcloud container clusters describe $K8S_CLUSTER_NAME --region $GCLOUD_REGION --format=&#39;value[terminator=&quot;,&quot;](nodePools.config.tags)&#39; --flatten=&#39;nodePools[].config.tags[]&#39; | sed &#39;s/,\{2,\}//g&#39;)</pre><pre>gcloud compute firewall-rules create &quot;allow-elassandra-inbound&quot; \<br>  --allow tcp:39000-39002 \<br>  --network=&quot;$VPC_NETWORK&quot; \<br>  --target-tags=&quot;$NODE_POOLS_TARGET_TAGS&quot; \<br>  --description=&quot;Allow elassandra inbound&quot; \<br>  --direction INGRESS</pre><h4>GKE CoreDNS installation</h4><p>GKE is provided with KubeDNS by default, which does not allows to configure host aliases to resolve public IP addresses to internal Kubernetes node IP addresses (required by the Cassandra <a href="https://docs.datastax.com/en/drivers/java/2.2/com/datastax/driver/core/policies/AddressTranslator.html">AddressTranslator</a> to connect to Elassandra nodes using the internal IP address). So we need to install CoreDNS configured to import custom configuration (see <a href="https://coredns.io/plugins/import/">CoreDNS import plugin</a>), and configure KubeDNS with a stub domain to forward to CoreDNS.</p><pre>helm install --name coredns --namespace=kube-system -f <a href="https://raw.githubusercontent.com/strapdata/elassandra-operator/master/integ-test/gke/coredns-values.yaml">coredns-values.yaml</a> stable/coredns</pre><p>The used coredns-value.yaml is available <a href="https://raw.githubusercontent.com/strapdata/elassandra-operator/master/integ-test/gke/coredns-values.yaml">here</a></p><p>Once CoreDNS is installed, add a stub domain to forward request for domain <strong>internal.strapdata.com</strong> to the CoreDNS service, and restart KubeDNS pods. The <strong>internal.strapdata.com</strong> is just a dummy DNS domain used to resolve public IP addresses to Kubernetes nodes internal IP addresses.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/364cd2c810bd3cae1fcb2771d51ac648/href">https://medium.com/media/364cd2c810bd3cae1fcb2771d51ac648/href</a></iframe><h3>Prepare your Kubernetes clusters</h3><p>Once your AKS and GKE clusters are running, we need to deploy and configure additional services in these two clusters.</p><h4>Elassandra Operator</h4><p>Install the Elassandra operator in the <strong>default</strong> namespace:</p><pre>helm install --namespace default --name elassop --wait strapdata/elassandra-operator</pre><h4><strong>Configure CoreDNS</strong></h4><p>The Kubernetes CoreDNS is used for two reasons:</p><ul><li>Resolve DNS name of you DNS zone from inside the Kubernetes cluster using DNS forwarders to your DNS zone.</li><li>Reverse resolution of the broadcast Elassandra public IP addresses to Kubernetes nodes private IP.</li></ul><p>You can deploy the CodeDNS custom configuration with the strapdata coredns-forwarder HELM chart to basically install (or replace) the <strong>coredns-custom</strong> configmap, and restart coreDNS pods.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9c154f30e2e9a58e4bbb8b6682de1fa/href">https://medium.com/media/b9c154f30e2e9a58e4bbb8b6682de1fa/href</a></iframe><p>If your Kubernetes nodes does not have the ExternalIP set (like AKS), public node IP address should be available through the custom label elassandra.strapdata.com/public-ip.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aeb03ee55077b88590225083c1c67e2c/href">https://medium.com/media/aeb03ee55077b88590225083c1c67e2c/href</a></iframe><p>Then configure the CoreDNS custom configmap with your DNS name servers and host aliases. In the following example, this is Azure DNS name servers:</p><pre>kubectl delete configmap --namespace kube-system coredns-custom<br>helm install --name coredns-forwarder --namespace kube-system \<br>    --set forwarders.domain=&quot;${DNS_DOMAIN}&quot; \<br>    --set forwarders.hosts[0]=&quot;40.90.4.8&quot; \<br>    --set forwarders.hosts[1]=&quot;64.4.48.8&quot; \<br>    --set forwarders.hosts[2]=&quot;13.107.24.8&quot; \<br>    --set forwarders.hosts[3]=&quot;13.107.160.8&quot; \<br>    --set nodes.domain=internal.strapdata.com \<br>    --set $HOST_ALIASES \<br>    strapdata/coredns-forwarder</pre><p>Then restart CoreDNS pods to reload our configuration, but this depends on coreDNS deployment labels !</p><p>On AKS:</p><pre>kubectl delete pod --namespace kube-system -l k8s-app=kube-dns</pre><p>On GKE:</p><pre>kubectl delete pod --namespace kube-system -l k8s-app=coredns</pre><p>Check the CoreDNS custom configuration:</p><pre>kubectl get configmap -n kube-system coredns-custom -o yaml<br>apiVersion: v1<br>data:<br>  dns.server: |<br>    test.strapkube.com:53 {<br>        errors<br>        cache 30<br>        forward $DNS_DOMAIN 40.90.4.8 64.4.48.8 13.107.24.8 13.107.160.8<br>    }<br>  hosts.override: |<br>    hosts nodes.hosts internal.strapdata.com {<br>        10.132.0.57 146-148-117-125.internal.strapdata.com 146-148-117-125<br>        10.132.0.58 35-240-56-87.internal.strapdata.com 35-240-56-87<br>        10.132.0.56 34-76-40-251.internal.strapdata.com 34-76-40-251<br>        fallthrough<br>    }<br>kind: ConfigMap<br>metadata:<br>  creationTimestamp: &quot;2020-06-26T16:45:52Z&quot;<br>  name: coredns-custom<br>  namespace: kube-system<br>  resourceVersion: &quot;6632&quot;<br>  selfLink: /api/v1/namespaces/kube-system/configmaps/coredns-custom<br>  uid: dca59c7d-6503-48c1-864f-28ae46319725</pre><p>Deploy a dnsutil pod:</p><pre>cat &lt;&lt;EOF | kubectl apply -f -<br>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: dnsutils<br>  namespace: default<br>spec:<br>  containers:<br>  - name: dnsutils<br>    image: gcr.io/kubernetes-e2e-test-images/dnsutils:1.3<br>    command:<br>      - sleep<br>      - &quot;3600&quot;<br>    imagePullPolicy: IfNotPresent<br>  restartPolicy: Always<br>EOF</pre><p>Test resolution of public IP names to internal Kubernetes node IP address:</p><pre>kubectl exec -ti dnsutils -- nslookup 146-148-117-125.internal.strapdata.com<br>Server:             10.19.240.10<br>Address:    10.19.240.10<em>#53</em></pre><pre>Name:       146-148-117-125.internal.strapdata.com<br>Address: 10.132.0.57</pre><h4>ExternalDNS</h4><p>The <a href="https://github.com/kubernetes-sigs/external-dns">ExternalDNS</a> is used to automatically update your DNS zone and create an <strong>A</strong> record for the Cassandra broadcast IP addresses. You can use it with a public or a private DNS zone, and with any DNS provider supported by ExternalDNS. In the following setup, we will use a DNS zone hosted on Azure.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/167e006f71853debf6d2f892affe7f05/href">https://medium.com/media/167e006f71853debf6d2f892affe7f05/href</a></iframe><h4>Deploy Elassandra DC1</h4><p>Deploy the first datacenter <strong>dc1</strong> of the Elassandra cluster <strong>cl1</strong> in the Kubernetes cluster <strong>kube1</strong>, with Kibana and Cassandra Reaper available through the Traefik ingress controller.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1e087a7a09ad282531b7e72fc451320/href">https://medium.com/media/c1e087a7a09ad282531b7e72fc451320/href</a></iframe><p>Once the Elassandra datacenter is deployed, you get 3 Elassandra pods from 3 StatefulSets:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/043f2eeae849b7cb92a2bee45dd814ae/href">https://medium.com/media/043f2eeae849b7cb92a2bee45dd814ae/href</a></iframe><p>Once the datacenter is ready, check the cluster status:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3f8ef6062c565ae8bd88e1ba00311b70/href">https://medium.com/media/3f8ef6062c565ae8bd88e1ba00311b70/href</a></iframe><p>Then get the generated TLS certificates and the Cassandra admin password (Because using the default cassandra user is not recommended, the Elassandra operator automatically creates an admin superuser role):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/491ab90a068997cbfdeff0ce973e33fa/href">https://medium.com/media/491ab90a068997cbfdeff0ce973e33fa/href</a></iframe><p>Connect to the Elassandra/Cassandra node from the internet:</p><pre>SSL_CERTFILE=cl1-cacert.pem bin/cqlsh --ssl -u admin -p $CASSANDRA_ADMIN_PASSWORD cassandra-cl1-dc1-0-0.$DNS_DOMAIN 39001<br>Connected to cl1 at cassandra-cl1-dc1-0-0.test.strapkube.com:39001.<br>[cqlsh 5.0.1 | Cassandra 3.11.6.1 | CQL spec 3.4.4 | Native protocol v4]<br>Use HELP for help.<br>admin@cqlsh&gt;</pre><p>Finally, you can check the Elassandra datacenter status (The CRD managed by the Elassandra Operator):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4da1aeede51049b57499fb24e1f80009/href">https://medium.com/media/4da1aeede51049b57499fb24e1f80009/href</a></iframe><h3>Deploy Elassandra DC2</h3><p>First, we need to copy cluster secrets from the Elassandra datacenter <strong>dc1</strong> into the Kubernetes <strong>kube2</strong> running on GKE.</p><pre>for s in elassandra-cl1 elassandra-cl1-ca-pub elassandra-cl1-ca-key elassandra-cl1-kibana; do<br> kubectl get secret $s — context kube1 — export -n default -o yaml | kubectl apply — context kube2 -n default -f -<br>done</pre><p>Then deploy the Elassandra datacenter <strong>dc2</strong> into the GKE cluster2, using the same ports.</p><ul><li>The TRAEFIK_FQDN should be something like traefik-cluster2.$DNS_DOMAIN.</li><li>The cassandra.remoteSeeds must include the DNS names of <strong>dc1</strong> seed nodes, the first node of each rack StatefulSet with index 0.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2110743b873f7de28f44a11d9ebd4f5d/href">https://medium.com/media/2110743b873f7de28f44a11d9ebd4f5d/href</a></iframe><p>Once <strong>dc2 </strong>Elassandra pods are started, you get a running Elassandra cluster in AKS and GKE.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d51a10142f2e08bea79153aa046df74/href">https://medium.com/media/5d51a10142f2e08bea79153aa046df74/href</a></iframe><p>The datacenter <strong>dc2</strong> started without streaming data, and we now setup keyspace replication before rebuilding the datacenter from <strong>dc1 </strong>using an<strong> Elassandra task </strong>CRD. This task automatically includes Cassandra system keyspaces (system_auth, system_distributed, system_traces, and elastic_admin if Elasticsearch is enabled).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f77a96d40f1fea35cff9bdc91d87ea8/href">https://medium.com/media/2f77a96d40f1fea35cff9bdc91d87ea8/href</a></iframe><p>The <a href="https://github.com/strapdata/elassandra-operator/releases/tag/v0.1.1"><strong>edctl</strong></a> utility allow to wait on conditions on Elassandra datacenters or tasks. We now rebuild <strong>dc2</strong> from <strong>dc1</strong> by streaming the data:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70deb235e65d35947cbaf5c255432f5a/href">https://medium.com/media/70deb235e65d35947cbaf5c255432f5a/href</a></iframe><p>If Elasticsearch is enabled in <strong>dc2</strong>, you need to run restart Elassandra pods to update the Elasticsearch cluster state since data have been populated by streaming data from <strong>dc1</strong>.</p><pre>kubectl delete pod --namespace default -l app=elassandra,elassandra.strapdata.com/datacenter=dc2</pre><p>Finally, check you can connect on <strong>dc2</strong>:</p><pre>SSL_CERTFILE=cl1-cacert.pem bin/cqlsh --ssl -u admin -p $CASSANDRA_ADMIN_PASSWORD cassandra-cl1-<strong>dc2</strong>-0-0.$DNS_DOMAIN 39001<br>Connected to cl1 at cassandra-cl1-<strong>dc2</strong>-0-0.test.strapkube.com:39001.<br>[cqlsh 5.0.1 | Cassandra 3.11.6.1 | CQL spec 3.4.4 | Native protocol v4]<br>Use HELP for help.<br>admin@cqlsh&gt;</pre><p>Check the Elasticsearch cluster status on <strong>dc2</strong>. The kibana index was automatically created by the deployed kibana pod running in the Kubernetes cluster <strong>kube2</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ef54bcc948ea16b691c23493656d493/href">https://medium.com/media/1ef54bcc948ea16b691c23493656d493/href</a></iframe><h3><strong>Conclusion</strong></h3><p>Here you get a <strong>multi-cloud Elassandra cluster running in multiple Kubernetes</strong> <strong>clusters</strong>. The Elassandra Operator gives you the flexibility to deploy on the cloud or on premise, in a public or private network. You can scale up/scale down, park/unpark your datacenters, you can loose a kubernetes node, a persistent volume or event a zone, the Elassandra datacenter remains up and running and you don’t have to manage any sync issue between your database and your Elasticsearch cluster.</p><p>In next the articles, we’ll see how the Elassandra Operator deploys Kibana for data visualisation and Cassandra Reaper to manage continuous Cassandra repairs. We’ll also see how to setup the Prometheus Operator with Grafana dashboards to monitor the Elassandra Operator, the Elassandra nodes and Kubernetes resources.</p><p>Have fun with this Elassandra Operator and thanks in advance for your feedbacks !</p><h4>References</h4><ul><li><a href="http://operator.elassandra.io/">http://operator.elassandra.io/</a></li><li><a href="https://github.com/strapdata/elassandra-operator">https://github.com/strapdata/elassandra-operator</a></li><li><a href="https://elassandra.readthedocs.io/en/latest/">https://elassandra.readthedocs.io/en/latest/</a></li><li><a href="https://github.com/strapdata/elassandra">https://github.com/strapdata/elassandra</a></li><li><a href="https://medium.com/@john.sanda/deploying-cassandra-in-kubernetes-with-casskop-1f721586825b">https://medium.com/@john.sanda/deploying-cassandra-in-kubernetes-with-casskop-1f721586825b</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4917c7659dbd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Elassandra Search Strategy explained]]></title>
            <link>https://medium.com/@vroyer/elassandra-search-strategy-explained-196747d5701?source=rss-1e45494cefee------2</link>
            <guid isPermaLink="false">https://medium.com/p/196747d5701</guid>
            <dc:creator><![CDATA[Vincent Royer]]></dc:creator>
            <pubDate>Fri, 17 Apr 2020 15:01:00 GMT</pubDate>
            <atom:updated>2020-04-17T15:15:12.644Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zcoChhgSXOkE-kMLTYl4Ig.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@glencarrie?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Glen Carrie</a> on <a href="https://unsplash.com/s/photos/labyrinth?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Elassandra is a modified distribution of Apache Cassandra with an embedded Elasticsearch search engine. Like MySQL, Postgres, MongoDB or CouchBase, Elasticsearch is a master-slave system with a Single Point of Write when a primary shard is down. Based on Cassandra, Elassandra provides Elasticsearch features with no Single Point of Write, allowing to build modern applications running active/active on two datacenters or more. We’re going to see how Elassandra process Elasticsearch search queries across Cassandra nodes.</p><h3>Elassandra write path</h3><p>On write path, Elassandra adds an internal <strong>_token</strong> field computed from the Cassandra partition key to each index Elasticsearch document. It’s a long number indexed by Lucene.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8a6dduj5Is-kZWT3Cgbl9g.png" /><figcaption>Elassandra write path to Elasticsearch</figcaption></figure><h3>Elassandra search path</h3><p>On the search path, Elassandra split a full-search query to a sub-queries for a set of nodes in the Cassandra datacenter. When the Cassandra replication factor is greater than one, Elassandra automatically adds a <strong>token_range</strong> filter to your Elasticsearch query to avoid duplicate results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NsaKOqekcMMZEh8BDCOvUQ.png" /><figcaption>Elassandra search path</figcaption></figure><p>This token range filter cover 100% of the Cassandra ring, and each token range is served by exactly one node in the datacenter. If a node becomes unavailable, Elassandra automatically compute another set of Cassandra token ranges and distribute sub-queries to available nodes.</p><h3>The Elassandra search strategy</h3><p>The Elassandra Search Strategy controls the subset of nodes involved to process a full-search query. The default Elassandra search strategy is the <strong>PrimaryFirstSearchStrategy, </strong>it broadcasts a sub-query to all nodes in the datacenter, with a token_range filter matching the node’s primary token ranges. For example, for node 1 having the primary token range 0–99, Elassandra adds the Lucene token_range filter [0:99[ to sub-query node 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/942/1*3ovmmuOTNbD-U01pEhiTTQ.png" /></figure><p>Be careful, with the default Cassandra configuration with 256 vnodes, the token_range filter contains 256 token ranges. In order to reduce the complexity of this filter, it is recommended to use 8 or 16 vnodes per nodes.</p><p>When the Cassandra replication factor is greater than one, Elassandra can logically reduce the number of nodes involved in a full-search request. For exemple, in a 6 nodes datacenter with RF=3, Elassandra could sub-query only 2 nodes.</p><p>The <strong>RandomSearchStreategy </strong>randomly choose nodes until all token ranges of the datacenter are scanned, starting with the coordinator node if the Elasticsearch index shard is available.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PEsL-YGMu0XGJopvcPXfFg.png" /></figure><p>Since version 6.2.3.27 and 6.8.4.4, the <strong>RackAwareSearchStrategy</strong> works as the RandomSearchStrategy but try first to use nodes in the same Cassandra rack. As the Cassandra <strong>NetworkTopologyStrategy </strong>is rack-aware, it tries to avoid two replicas to be placed on the same rack, and the <strong>RackAwareSearchStrategy</strong> use this property to<strong> </strong>get the lowest possible number of nodes to distribute a full-search request.</p><p>For example, in a 6 nodes datacenter, 3 racks and RF=3, a full-search query can be achieved on 2 node in a rack. If a node or shard is unavailable for some reasons, the search strategy use nodes from other nodes, but due to token range distribution, 3 nodes or more will be involved.</p><p>You can set or update the search strategy as an Elasticsearch dynamic setting:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d8ad1df57a7c48e5222c8f8dded04c17/href">https://medium.com/media/d8ad1df57a7c48e5222c8f8dded04c17/href</a></iframe><p>You can also setup an Elasticsearch template to automatically set the Elassandra search strategy and Cassandra replication.</p><p>You can check computed token ranges used for each sub-query by setting the log level to TRACE for class <strong>org.elassandra.cluster.routing</strong> in your <strong>conf/logback.xml</strong>, or dynamically<strong>:</strong></p><blockquote>nodetool setlogginglevel org.elassandra.cluster.routing TRACE</blockquote><h3>Full vs Partition search</h3><p>When processing a search request, Elassandra broadcast sub-queries to all nodes in the Cassandra datacenter. This is a full dataset search (like an Elasticsearch search request on all shards).</p><p>If the Cassandra partition key is specified in the search query, Elassandra only send one search sub-query to an Elassandra node hosting the document without adding any token range filter to the Lucene query. It’s a <strong>partition search</strong> involving only ONE node in the datacenter. Of course, such a partition request consume far less resources in the cluster and scale linearly with the number of nodes. Moreover, if your Cassandra Replication Factor is greater than one, queries are load balanced to all replica nodes in the Cassandra datacenter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9l5IZHS98zjlIyeARoUEIw.png" /></figure><p>There is two ways to provide the partition key in an Elasticsearch search request. Using the <strong>_routing</strong> parameter in an Elasticsearch REST search request, as shown bellow:</p><p><em>curl “</em><a href="http://localhost:9200/test?_routing=1"><em>http://localhost:9200/test?_routing=1</em></a><em>&quot; -d’{ “query”:{ “match_all”:{}}}’</em></p><p>You can also execute an Elasticsearch search query through a CQL statement, and specify the partition key columns as usual. The Cassandra coordinator node detects that the query is an Elasticsearch query and use the partition key to restrict the search to one node hosting the row or document. Therefore, if your CQL driver properly use the TokenAwarePolicy, the coordinator node can process the Elasticsearh query locally, with no network overhead.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96840a4eaea31739d74f5d6048c2e7be/href">https://medium.com/media/96840a4eaea31739d74f5d6048c2e7be/href</a></iframe><h3>Conclusion</h3><p>Using the most appropriate search strategy matching your cluster configuration can drastically reduce the global CPU load of your Elassandra cluster.</p><p>If your application is <strong>multi-tenant</strong>, you can probably use the tenant id as the Cassandra partition key in your data-model and execute partition-search queries to make your application much more efficient and scalable. Therefore, you’ll get all the benefits of Elasticsearch capabilities when the Cassandra “where” clause is not enough powerful to express your application needs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=196747d5701" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to deploy your Microservices under Kubernetes with Gravitee and Elassandra]]></title>
            <link>https://medium.com/swlh/how-to-deploy-your-microservices-under-kubernetes-with-gravitee-and-elassandra-fa533adde64d?source=rss-1e45494cefee------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa533adde64d</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[elassandra]]></category>
            <dc:creator><![CDATA[Vincent Royer]]></dc:creator>
            <pubDate>Tue, 15 Oct 2019 23:08:06 GMT</pubDate>
            <atom:updated>2019-10-16T18:19:36.575Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://gravitee.io/">Gravitee.io</a> is an open-source, flexible, lightweight and super-fast <strong>API Management solution</strong> that helps to control who, when and how consumers access your APIs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*48SZzjhIOAL-51LMgh-ycg.png" /></figure><p>By default, the <strong>Gravitee API Manager</strong> rely on <strong>MongoDB</strong> for its configuration and <strong>Elasticsearch</strong> for log analytics, but deploying many components can by more tricky and more expensive than having a single distributed data store. To simplify the stack, the <a href="https://github.com/strapdata/gravitee-repository-elassandra">Gravitee repository for <strong>Elassandra</strong></a> can be used to store Gravitee configuration, Rate Limits, Logs and Metrics, along with your application data in <a href="http://www.elassandra.io/"><strong>Elassandra</strong></a> (aka Elasticsearch + Cassandra), with the following benefits:</p><ul><li>Distributed Gravitee configuration on many datacenters through the Cassandra replication (in active/active mode).</li><li>Elasticsearch reporting for Gravitee analytics (gravitee logs and metrics).</li><li>Scalability by adding Elassandra nodes (without re-indexing) and datacenters (for geo localisation concerns or workload separation)</li><li>Reduce the global complexity and TCO by using the same NoSQL datastore for both Gravitee and APIs data storage.</li></ul><p>We will now see how to deploy all these components under Kubernetes.</p><h3>Deploy Traefik</h3><p>In order to expose the Gravitee components to the internet (gateways and management services), we obviously use <a href="https://traefik.io/">Traefik</a>, the modern reverse proxy. Traefik watches for incoming kubernetes ingresses events and automatically deploy routers, services, handlers, etc…</p><p>Traefik is deployed using a HELM Chart as follow:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8fac80febcb7e5ed5b7a638807d8ed26/href">https://medium.com/media/8fac80febcb7e5ed5b7a638807d8ed26/href</a></iframe><h3>Deploy an Elassandra Cluster</h3><p>3 Elassandra PODs has been deployed as a Kubernetes StatefulSet using this <a href="https://github.com/strapdata/helm-elassandra">HELM chart</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/edea9c10b115f28582dcd36c6ecb1d07/href">https://medium.com/media/edea9c10b115f28582dcd36c6ecb1d07/href</a></iframe><p>IMPORTANT NOTE: Cassandra spread replicas across racks to ensure data remains available if a rack goes down. Deploying Cassandra or Elassandra with one Kubernetes StatefulSet cannot ensure that a pod are always deployed on the right cloud-provider zone or region. In order to meet this constraint, Strapdata will release soon a Kubernetes operator for Elassandra.</p><h3>Deploy Gravitee</h3><p>As shown in the main figure, Gravitee has 3 components:</p><ul><li>The manager service to manage the gravitee configuration</li><li>The user interface (or portal)</li><li>The gateways, to manager acces to your API endpoints</li></ul><p>In order to deploy <strong>Gravitee</strong> including the <strong>Elassandra repository</strong>, we have used the HELM chart available at <a href="https://github.com/strapdata/helm-gravitee">helm-gravitee</a>. In the HELM values.yaml, the following <strong>es</strong> and <strong>elassandra</strong> blocks describe connection to both Elasticsearch (for Gravitee Analytics) and to <strong>Elassandra</strong>, which is very close to Apache Cassandra. The <strong>elassandra.endpoint</strong> specifies the Elasticsearch endpoint to be able to create and search across Elasticsearch indices.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c67150f10f771c8142e10eec95636238/href">https://medium.com/media/c67150f10f771c8142e10eec95636238/href</a></iframe><p>Detail about deploying Gravitee under Kubernetes can be found <a href="https://medium.com/graviteeio/gravitee-io-apim-on-kubernetes-c0c0107d5e3c">here on Medium</a>.</p><h3>Deploy your application</h3><p>We deploy here a sample <a href="https://micronaut.io/">Micronaut</a> application <a href="https://github.com/strapdata/basketapp"><strong>basketapp</strong></a> allowing to store and search baskets stored as JSON documents through a REST API. The basketapp stores its data into Elassandra, using Cassandra CQL to insert/select rows, and Elasticsearch queries through the CQL driver to search for documents.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SUH-JkmSMy4gFcRdsq9ZKA.png" /></figure><p>This basic application is deployed as a Kubernetes deployment with an HELM chart included in the <a href="https://github.com/strapdata/basketapp">basketapp code</a>.</p><p>When everything is deployed, we have the following pods running in our Kuberenetes cluster:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e9cf1b37c0e2a80daa56bd7164bd9969/href">https://medium.com/media/e9cf1b37c0e2a80daa56bd7164bd9969/href</a></iframe><p>The 3 Gravitee components (api management, ui, and gateway) are accessible from outside the Kubernetes cluster through Traefik with an external load balancer.</p><p>On an Elassandra pod, we can check that the basketapp and the Gravitee Elasticsearch indices are green:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e30ae8aa240a1dd0c692d136a67e6b86/href">https://medium.com/media/e30ae8aa240a1dd0c692d136a67e6b86/href</a></iframe><h3>Register your API into Gravitee</h3><p>As described in the <a href="https://micronaut-projects.github.io/micronaut-openapi/latest/guide/index.html">micronaut documentation</a>, we use an annotation in the Micronaut <strong>Application.java</strong>, where the <strong>servers.url</strong> points to our application. Be careful, URL context path cannot be null:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7976d06316b4d81dff12edf5887429ea/href">https://medium.com/media/7976d06316b4d81dff12edf5887429ea/href</a></iframe><p>The swagger descriptor is generated at compile time by Micronaut, and server URLs may depend on your deployments, so we introduced a controller to dynamically replace the servers.url with the application kuberenetes service name. The swagger descriptor is available from a pod at <a href="http://basketapp:8080/basketapp/swagger,"><strong>http://basketapp:8080/basketapp/swagger</strong>,</a> the URL used to import the API into Gravitee:</p><ol><li>Log into the API Manager portal as the administrator and register your application by providing a swagger descriptor.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/625/1*ItlwtClQ20LQM_GLWxuoKA.png" /></figure><p>2. Start and publish the API</p><p>3. Create an API plan. To keep the demo simple, you choose a keyless authentication, but Gravitee provides many ways to secure access to your API.</p><p>4. Publish to the API plan and deploy it to the gateways.</p><p>You can request then your basket API through the Gravitee gateway service:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6ca3d90a440d6e947559ec3c17d6fc6/href">https://medium.com/media/e6ca3d90a440d6e947559ec3c17d6fc6/href</a></iframe><h3>Logs and metrics</h3><p>Thanks to Elassandra, Gravitee analytics works like Elasticsearch. You can check API performances, application load, and enable API logging for a while.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j79lgLw1pXInCak2M5j8Pw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6t1y2Liv9s4Gbx6Fxkoh0A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FnWnZm6Tq_4VACyYzfCHLQ.png" /></figure><h3>Conlusion</h3><p>This article shows how to use <strong>Elassandra</strong> to store both application data and <strong>Gravitee</strong> configuration and logs. <strong>Elassandra</strong> and <strong>Gravitee</strong> can scale up/down to achieve high throughput and high availability. In a next article, I will show how to deploy this configuration on several Kubernetes clusters located in several datacenters.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa533adde64d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/how-to-deploy-your-microservices-under-kubernetes-with-gravitee-and-elassandra-fa533adde64d">How to deploy your Microservices under Kubernetes with Gravitee and Elassandra</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing reactive microservices with Micronaut, Elassandra and JUnit5]]></title>
            <link>https://medium.com/@vroyer/testing-reactive-microservices-with-micronaut-elassandra-and-junit5-970963f652bb?source=rss-1e45494cefee------2</link>
            <guid isPermaLink="false">https://medium.com/p/970963f652bb</guid>
            <category><![CDATA[micronaut]]></category>
            <category><![CDATA[cassandra]]></category>
            <category><![CDATA[junit]]></category>
            <category><![CDATA[elassandra]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <dc:creator><![CDATA[Vincent Royer]]></dc:creator>
            <pubDate>Wed, 13 Mar 2019 20:02:22 GMT</pubDate>
            <atom:updated>2019-03-13T20:02:22.850Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://micronaut.io/">Micronau</a>t is a new JVM-based framework designed to make creating microservices quick and easy. One of the most exciting features of Micronaut is its support for <a href="http://reactivex.io/"><em>reactive programming</em></a> and we will see in this article how to store and search data in <a href="https://www.elassandra.io/">Elassandra</a> in a reactive way through the Cassandra driver and run unit tests with JUnit5.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*wIXmR0MRVAwuIwLXNPq0aA.png" /></figure><p>Here a basic JSON sales receipt with 3 products items:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/46c71a4d68335b35af319b44d9a00f92/href">https://medium.com/media/46c71a4d68335b35af319b44d9a00f92/href</a></iframe><p>In order to handle conversion between Cassandra types and custom Java object , and generate CQL queries, the java Cassandra driver provides a <a href="https://docs.datastax.com/en/developer/java-driver/3.5/manual/object_mapper/using/">Cassandra mapper</a>. By combining <a href="https://github.com/FasterXML/jackson">Jackson</a>, <a href="https://projectlombok.org/">Lombok</a> and Cassandra mapper java annotations in the Basket POJO object, we get both JSON serialization and Cassandra Data Access Object.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/439347657721ad58d9fa0450018b4a9f/href">https://medium.com/media/439347657721ad58d9fa0450018b4a9f/href</a></iframe><p>In the same way, the <strong>BasketItem</strong> is mapped to a <a href="https://docs.datastax.com/en/cql/3.3/cql/cql_using/useCreateUDT.html">Cassandra User Defined Type</a> as shown bellow. This will be a nested object in the Elasicsearch documents.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e375815689703de26f707a13856ff9a/href">https://medium.com/media/4e375815689703de26f707a13856ff9a/href</a></iframe><p>Finally, BascketStatus, a java enum, is managed through a registered codec as described in the <a href="https://docs.datastax.com/en/developer/java-driver/3.5/manual/custom_codecs/extras/#Enums">driver documentation</a>. Unfortunately, the java Cassandra mapper cannot generate the CQL schema, so we need to write it manually:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a2eef0be11f569a7c6e7f5a1291824b4/href">https://medium.com/media/a2eef0be11f569a7c6e7f5a1291824b4/href</a></iframe><p>To manage <a href="https://docs.datastax.com/en/developer/java-driver/3.5/manual/object_mapper/">CQL mapper</a> and initialize the CQL schema and Elasticsearch indices, we use a Micronaut bean <a href="https://github.com/strapdata/basketapp/blob/master/src/main/java/com/strapdata/basketapp/ElassandraStorage.java">ElassandraStorage</a> that use the <a href="https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-create-index.html">Elasticsearch REST Client</a> java API. To put it simply, we have run an <a href="https://elassandra.readthedocs.io/en/latest/mapping.html#bi-directional-mapping">Elassandra discover</a><br>through the <a href="https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-create-index.html">Create Index API</a> to create the Elasticsearch index <strong>baskets</strong> with a mapping automatically generated from the CQL schema.</p><h3>Elasticsearch query over CQL</h3><p>Elassandra closely integrates the Elasticsearch code and since version 6.2.3.11+, support for Elasticsearch query over the Cassandra driver is opensource, meaning that you can query Elasticsearch through the various CQL driver implementations, with several advantages:</p><ul><li>Reuse the same DAO’s in your application when retrieving data from Cassandra or Elasticsearch.</li><li>No JSON overhead, query results are sent back to the application in binary.</li><li>The CQL paging automatically manages Elasticsearch scrolling, and the last page close the scroll context.</li><li>The CQL driver acts as a load balancer and know about load and availability of Elassandra nodes.</li><li>When authentication is enabled, the CQL driver manage authentication at a session level while per HTTP request authentication involve an overhead.</li></ul><p>To send the Elasticsearch search requests to an Elassandra coordinator node, we need two dummy Cassandra columns <strong>es_query</strong> and <strong>es_options</strong>. The Elasticsearch results comes back as Cassandra rows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d59c878b00ebb9283436657766975559/href">https://medium.com/media/d59c878b00ebb9283436657766975559/href</a></iframe><p>The Cassandra <a href="https://docs.datastax.com/en/developer/java-driver/3.5/manual/object_mapper/using/#Accessors">Accessors</a> annotation provides a nice way to map such custom queries. The CQL LIMIT clause manage the number of results returned, equivalent to the Elasticsearch query size.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/858d35308c8331acfc7498420024a961/href">https://medium.com/media/858d35308c8331acfc7498420024a961/href</a></iframe><p>A static helper method based on the <a href="https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-getting-started-initialization.html">Elasticsearch REST High-Level</a><br>API provides an easy way to build Elasticsearch queries, here a boolean query with two clauses, a term query and a nested query.</p><h3>Micronaut Reactive Data Access</h3><p>Micronaut supports any framework that implements Reactive Streams, including RxJava, and Reactor. As said in the documentation, if your controller method returns a non-blocking type then Micronaut will use the Event loop thread to subscribe to the result.</p><p>In our Micronaut basket controller, <a href="https://google.github.io/guava/releases/21.0/api/docs/com/google/common/util/concurrent/ListenableFuture.html">ListenableFutures</a> returned by the Cassandra driver are converted to reactive types such as Single or Observable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6b5e00b4ab22224c016252b645a1c9be/href">https://medium.com/media/6b5e00b4ab22224c016252b645a1c9be/href</a></iframe><p>The <a href="https://github.com/strapdata/basketapp/blob/master/src/main/java/com/strapdata/basketapp/utils/TransformedListenableFuture.java">TransformedListenableFuture</a> wraps the ListenableFuture&lt;Result&lt;X&gt;&gt; to convert the result by applying a mapper function, here <a href="https://docs.datastax.com/en/drivers/java/3.5/index.html?com/datastax/driver/mapping/Mapper.html">Result::all</a>.</p><h3>Junit5 Elassandra Tests</h3><p>The <a href="https://micronaut-projects.github.io/micronaut-test/latest/guide/index.html#introduction">Micronaut Testing Framework extensions</a> included support for <a href="https://junit.org/junit5/">JUnit 5</a>, the next generation of JUnit. To test our Cassandra and Elasticsearch queries, we wanted to use <a href="https://github.com/strapdata/elassandra-unit">Elassandra-Unit</a> to run an embedded Elassandra node during unit tests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/321/1*eW_h-sgpfoanS1Aq4HtGRQ.png" /></figure><p>Nevertheless, in order to use the <a href="https://github.com/strapdata/elassandra-unit">Elassandra-Unit</a> based on Junit 4, <br>we need to implements some Junit 5 extensions to trigger before and after test operations.</p><p>First, an ElassandraCQLUnit5 extension to start an embedded Elassandra node where we set the Cassandra system property <strong>cassandra.custom_query_handler_class</strong> to enable support for Elasticsearch query over CQL. This could be done in the <strong>build.gradle</strong>, but it won’t be set when launching tests from IntelliJ IDEA, so this is more practical like that.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5a412a6ad006622c45ad1ec568aa8414/href">https://medium.com/media/5a412a6ad006622c45ad1ec568aa8414/href</a></iframe><p>Then, our <strong>BasketControllerTest</strong> also implements a JUnit5 extension to open and cleanup Elassandra node before and after each tests. The <strong>testElassandraStorage</strong> tests our elasticsearch nested query on the baskets index.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d31f1b3730e89f92043e8ae7de409c5e/href">https://medium.com/media/d31f1b3730e89f92043e8ae7de409c5e/href</a></iframe><p>Elassandra-Unit (like <a href="https://github.com/jsevellec/cassandra-unit">Cassandra-Unit</a> developed by Jeremy Sevellec) <br>use the CQL port <strong>9142</strong> (not the default 9042/tcp) and cluster name <strong>”Test Cluster”</strong> (defined in a resource file of elassandra-unit), <br>the <strong>test/resources/application.yaml</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/03c25800f780300027a29003885b1dbb/href">https://medium.com/media/03c25800f780300027a29003885b1dbb/href</a></iframe><p>Finally, tests are successful with our embedded Elassandra node:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bbDqD6mG-ZseqChYwavgHw.png" /></figure><h3>Kubernetes deployment</h3><p>As a take away, the <a href="https://github.com/GoogleContainerTools/jib">gradle JIB plugin</a> quickly containerize the <strong>basketapp</strong><br>application and publish the docker image to a docker registry:</p><p>./gradlew clean jib — image strapdata/basketapp:0.1</p><p>Then, deploy the <strong>basketapp</strong> on Kubernetes with a service and a deployment:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50c8d67bc36ff56b40ecb6f4eed3b761/href">https://medium.com/media/50c8d67bc36ff56b40ecb6f4eed3b761/href</a></iframe><p>You can also deploy Elassandra (Using the <a href="https://github.com/strapdata/helm-charts">Elassandra HELM Chart</a>), Kibana for reporting and Traefik to expose the basketapp service:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*RIJVjCnmoaoDFxIWIfGmbg.png" /></figure><h3>Conclusion</h3><p>Et voilà, you get a reliable, reactive and efficient REST micro-service backed by Elassandra. Data integration tests are very useful in terms of making sure that our code runs correctly up to the database, and Elassandra-Unit helps you to check both Cassandra and Elasticsearch queries.</p><p>Next step is to run automated integration tests, and Kubernetes can help to dynamically create a whole environment and discard it afterward. You can have a look at the <a href="https://github.com/strapdata/helm-charts">Elassandra HELM charts</a> for that.</p><p>Finally, this architecture is easy to scale by adding nodes (app or Elassandra pods), always up during node failures or rolling upgrades. No more database to Elasticsearch synchronization headache, Elassandra properly index your Cassandra data into Elasticsearch !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=970963f652bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes logs analysis with Elassandra, Fluent-Bit and Kibana]]></title>
            <link>https://medium.com/@vroyer/kubernetes-logs-analysis-with-elassandra-fluent-bit-and-kibana-4f827854e5c8?source=rss-1e45494cefee------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f827854e5c8</guid>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[fluentbit]]></category>
            <category><![CDATA[cassandra]]></category>
            <category><![CDATA[elassandra]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Vincent Royer]]></dc:creator>
            <pubDate>Thu, 17 Jan 2019 14:28:09 GMT</pubDate>
            <atom:updated>2020-02-14T13:37:12.931Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://www.elassandra.io/">Elassandra</a> simplifies your data stack by combining the power of <a href="https://www.elastic.co/fr/products/elasticsearch">Elasticsearch</a> and <a href="http://cassandra.apache.org/">Apache Cassandra</a> into a single unique solution.</p><h3>No Single Point Of Failure</h3><p>Elasticsearch is by design a sharded master-slave architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DujOPqTTA9BHDB1zrt8oPQ.png" /></figure><p>The Elasticsearch master node manages the mapping changes and only the primary shards takes write operations. The replica shards are read-only and can be promoted to primary shards by the master node in case of failure or maintenance. By relying on Apache Cassandra, Elassandra is master-less and has no Single Point Of Write. All nodes can process the search requests, request a mapping update, and depending on the Cassandra replication factor, take write operations.</p><p>As a result, Elassandra is pretty simple to manage with Kubernetes and maintenance operations (rolling restart for upgrade) can be done without any downtimes. Scaling up or down also becomes a lot more simple, no need to re-index the existing Elasticsearch indices, only the moved data is re-indexed in Elasticsearch. Elassandra also natively supports cross datacenter replication.</p><h3>Elassandra, Fluentbit and Kibana on Kubernetes</h3><p>To show the ability of Elassandra to work properly on Kubernetes, we have used <a href="https://github.com/fluent/fluent-bit-docs">Fluent-Bit</a>, a fast and lightweight log processor and forwarder that support the Elasticsearch backend, but the same configuration could also use <a href="https://github.com/fluent/fluentd">Fluentd</a> or <a href="https://github.com/elastic/beats/tree/master/filebeat">Filebeat</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*AITKz8GbrWwQoXPDuQhKTQ.png" /></figure><p>To deploy our EFK stack on Kubernetes, we have used the HELM charts as follow. First one needs to deploy an Elassandra with a 3 nodes cluster with SSD storage (here on Azure Kubernetes Service) from the <a href="https://github.com/strapdata/strapcharts">Strapdata HELM repository</a>.</p><pre>helm install --name &quot;elassandra&quot; --namespace default \<br> --set image.repo=strapdata/elassandra \<br> --set image.tag=6.2.3.10 \<br> --set config.cluster_size=3 \<br> --set persistence.storageClass=managed-premium \<br> strapdata/elassandra</pre><p>Elassandra exposes an Elasticsearch and an Apache Cassandra service. Then, one needs to deploy Kibana with the same Elasticsearch version as the one embedded in Elassandra:</p><pre>helm install --namespace default --name my-kibana  \<br>        --set image.tag=6.2.3 \<br>        --set service.externalPort=5601 \<br>        stable/kibana</pre><p>Alternatively, you can deploy <a href="https://traefik.io/">Traefik</a>, a Kubernetes ingress proxy allowing to expose Kibana on a public IP:</p><pre>helm install --name traefik --namespace kube-system --set dashboard.domain=traefik-dashboard.aks1.strapdata.com stable/traefik</pre><pre>helm install --namespace $NAMESAPCE --name my-kibana <br>        --set image.tag=6.2.3 \<br>        --set service.externalPort=5601 \<br>        --set env.ELASTICSEARCH_URL=&quot;http://elassandra-elasticsearch:9200&quot; \<br>        --set ingress.enabled=true,ingress.hosts[0]=&quot;kibana.${1:-aks1.strapdata.com}&quot;,ingress.annotations.&quot;kubernetes\.io/ingress\.class&quot;=&quot;traefik&quot; \<br>        stable/kibana</pre><p>Third, you need to deploy fluent-bit with a specific Elasticsearch index template. This template includes the Elassandra specific settings to optimise the storage and search performances.</p><pre>helm install --name my-fluentbit --set trackOffsets=&quot;true&quot; \<br>	--set backend.type=&quot;es&quot;,backend.es.host=&quot;elassandra-elasticsearch.default.svc.cluster.local&quot;,backend.es.time_key=&quot;es_time&quot;,backend.es.pipeline=&quot;fluentbit&quot; \<br>	--set parsers.enabled=true,parsers.json[0].name=&quot;docker&quot;,parsers.json[0].timeKey=&quot;time&quot;,parsers.json[0].timeFormat=&quot;%Y-%m-%dT%H:%M:%S.%L&quot;,parsers.json[0].timeKeep=&quot;Off&quot; <br>        strapdata/fluent-bit</pre><p>Once deployed on Kubernetes nodes, fluent-bit starts to send pod’s logs to our Elassandra cluster.</p><h3>Elassandra index optimization</h3><p>Our <a href="https://github.com/strapdata/helm-charts/tree/master/charts/fluent-bit">Fluent-bit HELM chart </a>basically provides an <a href="https://github.com/strapdata/helm-charts/blob/master/charts/fluent-bit/templates/elassandra-template.yaml">Elasticsearch index template optimised for Elassandra</a> with the following index template settings:</p><pre>&quot;settings&quot;: {<br>      &quot;index&quot;: {<br>        &quot;replication&quot;: &quot;DC1:2&quot;,<br>        &quot;table_options&quot;: &quot;compaction = {&#39;compaction_window_size&#39;: &#39;4&#39;, &#39;compaction_window_unit&#39;: &#39;HOURS&#39;, &#39;class&#39;: &#39;org.apache.cassandra.db.compaction.TimeWindowCompactionStrategy&#39;}&quot;,<br>        &quot;mapping&quot;: {<br>          &quot;total_fields&quot;: {<br>            &quot;limit&quot;: &quot;10000&quot;<br>          }<br>        },<br>        &quot;refresh_interval&quot;: &quot;15s&quot;,<br>        &quot;drop_on_delete_index&quot;: &quot;true&quot;,<br>        &quot;index_insert_only&quot;: &quot;true&quot;,<br>        &quot;search_strategy_class&quot;: &quot;RandomSearchStrategy&quot;<br>      }</pre><h4>Insert only mode</h4><p>In Elassandra, Elasticsearch _source document are stored in a Cassandra table as rows. When inserting into Elassandra via the the Elasticsearch index API, empty fields are populated with null by default in the Cassandra storage layer in order to overwrite any existing documents. It generates some Cassandra tombstones, but when inserting some immutable log records, it is useless, and in this case, the index.index_insert_only settings optimise the Cassandra storage.</p><h4>Drop on delete index</h4><p>In Elassandra, Cassandra is basically the data storage layer and by default, removing an index does not remove the underlying Cassandra table and keyspace. You can alter it with the index.drop_on_delete_index setting, removing the last index on a table will remove the underlying Cassandra table. Thus, purging Elasticsearch indices will also drop underlying keyspaces automatically.</p><h4>Replication</h4><p>In Elassandra, data replication is no longer done by Elasticsearch but by Cassandra itself. Then, the underlying keyspace replication map controls the location (in which Cassandra datacenters) and the number of copies. The replication setting in the Elasticsearch template defines the Cassandra replication map, here on DC1 with 2 copies.</p><h4>Table options</h4><p>The table_options settings define the Cassandra table options used at creation time. Here, as the log records are immutable, we have chosen the Time Window Compaction Strategy designed for the time series data. You could also set here the Cassandra default TTL or the compression settings (LZ4 by default).</p><h4>Search strategy</h4><p>In Elassandra, the coordinator node distributes the sub-queries to the available nodes according the search strategy defined by a <em>search_strategy_class</em>. By default, the <em>PrimaryFirstSearchStrategy</em> sends a sub-query to all nodes in the Cassandra datacenter. Here, we use the <em>RandomSearchStrategy</em> that computes the smallest set of nodes required to get a consistent result in the datacenter. For example, with a replication factor of 2 in a 6 nodes cluster, this strategy will only request 3 nodes, reducing the global load of the clusters.</p><h3>Elassandra mapping</h3><p>Because the Elasticsearch fields are multi-valued, Elassandra stores each field of type X in a Cassandra list. If you look at the generated SSTables with the <a href="https://murukeshm.github.io/cassandra/trunk/tools/sstable/sstabledump.html">sstabledump</a> utility, you will be able to find Cassandra rows generated by fluent-bit:</p><pre>{<br>    &quot;partition&quot; : {<br>      &quot;key&quot; : [ &quot;RL5Bp2cBWzCxo-DQnARL&quot; ],<br>      &quot;position&quot; : 160123<br>    },<br>    &quot;rows&quot; : [<br>      {<br>        &quot;type&quot; : &quot;row&quot;,<br>        &quot;position&quot; : 160691,<br>        &quot;liveness_info&quot; : { &quot;tstamp&quot; : &quot;2018-12-13T11:09:14.378005Z&quot; },<br>        &quot;cells&quot; : [<br>          { &quot;name&quot; : &quot;es_time&quot;, &quot;deletion_info&quot; : { &quot;marked_deleted&quot; : &quot;2018-12-13T11:09:14.378004Z&quot;, &quot;local_delete_time&quot; : &quot;2018-12-13T11:09:14Z&quot; } },<br>          { &quot;name&quot; : &quot;es_time&quot;, &quot;path&quot; : [ &quot;868796ae-fec7-11e8-aa29-7b1a7ab32955&quot; ], &quot;value&quot; : &quot;2018-12-13 11:08:42.265Z&quot; },<br>          { &quot;name&quot; : &quot;kubernetes&quot;, &quot;deletion_info&quot; : { &quot;marked_deleted&quot; : &quot;2018-12-13T11:09:14.378004Z&quot;, &quot;local_delete_time&quot; : &quot;2018-12-13T11:09:14Z&quot; } },<br>          { &quot;name&quot; : &quot;kubernetes&quot;, &quot;path&quot; : [ &quot;868796aa-fec7-11e8-aa29-7b1a7ab32955&quot; ], &quot;value&quot; : {&quot;container_name&quot;: [&quot;logs-generator&quot;], &quot;host&quot;: [&quot;aks-nodepool1-36080323-0&quot;], &quot;annotations&quot;: null, &quot;docker_id&quot;: [&quot;e38071228edf79584ef4eafdfb67c0144605a31730e71b02b3f6e1c8f27e0ea3&quot;], &quot;pod_id&quot;: [&quot;721a6540-fca4-11e8-8d8b-f6dcc5e73f85&quot;], &quot;pod_name&quot;: [&quot;logs-generator&quot;], &quot;namespace_name&quot;: [&quot;default&quot;], &quot;labels&quot;: [{&quot;app&quot;: null, &quot;controller-revision-hash&quot;: null, &quot;release&quot;: null, &quot;pod-template-generation&quot;: null, &quot;statefulset_kubernetes_io/pod-name&quot;: null, &quot;kubernetes_io/cluster-service&quot;: null, &quot;k8s-app&quot;: null, &quot;name&quot;: null}]} },<br>          { &quot;name&quot; : &quot;log&quot;, &quot;deletion_info&quot; : { &quot;marked_deleted&quot; : &quot;2018-12-13T11:09:14.378004Z&quot;, &quot;local_delete_time&quot; : &quot;2018-12-13T11:09:14Z&quot; } },<br>          { &quot;name&quot; : &quot;log&quot;, &quot;path&quot; : [ &quot;868796ab-fec7-11e8-aa29-7b1a7ab32955&quot; ], &quot;value&quot; : &quot;I1213 11:08:42.265287       6 logs_generator.go:67] 362287 PUT /api/v1/namespaces/ns/pods/s2qj 215\n&quot; },<br>          { &quot;name&quot; : &quot;stream&quot;, &quot;deletion_info&quot; : { &quot;marked_deleted&quot; : &quot;2018-12-13T11:09:14.378004Z&quot;, &quot;local_delete_time&quot; : &quot;2018-12-13T11:09:14Z&quot; } },<br>          { &quot;name&quot; : &quot;stream&quot;, &quot;path&quot; : [ &quot;868796ac-fec7-11e8-aa29-7b1a7ab32955&quot; ], &quot;value&quot; : &quot;stderr&quot; },<br>          { &quot;name&quot; : &quot;time&quot;, &quot;deletion_info&quot; : { &quot;marked_deleted&quot; : &quot;2018-12-13T11:09:14.378004Z&quot;, &quot;local_delete_time&quot; : &quot;2018-12-13T11:09:14Z&quot; } },<br>          { &quot;name&quot; : &quot;time&quot;, &quot;path&quot; : [ &quot;868796ad-fec7-11e8-aa29-7b1a7ab32955&quot; ], &quot;value&quot; : &quot;2018-12-13 11:08:42.265Z&quot; }<br>        ]<br>      }<br>    ]<br>  }</pre><p>As you can see, due to the <a href="https://docs.datastax.com/en/cql/3.3/cql/cql_using/useCollections.html">Cassandra collections</a> (list, set and map), useless overheads are created. Elassandra extends the Elasticsearch mapping with new attributes, and the <strong>“cql_collection”:”singleton”</strong> attribute allows to explicitly map the single-valued fields to the corresponding Cassandra type. By adding this, to the single-valued fields in our fluent-bit index template, the Cassandra rows becomes lighter as shown bellow:</p><pre>root@elassandra-0:/usr/share/cassandra# tools/bin/sstabledump /var/lib/cassandra/data/logstash_2018_12_17/flb_type-751e28a0022f11e9a83bbd84c8d6464a/mc-9-big-Data.db</pre><pre>....<br>{<br>    &quot;partition&quot; : {<br>      &quot;key&quot; : [ &quot;nmWfvWcBHsJPeHipoGsM&quot; ],<br>      &quot;position&quot; : 402735<br>    },<br>    &quot;rows&quot; : [<br>      {<br>        &quot;type&quot; : &quot;row&quot;,<br>        &quot;position&quot; : 403179,<br>        &quot;liveness_info&quot; : { &quot;tstamp&quot; : &quot;2018-12-17T19:23:34.412Z&quot; },<br>        &quot;cells&quot; : [<br>          { &quot;name&quot; : &quot;es_time&quot;, &quot;value&quot; : &quot;2018-12-17 19:23:33.603Z&quot; },<br>          { &quot;name&quot; : &quot;kubernetes&quot;, &quot;value&quot; : {&quot;container_name&quot;: &quot;logs-generator&quot;, &quot;host&quot;: &quot;aks-nodepool1-36080323-0&quot;, &quot;docker_id&quot;: &quot;e33b2cda2ed7ac3bc5a6504cd79b6ea999137a11791d67fbb8b497fe06d8d700&quot;, &quot;pod_id&quot;: &quot;8ecacdcd-0229-11e9-8d8b-f6dcc5e73f85&quot;, &quot;pod_name&quot;: &quot;logs-generator&quot;, &quot;namespace_name&quot;: &quot;default&quot;, &quot;labels&quot;: [{&quot;app&quot;: null, &quot;component&quot;: null, &quot;controller-revision-hash&quot;: null, &quot;tier&quot;: null, &quot;pod-template-generation&quot;: null, &quot;name&quot;: null, &quot;pod-template-hash&quot;: null, &quot;version&quot;: null, &quot;k8s-app&quot;: null, &quot;kubernetes_io/cluster-service&quot;: null, &quot;release&quot;: null, &quot;statefulset_kubernetes_io/pod-name&quot;: null, &quot;run&quot;: [&quot;logs-generator&quot;]}], &quot;annotations&quot;: null} },<br>          { &quot;name&quot; : &quot;log&quot;, &quot;value&quot; : &quot;I1217 19:23:33.600235       6 logs_generator.go:67] 2850 POST /api/v1/namespaces/ns/pods/65w 207\n&quot; },<br>          { &quot;name&quot; : &quot;stream&quot;, &quot;value&quot; : &quot;stderr&quot; },<br>          { &quot;name&quot; : &quot;time&quot;, &quot;value&quot; : &quot;2018-12-17 19:23:33.603Z&quot; }<br>        ]<br>      }<br>    ]<br>  }</pre><p>As a result, the Cassandra storage for logs is optimized and becomes a lot more efficient than storing the JSON <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html">_source</a> document in a Lucene stored field.</p><h3>Elassandra storage optimization</h3><p>For each log records, Fluentbit adds some Kubernetes metadata, and for a docker container, these metadata are always the same. With the Cassandra wide row storage, we can store these metadata only once and for many log records, thus reducing the disk size of SSTables. The following figure illustrates the Cassandra storage of Elasticsearch documents:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*uE0HAWdRcaDT4tWlqAUSbA.png" /></figure><p>To achieve this, an <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/pipeline-processor.html">Elasticsearch pipeline</a> transforms the original JSON documents to add a new unique timestamp stored as a timeuuid (a Type 1 UUID), and build a document _id in the form of a Cassandra compound key with the docker container id as the partition key, and the new timeuuid as a clustering key.</p><pre>curl -H &quot;Content-Type: application/json&quot; -XPUT <br>&quot;http://elassandra-0:9200/_ingest/pipeline/fluentbit&quot; -d&#39;<br>{<br>     &quot;description&quot; : &quot;fluentbit elassandra pipeline&quot;,<br>     &quot;processors&quot; : [<br>       {<br>         &quot;timeuuid&quot; : {<br>           &quot;field&quot;: &quot;es_time&quot;,<br>           &quot;target_field&quot;: &quot;ts&quot;,<br>           &quot;formats&quot; : [&quot;ISO8601&quot;],<br>           &quot;timezone&quot; : &quot;Europe/Amsterdam&quot;<br>         }<br>       },<br>       {<br>         &quot;set&quot; : {<br>           &quot;field&quot;: &quot;_id&quot;,<br>            &quot;value&quot;: &quot;[\&quot;{{kubernetes.docker_id}}\&quot;,\&quot;{{ts}}\&quot;]&quot;<br>         }<br>       }<br>     ]<br>}&#39;</pre><p>Then, we can add the following mapping attributes to our Fluent-bit Elasticsearch template:</p><ul><li>On the partition key column, cql_partition_key: true and cql_primary_key_order:0</li><li>On the clustering key column, cql_primary_key_order:1 and cql_type:timeuuid</li><li>On the Kubernetes metadata column, cql_static_column: true</li></ul><pre>curl -H &quot;Content-Type: application/json&quot; -XPUT &quot;http://elassandra-0:9200/_template/template_fluentbit&quot; -d@<a href="https://gist.github.com/vroyer/c7bf86013e0f0854045a5feb7f5645de.js">fluentbit_template.json</a></pre><p>After cleaning the existing index and redeploying the new Elasticsearch pipeline and template, the SSTables contains one wide row per container and per day. The log storage is now optimal and Kubernetes metadata is only stored once per day for each docker container. Even timestamp fields (es_time and time) can be removed because some time is freed up for the Cassandra clustering key, a timeuuid column seen as a date by Elasticsearch.</p><pre>{<br>    &quot;partition&quot; : {<br>      &quot;key&quot; : [ &quot;f9f237c2d64dd8b92130fd34f567b162f0ae1972e7afabee9151539ba31ccadd&quot; ],<br>      &quot;position&quot; : 2800<br>    },<br>    &quot;rows&quot; : [<br>      {<br>        &quot;type&quot; : &quot;static_block&quot;,<br>        &quot;position&quot; : 3326,<br>        &quot;cells&quot; : [<br>          { &quot;name&quot; : &quot;kubernetes&quot;, &quot;value&quot; : {&quot;container_name&quot;: &quot;put-template&quot;, &quot;host&quot;: &quot;aks-nodepool1-36080323-0&quot;, <br>          &quot;pod_id&quot;: &quot;e24f2521-1256-11e9-8fe6-de1ce27ac649&quot;, <br>          &quot;pod_name&quot;: &quot;fluent-bit-sc6m6&quot;, &quot;namespace_name&quot;: &quot;default&quot;, <br>          &quot;labels&quot;: [{&quot;app&quot;: &quot;my-fluentbit-fluent-bit&quot;, &quot;component&quot;: null, &quot;controller-revision-hash&quot;: &quot;3156758786&quot;, &quot;tier&quot;: null, <br>          	&quot;pod-template-generation&quot;: &quot;1&quot;, &quot;name&quot;: null, &quot;pod-template-hash&quot;: null, &quot;version&quot;: null, &quot;k8s-app&quot;: null, &quot;kubernetes_io/cluster-service&quot;: null, <br>          	&quot;release&quot;: [&quot;my-fluentbit&quot;], &quot;statefulset_kubernetes_io/pod-name&quot;: null}], <br>          &quot;annotations&quot;: [{&quot;checksum/config&quot;: [&quot;3375211361605629fc5a1f970e1fce0ce2fabbcb08ef4631acdc4bd2ac41fd7b&quot;], <br>          &quot;scheduler_alpha_kubernetes_io/critical-pod&quot;: null, &quot;prometheus_io/port&quot;: null, &quot;prometheus_io/scrape&quot;: null}]}, <br>          &quot;tstamp&quot; : &quot;2019-01-07T08:33:35.968Z&quot; }<br>        ]<br>      },<br>      {<br>        &quot;type&quot; : &quot;row&quot;,<br>        &quot;position&quot; : 3326,<br>        &quot;clustering&quot; : [ &quot;e4375630-1256-11e9-a990-c3ec4d724241&quot; ],<br>        &quot;liveness_info&quot; : { &quot;tstamp&quot; : &quot;2019-01-07T08:33:35.954Z&quot; },<br>        &quot;cells&quot; : [<br>          { &quot;name&quot; : &quot;log&quot;, &quot;value&quot; : &quot;  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n&quot; },<br>          { &quot;name&quot; : &quot;stream&quot;, &quot;value&quot; : &quot;stderr&quot; }<br>        ]<br>      },<br>      {<br>        &quot;type&quot; : &quot;row&quot;,<br>        &quot;position&quot; : 3326,<br>        &quot;clustering&quot; : [ &quot;e4375630-1256-11e9-0566-b0312df0dcfc&quot; ],<br>        &quot;liveness_info&quot; : { &quot;tstamp&quot; : &quot;2019-01-07T08:33:35.964Z&quot; },<br>        &quot;cells&quot; : [<br>          { &quot;name&quot; : &quot;log&quot;, &quot;value&quot; : &quot;                                 Dload  Upload   Total   Spent    Left  Speed\n&quot; },<br>          { &quot;name&quot; : &quot;stream&quot;, &quot;value&quot; : &quot;stderr&quot; }<br>        ]<br>      }</pre><p>You can then use Kibana as usual to explore your logs and create dashboards.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_K91TTsfHGegupzTpbhTsA.png" /></figure><h3>Availability test</h3><p>In order to check the availability of Elassandra, we have ingested some logs with a log generator.</p><pre>for i in {1..20}; do kubectl run logs-generator${i} --generator=run-pod/v1 --image=k8s.gcr.io/logs-generator:v0.1.1 \<br>--restart=Never --env &quot;LOGS_GENERATOR_LINES_TOTAL=50000&quot; --env &quot;LOGS_GENERATOR_DURATION=3m&quot;; done</pre><p>Then, we have killed an Elassandra POD, causing the node to be restarted by the Kubernetes controller.</p><p>$kubectl delete pod/elassandra-1 pod “elassandra-1” deleted</p><p>With a Cassandra replication factor of 1, loosing one Elassandra node causes write errors as expected:</p><pre>[2019/01/10 16:46:09] [ warn] [out_es] Elasticsearch error<br>{&quot;took&quot;:3,&quot;ingest_took&quot;:2,&quot;errors&quot;:true,&quot;items&quot;:[{&quot;index&quot;:{&quot;_index&quot;:&quot;logstash-2019.01.10&quot;,&quot;_type&quot;:&quot;flb_type&quot;,&quot;_id&quot;:&quot;[\&quot;c0e45980637031ed19386d8a2b3fa736597057eea46917b8c28b73ba640e3cc3\&quot;,\&quot;25c13480-14f6-11e9-2b53-a734ca6c6447\&quot;]&quot;,&quot;status&quot;:500,&quot;error&quot;:{&quot;type&quot;:&quot;write_failure_exception&quot;,&quot;reason&quot;:&quot;Operation failed - received 0 responses and 1 failures&quot;}}},{&quot;index&quot;:{&quot;_index&quot;:&quot;logstash-2019.01.10&quot;,&quot;_type&quot;:&quot;flb_type&quot;,&quot;_id&quot;:&quot;[\&quot;c0e45980637031ed19386d8a2b3fa736597057eea46917b8c28b73ba640e3cc3\&quot;,\&quot;372b3680-14f6-11e9-d3d8-e1397bcf3034\&quot;]&quot;,&quot;status&quot;:500,&quot;error&quot;:{&quot;type&quot;:&quot;write_failure_exception&quot;,&quot;reason&quot;:&quot;Operation failed - received 0 responses and 1 failures&quot;}}},{&quot;index&quot;:{&quot;_index&quot;:&quot;logstash-2019.01.10&quot;,&quot;_type&quot;:&quot;flb_type&quot;,&quot;_id&quot;:&quot;[\&quot;c0e45980637031ed19386d8a2b3fa736597057eea46917b8c28b73ba640e3cc3\&quot;,\&quot;41a8c280-14f6-11e9-bc51-b90088b4aa65\&quot;]&quot;,&quot;status&quot;:500,&quot;error&quot;:{&quot;type&quot;:&quot;write_failure_exception&quot;,&quot;reason&quot;:&quot;Operation failed - received 0 responses and 1 failur</pre><p>Then we setup a Cassandra replication factor of two for the Logstash index:</p><pre>kubectl exec -it elassandra-0 -- cqlsh<br>Connected to elassandra at 127.0.0.1:9042.<br>[cqlsh 5.0.1 | Cassandra 3.11.3.5 | CQL spec 3.4.4 | Native protocol v4]<br>Use HELP for help.<br>cqlsh&gt; ALTER KEYSPACE logstash_2019_01_10  WITH replication = {&#39;class&#39;: &#39;NetworkTopologyStrategy&#39;,&#39;DC1&#39;:&#39;2&#39;};</pre><p>During the same test, Fluentbit indicated some broken connection errors, but managed and succeeded to write to Elassandra.</p><pre>[2019/01/10 16:57:39] [error] [http_client] broken connection to elassandra-elasticsearch.default.svc.cluster.local:9200 ?<br>[2019/01/10 16:57:39] [ warn] [out_es] http_do=-1<br>[2019/01/10 16:57:39] [error] [http_client] broken connection to elassandra-elasticsearch.default.svc.cluster.local:9200 ?<br>[2019/01/10 16:57:39] [ warn] [out_es] http_do=-1</pre><p>Thanks to the Cassandra multi-master architecture, write operations were made possible on at least one node while one was restarting, event through the Elasticsearch API ! While a node was missing, the Elasticsearch indices became yellow, indicating there was a missing node, but the search was still consistent.</p><pre>health status index               uuid                   pri rep docs.count docs.deleted store.size pri.store.size<br>yellow open   logstash-2019.01.10 p01ngidBRDSVsi99NupG5g   3   1     227478            0     88.3mb         88.3mb<br>yellow open   .kibana             68N_Dsk0SoOG9jHElafDUw   3   1          3            0     15.8kb         15.8kb</pre><p>After the node restarted, the Elasticsearch indices switched back to green and the Cassandra nodes 0 and 2 sent <a href="https://docs.datastax.com/en/cassandra/3.0/cassandra/operations/opsRepairNodesHintedHandoff.html">hint handoff</a> to node 1 to recover from the missed log records.</p><h3>Conclusion</h3><p>Elassandra presents an efficient new opportunity with Kuberntes for many user-cases. As demonstrated, with the right configuration, you can use the Elasticsearch pipeline processors to change and optimise the Cassandra storage, even if you don’t index at all in Elasticsearch (just say index=no in your Elasticsearch mapping, and you will only get the data in the underlying Cassandra table). And furthermore, you can maintain your Elassandra clusters with no downtime when rolling upgrades or easily scale up/down Elassandra (no need to re-index all).</p><p>Finally, Elassandra will support the cross-kuberentes-cluster replication in the multi-cloud environments, but that’s another story!</p><h3>References</h3><ul><li><a href="http://doc.elassandra.io/en/latest/">Elassandra documentation - Elassandra 6.8.4.5 documentation</a></li><li><a href="https://github.com/strapdata/elassandra">strapdata/elassandra</a></li><li><a href="https://github.com/strapdata/helm-charts">strapdata/helm-charts</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f827854e5c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>