Sumedh Meshram

A Personal Blog

What is Helm and why you should love it?

Helm is the first application package manager running atop Kubernetes. It allows describing the application structure through convenient helm-charts and managing it with simple commands.

 

Why is Helm important? Because it’s a huge shift in the way the server-side applications are defined, stored and managed. Adoption of Helm might well be the key to mass adoption of microservices, as using this package manager simplifies their management greatly.

What is Helm and why you should love it

Why are microservices so important? They have quite a few uses:

  • When there are several microservices instead of a monolithic application, each microservice can be managed, updated and scaled individually
  • Issues with one microservice do not affect the functionality of other components of the application
  • New application can be easily composed of existing loosely-coupled microservices

Of course, Helm is not the unique package manager, nor is it perfect. However, the project is now being actively developed and grows a passionate community that appreciates the benefits of using Helm charts for software development.

Helm benefits and flaws

Unlike Homebrew or Aptitude desktop package managers, or Azure Resource Manager templates (ARMs) / Amazon Machine Images (AMIs) that are run on a single server, Helm charts are built atop Kubernetes and benefit from its cluster architecture. The main benefit of this approach is the ability to consider scalability from the start. The charts of all the images used by Helm are stored in a registry called Helm Workspace, so the DevOps teams can search them and add to their projects with ease.

What is Helm and why you should love it 1

For example, you need to launch a website built with WordPress, Joomla, Django or any other CMS. You expect the website to receive millions of daily visitors from the day one and you must make sure such huge numbers of connections will not lead to freezes or service unavailability.

Using virtualization capabilities ensures scaling, yes. Just keep in mind that an AMI, ARM (or a Docker container for that matter) you use to launch the app will be dependent on the Virtual Machine it is stored on and will be able to scale only the way the virtual machines are scaled — by adding more resources to the pool.

With Helm, we have quite another picture. The application can be composed of clearly defined microservices and we can scale only the ones we need to scale, adding more Kubernetes nodes and pods to the cluster. Instead of working with a holistic image and growing all the resources, you operate a set of images and scale them independently.

The problems begin when you want to launch a new instance of an application that runs, let’s say, 50 microservices. Starting and combining them all will be a laborious and error-prone task. However, with Helm, all you need to know is the name of the charts for the images responsible. Launching a new instance is the question of executing the corresponding Helm chart.

The only significant issue with Helm so far was the fact that when 2 helm charts have the same labels they interfere with each other and impair the underlying resources. This means it’s better to compose a new image for the project than adding a single Helm chart to it and affects the rollbacks too. However, the community has found workarounds for the issue and we are sure it will be removed for good in the future versions of the tool.

Final thoughts on the future of Helm

We are sure Kubernetes is the future of container orchestration in the cloud, and Helm is the way to use Kubernetes most efficiently. Of course, the DevOps team can do the same using standard kubectl commands, yet working with Helm provides the ability to quickly define, cleanly manage and easily deploy the applications. Thus said, the Kubernetes + Helm duo can (and must) become the basic toolset for any DevOps specialist in the years to come, namely a helm to navigate the cloud and deliver the containers safely.

Artificial Intelligence in Software Development and Testing

According to Gartner, artificial intelligence will be omnipresent in all spheres of technology and will successfully make its presence prominent among the top investment priority of CIOs by 2020. Going by the figures of the market research firm, the worldwide scope for artificial intelligence in 2019 is approximately $6.36 billion in North America.

Technical masters like Amazon, Facebook, Google, and many others spend a huge sum of money on acquiring AI in software.

AI emerged as an enterprise technology and has changed the outlook of everything, including software development and software testing. It is, therefore, important that we take a minute to look into the role of artificial intelligence in software development and testing.

Higher Level of Precision

It is natural for humans to make errors. Even highly skilled testers sometimes end up making mistakes while performing annual testing. With automated testing, similar steps can be executed with precision every time the task of testing is undertaken and never miss an opportunity to notify specific outcomes. Testers are exempted from ongoing manual examination and they can have a more significant proportion of time to develop new automated software tests and manage chic properties.

Artificial intelligence can help to overcome the drawbacks of annual testing. It is practically unsustainable for leading software or quality assurance (QA) segments to perform a well-managed web app test with more than thousands of users. With the help of automated testing, the user can trigger tens, hundreds, or thousands of optical group of users who can communicate with a network, software, or web-based app.

Massive Support for Developers as Well as Testers

Developers can utilize the shared tests conducted by the computing device to monitor errors instantly before sending it for quality assurance. These tests can function automatically as and when the source code alterations are examined based on which the squad or the app builder can be notified accordingly if a test result turns out to be unsuccessful. Different properties like these help in securing a time for developers and boosts up their self-confidence.

Leveraging the Whole Test Scope

