<?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 Shubhra Kar on Medium]]></title>
        <description><![CDATA[Stories by Shubhra Kar on Medium]]></description>
        <link>https://medium.com/@shubhra.kar?source=rss-17b180ad7b15------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wazmLFJ6wMqLX4QGN4RaAQ.jpeg</url>
            <title>Stories by Shubhra Kar on Medium</title>
            <link>https://medium.com/@shubhra.kar?source=rss-17b180ad7b15------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 11:22:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shubhra.kar/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[Node.js API Tip: GeoLocation]]></title>
            <link>https://medium.com/@shubhra.kar/node-js-api-tip-geolocation-edacb7c0dce6?source=rss-17b180ad7b15------2</link>
            <guid isPermaLink="false">https://medium.com/p/edacb7c0dce6</guid>
            <dc:creator><![CDATA[Shubhra Kar]]></dc:creator>
            <pubDate>Mon, 20 Jul 2020 00:00:46 GMT</pubDate>
            <atom:updated>2020-07-20T00:00:46.495Z</atom:updated>
            <content:encoded><![CDATA[<p>In the rapidly evolving data analytics space that is driving renewed IT and marketing spend, one of the key metrics is end user tracking is…</p><ul><li>Who are you (Identity)?</li><li>What are you entitled to (Access)?</li><li>How are you (Wellness)?</li><li>Which things draw/drive your attention (Behavior Patterns)</li><li>“Where are you?” (Location)</li></ul><p>Every location based app out there wants your mobile phone or wearable to tell it where you are. This is achieved with a small bit of technology called “geolocation.” “Where are you?” — is what we’ll focus on in this blog post.</p><h3>How does geolocation work?</h3><p>In general, mobile apps with geolocation capabilities do two things:</p><ul><li>They report your location to other users</li><li>They associate real-world locations to things like events, points of interests (ATMs, stores, restaurants, etc) to your location.</li></ul><p>There are two mechanisms currently used to determine geolocation. One is based on radio frequency location and second on IP/Mac address type information.</p><p>Geolocation for mobile and GPS traditionally use <a href="http://en.wikipedia.org/wiki/Radio_navigation">radio frequency (RF) location</a> methods, for example Time Difference Of Arrival ( <a href="http://en.wikipedia.org/wiki/TDOA">TDOA</a>) for precision. TDOA systems often utilize mapping displays or other <a href="http://en.wikipedia.org/wiki/Geographic_information_system">geographic information systems</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/0*98NdHtNOzDRFV5vC.jpg" /></figure><p>Smartphones have a richer geolocation experience than desktops because of the real-time feedback services to the location. Usually they have an embedded GPS chip which uses satellite data to calculate your exact position, which services such as Google Maps can then map. When a GPS signal is unavailable, geolocation apps can use information from cell towers to triangulate your approximate position. Some hybrid techniques have evolved recently like Assisted GPS ( <a href="http://en.wikipedia.org/wiki/Assisted_GPS">A-GPS</a>) for higher accuracy.</p><p>Internet and computer geolocation can be performed by associating a geog <a href="http://www.techhive.com/article/192803/geolo.html#">r</a> aphic location with the Internet Protocol (IP) address, MAC address, RFID, embedded hardware article/software number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wNDyd9ZYDQMEjUKc.jpg" /></figure><p>Geolocation usually works by automatically looking up an IP address on a WHOIS service and retrieving the registrant’s physical address.</p><p>IP address location data can include information such as country, region, city, postal/zip code, latitude, longitude and timezone.</p><p>In this post we won’t cover native (iPhone, Android) navigator capabilities, instead we’ll focus on a more generic solution for JavaScript developers.</p><h3>How can I get started as a JavaScript developer ?</h3><p>Most modern browsers like Firefox, Internet Explorer, Safari, Chrome, and Opera have geolocation API support. Chrome even has support for the <a href="http://en.wikipedia.org/wiki/WGS84">World Geodetic System (WGS 84)</a> navigation system, which is the reference coordinate system for GPS.</p><p>These geolocation APIs center around a new property on the global navigator object: navigator.geolocation. The API is designed to enable both &quot;one-shot&quot; position requests and repeated position updates, as well as the ability to explicitly query the cached positions. Location information is represented by latitude and longitude coordinates.</p><p>The simplest use of the geolocation API looks like this:</p><p>As you’d expect, privacy is a first class citizen for the geolocation API. What this means is that geolocation support is “opt-in” by default. The browser will never force you to reveal your current physical location to a remote server without explicit permission. The user experience may differ slightly from browser to browser, but everyone has seen pop-up messages like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/0*vjY2oZbitYveUajx.jpg" /></figure><p>Calling the getCurrentPosition() function of the geolocation API will cause the browser to pop up an &quot;infobar&quot; at the top of the browser window providing the website name that is seeking to know your location. Thus letting you choose (opt-in) to share your location or deny sharing and allowing the browser to save your opt-in choice (share/don&#39;t share).</p><p>A similar workflow is seen for mobile apps as well, but in this case the requester is the WiFi radio locator instead of the browser. Device notifications are similarly specific to platform and use mobile backend services like <a href="http://docs.strongloop.com/display/LB/Push+notifications+for+iOS+apps#PushnotificationsforiOSapps-ConfigureAPNpushsettingsinyourserverapplication">APN</a> for iOS as an example</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/0*qsOfWpRLaz80e6CF.png" /></figure><p>Codewise, we just invoked a single function call which takes a callback function (which is called show_map). The call to getCurrentPosition() returns immediately, but without access to the user&#39;s location. Access to the location/position data is in the callback function. The callback function looks like this:</p><p>You can find comprehensive examples of recursive location/position updates, error handling, caching and more on <a href="http://dev.w3.org/geo/api/spec-source.html">W3C spec for Geolocation API</a>.</p><h3>Can I get geolocation served as an API or a backend service ?</h3><p>Increasingly mobile and app services are being rendered through universal backends providing device/platform/form factor independence on the client side. These backends are referred to as BaaS (Backend-as-a-Service) or mBaaS (mobile Backend-as-a-Service) in the case of mobile specific services that are exposed. Node.js has become technology of choice to build extremely fast, scalable and lightweight mBaaS primarily due to REST based data transfer, a huge ecosystem of data connectors and integration with frontend JavaScript stacks like Angular and Backbone. Also working in Node.js favor is its ability to interoperate using JSON models with NoSQL databases like MongoDB.</p><p><a href="http://loopback.io/">LoopBack</a> is the leading open source Node.js framework built on top of <a href="http://expressjs.com/">express.js</a> middleware that can help you build your own mBaaS using <a href="http://strongloop.com/strongblog/node-js-api-tip-model-driven-development/">model-driven API development</a>. In addition to built in capabilities like ORM, object discovery, offline sync, replication and multi-channel (iOS, Android, Angular, HTML5) SDKs; geolocation and push notifications are available out of box. Loopback uses isomorphic JavaScript, essentially RPC/remoting capabilities and <a href="http://browserify.org/">browersify</a> support to share definition and state of server side JavaScript/JSON data models written in Node.js with frontend JavaScript stacks.</p><h3>Let’s build geolocation as a service!</h3><p>First, install the StrongLoop package</p><p>We will now get an example LoopBack app with pre-wired location and push notification services</p><p>We are then prompted by the LoopBack generator for a project structure. I am choosing the project name as <em>Rental_Car_App</em></p><p>The generator will pull down the required npm modules for scaffolding, data connection, API documentation and testing. Now we can simply change directory to the project</p><p>And boot up the API application using:</p><p>For more advanced runtime commands like running daemonized, in-cluster mode, with log aggregation, with monitoring et all, please checkout the StrongLoop <a href="http://strongloop.com/node-js/controller/">Controller</a> and <a href="http://strongloop.com/node-js/monitoring/">Perfromance Monitoring</a> pages.</p><p>By default the Loopback API Server instance connects to an in-memory object store. You have options of connecting to relational datasources (Oracle, MySQL, PostgreSQL or SQL Server), NoSQL databases like MongoDB, services like REST and SOAP, or proprietary backends like Sharepoint, SAP, or ATG.</p><p>Opening a browser and running the URL <a href="http://localhost:3000/explorer">http://localhost:3000/explorer</a>, we instantaneously get our APIs running in <a href="http://strongloop.com/strongblog/enterprise-api-swagger-2-0-loopback/">Swagger 2.0</a> interface with RPC/remoting built-in from the browser to the Node.js server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c_ZHBKDdIbqObwPI.png" /></figure><p>Here we see that APIs have been auto-created for <em>Car Rental</em> services, which help detect cars, inventory, locations for dealerships, etc along with automatic API end-points for every CRUD and custom operations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0XPseY5c_wmgml9o.png" /></figure><p>Clicking on the <em>Location</em> API, we can see all endpoints. Of particular interest are <em>“GET /Locations”</em> and <em>“GET /Locations/nearby”</em>.</p><p>We can click on the <em>“Try it out !”</em> button under both these API endpoints. <em>GET /Locations</em> returns us a list of all the rental car center/dealership locations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*H6wmf6uAMGQBs0bl.png" /></figure><p>In each physical location adhering to the location model schema, following attributes are found returned as JSON objects. See one of the records below:</p><p>For more on modeling from scratch, visit <a href="http://docs.strongloop.com/display/LB/Getting+started+with+LoopBack">http://docs.strongloop.com/display/LB/Getting+started+with+LoopBack</a></p><p>We can see that the geolocation is being calculated by the server and would be great we query nearby rental car centers based on a particular geolocation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jk2mLeYjqRJhZtb0.png" /></figure><p>Here I am passing a geolocation as a query in terms of latitude and longitude and a Distance To query parameter, which is “5 miles” from that geopoint. In the result set, I get back a list of all rental car centers in a 5 mile radius from the specified lat/long.</p><p>WOW ! that was slick, but how much code do I need to write ?</p><p>Not much. Once location is embedded in a model, Loopback framework takes care of all the compute, filter, pagination, middleware wiring and rendering. Here is the code snippet that makes geopoint work for finding coffee shops near a physical location (lat/long pair).</p><h4>geoPoint.distanceBetween(pointA, pointB, options)</h4><p>Determine the spherical distance between two GeoPoints.</p><h4>geoPoint.distanceTo(point, options)</h4><p>Determine the spherical distance to the given point. Example:</p><h4>geoPoint.toString()</h4><p>Simple serialization.</p><p>For more details please check out <a href="http://docs.strongloop.com/display/LB/GeoPoint+class">http://docs.strongloop.com/display/LB/GeoPoint+class</a>.</p><p>These APIs now can be surfaced into a mobile or JavaScript app using out of box client SDKs or direct remoting calls. Below is an example of the <em>Rental Car</em> app using these backend APIs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/523/0*7CdGzx_dOERJxziO.png" /></figure><p><em>Originally published at </em><a href="https://strongloop.com/strongblog/node-js-api-geolocation/"><em>https://strongloop.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edacb7c0dce6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Connected Cloud: Samsung Mobile’s Multi-cloud Architecture]]></title>
            <link>https://medium.com/@shubhra.kar/the-connected-cloud-samsung-mobiles-multi-cloud-architecture-10da590dda1c?source=rss-17b180ad7b15------2</link>
            <guid isPermaLink="false">https://medium.com/p/10da590dda1c</guid>
            <dc:creator><![CDATA[Shubhra Kar]]></dc:creator>
            <pubDate>Mon, 20 Jul 2020 00:00:03 GMT</pubDate>
            <atom:updated>2020-07-20T00:00:03.481Z</atom:updated>
            <content:encoded><![CDATA[<p>“Connected Thinking” is the theme of this year’s <a href="http://www.sdc2017.com/?utm_source=blog&amp;utm_medium=social&amp;utm_campaign=joyent">Samsung Developer Conference</a>, and it is at the core of Samsung’s strategy to create intelligent platforms that connect Samsung devices to deliver unique and seamless user experiences. Internally at Samsung, this focus on connected software and services triggered the need to rethink how Samsung uses cloud infrastructure to power these connected experiences. How can the data that is the strategic foundation of many of these services be securely controlled and shared? How can connectivity and portability between key cloud providers be achieved? And, as cloud usage increases, how can cloud costs be controlled?</p><p>Just over one year ago Samsung acquired <a href="https://www.joyent.com/">Joyent</a> to be the cornerstone of a new, connected cloud strategy designed to allow Samsung to drive down its cloud costs, control strategic data, and enable portability across cloud providers. This post highlights two key elements of Samsung’s connected cloud strategy:</p><ul><li>How Samsung is leveraging <a href="https://www.joyent.com/pricing/private-regions">Triton Private Regions</a> from Joyent to take control of its data and lower its object storage costs.</li><li>Patterns for using containers and container scheduling tools like <a href="https://kubernetes.io/">Kubernetes</a> to enable portability of software and services across cloud providers.</li></ul><h3>Taking back control of data, while lowering storage costs</h3><p>Historically, Samsung has leveraged public cloud object storage services to hold the data that many of the enhanced user experiences Samsung is building depend upon. This creates two problems. First, as the amount of data being stored grows the cost of storing that data in a public cloud simply becomes too expensive. A more cost effective solution is needed. Second, because connected data is at the foundation of Samsung’s integrated platforms, that data is a strategic asset. Securely controlling it is a requirement.</p><p>To solve these two challenges Samsung turned to Joyent to build and run for them <a href="https://www.joyent.com/pricing/private-regions">Triton Private Regions</a> around the world to support a hybrid cloud architecture where object storage is placed in Private Regions, while unpredictable compute workloads continue to run on a public cloud.</p><h4>An example: Samsung Cloud</h4><p><a href="http://www.samsung.com/us/support/owners/app/samsung-cloud">Samsung Cloud</a> allows users to backup and sync photos as well as content from apps such as Samsung Notes, Calendar and Contacts across their devices in accordance with their preferences. Before the move to Triton Private Regions, all the compute, storage and mobile backend services that make up the Samsung Cloud application were deployed on a single public cloud provider’s infrastructure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/973/0*_xsliS1PqVUw5v2s.jpg" /></figure><p>By leveraging Triton Private Regions to provide object storage for Samsung Cloud, a new connected cloud architecture is now being deployed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/0*C6O_wyMCfxfeHmHN.jpg" /></figure><p>Migrating to a connected cloud architecture, where Samsung Cloud’s object storage needs are served by Triton Private Regions, while its computing and mobile backend needs are served by a public cloud vendor, significantly reduces overall costs and gives Samsung back control over its data. If it had continued to push data into a public cloud vendor’s object storage service, the size and gravity of this application’s data would have effectively locked Samsung Cloud into a single provider and an unsustainable cost structure.</p><h3>Creating cloud portability</h3><p>Once a long term solution to Samsung’s data storage requirements was defined, the team’s attention turned to finding a way to enable applications and application components, like the mobile back end services referenced in the Samsung Cloud example, above, to be easily moved between cloud providers. Creating this kind of portability is essential to support a connected cloud where independent development teams can operate in harmony with each other, and to enable each team to chose the cloud environment that best fits their application’s needs.</p><h3>An example: Containers and Kubernetes</h3><h4>What are containers?</h4><p>With VMs, one installs applications on a host using the operating system package manager. This entangles application executables, configuration, libraries, and lifecycle with each other and with the host OS. One could build immutable VM images for predictable rollouts, but they are heavyweight and non-portable between different cloud vendors.</p><p>Containers on the other hand, use OS-level virtualization rather than hardware virtualization. Containers are isolated from each other and from the host: they have their own filesystems, they can’t see each other’s processes, and their computational resource usage can be bounded. They are easier to build than VMs. The most popular and robust container platform is <a href="https://github.com/docker">Docker</a>.</p><h4>What is Kubernetes?</h4><p><a href="https://github.com/kubernetes">Kubernetes (K8s)</a> is an open-source system for automating deployment, scaling, and management of containerized applications. It groups containers that make up an application into logical units for easy management and discovery. K8s was designed with <a href="https://martinfowler.com/articles/microservices.html">microservices</a> in mind. Microservices architectures are common in mobile and IoT applications. In simple terms, a microservices architecture decouples a traditional multi-function/tier service into a single-function/tier service. These microservice units are best deployed on containers due to their lightweight runtime. The problem, however, is that you can end up with 1000s of microservices in place of the 10–100 legacy services you had earlier. This makes orchestration and scaling very complex. Enter Kubernetes, which provides a framework for running 1000s of microservices at scale. Kubernetes provides a full set of container specific services like networking, auto-scaling, self-healing, load balancing, authentication and application level grouping of resources among it’s many cloud like features.</p><h4>How do you get started with Kubernetes?</h4><p>At Joyent, we created a 100% open source quickstart experience for developers to rapidly deploy production ready Kubernetes clusters. Here is a <a href="https://vimeo.com/236179433">demo</a> of the solution and <a href="https://github.com/joyent/k8s-triton-supervisor">link to the github project.</a></p><p>The solution provides a highly resilient container management system with built in clustering and HA. Under the hood, the solution uses open source projects like Docker, Kubernetes, Rancher, Terraform, Ansible and Packer to deploy and manage a large scale kubernetes cluster. The following diagram explains the architecture of Kubernetes on Triton solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YmJu4oTgvPHWAGUo.jpg" /></figure><h4>How containers and Kubernetes solve the portability issue</h4><p>Because containers are small and fast, one application can be packed in each container image. This one-to-one application-to-image relationship unlocks the full benefits of containers. With containers, immutable container images can be created at build/release time rather than deployment time, since each application doesn’t need to be composed with the rest of the application stack, nor married to the production environment. This concept of build local, run anywhere enables a consistent environment to be carried from development into production.</p><p>Also Kubernetes is evolving to be the standard way everyone orchestrates containers and applications deployed on them. As containers are decoupled from the underlying infrastructure and from the host filesystem, they are portable across clouds and OS distributions. It works on premises on your own hardware and also on every major cloud provider. This makes porting your application workloads across clouds very easy, as long as you containerize and orchestrate them following standards.</p><h3>The power of a connected cloud</h3><p>Putting all of these pieces together allows us to do things we couldn’t before. As an example, we can create a blueprint for a common IoT application pattern that can connect multiple devices into a seamless experience for a user, which can easily be deployed on any cloud. If you want to give it a try yourself, dig into <a href="https://www.joyent.com/blog/microservices-containers-nodejs">this</a> open source project that will give you a working IoT dashboard connected to a SmartThings IoT hub and devices. You can use it to monitor IoT devices, but it’s really designed as an example of how to build containerized microservices applications in Node.js.</p><p>Joyent is the Official Cloud Provider of the Samsung Developer Conference. Come visit us at booth 201 in the Pavilion on the second floor to see how Triton Private Regions can benefit your organization.</p><p><em>Originally published at </em><a href="https://developer.samsung.com/sdp/blog/en-us/2017/10/13/the-connected-cloud-samsung-mobiles-multi-cloud-architecture"><em>https://developer.samsung.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10da590dda1c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Deploy a Node.js REST API Server on Red Hat’s OpenShift]]></title>
            <link>https://medium.com/@shubhra.kar/how-to-deploy-a-node-js-rest-api-server-on-red-hats-openshift-79452a0eb7c3?source=rss-17b180ad7b15------2</link>
            <guid isPermaLink="false">https://medium.com/p/79452a0eb7c3</guid>
            <dc:creator><![CDATA[Shubhra Kar]]></dc:creator>
            <pubDate>Tue, 07 Jul 2020 06:02:45 GMT</pubDate>
            <atom:updated>2020-07-07T06:02:45.258Z</atom:updated>
            <content:encoded><![CDATA[<p>The world is moving toward the cloud-both public and private clouds-and infrastructure demands are giving rise to a new generation of integration platform-as-a-service (iPaaS) API servers which specifically handle this use case with the added dimension of cloud versus your own datacenter. Node.js is powering these new iPaaS products because it’s dynamic, highly scriptable, and high-performance. Node hits the sweet spot because it enables developers to glue together disparate pieces of legacy infrastructure and quickly surface an API for next-generation web and mobile applications. Ultimately, it promises to address the emerging requirements for the internet of things (IoT).</p><h3>What is OpenShift?##</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/0*ZmtGeHDocp4XQoSe.png" /></figure><p>OpenShift is one of the most popular PaaS (Platform as a Service) provider used by developers worldwide. OpenShift supports Node.js and StrongLoop API server platforms with default built in cartridges.</p><h3>StrongLoop API Server highlights##</h3><p>For organizations looking to leverage OpenShift for their omni-channel API / ESB initiatives, StrongLoop’s API Server offers many advantages:</p><ul><li>On-premise — take control of your BaaS and run it in your datacenter or on your own cloud infrastructure.</li><li>Powered by <a href="http://loopback.io/">LoopBack</a> — the leading, open source API framework project built 100% in Node.js .</li><li>Built in mBaaS with <a href="http://docs.strongloop.com/display/LB/Push+notifications">Push</a> , <a href="http://docs.strongloop.com/display/LB/GeoPoint+class">Geopoint</a> , <a href="http://strongloop.com/node-js/mbaas/#social-login">Social Login</a>, <a href="http://strongloop.com/node-js/mbaas/#storage-service">Storage</a>, etc.</li><li><a href="http://docs.strongloop.com/display/LB/Synchronization">Offline sync</a> — isomorphic JavaScript front to back with conflict resolution and a variety of sync algorithms supported.</li><li><a href="http://docs.strongloop.com/display/LB/Synchronization">Replication</a> — client to server, server to client, app to app and database to database.</li><li><a href="http://strongloop.com/node-js/connectors/">Connectors</a> to interface and autodiscover new and existing datasources including RDBMS, NoSQL and proprietary backends.</li><li><a href="http://strongloop.com/node-js/controller/">Controller</a> to automate DevOps tasks like clustering, debugging, log management, build and deploy.</li><li><a href="http://strongloop.com/node-js/monitoring/">Monitoring</a> to provide deep application performance visibility and deep profiling in production.</li></ul><p>Here’s how to get started with Openshift and StrongLoop in four simple steps…</p><h3>Step 1: Create an OpenShift account##</h3><p>Login at at <a href="http://www.openshift.com/">http://www.openshift.co</a> m/. Create an account if you don’t already have one.</p><p>Ensure you have the latest version of the <a href="https://www.openshift.com/get-started#cli">client tools</a>. As part of this process, you’ll run the rhc setup command and choose a unique name (called a namespace) that becomes part of your public application URL.</p><p>For example On OS X, you’ll need to install either the <a href="http://developer.apple.com/xcode">Full Xcode Suite</a> — or — <a href="http://code.google.com/p/git-osx-installer/">git for OS X</a>. These packages ensure that Ruby and Git are installed and configured.</p><p>Install the gem using:</p><p>To update to the latest version of the client tools, use the gem update command:</p><p>Using your OpenShift login and password, run $ rhc setup to connect to OpenShift and create a unique namespace for your applications.</p><h3>Step 2: Create a Loopback API application##</h3><p>Create an application on OpenShift with the following command:</p><p>Replace “myAPI” with your application name. You’ll see the following message printed on your console:</p><p>Give it a few minutes to complete provisioning of the API server. Once complete you will see the following message printed on the console:</p><p>Select “yes”, which will deploy the app finally to OpenShift as well as clone a replica of the deployed app on to your local machine.</p><p>As printed on the console output, we can see that the provisioned api application is available on a Red Hat cloud url and also has SSH and Git urls for access. Additionally the project has been cloned to my home folder on my local machine i.e. under /users/username/</p><p>Logging into OpenShift we can see the application name and details published under the “applications” tab:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*oklB7OAjWlxR77o9.png" /></figure><p>Clicking on the app name lets us see the provisioned specifications of the host system, remote url information as well as gives us options to add multiple backends like MongoDB, MySQL or PostgreSQL to this API application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*q7k6P2ZvOhoxo2_a.png" /></figure><p>Let’s open a browser and type in the /explorer, which in our case would be &lt;http://myapi-strongdemo.rhcloud.com/explorer&gt;.</p><p>Below we can see StrongLoop’s API explorer which provides an interface to visualize and test the out of box default APIs. As Loopback advocates and follows <a href="http://strongloop.com/strongblog/node-js-api-tip-model-driven-development/">Model driven development</a>, the User Model is created by default along with all the CRUD endpoints…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*D56iCBmNx2uysnjf.png" /></figure><p>Now let’s try to update this API application by adding some custom models and API endpoints.</p><p>First of all, we will create a datasource for myAPI application.We will start with a MongoDB type datasource.</p><p>As Loopback supports MongoDB out of box from it’s large list of connectors, we will choose the default connector type for our datasource.</p><p>This will create the datasource definition and we can see the same in the /server/datasources.json file. The contents look like below:</p><p>Note that the actual mongodb host and port information still needs to be updated in the json. We can add a MongoDB instance on OpenShift and simply point at that within the connector. Please see <a href="http://docs.strongloop.com/display/LB/MongoDB+connector">working with MongoDB or MongoLab</a></p><p>Now let’s create a basic model which is attached to this MongoDB datasource:</p><p>As prompted, we can choose to expose the created API over REST and also provide a custom plural name for the account model.</p><p>We can now add model properties following the prompts and also if the model follows backend schema validation by setting the “required” property.</p><p>Similarly we will define additional properties of this model.</p><p>We will also install the MongoDB connector module of LoopBack as that is a required dependency for the model to work.</p><p>Now let us try to publish this updated myAPI application to OpenShift. We will be using git commands as described below for doing that. We will initialize the project in git, add our new files and commit to the git repository</p><p>To update the same project on OpenShift we need the Git URL. When we provisioned the app, we got the GitURL as :</p><p>In case we forget that we can extract the URL info from the OpenShift console or by using the git command:</p><p>To republish the app, we simply use the following commands:</p><p>We should get a successful status as below after a series of npm messages:</p><p>We can now validate the updated myapi application on OpenShift cloud by refreshing the same API explorer URL and checking for the accounts model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JzeQghbZszbBFReQ.png" /></figure><p>First off we can see the new Accounts model (pluralized) being added. Expanding that API, we can also see all the auto-provisioned API endpoints for CRUD operations on Accounts model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rjDZ1eYrTpy1f14Q.png" /></figure><p>The endpoints can actually be tested and executed through this interface. Here we see a “Get” operation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*L0ytWHZhvNwLL6DO.png" /></figure><h3>What’s next?##</h3><ul><li>In the first blog of this sequence, we got up and running with Loopback API framework and generated REST APIs within minutes on OpenShift PaaS. In the following blogs we will discuss more detailed use cases, frontend integration and DevOps features and capabilities of Node.js APIs on OpenShift.&lt;/span&gt;</li><li>Ready to develop APIs in Node.js and get them connected to your data? Check out the Node.js LoopBack framework. We’ve made it easy to</li></ul><p><em>Originally published at </em><a href="https://strongloop.com/strongblog/node-js-rest-api-openshift-redhat/"><em>https://strongloop.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79452a0eb7c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Node.js API Tip: Offline Sync and ReplicationMobile technologies have radically changed our…]]></title>
            <link>https://medium.com/@shubhra.kar/node-js-api-tip-offline-sync-and-replicationmobile-technologies-have-radically-changed-our-460680002c58?source=rss-17b180ad7b15------2</link>
            <guid isPermaLink="false">https://medium.com/p/460680002c58</guid>
            <dc:creator><![CDATA[Shubhra Kar]]></dc:creator>
            <pubDate>Tue, 07 Jul 2020 06:02:18 GMT</pubDate>
            <atom:updated>2020-07-07T06:02:18.113Z</atom:updated>
            <content:encoded><![CDATA[<h3>Node.js API Tip: Offline Sync and ReplicationMobile technologies have radically changed our personal lives and are now doing the same in the workplace-perhaps not as rapidly as many of us would like!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/0*ZYhDh9T5p1yPoebD.jpg" /></figure><p>Not every office looks like this, although at times we might feel this way. Many of us now have two or sometimes even three personal and company devices we wish were always in sync with realtime updates to email, schedules, storage, and even transactions. However, this is far from reality. Data replication and offline sync are not seamless across multi-vendor devices or disparate backends.</p><h3>How does this affect the enterprise ?</h3><p>The ability to work offline has emerged as a requirement for almost all data-driven enterprise mobile applications. This is especially true with relaxed BYOD policies plus enterprise field and sales enablement apps growing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/0*UZEx-KWtf9HfZTrs.png" /></figure><p>However, a wireless app is only as good as the network. When disconnected from the network, a client app should have the capability to save the state of the transaction locally and synchronize with the server when it reconnects.</p><p>Until now, developers first had to figure out how to store a subset of the application’s data locally. Second, they had to implement a mechanism to keep the data synchronized on both the client and server.</p><p>Existing sync and replication techniques are limited to proprietary data sources, and are heavy and inflexible. Most synching is native in the implementation stack and also platform/device specific. Fine-grained controls on the behavior for common use cases like change detection and conflict resolution are also lacking.</p><h3>Introducing Loopback</h3><p><a href="http://loopback.io/">LoopBack</a> is an open source Node.js API framework from StrongLoop that provides out of box offline synchronization using isomorphic JavaScript. For data replication it uses model-based data persistence.</p><p>This functionality is available for client side <a href="http://docs.strongloop.com/display/LB/AngularJS+JavaScript+SDK">Angularjs</a> and <a href="http://docs.strongloop.com/display/LB/AngularJS+JavaScript+SDK">JavaScript</a> web or mobile apps. It also supports backend data sources like <a href="http://docs.strongloop.com/display/LB/Oracle+connector">Oracle</a>, <a href="http://docs.strongloop.com/display/LB/SQL+Server+connector">SQL Server</a>, <a href="http://docs.strongloop.com/display/LB/MongoDB+connector">MongoDB</a>, <a href="http://docs.strongloop.com/display/LB/PostgreSQL+connector">PostgreSQL</a>, <a href="http://docs.strongloop.com/display/LB/MySQL+connector">MySQL</a> and any <a href="http://docs.strongloop.com/display/LB/Data+sources+and+connectors">LoopBack connector</a> that supports create, read, update and delete (CRUD) operations.</p><h3>Isomorphic JavaScript and model-based replication</h3><p>The Loopback API framework is designed around the idea of <a href="http://strongloop.com/strongblog/node-js-api-tip-model-driven-development/">model-driven API development</a>. In a the server-side Node application, logical objects like tables from relational databases or collections from NoSQL datasources like MongoDB or even existing SOAP or REST APIs are discovered and persisted as models. Each model can be aggregated, mashed up and customized with business logic during the modeling exercise. A model’s structure and schema validation are defined in JavaScript and are independent of the connected backend structure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/0*9w-FTZwYXJm4H40x.png" /></figure><p>When switching between datasources, these models and references remain unaffected. This permits the seamless replication of data between say a MongoDB instance, and an Oracle database or between two relational data stores like SQL Server and PostgreSQL. Because Loopback can run in your datacenter or on the cloud, it allows data replication to happen across production environments.</p><p>These server side models are exposed to the client as JavaScript or natively in iOS and Android using <a href="http://docs.strongloop.com/display/LB/Client+SDKs">SDKs</a>. The state of these models is synchronous, thereby allowing CRUD operations to occur with built-in conflict resolution capabilities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sUbsRCu_Lijd-eI7.png" /></figure><p>Because LoopBack is leveraging isomorphic JavaScript, it can take this remoting capability much further. You can even persist the backend data models into the HTML5 local storage of the browser.</p><p>When the client app goes offline, these stored models are still available in the browser. When the device reconnects, any changes to these models or data stored within it is synched to the model on the backend or vice versa. Multiple app instances on the client or multiple clients may be updating the same shared data model. Hence, to avoid data corruption, special asynchronous conflict resolution is built into the server side.</p><h3>Why replication?</h3><p>Replication allows you to easily sync data across various databases using Node or the browser. This functionality moves data between clients and servers, plus lets you focus on what makes your app useful. Below are some use cases that I find particularly interesting:</p><ul><li>In the browser, attach your model to a local storage database and sync with the server when you have connectivity.</li><li>In a turn based multiplayer game sync game objects (models) with an in memory database on the server and client.</li><li>In an enterprise application, sync your Oracle and Mongo databases, allowing you to use features from Mongo while using Oracle for persistence.</li><li>Replicate data from a slower database into Redis for better read performance.</li></ul><h3>A simple replication example</h3><p>Below is example that describes a simple todo list application.</p><p>As a busy person on the go, I should be able to read and write to my todo list. I need access to my todo list on my phone while I walk to the office. While at work, on my laptop, I should be able to view the tasks I’ve entered on my phone and vice-versa.</p><p>This app represents the typical “sync” problem. You have data on several client devices that must be kept in-sync. Below is a basic example of LoopBack in the browser that replicates a todo list to and from a LoopBack server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PlmcrPJu0vmzPL8l.png" /></figure><p>Below is the server side of the basic todo application. It attaches the server’s Todo model to both MongoDB and the LoopBack REST API. You could swap MongoDB out for MySQL, Postgres, Oracle, or any other database that LoopBack supports. To learn more about how to work with models in LoopBack, check out the <a href="http://docs.strongloop.com/display/LB/Working+with+models">documentation</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*U6Iiu77WY2KeXwvy.png" /></figure><h3>Add some todos and watch them autosync</h3><p>next we will add a couple of todos in our client app. Here we are connected on the network, hence the changes should be reflected in realtime on the server side models and persisted into MongoDB.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BIW0EQ7AOWVmusJ_.png" /></figure><p>Now, lets add two todos — “eat food” and “drink water” on the Angularjs client app running on my smartphone. When I query the REST API on the server side with Loopback explorer, I can see that the “Get” request for todos returns me the same two items we already entered. You can notice here that our debug statement provides the network status connected:true.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TSav2N2vArBud7oN.png" /></figure><p>What happened under the hood was that the data we applied to the models on the frontend app was synchronously remoted to the same model definition we had on the backend. The LoopBack Node application then persisted this data on the MongoDB backend that it is connected to. When we query MongoDB with an auto-generated REST API endpoint (“GET”) that Loopback provides, we are able to fetch the same dataset.</p><h3>Now for some fun!</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/0*rqKKTIn8c6jTiKxe.png" /></figure><p>Let’s saw while taking the walk to the office, we are day-dreaming and wander off into a forest. In a brilliant state of mind, we are not aware of that we have lost network connectivity and we keep punching in todos items.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/0*VN1MPKni9f9V2oJA.png" /></figure><p>You’ll notice that our debug statement provides the network status “connected:false” . Obviously, the server persistence does not happen at this time. Let’s check to make sure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nLW5vsiItM8tr6C3.png" /></figure><h3>Let’s get online</h3><p>Finally, we come to our senses and realize that we are miles away from our office. So, let’s head back and come to a street where network reception is strong. Let’s check the server one more time now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k1AQE9-1jBpYA53t.png" /></figure><p>We can see that the two new todos that we entered while offline have been synced to the server automatically. Other use cases like server-server replication, conflict management, etc, can all be executed using the same example app.</p><h3>Try it yourself</h3><p>This <a href="https://github.com/strongloop/loopback-example-full-stack">full-stack example</a> illustrates the basic approach for offline sync using LoopBack on both the server and in the browser. Stay tuned for more detailed examples of some of the use cases above. Get started today by checking out the <a href="http://docs.strongloop.com/display/LB/Synchronization">replication docs</a>.</p><p><em>Originally published at </em><a href="https://strongloop.com/strongblog/node-js-api-offline-sync-replication/"><em>https://strongloop.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=460680002c58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Node.js API Tip: Model Driven Development]]></title>
            <link>https://medium.com/@shubhra.kar/node-js-api-tip-model-driven-development-9aec23c8da72?source=rss-17b180ad7b15------2</link>
            <guid isPermaLink="false">https://medium.com/p/9aec23c8da72</guid>
            <dc:creator><![CDATA[Shubhra Kar]]></dc:creator>
            <pubDate>Tue, 07 Jul 2020 06:01:30 GMT</pubDate>
            <atom:updated>2020-07-07T06:01:30.338Z</atom:updated>
            <content:encoded><![CDATA[<p>Today’s tip focuses on APIs — which just so happen to be the primary use case for Node.js! APIs are driving the new frontedge — inclusive of mobile, tablets, wearables, web browsers, sensors, et al by providing rich backend data access in a flexible interface. These APIs are being increasingly generated using API <em>frameworks,</em> which act as “super glue” tying together the endpoints of disparate enterprise systems and data sources, and then exposing them in a uniform API to all clients.</p><p>API development usually starts on the backend with constructing a data access layer, modeling data objects and defining relationship mapping. Today, we will focus on Models and Model driven development of APIs in Node. The origins of modeling lies in a software design paradigm called “ <a href="http://en.wikipedia.org/wiki/Convention_over_configuration">Convention over Configuration</a>.”</p><h3>Convention over Configuration</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/0*7T97DSXEKqxzJmdO.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t368G26qZW0lGE_O.jpg" /></figure><p>Convention over configuration (also known as coding by convention) seeks to decrease the number of decisions that <a href="http://en.wikipedia.org/wiki/Software_developer">developers</a> need to make, gaining simplicity, but not necessarily losing flexibility. This means a developer only needs to specify unconventional aspects of the application. For example, if there’s a class Sale in the model, the corresponding table in the database is called sales by default. It is only if one deviates from this convention, such as calling the table sale, or product_sold that one needs to write code regarding these names.</p><p>When the convention implemented by the tool matches the desired behavior, it behaves as expected without having to write configuration files. Only when the desired behavior deviates from the implemented convention is explicit configuration required.</p><p>ASP .Net MVC does this by default. When you create a controller named Home the class is HomeController and the views of the HomeController are found in /Views/Home for your project. When dealing with <a href="http://en.wikipedia.org/wiki/Inversion_of_control">IoC</a> containers there&#39;s the task of registering your types to resolve correct.</p><p><strong>Node Specific</strong></p><p>Some popular frameworks who use convention over configuration are :</p><h3>Newer modeling approaches</h3><p>We have seen a couple new modeling approaches pop up in API development space, particularly for Node:</p><ol><li>Object Relationship Mapping (ORM)</li><li>Object Datasource Mapping (ODM)</li></ol><h3>Object Relational Mapping</h3><p><a href="http://en.wikipedia.org/wiki/Object-relational_mapping">ORM</a> was made popular in the J2EE world by engines like Hibernate, but is a widely accepted model across many frameworks and languages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/0*Dh6aOOsm6jqwIFif.png" /></figure><p>Relational databases are at the core of most enterprise applications. However, when you map a relational database to objects, it becomes a challenge. Object relational mapping (ORM) is a programming framework that allows you to define a mapping between application object model and the relational database.</p><p>Traditionally, an Object Model (OM) deals with object oriented “blue-print” of your system. This includes, class diagrams (classes you will be creating), relationship between these classes, methods in the classes, properties etc. Typically, it is not aware of the database structure. Objects have properties and references to other objects.</p><p>The Data Model (DM) deals with entities at the database level. Like how the classes in the OM will get stored and in which tables. So, DM deals with table schema and the relationships between different tables (PKs, FKs) etc.</p><p>Databases consist of tables with columns that maybe related to other tables. ORM provides a bridge between the relational database and the object model. Object-relational mapping (ORM, O/RM, and O/R mapping) creates, in effect, a “virtual <a href="http://en.wikipedia.org/wiki/Object_database">object database</a> “ that can be used from within the programming language and is database vendor independent. Additionally, ORM can significantly reduce the lines of code needed to be written by providing a higher level of abstraction.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*b0Kj2hhtKzUGX7hG.png" /></figure><h3>Object Datasource Mapping (ODM)</h3><p>Traditionally, Data Models deal with entities at the persistence level. Like how the classes in the Object Model will get stored in the database, in which tables etc. So, Data Model deals with Table schema, relationship between different tables (PKs, FKs) etc.</p><p>However, NoSQL and unstructured databases like MongoDB enabled the creation of Node packages like <a href="http://mongoosejs.com/">Mongoose</a> that provide a straight-forward, schema-based solution for modeling your application data and includes built-in type casting, validation, query building, business logic hooks and more. We call this as ODM (Object Datasource Mapping). Interestingly, the MongoDB model tooling is also called “ <strong>Object Document Mapping</strong> “ as MongoDB stores data in JSON document format.</p><p>Due to the absence of SQL queries and planners, NoSQL databases get better performance with ODM. Additionally, there is no SQL to write, which reduces the possibility of SQL injections.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/0*Eg1MUkmrEAwVVuqD.png" /></figure><h3>Modeling gurus warn of pitfalls</h3><p>ORM can have a few rough edges in the case of “Logic Intensive Systems” i.e. systems that perform complex calculations, make optimizations, determinations, decisions, etc. This makes persistence easier by locking the object model to the database model that can make writing and consuming the business logic harder. For example, in a system that uses business objects that are basically codegen’d one to one from a legacy codebase with 400+ tables, the temptation and driver for codegen’ing the business objects is obvious (400+ tables).</p><p>The problem is that consuming these business objects in the service layer is that the business objects do not really reflect the behavior of the business logic. Not having the encapsulation of the raw database structure from the service layer makes it even worse.</p><p>Just some examples:</p><ul><li><strong>Big tables don’t map to a single object. </strong>It’s not possible that a class with a 100 different properties can possibly be cohesive. We’d have better business logic if that 100 column table is modeled in the middle tier by a half dozen classes, each with a cohesive responsibility. Only one table for the entire object hierarchy may look ok, but big classes are almost always a bad thing.</li><li><a href="http://www.codinghorror.com/blog/archives/000589.html"><strong>Data Clump and Primitive Obsession code smells </strong></a><strong>. </strong>A database row is naturally flat. But think about a database table(s) with lot’s of something_currency/something_amount combinations. There’s a separate object for <a href="http://www.martinfowler.com/eaaCatalog/money.html">Money</a> wanting to come out. To make your business objects pure representations of the database you can end up with lots of duplicate logic for currency &amp; quantity conversions.</li><li><strong>Natural cases for polymorphism in your object model. </strong>I think the roughest part of O/R mapping is handling polymorphism inside the database. Check out Fowler’s patterns on <a href="http://www.martinfowler.com/eaaCatalog/">database mappings for inheritance</a>.</li></ul><p>ODM on the other hand is proprietary to each type of NoSQL backend like MongoDB and cannot deal with RDBMs based table-model structures. With no schema enforcement at the DB level and objects stored as flexible JSON documents, model validations will need to be handled at an application level. It too does not have complex OO features like polymorphism, inheritance, overloading etc which are usually listed in an OM, making it impractical to use with enterprise systems in addition too the below issues:</p><ul><li><strong>Automatic persistence of updated documents. </strong>If you change an instance of an application JSON document, it’s up to you to make sure that change gets persisted back to MongoDB. This leads to more verbose code and generally more errors, as it’s easy to forget to .save() a document when you’re done.</li><li><strong>An Identity Map. </strong>If you’re working with several documents at once, you can get into a situation where you have two documents in memory that both represent the same document in MongoDB. This can cause consistency problems, particularly if the documents are both modified, but in different ways.</li><li><strong>A Unit of Work. </strong>When you’re doing several updates, it’s nice to be able to “batch up” the updates and flush them to MongoDB all at once, particularly in a NoSQL database like MongoDB which has no multi-document transactions. You don’t get true transactional behavior with a unit of work, but can at least skip the flush step and the database doesn’t change.</li><li><strong>Support for relationships between documents. </strong>I like to be able to construct object graphs in RAM that aren’t necessarily represented by embedded documents in MongoDB.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/194/0*fdGXaGZtxqWmuLV6.png" /></figure><h3>Introducing Loopback</h3><p><a href="http://strongloop.com/">StrongLoop</a> created <a href="http://loopback.io/">LoopBack</a>, a fully open-source, Node API framework on top of <a href="http://expressjs.com/">Express</a> which assimilates the best practices of both types of modeling. Because it extends from express.js, it follows convention over configuration.</p><p>LoopBack simplifies and speeds up REST API development. It consists of:</p><ul><li>A library of Node.js modules for connecting web and mobile apps to data sources such as databases and REST APIs.</li><li>A <a href="http://docs.strongloop.com/pages/viewpage.action?pageId=3180173">command-line tool (slc)</a>, for creating and working with LoopBack applications.</li><li><a href="http://docs.strongloop.com/display/LB/Client+SDKs">Client SDKs</a> for native and web-based mobile clients.</li></ul><p>A LoopBack application has three components:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/0*co4tLajCzn_o7_PD.png" /></figure><ul><li>Models that represent business data and behavior.</li><li>Data sources and connectors.</li><li>Data sources are databases or other backend services such as REST APIs, SOAP web services, or storage services.</li><li>Connectors provide apps access to enterprise data sources such as Oracle, MySQL, and MongoDB.</li><li>Mobile clients using the LoopBack client SDKs.</li></ul><p>An application interacts with data sources through the LoopBack model API, available locally within Node, <a href="http://docs.strongloop.com/display/LB/REST+API">remotely over REST</a>, and via native client APIs for <a href="http://docs.strongloop.com/display/LB/Client+SDKs">iOS, Android, and HTML5</a>. Using the API, apps can query databases, store data, upload files, send emails, create push notifications, register users, and perform other actions provided by data sources.</p><p>Mobile clients can call LoopBack server APIs directly using <a href="http://docs.strongloop.com/display/NODE/Strong+Remoting">Strong Remoting</a>, a pluggable transport layer that enables you to provide backend APIs over REST, WebSockets, and other transports.</p><p>LoopBack supports both “dynamic” schema-less models and “static”, schema-driven models. A LoopBack model represents data in backend systems such as databases and REST APIs, and provides APIs for working with it. If your app connects to a relational database, then a model can be a table. Additionally, a model is updated with validation rules and business logic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/181/0*uEUBVaUi3mA2iQTH.gif" /></figure><h3>Creating Models</h3><p>You can create LoopBack models in various ways, depending on what kind of data source the model is based on. You can create:</p><p>The REST API enables HTTP clients like web browsers, JS programs, mobile SDKs, curl scripts or any other compatible client to interact with LoopBack models. LoopBack automatically binds a model to a list of HTTP endpoints that provide REST APIs for model instance data manipulations (CRUD) and other remote operations.</p><p>By default, the REST APIs are mounted to /&lt;Model.settings.plural | pluralized(Model.modelName)&gt;, for example, /locations, to the base URL such as <a href="http://localhost:3000/">http://localhost:3000/</a>. LoopBack provides a number of <a href="http://docs.strongloop.com/display/LB/Using+built-in+models">built-in models</a> that have REST APIs. See the <a href="http://docs.strongloop.com/display/LB/REST+API">REST API</a> docs for more information.</p><h3>Predefined remote methods</h3><p>By default, for a model backed by a datasource, LoopBack exposes a REST API that provides all the standard create, read, update, and delete (CRUD) operations. For example, for a model called Location (that provides business locations), LoopBack automatically creates the following REST API endpoints:</p><h3>Relationship Mapping</h3><p>Individual models are easy to understand and work with. But in reality, models are often connected or related. When you build a real-world application with multiple models, you’ll typically need to define relations between models. For example:</p><ul><li>A customer has many orders and each order is owned by a customer.</li><li>A user can be assigned to one or more roles and a role can have zero or more users.</li><li>A physician takes care of many patients through appointments. A patient can see many physicians too.</li></ul><p>With connected models, LoopBack exposes as a set of APIs to interact with each of the model instances and query and filter the information based on the client’s needs. You can define the following relations between models:</p><p>You can define models relations in JSON or in JavaScript code. When you define a relation for a model, LoopBack adds a set of methods to the model:</p><h3>belongsTo</h3><p>A belongsTo relation sets up a one-to-one connection with another model, such that each instance of the declaring model &quot;belongs to&quot; one instance of the other model. For example, if your app includes customers and orders, and each order can be placed by exactly one customer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/0*8ZgHV2nykaoEgrbv.png" /></figure><p>The declaring model (Order) has a foreign key property that references the primary key property of the target model (Customer). If a primary key is not present, LoopBack will auto add one.</p><h3>hasMany</h3><p>A hasMany relation builds a one-to-many connection with another model. You&#39;ll often find this relation on the &quot;other side&quot; of a belongsTo relation. Here each instance of the model has zero or more instances of another model. For example, in an app with customers and orders, a customer can have many orders.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/0*U9hrG9OvBe_05flR.png" /></figure><p>The target model, Order, has a property, customerId, as the foreign key to reference the declaring model (Customer) primary key id.</p><h3>hasManyThrough</h3><p>A hasMany through relation is often used to set up a many-to-many connection with another model. Here the declaring model can be matched with zero or more instances of another model by proceeding through a third model. For example, in an app for a medical practice where patients make appointments to see physicians, the relevant relation declarations might be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/589/0*SDafpOlMV30XSKLY.png" /></figure><p>The “through” model, Appointment, has two foreign key properties, physicianId and patientId, that reference the primary keys in the declaring model, Physician, and the target model, Patient.</p><h3>hasAndBelongsToMany</h3><p>A hasAndBelongsToMany relation creates a direct many-to-many connection with another model, with no intervening model. For example, in an app with assemblies and parts, where each assembly has many parts and each part appears in many assemblies, you could declare the models as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/0*SidWEfu6vuWjt6mw.png" /></figure><p>You can define a model declaratively in models.json and you can programmatically define and extend models using the Model class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*MqV2FIXu0_iFPVDa.png" /></figure><h3>Data sources and connectors</h3><p>LoopBack is centered around models that represent data and behaviors. Data sources enable exchange of data between models and backend systems such as databases. Data sources typically provide create, retrieve, update, and delete (CRUD) functions. LoopBack also generalizes other backend services, such as REST APIs, SOAP web services, and storage services, as data sources.</p><p>Data sources are backed by connectors which implement the data exchange logic using database drivers or other client APIs. Connectors are not used directly by application code. The DataSource class provides APIs to configure the underlying connector and exposes functions via DataSource or model classes.</p><p>The diagram illustrates the relationship between LoopBack Model, DataSource, and Connector.</p><ul><li>Define the model using <a href="http://docs.strongloop.com/display/LB/LoopBack+Definition+Language">LoopBack Definition Language (LDL)</a>. This provides a model definition in JSON or as a JavaScript object.</li><li>Create an instance of ModelBuilder or DataSource which extends from ModelBuilder. ModelBuilder compiles model definitions to JavaScript constructors of model classes.DataSource inherits that function from ModelBuilder. In addition, DataSource adds behaviors to model classes by mixing in methods from the DataAccessObject (DAO) into the model class.</li><li>Use ModelBuilder or DataSource to build a JavaScript constructor (i.e, the model class) from the model definition. Model classes built from ModelBuilder can be later attached to a DataSource to receive the mixin of data access functions.</li><li>As part of step 2, DataSource initializes the underlying Connector to provides configurations to the connector instance.Connector works with DataSource to define the functions as DataAccessObject to be mixed into the model class. The DataAccessObject consists of a list of static &amp; prototype methods.</li></ul><h3>LoopBack DataSource object</h3><p>DataSource object is the unified interface for LoopBack applications to integrate with backend systems. It&#39;s a factory for data access logic around model classes. With the ability to plug in various connectors, DataSource provides the necessary abstraction to interact with databases or services to decouple the business logic from plumbing technologies.</p><p>Depicted below is the end to end Loopback API framework architecture for model driven development.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mucsWcLp_uu5aAmP.png" /></figure><p>To checkout more details please visit <a href="http://loopback.io/">Loopback.io</a> or <a href="http://strongloop.com/mobile-application-development/loopback/">Strongloop</a> website. In our next weekly blog we will deep-dive into the API services architecture of Loopback.</p><p><em>Originally published at </em><a href="https://strongloop.com/strongblog/node-js-api-tip-model-driven-development/"><em>https://strongloop.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9aec23c8da72" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Node.js Performance Tip of the Week: Managing Garbage Collection]]></title>
            <link>https://medium.com/@shubhra.kar/node-js-performance-tip-of-the-week-managing-garbage-collection-19ac124744d4?source=rss-17b180ad7b15------2</link>
            <guid isPermaLink="false">https://medium.com/p/19ac124744d4</guid>
            <dc:creator><![CDATA[Shubhra Kar]]></dc:creator>
            <pubDate>Mon, 06 Jul 2020 01:47:02 GMT</pubDate>
            <atom:updated>2020-07-06T01:47:02.333Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Please note that as of Aug 3, 2015, StrongOps has been EOL’d.</em></p><p>In our <a href="http://strongloop.com/strongblog/node-js-performance-event-loop-monitoring/">last weekly performance tip</a>, we discussed in detail how the Node.js event-loop works as the orchestrator of requests, events and callbacks. We also troubleshot a blocked event-loop which could wreck havoc on application performance. In this week’s post we’ll dive into the fundamentals of garbage collection (GC) in <a href="https://code.google.com/p/v8/">V8</a> and how it holds the “keys to the kingdom” in the optimization of Node applications. We will also look at some tools to triage GC and memory management issues in V8.</p><h3>Where did it all start</h3><p>Contrary to folklore, V8 was not designed explicitly for Node; rather was built to power a fast browser (Chrome/Chromium) or client side JavaScript (V8.NET). Eventually it got ported to the server as a high performance engine for running server side JavaScript and became the basis of Node. But, just like any server side runtime like the JVM or CLR, V8 runs on memory and needs memory management.</p><p>In some systems or languages, it is up to the application program to manage all the bookkeeping details of <a href="http://www.memorymanagement.org/glossary/a.html#term-allocate">allocating</a> <a href="http://www.memorymanagement.org/glossary/m.html#term-memory-2">memory</a> from the <a href="http://www.memorymanagement.org/glossary/h.html#term-heap">heap</a> and <a href="http://www.memorymanagement.org/glossary/f.html#term-free-1">freeing</a> it when it is no longer required. This is known as manual <a href="http://www.memorymanagement.org/glossary/m.html#term-memory-management">memory management</a>. Manual memory management may be appropriate for small programs, but it does not scale well in general, nor does it encourage modular or object-oriented programming.</p><h3>Who/What is the Garbage Collector?</h3><p>V8 embraces <a href="http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)">garbage collection </a>(GC) also known as managed memory. Built in GC provides huge simplification for developers by not having to explicitly handle memory bookkeeping in code as was done in the “C” era. It reduces a large class of errors and memory leaks, which are typical in large long-running applications and in some cases, it can even improve performance.</p><p>However, you also give up control on memory management, which could be a problem particularly for mobile applications aiming for the optimization of device resources. In particular for JavaScript, the <a href="http://en.wikipedia.org/wiki/ECMAScript">ECMAScript</a> specification doesn’t expose any interface to the garbage collector blocking visibility and forced GC.</p><p>Performance wise, it is a wash. In C, allocating (malloc) and freeing objects can be costly, since heap bookkeeping tends to be more complicated. With managed memory, allocation usually means just incrementing a pointer, but you pay for it eventually when you run out of memory and the garbage collector kicks in. The fact is that V8 uses garbage collection for better or worse.</p><h3>How does V8 Organize the heap?</h3><p>V8 divides the heap into several different spaces for effective memory management:</p><ul><li><strong>New-space:</strong> Most objects are allocated here. New-space is small and is designed to be garbage collected very quickly</li><li><strong>Old-pointer-space:</strong> Contains most objects which may have pointers to other objects. Most objects are moved here after surviving in new-space for a while.</li><li><strong>Old-data-space:</strong> Contains objects which just contain raw data (no pointers to other objects). Strings, boxed numbers, and arrays of unboxed doubles are moved here after surviving in new-space for a while.</li><li><strong>Large-object-space:</strong> Contains objects which are larger than the size limits of other spaces. Each object gets its own mmap’d region of memory. Large objects are never moved by the garbage collector.</li><li><strong>Code-space:</strong> Code objects, which contain JITed instructions, are allocated here. This is the only space with executable memory.</li><li><strong>Cell-space, property-cell-space and map-space:</strong> Contain Cells, PropertyCells, and Maps, respectively. Each space contains objects which are all the same size and is restricted in pointers, which simplifies collection.</li></ul><p>Each space is composed of a set of “pages”. A Page is a contiguous chunk of memory, allocated from the operating system with mmap. Pages are always 1 MB in size and 1 MB aligned, except in large-object-space, where they may be larger.</p><h3>How does the Garbage Collector work?</h3><p>The central concept of Node.js/JavaScript application memory management is a concept of reachability.</p><ul><li>A distinguished set of objects are assumed to be reachable or in live scope: these are known as the “roots.” Typically, these include all the objects referenced from anywhere in the call stack (that is, all local variables and parameters in the functions currently being invoked), and any global variables.</li><li>Objects are kept in memory while they are accessible from roots through a reference or a chain of references.</li><li>Root objects are pointed directly from V8 or the Web browser like DOM elements</li></ul><p>The fundamental problem garbage collection solves is to identify dead memory regions (unreachable objects/garbage) which are not reachable through some chain of pointers from an object which is live. Once identified, these regions can be re-used for new allocations or released back to the operating system</p><p>To ensure fast object allocation, short garbage collection pauses, and the “no memory fragmentation V8” employs a stop-the-world, generational, accurate, garbage collector. V8 essentially:</p><ul><li>stops program execution when performing a garbage collection cycle.</li><li>processes only part of the object heap in most garbage collection cycles. This minimizes the impact of stopping the application.</li><li>always knows exactly where all objects and pointers are in memory. This avoids falsely identifying objects as pointers which can result in memory leaks.</li></ul><p>In V8, the object heap is segmented into many parts; hence If an object is moved in a garbage collection cycle, V8 updates all pointers to the object.</p><h3>No, no…how does it really work ?</h3><p>The GC needs to follow pointers in order to discover live objects. Most garbage collection algorithms can migrate objects from one part of memory to another (to reduce fragmentation and increase locality), so we also need to be able to rewrite pointers without disturbing plain old data.</p><p>V8 uses “tagged” pointers. Most objects on the heap just contain a list of tagged words, so the garbage collector can quickly scan them, following the pointers and ignoring the integers. Some objects, such as strings, are known to contain only data (no pointers), so their contents do not have to be tagged.</p><p>Next, let’s check which algorithms V8 uses to execute garbage collection.</p><h3>Short GC/scavenging</h3><p>V8 divides the heap into two generations. Objects are allocated in new-space, which is fairly small (between 1 and 8 MB, depending on behavior heuristics). Allocation in new space is very cheap: we just have an allocation pointer which we increment whenever we want to reserve space for a new object. When the allocation pointer reaches the end of new space, a scavenge (minor garbage collection cycle) is triggered, which quickly removes the dead objects from new space.</p><p>Scavenging/copying GC is a kind of <a href="http://www.memorymanagement.org/glossary/t.html#term-tracing-garbage-collection">tracing garbage collection</a> that operates by <a href="http://www.memorymanagement.org/glossary/r.html#term-relocation">relocating</a> reachable <a href="http://www.memorymanagement.org/glossary/o.html#term-object">objects</a> and then <a href="http://www.memorymanagement.org/glossary/r.html#term-reclaim">reclaiming</a> objects that are left behind, which must be <a href="http://www.memorymanagement.org/glossary/u.html#term-unreachable">unreachable</a> and therefore <a href="http://www.memorymanagement.org/glossary/d.html#term-dead">dead</a>.</p><p>A copying garbage collection relies on being able to find and correct all references to copied objects.</p><p>The Scavenge algorithm is great for quickly collecting and compacting a small amount of memory, but it has large space overhead, since we need physical memory backing both to-space and from-space. This is acceptable as long as we keep new-space small, but it’s impractical to use this approach for more than a few megabytes.</p><p>Scavenging is supposed to be fast by design. Hence, it is suitable for frequently occurring short GC cycles.</p><h3>Full GC/mark-sweep &amp; mark-compact</h3><p>Objects which have survived two minor garbage collections are promoted to “old-space.” Old-space is garbage collected in full GC (major garbage collection cycle), which is much less frequent. A full GC cycle is triggered when we get over a certain amount of memory in old space.</p><p>To collect old space, which may contain several hundred megabytes of data, we use two closely related algorithms, Mark-sweep and Mark-compact.</p><p>Mark-sweep collection is a kind of <a href="http://www.memorymanagement.org/glossary/t.html#term-tracing-garbage-collection">tracing garbage collection</a> that operates by marking reachable <a href="http://www.memorymanagement.org/glossary/o.html#term-object">objects</a>, then <a href="http://www.memorymanagement.org/glossary/s.html#term-sweeping">sweeping</a> over <a href="http://www.memorymanagement.org/glossary/m.html#term-memory-2">memory</a> and <a href="http://www.memorymanagement.org/glossary/r.html#term-recycle">recycling</a> objects that are unmarked (which must be <a href="http://www.memorymanagement.org/glossary/u.html#term-unreachable">unreachable</a>), putting them on a <a href="http://www.memorymanagement.org/glossary/f.html#term-free-list">free list</a>.</p><p>The mark phase follows <a href="http://www.memorymanagement.org/glossary/r.html#term-reference">reference</a> chains to mark all reachable objects. Once marking is complete, we can reclaim memory by either sweeping or compacting. Both algorithms work at a page level. The sweep phase performs a sequential ( <a href="http://www.memorymanagement.org/glossary/a.html#term-address">address</a>-order) pass over memory to recycle all unmarked objects. A mark-sweep <a href="http://www.memorymanagement.org/glossary/c.html#term-collector-1">collector</a> doesn’t move objects.</p><p>Mark-compact collection is a kind of <a href="http://www.memorymanagement.org/glossary/t.html#term-tracing-garbage-collection">tracing garbage collection</a> that operates by <a href="http://www.memorymanagement.org/glossary/m.html#term-marking">marking</a> <a href="http://www.memorymanagement.org/glossary/r.html#term-reachable">reachable</a> <a href="http://www.memorymanagement.org/glossary/o.html#term-object">objects</a>, then <a href="http://www.memorymanagement.org/glossary/c.html#term-compaction">compacting</a> the marked objects (which must include all the <a href="http://www.memorymanagement.org/glossary/l.html#term-live">live</a> objects).</p><p>The mark phase follows <a href="http://www.memorymanagement.org/glossary/r.html#term-reference">reference</a> chains to mark all reachable objects; the compaction phase typically performs a number of sequential passes over <a href="http://www.memorymanagement.org/glossary/m.html#term-memory-2">memory</a> to move objects and update references. Due to compaction, all the marked objects are moved into a single contiguous block of memory (or a small number of such blocks); the memory left unused after compaction is <a href="http://www.memorymanagement.org/glossary/r.html#term-recycle">recycled</a>. The compacting algorithm also tries to reduce actual memory usage by migrating objects from fragmented pages (containing a lot of small free spaces) to free spaces on other pages</p><p>However, the pause time in mark-sweep and mark-compact were found to be high, slowing down overall performance.</p><h3>Incremental marking &amp; lazy sweeping</h3><p>In mid-2012, Google introduced two improvements that reduced garbage collection pauses significantly: incremental marking and lazy sweeping.</p><p>Incremental marking means being able to do a bit of marking work, then let the mutator (JavaScript program) run a bit, then do another bit of marking work. Thus, instead of one long pause for marking, the GC marks the heap in a series of short pauses in the order of 5–10 ms each as an example. Incremental marking begins when the heap reaches a certain threshold size. Post threshold, every time a certain amount of memory is allocated, execution is paused to perform an incremental marking step.</p><p>If the allocation rate is high during incremental GC, the engine may run out of memory before finishing the incremental cycle. If so, the engine must immediately restart a full, non-incremental GC in order to reclaim some memory and continue execution.</p><p>After marking, lazy sweeping begins. All objects have been marked live or dead, and the heap knows exactly how much memory could be freed by sweeping. All this memory doesn’t necessarily have to be freed up right away though, and delaying the sweeping doesn’t hurt. Hence instead of one-go, the garbage collector sweeps pages on an as-needed basis until all pages have been swept. At that point, the garbage collection cycle is complete, and incremental marking is free to start again.</p><h3>What’s next?</h3><p><a href="http://strongloop.com/node-js/whats-new-in-node-js-v0-12/">Read about eight exciting new Node v0.12 features</a> and how to make the most of them, from the authors themselves.</p><p><em>Originally published at </em><a href="https://strongloop.com/strongblog/node-js-performance-garbage-collection/"><em>https://strongloop.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19ac124744d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Node.js Performance Tip of the Week: Scaling with Proxies and Clusters]]></title>
            <link>https://medium.com/@shubhra.kar/node-js-performance-tip-of-the-week-scaling-with-proxies-and-clusters-194105093381?source=rss-17b180ad7b15------2</link>
            <guid isPermaLink="false">https://medium.com/p/194105093381</guid>
            <dc:creator><![CDATA[Shubhra Kar]]></dc:creator>
            <pubDate>Mon, 06 Jul 2020 01:46:14 GMT</pubDate>
            <atom:updated>2020-07-06T01:46:14.986Z</atom:updated>
            <content:encoded><![CDATA[<p>In <a href="http://strongloop.com/strongblog/node-js-performance-tip-cpu-profiler/">last week’s performance tip</a>, we discussed in detail how to diagnose application performance bottlenecks using CPU profiling on Node.js applications. In this go around we look at scaling Node.js applications in production.</p><h3>With great power comes tiny difficulties</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/871/0*UkP43gztH8FStgc8.jpg" /></figure><p>Node apps essentially run <a href="http://en.wikipedia.org/wiki/Single_threading">single-threaded</a>, even though file and network events could leverage multiple threads. This architecture thereby binds the performance of each application instance/process to one logical CPU core that the thread it’s attached to. To a J2EE architect like me, this highlights immaturity in Node as an enterprise ready technology. Application servers like JBoss or Weblogic already solved this 10 years back using server core <a href="http://en.wikipedia.org/wiki/Multithreading_(computer_architecture)">multi-threading</a> and parallelism. Little did I realize that context switching between threads ate up my memory and I still had a blocking IO problem.</p><p>In a way, discovering the lack of threading prepares the Node developer to write scalable asynchronous code and use libraries like web-sockets from the get-go rather than worry about scalability later in the application life cycle. But this code optimization is still capped to the scaling limits of a single CPU core. So, how is production scaling achieved in the Node world today?</p><h3>Proxy-based Scaling</h3><p>HTTP proxies are commonly used with web applications for gzip encoding, static file serving, HTTP caching, SSL handling, load balancing and spoon feeding clients. Hence, DevOps teams try to gain the benefits of such web-servers even with Node. However, as Node applications generally have http server capabilities built in — the use cases are slightly different.</p><h3>Nginx</h3><p><a href="http://wiki.nginx.org/Main">Nginx</a> is a lightweight and easy to configure web server, which can be used to proxy/reverse-proxy through to Node.js processes. Additionally nginx also supports web-sockets with minimal configuration. Distributing load to specific application processes based on type of work — example dynamic content rendering vs. static content is a common use case. The Node application hosts can be added to the http handler on nginx and then you could simple match for regular extensions like ~* ^.+\.(jpg|jpeg|css|js) for static and send it to a subset of hosts in the handler. Similarly you can match for any content without a .(dot) and route to separate set of hosts listed in the http handlers.</p><h3>Apache</h3><p>Although Node typically does not need a web server, Node apps are sometimes part of a bigger composite application with components written in PHP or Java servlets. Apache may already be used as http reverse proxy and node has serve up content through the same channel. Running both Apache and Node on port 80 would be conflicting. Hence, there is a module called Proxy Pass which can be enabled in the httpd.conf file: ProxyPass /node http://host.xyz.com:3000. This will let Apache send requests to Node apps running on desired host on port 3000.</p><p>Also, we will need to make sure that right proxy modules and submodules are loaded for the correct routing to happen. These are generally the mod_proxy.so and mod_http_proxy.so.</p><h3>Application Level Scaling</h3><p>To take advantage of multi-core systems, Node applications can be run as cluster of Node processes to handle the load. However there are programmatic and runtime ways of managing these clusters.</p><h3>node-cluster</h3><p>The <a href="http://nodejs.org/api/cluster.html">node-cluster</a> module which was introduced as of v0.8 is the basic mechanism allowing a master process to spawn worker processes and allowing you to share a socket across multiple networked Node applications. This is achieved using file descriptors and serialization. When you call server.listen(…) in a worker, it serializes the arguments and passes the request to the master process. If the master process already has a listening server matching the worker’s requirements, then it passes the handle to the worker. If it does not already have a listening server matching that requirement, then it will create one, and pass the handle to the worker.</p><p>Multiple events are messages including term signal are supported out of box. The master — worker logic is simple, but needs to be implemented within all managed Node applications individually.</p><p>Load balancing is taken care of by the underlying OS. However, it is not very efficient and we can have uneven distribution of workload across processes. This problem is being solved using <a href="http://strongloop.com/strongblog/whats-new-in-node-js-v0-12-cluster-round-robin-load-balancing/">Cluster-Round-Robin-Load-Balancing</a>, which is upcoming feature in Node v0.12</p><p>The cluster module makes it straightforward for applications that have little or no shared state, or store their shared state that in an external resource like a database or a web service. For managing shared state or session between processes, StrongLoop provides modules like <a href="http://docs.strongloop.com/display/SLC/Strong+Cluster+Connect+Store">Strong-Cluster-Connect-Store</a></p><p>Node does not automatically manage the number of workers for you, however. It is your responsibility to manage the worker pool for your application’s needs. Hence improvements have been made to create runtime tooling built on top of node-cluster</p><h3>PM2</h3><p>Native clustering was introduced way back in Node v0.6, <a href="https://github.com/Unitech/pm2">PM2</a> is implemented on top of the same. PM2 itself acts as the master process and wrap your code to add some global or environmental variables into the application files.</p><p>PM2 provides many runtime features like keepalive, clustering, controller api, some basic system monitoring and some log aggregation. Also syntactically, it is easy with commands like “pm2 app.js” start for application kick-off or “pm2 monit” for monitoring or “pm2 dump, pm2 kill, pm2 resurrect” for resurrecting applications from hard restart.</p><p>However, pm2 will need to be run from each host individually and does not have remote control capabilities, which are essential in larger multi-server installations. It tries to do too many things like application restart on file change, which is not a mature feature like in <a href="https://github.com/remy/nodemon">nodemon</a>.</p><p>It also tries to do application monitoring, which under par with Node APM capabilities from NewRelic, AppDynamics or StrongLoop.</p><h3>StrongLoop Cluster Management</h3><p><a href="http://docs.strongloop.com/display/NODE/Controlling+an+application+cluster">StrongLoop Cluster Management</a> is a production tested clustering and management runtime. Main highlights are a command line runtime tool called “slc” with options like <a href="http://docs.strongloop.com/display/SLC/Running+apps+with+slc">run</a> (runtime management), <a href="http://docs.strongloop.com/display/NODE/slc+runctl">runctl</a> (cluster control), <a href="http://docs.strongloop.com/display/SLC/Debugging+applications">debug</a> (debugging), <a href="http://docs.strongloop.com/display/SLC/Viewing+metrics+with+Arc">arc</a> (monitoring), <a href="http://docs.strongloop.com/display/NODE/slc+registry">registry</a> (private registry)</p><p><a href="http://docs.strongloop.com/display/SLC/Running+apps+with+slc">slc run</a> has options to run as background process (detached), clustered (with options of specifying number of CPU cores), non-profiled, profiled, with Log aggregation and routing options, with ability to send PIDs to file for history tracking and also option of application files to manage (file, directory or package.json)</p><p>It does not require any changes to the application files and rather does app-wrapping and uses global environment variables defined in JSON config.</p><p><a href="http://docs.strongloop.com/display/NODE/slc+runctl">slc runctl</a> provides similar runtime options as node-cluster but in a more graceful and wrapped way without having to change code or manage master-worker synchronization.</p><p>You can start, stop, restart, list any processes within a cluster. If any one process in a cluster is terminated or dies due to application error, clusterctl automatically starts up another process and attaches it to the liver cluster master without having to restart the application instances. This is also called as “Zero Downtime” in Node.</p><p>Runctl lets you size the number of processes in the cluster at startup; but also lets you <a href="http://docs.strongloop.com/display/SLC/Control+an+application+cluster">resize</a> the cluster on the fly with options like set-size. Additional capabilities include disconnect — disconnecting a process from a cluster or fork — forking or replacing an active process in a cluster with another process for inspecting the original process.</p><p>In case, a faulty deployment is pushed out to a cluster, StrongLoop clusterctl ensures rolling restarts, so that if the first process being restarted crashes, then the deployment is not pushed out to the remaining processes in the cluster. If the issues on the faulty code is fixed on the fly, clusterctl also has hot deploy capability to auto-correct the faulty process and restore it.</p><p>StrongLoop cluster control has both a CLI as well as a Web interface. The Web interface allows to remotely manage multiple clusters running on multiple hosts from a single console, which provides ease of runtime management.</p><p><em>Originally published at </em><a href="https://strongloop.com/strongblog/node-js-performance-scaling-proxies-clusters/"><em>https://strongloop.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=194105093381" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mobile App Development with Full-Stack Javascript (part 1 of 4)]]></title>
            <link>https://medium.com/@shubhra.kar/mobile-app-development-with-full-stack-javascript-part-1-of-4-b426ac5d304a?source=rss-17b180ad7b15------2</link>
            <guid isPermaLink="false">https://medium.com/p/b426ac5d304a</guid>
            <dc:creator><![CDATA[Shubhra Kar]]></dc:creator>
            <pubDate>Mon, 06 Jul 2020 01:43:57 GMT</pubDate>
            <atom:updated>2020-07-06T01:43:57.541Z</atom:updated>
            <content:encoded><![CDATA[<p>In this four part blog series, we talk about mobile application development using JavaScript on both front end and backend as a true platform. Although this concept of full-stack JavaScript is not new, there are limited reference implementations or products that actually exist to develop mobile apps using full-stack JavaScript. In part one of this series, we start with mobile back end developed in Node.js which is a platform for running Javascript on the server. In the next parts, we will talk about the front end, tools for building, deployment, automation, monitoring and optimization.</p><p>Recently there has been a lot of adoption for Node.js as a mobile backend acting as glue between front end applications (being built in native, hybrid or mobile web technologies) and the back end data sources. Here we discuss the characteristics of mobile back ends and the benefits of using JavaScript for building them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YO99qM9TNFvO--_a.png" /></figure><h3>Mobile apps aren’t useful without existing data</h3><p>In order for mobile applications to be useful as sales channels for the enterprise, access to existing corporate data is key. Without access to this back end data, mobile applications cannot cross the threshold of being relevant for an enterprise’s line of business. Today mobile backends are being either provided as a hosted service also called mBaaS (mobile Backend-as-a-Service) or being built in-house by developers.</p><p>The majority of mBaaS providers assume that you’re building your mobile app from scratch and that no legacy data exists. This means that private application’s data ends up getting locked up in the provider’s cloud. The truth is that enterprise mobile applications are being developed mostly as an extension to an existing platform rather than a brand new one. These applications might be used by employees, sales personnel, field operations (B2E) or as a new consumer sales channel (B2C). By their function, these mobile apps need access to the same enterprise data sets that traditional web apps have been using for years.</p><p>Existing data sources typically reside inside the datacenter and increasingly in a private cloud. Existing distributed systems like ERP, enterprise databases like Oracle, et cetera on contain business critical data that traditionally has only been available to legacy or web apps. To help simplify data access from mobile devices to these distributed platforms, StrongLoop <a href="http://strongloop.com/strongblog/announcing-loopback-an-open-source-mobile-backend-as-a-service-based-on-node-js/">announced LoopBack</a> earlier this year. <a href="http://strongloop.com/strongloop-suite/loopback/">LoopBack</a> is an open-source mobile API tier, built on top of Node.js. The diagram below shows LoopBack and how it interacts with various services and data sources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_mTrrcZ0I6z5sIIe.jpg" /></figure><h3>LoopBack addresses the shortcomings of existing mobile backend services:</h3><ul><li>Most are available only on public clouds with limited enterprise access.</li><li>A higher cost due to “hosted service”. Usually priced by number of APIs or users, which is expensive to scale.</li><li>Mobile apps need access to new data and existing data behind the firewall.</li><li>Most mobile back ends are built using proprietary stacks with built-in lock-in.</li><li>Some mobile back ends are built with Java or Ruby, where Node is the <a href="https://speakerdeck.com/tau_zero/building-a-mobile-backend-api-with-node-dot-js-better-than-expected">superior choice for mobile backends</a>.</li></ul><p>In contrast, Loopback can be run on-premises or in the cloud with enterprise connectors for Oracle, MySQL, MongoDB, In-memory datastore and REST services. LoopBack’s roadmap includes connectors for Postgres, SQLServer, SOAP, ATG Dynamo, SAP, Salesforce.com and Oracle Apps among others. LoopBack allows remote-able functions, that support dynamically saving data and invoking server-side functionality from mobile clients. Hence users can perform CRUD functions on the database directly from their devices. LoopBack provides data discovery and modelling to aggregate or mashup data objects from multiple data stores. Then it’s API engine generates JSON REST API for the modelled objects. Finally LoopBack provides SDKs for <a href="http://strongloop.com/strongblog/announcing-loopback-android-sdk/">Android</a> and <a href="http://docs.strongloop.com/display/DOC/iOS+SDK">iOS</a> to make it easy to consume these REST API from the client application.</p><h3>A mobile backend should do more than just surface APIs</h3><p>Just like Loopback, any mobile backend needs to satisfy following the criteria of enterprise use cases to be successful:</p><ul><li>Access to legacy, current generation and evolving data sources.</li><li>Advanced modelling to slice &amp; dice or aggregate data objects to fetch complex queries from backends with No SQL.</li><li>Easy generation of REST API services for direct/remote data access from mobile apps.</li><li>Easy generation of REST API services for consumption by application logic.</li><li>Mobile application management services like push notification, geolocation, file, etc.</li><li>API Security management.</li><li>API infrastructure management.</li><li>Tooling and Automation.</li></ul><p>The above listed functions and automation hugely reduce complexity, increase speed of development and reduce Go To Market time for a mobile app. In the diagram below we expand on the essential functions that Loopback delivers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GsUp2NxAV2LF_D0B.png" /></figure><p>When StrongLoop started to design an open-source mobile backend for the enterprise, time to accrue ROI from the product was primary success criteria. Loopback was designed specifically to address the use cases listed above. We ensured that the automation was present to help standup rich backend services in a matter of minutes vs days and months traditionally associated with these projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LB8Lbe93wChDdsGu.jpg" /></figure><p>The below example code snippets show, how easy it is to connect to an existing data store and dynamically create models and RESTful API endpoints for accessing the data objects.</p><h3>Create a project and a product</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/0*SBAmKJPFNzFGrMe1.png" /></figure><h3>Model the product</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/0*oi8MxXwXx2l1BvPg.png" /></figure><h3>Create a data source</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/0*T73nFxtkHvepMG7O.png" /></figure><h3>Generate REST APIs automatically</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DplqLwhSqLp9Llir.png" /></figure><h3>Push notification to iOS device</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/0*G6zgF5xltvZ6bL90.png" /></figure><h3>Node.js is the platform of choice for mobile backend</h3><p>User experience on mobile devices is key to customer stickiness. In the early days of the web, response times of 2–3 seconds were acceptable when users submitted a form and patiently waited for the response page to load. Smart web designers often cached content on CDNs and client-side to render static elements faster and render visualization preemptively to logic. On mobile, CDN technology and caching is not mature. Users access app components and expect instantaneous data. To achieve this, small snippets of data are fetched based on user events usually using API calls. These snippets must have a very light payload and must render content in milliseconds. Following are key design criteria for mobile backends.</p><ul><li>Low latency.</li><li>High concurrency.</li><li>Streaming data.</li><li>Evented models rather than request/response model.</li><li>Caching and sync.</li><li>Seamless technology integration.</li></ul><p>Top use cases where Node.js has been very popular are JSON API and single page apps. Both of these enable mobile/mobile-web applications to gain parity and sometimes a competitive advantage over legacy web applications. Node supports the workloads of a mobile backend: small and frequent structured data exchanges. Hence, it is ideal candidate for I/O bound applications that involve exchanges of information rather than computational processes, which are CPU bound.</p><h3>Node advantages</h3><p>Node.js is a scalable, event-driven I/O environment built on top of Google Chrome’s JavaScript runtime, a server-side implementation of JavaScript. Google V8 compiles JavaScript into native machine code prior to execution, resulting in extremely fast runtime performance-something not typically associated with JavaScript. As such, Node enables you to rapidly build network apps that are lightning fast and highly concurrent. Because it uses JavaScript, frontend developers can work in the same language as backend developers. This concept is referred to as JavaScript Everywhere and reduces time spent in mastering varied development concepts. Furthermore, the most used data exchange format, JSON, can be natively parsed by both ends. Processing overhead can be reduced through simplification of serialization. Additionally Node’s lightweight runtime enables rapid development and deployment. As a result, Node is a powerful solution for agile development. Node differs from most web-app runtimes in the manner that it handles concurrency. Instead of using threading to accomplish concurrency, Node relies on an event-driven loop running in a single process. Node promotes an asynchronous (non-blocking) model, while technologies such as Java support a synchronous (blocking) model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_QNgIVg6TY7MKf7i.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ijoHmnkZrCWTuk7I.png" /></figure><p>Java suffers additional overhead in context switching between threads. More threads means more time spent switching contexts and less time doing work on incoming requests making scalability of Java applications more expensive. Node supports asynchronous I/O, based on events such as the completion of a file read operation or a database query. These events are handled with callback functions, which enable the application to proceed while I/O is being performed. The event loop handles these events. Below is an infographic from an IBM benchmarking exercise for API endpoints for Node.js vs traditional java in terms of scalability as user concurrency grows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/0*zZ-BMa4NvA7NvJ13.png" /></figure><h3>Wrapping up</h3><p>We hope this blog provided insights into mobile back ends and general back end development using Node.js. We also covered why Node has become the platform of choice and hugely popular as a glue for mobile to the backend. In the part 2, we will talk about the front end development using technologies like Angular.js, Bootstrap.js, Cordova/PhoneGap, Backbone.js, etc and how they can be integrated seamlessly with a node back end.</p><h3>What’s next?</h3><p><em>Originally published at </em><a href="https://strongloop.com/strongblog/mobile-app-development-with-full-stack-javascript-part-1-of-4-loopback/"><em>https://strongloop.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b426ac5d304a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Update from the CommunityBridge Development Team]]></title>
            <link>https://medium.com/@shubhra.kar/update-from-the-communitybridge-development-team-6a10e62439f7?source=rss-17b180ad7b15------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a10e62439f7</guid>
            <dc:creator><![CDATA[Shubhra Kar]]></dc:creator>
            <pubDate>Wed, 15 Apr 2020 04:00:48 GMT</pubDate>
            <atom:updated>2020-07-18T19:40:43.133Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*geamSXjT6BM8S3iD.jpg" /></figure><h4>Open source powers more than 80% of the technology we all use every day, yet many open source developers and projects face barriers, from generating funding to attracting contributors, to finding and fixing vulnerabilities in the code base to drive mainstream adoption.</h4><p>Touted as an industry first, CommunityBridge is a platform created by Linux Foundation engineers to empower open source projects — and the individuals and organizations who support them — to advance sustainability, security, transparency and diversity in open source technology. Since the launch of the platform in the middle of 2019, we have come a long way, and have started making an impact.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*6_IniTnrgtHfCXDJ.png" /></figure><p><a href="https://funding.communitybridge.org/"><strong>CommunityBridge Funding</strong></a> is a trusted crowdfunding service that lets maintainers raise funds to support project activities like development, documentation, mentorships, marketing, travel, etc.</p><p>This service is governed and supported by the Linux Foundation with 100% of the funds going right into the hands of the developers. The Linux foundation is currently matching donations for diversity candidates and also underwriting any platform and payment processor fees. Book-keeping, processing of expense reports, reimbursements and nonprofit reporting is also provided for free as part of the program.</p><p>Since inception, the funding platform has <strong>helped projects raise a total of $475K+ from 23 corporate and 355 individual sponsors and disbursed a total of ~$74K to contributors</strong> in various categories like projects and mentorships.</p><p>Acceptance of projects on this platform is selective and prioritized for high impact (based on downstream dependencies, GitHub stars, forks, contributors) but underfunded projects.</p><h4>Some of the Projects Setup for Funding</h4><p>To apply your project for consideration or to support projects you use actively as an individual or corporate sponsor, please visit <a href="https://funding.communitybridge.org/">CommunityBridge Funding</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*fV5skLKxDyZ_NdA1.png" /></figure><p><a href="https://lfcla.com/"><strong>CommunityBridge EasyCLA</strong></a> streamlines the process of getting developers authorized under a project’s CLA for everyone:</p><ul><li>Coders can code more quickly by reducing manual steps to get themselves authorized.</li><li>Corporations and projects can save time by reducing manual steps managing CLAs and their signatures</li><li>Both Individual and Corporate CLA signing can be enforced for developers contributing to a project using GitHub or Gerrit</li></ul><p>EasyCLA is the only solution in the community which effectively manages both individual and corporate CLA agreements. Since inception, EasyCLA has made CLA management a breeze for 19 open source projects.</p><p><strong>Projects<br> Using EasyCLA</strong></p><p><strong>Repositories</strong><br><strong>Authorized</strong></p><p><strong>Total signed<br> CLAsCLA ManagersCompanies<br> Signing CLAs</strong></p><p>19</p><p>872</p><p>13,947</p><p>1009</p><p>746</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*I-DkMOSs6Xyki_Ki.png" /></figure><p>CommunityBridge Mentorship helps you increase the number and diversity of developers contributing to your project by providing mentorships and internships.</p><p>It is in essence a matchmaking service which lets you:</p><ul><li>Attract mentees by providing referrals to top companies committed to interviewing your candidates</li><li>Incentivize participation by offering free training, industry event passes and certifications</li><li>Expand your community of talented, diverse, and committed developers by offering paid internships with matching diversity grants</li><li>Attract funding, mentors, and mentees when you are listed on the mentorship leaderboard</li></ul><p>Since our launch last summer, the mentorship platform supported <strong>12 projects</strong> with mentorships. <strong>27 Mentees</strong> were selected from <strong>750 Applicants</strong> and used the platform to get stipends.</p><p>Projects Supported By Mentorship Program Since Summer 2019 Launch</p><p><strong>128 potential Mentors</strong> applied and <strong>52 Mentors</strong> were selected and onboarded onto the platform.</p><h4>Some of the Active Mentors on the Platform</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*B3kTtWHAONRi9j8L.jpg" /></figure><p>Latest posts by Shubhra Kar ( <a href="https://www.linuxfoundation.org/author/skar/">see all</a>)</p><p><em>Originally published at </em><a href="https://www.linuxfoundation.org/blog/2020/04/update-from-the-communitybridge-development-team/"><em>https://www.linuxfoundation.org</em></a><em> on April 15, 2020.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a10e62439f7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Multi-cloud Kubernetes with Triton]]></title>
            <link>https://medium.com/@shubhra.kar/multi-cloud-kubernetes-with-triton-1b6e1576009d?source=rss-17b180ad7b15------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b6e1576009d</guid>
            <dc:creator><![CDATA[Shubhra Kar]]></dc:creator>
            <pubDate>Tue, 02 Jan 2018 00:00:00 GMT</pubDate>
            <atom:updated>2020-07-18T19:40:18.114Z</atom:updated>
            <content:encoded><![CDATA[<p>While running an experimental <a href="https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/">Kubernetes</a> cluster is fairly simple, operationalizing K8s environments for production is not for the faint of heart. Some of us are also looking to expand their K8s environments across multiple clouds, private or public, for purposes of scalability, workload distribution, disaster recovery, etc. However managing cross-cloud K8s environments from a single control plane is quite challenging and lacks mature out of box solutions.</p><p>In this blog post we introduce <a href="https://github.com/joyent/triton-kubernetes/tree/v0.8">Triton Kubernetes</a>, the first truly <strong>multi-cloud Kubernetes</strong> solution that we are working on here at Joyent, and walk through steps to get up and running with a unified set of kubernetes clusters across 4 different public clouds. We will also show how simple it is to deploy an app to environments managed by this multi-cloud K8s solution.</p><p>Please actively follow the <a href="https://github.com/joyent/triton-kubernetes">project</a> for updates on roadmap items like backup and DR, workload migration, federation, full stack monitoring, auto-scaling hosts, alerting and notifications, et all.</p><p>The current solution version supports the following public cloud: Triton, AWS, Azure, and GCP. Triton running on-premises as a private or hybrid clouds is also supported. Bare Metal support is limited at this time, but available through professional services engagements. In near future, we plan to add automation to run the solution seamlessly on bare metal servers.</p><h3>Getting started in three simple steps:</h3><p>You can get up and running with production grade kubernetes across multiple-clouds by following the steps listed below. Please see details in the <strong>Quickstart</strong> section below.</p><h3>Step one: set up the pre-requisites</h3><p>To start, you must create a <strong>Triton</strong> account and install the <strong>Triton CLI</strong>, <strong>Terraform</strong>, and the <strong>Kubernetes CLI</strong>. To install the solution across multiple clouds like AWS, Azure or GCP, you must already have or create accounts for these cloud providers respectively.</p><p><a href="https://www.joyent.com/triton/compute">Triton</a> is Joyent’s hybrid and open source cloud and <a href="https://www.terraform.io/">Terraform</a> is an open source tool that enables you to safely and predictably create, change, and improve production infrastructure. We use Terraform to provision virtual machines, set up root access, and install python.</p><h3>Step two: create a Global K8s Cluster Manager.</h3><p>The next step will be to create a highly available Global Cluster Manager, which provides the cross-cloud control plane. This Manager provides scaling, push button upgrades, role based access control, ci/cd integration and monitoring of cluster health. <a href="https://github.com/joyent/triton-kubernetes/tree/v0.8">Triton Kubernetes</a> automates the provisioning of virtual machine hosts, Docker Engines, database server, networks and sets up the global cluster manager for you. By default, the installer deploys the control plane on Triton, however you can modify the underlying <a href="https://www.terraform.io/">Terraform</a> templates to install on any cloud.</p><h3>Step three: create K8s Environmental Clusters.</h3><p>The final step will be to provision Kubernetes environments on any region/datacenter on any cloud (having a set of published API endpoints) and have them managed by the global cluster manager. <a href="https://github.com/joyent/triton-kubernetes/tree/v0.8">Triton Kubernetes</a> does this for you as well. Each environmental cluster is self-sustaining with built-in features like high availability, auto-healing, clustering of etcd and orchestration services and the ability to run specific services on dedicated hosts. The installer automates the provisioning vms, docker, and networking based on the chosen cloud provider and leverages <a href="http://rancher.com/kubernetes">Rancher</a> as the underlying middleware to provision production grade, supportable (and easily upgradable) Kubernetes Environments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*k_fZCKVNCOS-07Mm.jpg" /></figure><h3>Quickstart</h3><p>Follow along as we walk through these three easy steps in detail below. Complete them on your own, Leveraging our <a href="https://www.joyent.com/downloads">free open source software</a>. You will have your very own, 100% open source, production-grade, multi-cloud Kubernetes stack.</p><p>Before you get going, you can also watch a brief demo:</p><h3>Pre-requisites</h3><h3>Install Triton</h3><p>In order to install Triton, you must have a Triton User Account. It’s important that you <a href="https://my.joyent.com/main/#!/account">add an ssh key</a> to your account. If you need instructions for how to generate and SSH key, <a href="https://docs.joyent.com/public-cloud/getting-started">read our documentation</a>.</p><ol><li>Install <a href="https://nodejs.org/en/download/">Node.js</a> and run npm install -g triton to install Triton CLI.</li><li>triton uses profiles to store access information. You&#39;ll need to set up profiles for relevant data centers.</li></ol><ul><li>triton profile create will give a <a href="https://docs.joyent.com/public-cloud/api/triton-cli#configuring-triton-profiles">step-by-step walkthrough</a> of how to create a profile.</li><li>Choose a profile to use for your Triton Kubernetes setup.</li></ul><ol><li>Get into the Triton environment with eval $(triton env &lt;profile name&gt;).</li><li>Run triton info to test your configuration.</li></ol><h3>Install Terraform</h3><p>Triton supports all recent versions of Terraform. <a href="https://www.terraform.io/downloads.html">Download Terraform</a> and unzip the package.</p><p>Terraform runs as a single binary named terraform. The final step is to make sure that the terraform binary is available on the PATH. See <a href="https://stackoverflow.com/questions/14637979/how-to-permanently-set-path-on-linux">this</a> page for instructions on setting the PATH on Linux and Mac.</p><p>Test your installation by running terraform. You should see an output similar to:</p><pre>&lt;code&gt;$ terraform Usage: terraform [--version] [--help] &lt;command&gt; [args] The available commands for execution are listed below. The most common, useful commands are shown first, followed by less common or more advanced commands. If you&#39;re just getting started with Terraform, stick with the common commands. For the other commands, please read the help and docs before usage. Common commands: apply Builds or changes infrastructure console Interactive console for Terraform interpolations # ...&lt;/code&gt;</pre><blockquote><em>terraform gets downloaded automatically if it isn&#39;t found in </em><em>$PATH.</em></blockquote><h3>Install the Kubernetes CLI</h3><p>This tool is not required to provision, but rather needed to connect to a provisioned kubernetes env. There are different ways to <a href="https://kubernetes.io/docs/tasks/kubectl/install/">install </a><a href="https://kubernetes.io/docs/tasks/kubectl/install/">kubectl</a>, but the simplest way is via curl:</p><pre>&lt;code class=&quot;language-bash&quot;&gt;# OS X curl -LO <a href="https://storage.googleapis.com/kubernetes-release/release/$(curl">https://storage.googleapis.com/kubernetes-release/release/$(curl</a> -s <a href="https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl">https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl</a> # Linux curl -LO <a href="https://storage.googleapis.com/kubernetes-release/release/$(curl">https://storage.googleapis.com/kubernetes-release/release/$(curl</a> -s <a href="https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl">https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl</a> # Windows curl -LO <a href="https://storage.googleapis.com/kubernetes-release/release/$(curl">https://storage.googleapis.com/kubernetes-release/release/$(curl</a> -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/windows/amd64/kubectl.exe&lt;/code&gt;</pre><h3>Create a Global K8s Cluster Manager</h3><p>Triton Kubernetes uses triton, and terraform to set up a global cluster manager and kubernetes environmental clusters. Once those have been installed, you can download the <a href="https://github.com/joyent/triton-kubernetes/tree/v0.8">Triton Kubernetes</a> package, run the script triton-kubernetes.sh -c and answer the prompted questions to start a cluster manager.</p><blockquote><em>triton-kubernetes -c can be passed an optional </em><a href="https://github.com/joyent/triton-kubernetes/blob/v0.8/template_clustermanager.conf"><strong><em>conf</em></strong></a><em> file for a silent install.</em></blockquote><p>Default values will be shown in parentheses and if no input is provided, defaults will be used.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;$ git clone <a href="https://github.com/joyent/triton-kubernetes.git">https://github.com/joyent/triton-kubernetes.git</a> -b v0.8 Cloning into &#39;triton-kubernetes&#39;... remote: Counting objects: 574, done. remote: Compressing objects: 100% (67/67), done. remote: Total 574 (delta 43), reused 50 (delta 18), pack-reused 487 Receiving objects: 100% (574/574), 6.57 MiB | 2.46 MiB/s, done. Resolving deltas: 100% (260/260), done. Note: checking out &#39;c77a983d85bfa10033a18e1ad2b77fa76692caab&#39;. You are in &#39;detached HEAD&#39; state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example: git checkout -b &lt;new-branch-name&gt; $ cd triton-kubernetes $ ./triton-kubernetes.sh -c Downloading Terraform v0.10.8 ... Extracting Terraform executable Using /Users/&lt;username&gt;/work/triton-kubernetes/bin/terraform ...&lt;/code&gt;</pre><p>If terraform is not found in $PATH, it will be downloaded.</p><blockquote><em>If a triton profile has been set (</em><em>eval &quot;$(triton env)&quot;), you will not be prompted for triton account details.</em></blockquote><pre>&lt;code class=&quot;language-bash&quot;&gt;Your Triton account login name: &lt;username&gt; (example fayazg) The Triton CloudAPI endpoint URL:&lt;region name&gt; (example <a href="https://us-east-1.api.joyent.com)/">https://us-east-1.api.joyent.com)</a> Your Triton account key id: &lt;keyid&gt; (example 2c:53:bc:63:97:9e:79:3f:91:35:5e:f4:c8:23:89:37)&lt;/code&gt;</pre><p>Global cluster managers run on Triton so the first few questions prompted will be account related. This is the same information provided by running triton profile get.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;Name your Global Cluster Manager: (global-cluster) gclustermanager&lt;/code&gt;</pre><p>Provide a name for the Global Cluster Manager and press Enter.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;Do you want to set up the Global Cluster Manager in HA mode? (yes | no) yes&lt;/code&gt;</pre><p>Global cluster manager can run in HA mode or non-HA configuration. In HA mode, there will be a two node cluster manager with a database as can be seen in the architectural diagram above.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;Which Triton networks should be used for this environment: (Joyent-SDC-Public)&lt;/code&gt;</pre><p>Triton CLI is used here to pull all the active networks (public, private, fabric — sdn) for the current data center defined in the Triton profile. Provide an option for which networks should the global cluster manager use. We are going to use the default so press Enter.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;Which Triton package should be used for Global Cluster Manager server(s): (k4-highcpu-kvm-1.75G) k4-highcpu-kvm-3.75G Which Triton package should be used for Global Cluster Manager database server: (k4-highcpu-kvm-1.75G) k4-highcpu-kvm-3.75G&lt;/code&gt;</pre><p>Since the global cluster manager is set up in HA mode, Triton Kubernetes will prompt for package names to use for the two HA nodes and the database server. Here we are going to use the <em>k4-highcpu-kvm-3.75G</em> package for both. For a production install, you should pick instance sizes appropriate to the expected workload and may need bigger resource packages.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;docker-engine install script: (https://releases.rancher.com/install-docker/1.12.sh) ############################################################ Cluster Manager gclustermanager will be created on Triton. gclustermanager will be running in HA configuration and provision three Triton machines ... gclustermanager-master-1 k4-highcpu-kvm-3.75G gclustermanager-master-2 k4-highcpu-kvm-3.75G gclustermanager-mysqldb k4-highcpu-kvm-3.75G Do you want to start the setup? (yes | no) yes&lt;/code&gt;</pre><p>The last prompt before verification of inputs is the docker-engine installation script that should be used. Leave the default here and press Enter.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;Apply complete! Resources: 4 added, 0 changed, 0 destroyed. The state of your infrastructure has been saved to the path below. This state is required to modify and destroy your infrastructure, so keep it safe. To inspect the complete state use the `terraform show` command. State path: terraform.tfstate Outputs: masters = [ &lt;cluster manager node1 ip&gt;, &lt;cluster manager node2 ip&gt; ] Cluster Manager gclustermanager has been started. This is an HA Active/Active setup so you can use either of the IP addresses. http://&lt;cluster manager node1 ip&gt;:8080/settings/env Next step is adding Kubernetes environments to be managed here. To start your first environment, run: ./triton-kubernetes.sh -e&lt;/code&gt;</pre><p>Once verification is finished, terraform will download the modules, initialize provider plugins, start provisioning three machines and configure a two node HA cluster manager. Next we will create two Kubernetes clusters (one on Triton and another on GCP), which will be managed by this global cluster manager.</p><h3>Create a HA, 5 Node, K8s environmental cluster on Triton</h3><p>Kubernetes environmental clusters in HA mode run their <strong>etcd</strong> and Kubernetes <strong>orchestration services</strong> (apiserver, scheduler, controller-manager…) in dedicated three node clusters. Once the global cluster manager is up and running, from the same directory, start triton-kubernetes.sh -e and answer the prompted questions to start provisioning the first environment.</p><p>Default values will be shown in parentheses and if no input is provided, defaults will be used.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;$ ./triton-kubernetes.sh -e Using triton-kubernetes/bin/terraform ... From clouds below: 1. Triton 2. AWS 3. Azure 4. GCP Which cloud do you want to run your environment on: (1)&lt;/code&gt;</pre><p>We want the first environmental cluster on Triton; so keep the default and press Enter.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;Your Triton account login name: &lt;username&gt; (example fayazg) The Triton CloudAPI endpoint URL: &lt;region name&gt; (example <a href="https://us-east-1.api.joyent.com)/">https://us-east-1.api.joyent.com)</a> Your Triton account key id: &lt;key id&gt; (example 2c:53:bc:63:97:9e:79:3f:91:35:5e:f4:c8:23:88:37)&lt;/code&gt;</pre><p>This environment will be running on Triton Cloud so the first few questions prompted will be account related. This is the same information provided by running triton profile get.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;Name your environment: (triton-test) devcluster Do you want this environment to run in HA mode? (yes | no) yes&lt;/code&gt;</pre><p>Provide a alphanumeric name for this environment and start it in HA mode.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;Number of compute nodes for devcluster environment: (3) 5&lt;/code&gt;</pre><p>Provide the number of worker nodes to create for this environment and press Enter.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;Which Triton networks should be used for this environment: (Joyent-SDC-Public)&lt;/code&gt;</pre><p>Leave the default value and press Enter.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;Which Triton package should be used for devcluster environment etcd nodes: (k4-highcpu-kvm-1.75G) k4-highcpu-kvm-3.75G Which Triton package should be used for devcluster environment orchestration nodes running apiserver/scheduler/controllermanager/...: (k4-highcpu-kvm-1.75G) k4-highcpu-kvm-3.75G Which Triton package should be used for devcluster environment compute nodes: (k4-highcpu-kvm-1.75G) k4-highcpu-kvm-3.75G&lt;/code&gt;</pre><p>Since this environment is going to run in HA mode, there will be three different type of VMs.</p><ul><li>etcd nodes: dedicated nodes that will will run an etcd cluster</li><li>orchestration nodes: dedicated nodes that will be running Kubernetes services like the apiserver, scheduler, controllermanager …</li><li>compute nodes: these are the Kubernetes worker nodes where the compute (deployments) will run</li></ul><p>Triton Kubernetes will prompt for package names to use for these nodes. Here we are going to use the <em>k4-highcpu-kvm-3.75G</em> package for all nodes.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;docker-engine install script: (https://releases.rancher.com/install-docker/1.12.sh) ############################################################ Environment devcluster will be created on Triton. devcluster will be running in HA configuration ... 6 dedicated hosts will be created ... devcluster-etcd-[123] k4-highcpu-kvm-3.75G devcluster-orchestration-[123] k4-highcpu-kvm-3.75G 5 compute nodes will be created for this environment ... devcluster-compute-# k4-highcpu-kvm-3.75G Do you want to start the setup? (yes | no) yes&lt;/code&gt;</pre><p>The last prompt before verification of inputs is the docker-engine installation script that should be used. Leave the default here and press Enter.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;Apply complete! Resources: 15 added, 0 changed, 0 destroyed. The state of your infrastructure has been saved to the path below. This state is required to modify and destroy your infrastructure, so keep it safe. To inspect the complete state use the `terraform show` command. State path: terraform.tfstate Outputs: masters = [ &lt;cluster manager node1 ip&gt;, &lt;cluster manager node2 ip&gt; ] Environment devcluster has been started. This is an HA setup of Kubernetes cluster so there are 3 dedicated etcd and 3 orchestration nodes. Cluster Manager URL: http://&lt;cluster manager node1 ip&gt;:8080/settings/env Kubernetes Hosts URL: http://&lt;cluster manager node1 ip&gt;:8080/env/1a7/infra/hosts?mode=dot Kubernetes Health: http://&lt;cluster manager node1 ip&gt;:8080/env/1a7/apps/stacks?which=cattle NOTE: Nodes might take a few minutes to connect and come up. To start another environment, run: ./triton-kubernetes.sh -e&lt;/code&gt;</pre><p>Once verification is finished, terraform will start provisioning and configuring a 5 node HA Kubernetes environment. Next we are going create a non-HA Kubernetes environment on GCP.</p><h3>Create a non-HA, 3 node, K8s environment on GCP</h3><p>Non-HA Kubernetes environments run their <strong>etcd</strong> and Kubernetes <strong>orchestration services</strong> (apiserver, scheduler, controller-manager…) on the compute nodes and don’t provision dedicated hosts. Once the global cluster manager is up and running, from the same directory, start triton-kubernetes.sh -e and answer the prompted questions to start provisioning another Kubernetes environment.</p><p>Default values will be shown in parentheses and if no input is provided, defaults will be used.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;./triton-kubernetes.sh -e Using /Users/fayaz.ghiasy/work/triton-kubernetes/bin/terraform ... From clouds below: 1. Triton 2. AWS 3. Azure 4. GCP Which cloud do you want to run your environment on: (1) 4&lt;/code&gt;</pre><p>This environment will be starated on GCP so enter 4 and press Enter.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;Path to GCP credentials file: /tmp/test-project-155122-credentials.json GCP Project ID: test-project-155122&lt;/code&gt;</pre><p>This environment will be running on GCP so the first two questions prompted will be account/project related. GCP credentials file should be the absolute path for your <a href="https://www.terraform.io/docs/providers/google/index.html#authentication-json-file">authentication json credentials file</a> for your GCP account. Also providet the project ID to use where the machiens will be provisioned and press Enter.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;Name your environment: (gcp-test) Do you want this environment to run in HA mode? (yes | no) no&lt;/code&gt;</pre><p>Provide a alphanumeric name for this environment and start it in non-HA mode.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;Number of compute nodes for gcp-test environment: (3)&lt;/code&gt;</pre><p>Provide the number of worker nodes to create for this kubernetes environment and press Enter.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;Compute Region: (us-west1) Instance Zone: (us-west1-a)&lt;/code&gt;</pre><p>For this environment we can use the default <a href="https://cloud.google.com/compute/docs/regions-zones/">Compute Region and Instance Zone</a>, and press Enter.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;What size hosts should be used for gcp-test environment compute nodes: (n1-standard-1)&lt;/code&gt;</pre><p>We will use the default <a href="https://cloud.google.com/compute/docs/machine-types">machine type</a> here, press Enter.</p><pre>&lt;code class=&quot;language-bash&quot;&gt;docker-engine install script: (https://releases.rancher.com/install-docker/1.12.sh) ############################################################ Environment gcp-test will be created on GCP. gcp-test will be running in non-HA configuration ... 3 compute nodes will be created for this environment ... gcp-test-compute-# n1-standard-1 Do you want to start the setup? (yes | no) yes&lt;/code&gt;</pre><p>The last prompt before verification of inputs is the docker-engine installation script that should be used. Leave the default here and press Enter.</p><p>Once verification is finished, terraform will start provisioning and configuring a 3 node non-HA Kubernetes environmental cluster. In this environment, the etcd and Kubernetes components all run on the compute (worker) nodes and share resources with deployments.</p><h3>Deploying your first multi-cloud K8s application.</h3><p>Now we are ready to deploy our first application on our multi-cloud Kubernetes environment using either the Kubernetes CLI kubectl or the <a href="https://kubernetes.io/docs/user-guide/ui/">Kubernetes Dashboard</a>.</p><p>In this section we will walk through the deployment of a “Ghost blog” app using the Kubernetes Dashboard and the example Kubernetes “Guestbook” app using kubectl.</p><h3>Deploy an app using the Kubernetes Dashboard (Web UI)</h3><p>The <a href="https://kubernetes.io/docs/user-guide/ui/">Kubernetes Dashboard</a> can be used to get an overview of applications running on your cluster, as well as to create or modify individual Kubernetes resources. The Kubernetes Dashboard also provides information on the state of Kubernetes resources in your cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*fHx585igyzJPEtZp.png" /></figure><p>Now, let’s deploy Ghost using the Kubernetes Dashboard.</p><p>First, get the URL for the Kubernetes Dashboard by going to the <em>Kubernetes Hosts URL</em> provided at the end of the <a href="https://www.joyent.com/blog/triton-kubernetes-multicloud#start-an-ha-5-node-kubernetes-environmental-cluster-on-triton-cloud">devcluster</a> cluster setup, and click <strong>Dashboard</strong> under the <strong>Kubernetes</strong> menu at the top. Note, every environment has a unique Dashboard URL printed to the console output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/0*CD-p7fgntle7GIWJ.png" /></figure><p>In this next page, click <strong>Kubernetes UI</strong> button to open the dashboard. Once you are in the Kubernetes Dashboard you should see a <strong>CREATE</strong> button at the top. Click the <strong>CREATE</strong> button to begin the process of deploying an app on your Kubernetes Environment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ouL8CTENIotoSz93.png" /></figure><p>Next, enter the details requested, using the inputs provided in the below image, and then click <strong>Deploy</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-MuEbqJpZ9D1yIgJ.png" /></figure><p>That’s it! Kubernetes should now be starting up your Ghost app and you should see something that looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*c-quQGLPndGg7G7X.png" /></figure><p>Your app is configured to be exposed externally on port 8080. So, you should see the app URL under the services screen. Once the deployment is complete and pods are up, the app should be available.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tlDmG4k6NAHyyl-0.png" /></figure><h3>Deploy an app using the Kubernetes CLI</h3><p>Now, let’s deploy the example Kubernetes Guestbook app using the Kubernetes CLI.</p><p>First, get the URL to the Kubernetes CLI config page, which will generate a kubectl config file, that the Triton Kubernetes provided at the end of the environment setup. Note that each K8s environment has it&#39;s own unique kubectl URL printed on the console output.</p><p>Go to the Kubernetes CLI config URL and click on <strong>Generate Config</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*S7x9YGRy8bvQGv4Q.png" /></figure><p>From the next screen click <strong>Copy to Clipboard</strong> and paste the content to the ~/.kube/config file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RJqloVyM1-ecOfqS.png" /></figure><p>Now you should be able to use the kubectl command to deploy your app.</p><p>The app we will deploy is called <a href="https://github.com/kubernetes/examples/tree/master/guestbook">Guestbook</a>. Clone the repository to your local machine, and navigate to the app’s directory in your terminal. We’ll make one minor change to the configuration file so that we can interact with it using a public IP address for this demo:</p><pre>&lt;code class=&quot;language-bash&quot;&gt;git clone <a href="https://github.com/kubernetes/examples.git">https://github.com/kubernetes/examples.git</a> cd examples/guestbook vi all-in-one/guestbook-all-in-one.yaml&lt;/code&gt;</pre><p>In that configuration file ( all-in-one/guestbook-all-in-one.yaml), uncomment the frontend service type, <a href="https://github.com/kubernetes/examples/blob/master/guestbook/all-in-one/guestbook-all-in-one.yaml#L108"># type: LoadBalancer</a>, so that it runs as a load balancer:</p><pre>&lt;code class=&quot;language-bash&quot;&gt;spec: # if your cluster supports it, uncomment the following to automatically create # an external load-balanced IP for the frontend service. type: LoadBalancer ports: # the port that this service should serve on - port: 80 selector: app: guestbook tier: frontend&lt;/code&gt;</pre><p>Be sure to save the file.</p><p>Now you should be able to use kubectl to deploy the app and get the external URL for the frontend service, which can be used to access the app once the pods are up:</p><pre>&lt;code class=&quot;language-bash&quot;&gt;# Deploy guestbook app $ kubectl create -f all-in-one/guestbook-all-in-one.yaml service &quot;redis-master&quot; created deployment &quot;redis-master&quot; created service &quot;redis-slave&quot; created deployment &quot;redis-slave&quot; created service &quot;frontend&quot; created deployment &quot;frontend&quot; created # Make sure that the pods are up and running $ kubectl get deployments NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE frontend 3 3 3 3 2m redis-master 1 1 1 1 2m redis-slave 2 2 2 2 2m $ kubectl get pods NAME READY STATUS RESTARTS AGE frontend-88237173-b23b9 1/1 Running 0 2m frontend-88237173-cq5jz 1/1 Running 0 2m frontend-88237173-sbkrb 1/1 Running 0 2m redis-master-343230949-3ll61 1/1 Running 0 2m redis-slave-132015689-p54lv 1/1 Running 0 2m redis-slave-132015689-t6z7z 1/1 Running 0 2m # Get the external service IP/URL $ kubectl get services NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE frontend 10.43.80.176 165.225.175.75 80:30896/TCP 14s kubernetes 10.43.0.1 &lt;none&gt; 443/TCP 7m redis-master 10.43.0.176 &lt;none&gt; 6379/TCP 15s redis-slave 10.43.141.195 &lt;none&gt; 6379/TCP 15s&lt;/code&gt;</pre><p>We can see above, for this demo, all pods are running and the only service exposed externally is the frontend service on 165.225.175.75:80.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uo9DT9V8rd91lBpZ.png" /></figure><p>The deployment status for all the pods and services can also be viewed using the Kubernetes Dashboard. To check using Dashboard, go to the URL for the Web UI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nWiG9mj6CJtE2Aw8.png" /></figure><p>For more information on Kubernetes itself, dig into the <a href="https://kubernetes.io/docs/user-guide/">official Kubernetes user guide</a> or the kubectl <a href="https://kubernetes.io/docs/user-guide/kubectl-cheatsheet/">cheatsheet</a>.</p><p><em>Originally published at </em><a href="https://www.joyent.com/blog/triton-kubernetes-multicloud"><em>https://www.joyent.com</em></a><em> on January 2, 2018.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b6e1576009d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>