In software testing, with the help of artificial intelligence, the user can leverage the complete coverage and depth of tests, thereby leading to massive enhancement in software quality. Artificial intelligence-driven software testing enables looking into the storage capacity and document content, internal strategy states, and data tables to ascertain whether the software is acting as it should or not. On the whole, test automation can perform more than a thousand various test cases in each test run, offering a scope that would never have been possible through manual testing.

Less Time-Consuming and Helps in Quick Marketing

With the help of software tests being replicated, every time a source code is altered, repetitive manual tests can prove to be time-consuming and tremendously expensive.

On the other hand, once developed, machine learning and testing together can be performed continuously without the need to incur any extra expenses.

The total time taken for software testing can be reduced from two or three days to a few hours, which indirectly helps to save money.

To Wrap Up

Integrating artificial intelligence (AI) with software testing and software development can help to build a society where software can be swiftly examined, diagnosed, and modified.

Artificial intelligence testing will permit high-quality engineering and will decrease the total time taken for examination and development. As a result, it will help to secure time, money, and resources; while allowing testers to pay attention to performing prime activities such as launching quality software.

 

Build A Serverless Function

In this tutorial, you’ll build and publish a serverless function that generates QR codes, using Cloudflare Workers.

Demo

This tutorial makes use of Wrangler, our command-line tool for generating, building, and publishing projects on the Cloudflare Workers platform. If you haven’t used Wrangler, we recommend checking out the “Installing the CLI” part of our Quick Start guide, which will get you set up with Wrangler, and familiar with the basic commands.

If you’re interested in building and publishing serverless functions, this is the guide for you! No prior experience with serverless functions or Cloudflare Workers is assumed.

One more thing before you start the tutorial: if you just want to jump straight to the code, we’ve made the final version of the codebase available on GitHub. You can take that code, customize it, and deploy it for use in your own projects. Happy coding!

Prerequisites

To publish your QR Code Generator function to Cloudflare Workers, you’ll need a few things:

  • A Cloudflare account, and access to the API keys for that account
  • A Wrangler installation running locally on your machine, and access to the command-line

If you don’t have those things quite yet, don’t worry. We’ll walk through each of them and make sure we’re ready to go, before you start creating your application.

You’ll need to get your Cloudflare API keys to deploy code to Cloudflare Workers: see “Finding your Cloudflare API keys” for a brief guide on how to find them.

Generate

Cloudflare’s command-line tool for managing Worker projects, Wrangler, has great support for templates – pre-built collections of code that make it easy to get started writing Workers. We’ll make use of the default JavaScript template to start building your project.

In the command line, generate your Worker project, using Wrangler’s worker-template, and pass the project name “qr-code-generator”:

wrangler generate qr-code-generator
cd qr-code-generator

Wrangler templates are just Git repositories, so if you want to create your own templates, or use one from our Template Gallery, there’s a ton of options to help you get started.

Cloudflare’s worker-template includes support for building and deploying JavaScript-based projects. Inside of your new qr-code-generator directory, index.js represents the entry-point to your Cloudflare Workers application.

All Cloudflare Workers applications start by listening for fetch events, which are fired when a client makes a request to a Workers route. When that request occurs, you can construct responses and return them to the user. This tutorial will walk you through understanding how the request/response pattern works, and how we can use it to build fully-featured applications.

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

/**
 * Fetch and log a request
 * @param {Request} request
 */
async function handleRequest(request) {
  return new Response('Hello worker!', { status: 200 })
}

In your default index.js file, we can see that request/response pattern in action. The handleRequest constructs a new Response with the body text “Hello worker”, as well as an explicit status code of 200.

When a fetch event comes into the worker, the script uses event.respondWith to return that new response back to the client. This means that your Cloudflare Worker script will serve new responses directly from Cloudflare’s cloud network: instead of continuing to the origin, where a standard server would accept requests, and return responses, Cloudflare Workers allows you to respond quickly and efficiently by constructing responses directly on the edge.

Build

Any project you publish to Cloudflare Workers can make use of modern JS tooling like ES modules, NPM packages, and async/await functions to put together your application. In addition, simple serverless functions aren’t the only thing you can publish on Cloudflare Workers: you can build full applications using the same tooling and process as what we’ll be building today.

The QR code generator we’ll build in this tutorial will be a serverless function that runs at a single route and receives requests. Given text sent inside of that request (such as URLs, or strings), the function will encode the text into a QR code, and serve the QR code as a PNG response.

Handling requests

Currently, our Workers function receives requests, and returns a simple response with the text “Hello worker!”. To handle data coming in to our serverless function, check if the incoming request is a POST:

async function handleRequest(request) {
  if (request.method === 'POST') {
    return new Response('Hello worker!', { status: 200 })
  }
}

Currently, if an incoming request isn’t a POST, response will be undefined. Since we only care about incoming POST requests, populate response with a new Responsewith a 500 status code, if the incoming request isn’t a POST:

async function handleRequest(request) {
  let response
  if (request.method === 'POST') {
    response = new Response('Hello worker!', { status: 200 })
  } else {
    response = new Response('Expected POST', { status: 500 })
  }
  return response
}

With the basic flow of handleRequest established, it’s time to think about how to handle incoming valid requests: if a POST request comes in, the function should generate a QR code. To start, move the “Hello worker!” response into a new function, generate, which will ultimately contain the bulk of our function’s logic:

const generate = async request => {
  return new Response('Hello worker!', { status: 200 })
}

async function handleRequest(request) {
  // ...
  if (request.method === 'POST') {
    response = await generate(request)
  // ...
}

Building a QR Code

All projects deployed to Cloudflare Workers support NPM packages, which makes it incredibly easy to rapidly build out a lot of functionality in your serverless functions. The qr-image package is a great way to take text, and encode it into a QR code, with support for generating the codes in a number of file formats (such as PNG, the default, and SVG), and configuring other aspects of the generated QR code. In the command-line, install and save qr-image to your project’s package.json:

npm install --save qr-image

In index.js, require the qr-image package as the variable qr. In the generatefunction, parse the incoming request as JSON, using request.json, and use the text to generate a QR code using qr.imageSync:

const qr = require('qr-image')

const generate = async request => {
  const body = await request.json()
  const text = body.text
  const qr_png = qr.imageSync(text || 'https://workers.dev')
}

By default, the QR code is generated as a PNG. Construct a new instance of Response, passing in the PNG data as the body, and a Content-Type header of image/png: this will allow browsers to properly parse the data coming back from your serverless function, as an image:

const generate = async request => {
  // ...
  return new Response(qr_png, { headers })
}

With the generate function filled out, we can simply wait for the generation to finish in handleRequest, and return it to the client as response:

async function handleRequest(request) {
  // ...
  if (request.method === 'POST') {
    response = await generate(request)
  // ...
}

Testing In a UI

The serverless function will work if a user sends a POST request to a route, but it would be great to also be able to test it with a proper interface. At the moment, if any request is received by your function that isn’t a POST, a 500 response is returned. The new version of handleRequest should return a new Response with a static HTML body, instead of the 500 error:

const landing = `
<h1>QR Generator</h1>
<p>Click the below button to generate a new QR code. This will make a request to your serverless function.</p>
<input type="text" id="text" value="https://workers.dev"></input>
<button onclick='generate()'>Generate QR Code</button>
<p>Check the "Network" tab in your browser's developer tools to see the generated QR code.</p>
<script>
  function generate() {
    fetch(window.location.pathname, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ text: document.querySelector("#text").value })
    })
  }
</script>
`

async function handleRequest(request) {
  let response
  if (request.method === 'POST') {
    response = await generate(request)
  } else {
    response = new Response(landing, { headers: { 'Content-Type': 'text/html' } })
  }
  return response
}

The landing variable, which is a static HTML string, sets up an input tag and a corresponding button, which calls the generate function. This function will make an HTTP POST request back to your serverless function, allowing you to see the corresponding QR code image data inside of your browser’s network inspector:

With that, your serverless function is complete! The full version of the code looks like this:

const qr = require('qr-image')

const generate = async request => {
  const { text } = await request.json()
  const headers = { 'Content-Type': 'image/png' }
  const qr_png = qr.imageSync(text || 'https://workers.dev')
  return new Response(qr_png, { headers })
}

const landing = `
<h1>QR Generator</h1>
<p>Click the below button to generate a new QR code. This will make a request to your serverless function.</p>
<input type="text" id="text" value="https://workers.dev"></input>
<button onclick='generate()'>Generate QR Code</button>
<p>Check the "Network" tab in your browser's developer tools to see the generated QR code.</p>
<script>
  function generate() {
    fetch(window.location.pathname, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ text: document.querySelector("#text").value })
    })
  }
</script>
`

async function handleRequest(request) {
  let response
  if (request.method === 'POST') {
    response = await generate(request)
  } else {
    response = new Response(landing, { headers: { 'Content-Type': 'text/html' } })
  }
  return response
}

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

Publish

And with that, you’re finished writing the code for the QR code serverless function, on Cloudflare Workers!

Wrangler has built-in support for bundling, uploading, and releasing your Cloudflare Workers application. To do this, we’ll run wrangler publish, which will build and publish your code:

Publish

Resources

In this tutorial, you built and published a serverless function to Cloudflare Workers for generating QR codes. If you’d like to see the full source code for this application, you can find it on GitHub.

If you enjoyed this tutorial, we encourage you to explore our other tutorials for building on Cloudflare Workers:

If you want to get started building your own projects, check out the quick-start templates we’ve provided in our Template Gallery.

Cheap MLB Jerseys maillot de foot pas cher www.fotballdrakter.org