Home Blog Page 375

Fluent Bit: Flexible Logging in Kubernetes

Logging by nature is complex and in containerized environments there are new challenges that need to be addressed. In this article we will describe the current status of the Fluentd Ecosystem and how Fluent Bit (a Fluentd sub-project) is filling the gaps in cloud native environments. Finally we will do a global overview of the new Fluent Bit v0.13 release and its major improvements for Kubernetes users.

Fluentd Ecosystem

Fluentd is an open source log processor and aggregator hosted by the Cloud Native Computing Foundation. It was started in 2011 by Sadayuki Furuhashi (Treasure Data co-founder), who wanted to solve the common pains associated with logging in production environments, most of them related to unstructured messages, security, aggregation and customizable input and outputs within others. Since the beginning Fluentd was open source, and that decision was the key that allowed several contributors to continue expanding the product. Today there are more than 700 plugins available.

Fluentd community created not only plugins but also specific language connectors which developers could use to ship logs from their own custom applications to Fluentd over the network, the best examples are connectors for Python, Golang, NodeJS, Java, etc. From that moment it was not only about Fluentd as a single project, it was a complete Logging Ecosystem around which it continued expanding, including the container’s space. Fluentd Docker driver was the entry point and then, Red Hat contributed with a Kubernetes Metadata Filter for Fluentd which helped to make it a default citizen and reliable solution for Kubernetes clusters.

What does Kubernetes Filter in Fluentd? When applications run in Kubernetes, likely they are not aware about the context where they are running, so when they generate logging information there are missing pieces associated to the origin of each application log entry like: container id, container name, Pod Name, Pod ID, Annotations, Labels, etc. Kubernetes Filter enriches each application log in Kubernetes with a proper metadata.

Fluent Bit

While Fluentd ecosystem continue to grow, Kubernetes users were in need of specific improvements associated with performance, monitoring and flexibility. Fluentd is a strong and reliable solution for log processing aggregation, but the team was always looking for ways to improve the overall performance in the ecosystem: Fluent Bit born as a lightweight log processor to fill the gaps in cloud native environments

Fluent Bit is a CNCF sub-project under the umbrella of Fluentd; written in C language and based in the design and experience of Fluentd, it has a pluggable architecture with built-in networking and security support. There are around 45 plugins available between inputs, filters and outputs. The most common used plugins in Fluent Bit are:

Fluent Bit was started almost 3 years ago, and in just the last year, more than 3 million of deployments had happened in Kubernetes clusters. The community around Fluentd and Kubernetes has been the key for it evolvement and positive impact in the ecosystem.

Fluent Bit in Kubernetes

Log processors, such as Fluentd or Fluent Bit, have to do some extra work in Kubernetes environments to get the logs enriched with proper metadata, an important actor is the Kubernetes API Server which provides such relevant information:

QKRUdJ9Vy42vDFx0ZCCFYE_MRlSefDAf-snTokAE

The model works pretty well but there are still some things raised by the community asking for improvement in certain areas:

  • Logs generated by Pods are encapsulated in JSON, but the original log message is likely unstructured. Also logs from an Apache Pod are different than a MySQL Pod, how to deal with different formats?

  • There are cases where would be ideal to exclude certain Pod logs, meaning: skip logs from Pod ABC.

  • Gather insights from the log processor. How to monitor it with Prometheus?

The new and exciting Fluent Bit 0.13 aims to address the needs described above, let’s explore a bit more about it.

Fluent Bit v0.13: What’s new?

In perfect timing, Fluent Bit 0.13 is being released at KubeCon+CloudNativeCon Europe 2018. Months of work between the developers and the community are bringing one of the most exciting versions available; here are the highlights.

Pods suggest a parser through a declarative annotation

From now Pods can suggest a pre-defined and known parser to the log processor, so a Pod running an Apache web server may suggest the following parser through a declarative annotation:

pdqfFOtk44YE-vOzk3md7hvXHXEeW_3axGARobMj

The new annotation fluent.io/parser allows to suggest the pre-defined parser apache to the log processor (Fluent Bit), so the data will be interpreted as a properly structured message.

Pods suggest to exclude the logs

If for some reason the logs from a specific logs should not be processed through the log processor, this can be suggested through the declarative annotation fluentbit.io/exclude: “true” :

Ec2CpOqzuGtblb8FsGD23FRwTWcm_RUosyc8Yt7Y

Monitor the Fluent Bit logging Pipeline

Fluent Bit 0.13 comes with built-in support for metrics which are exported through a HTTP end-point. By default the metrics and overall information are in JSON but also can be retrieved in Prometheus format, examples:

1. General information: $ curl -s http://127.0.0.1:2020 | jq

mTUO4-qC51v8KW5I-fYXA9YUmj0Z6VN6SwK-i1u8

2. Overall Metrics in JSON: $ curl -s http://127.0.0.1:2020/api/v1/metrics | jq

NduPLdD5FyRscS3EoBeTpE7c0KLDIRuhlbJGR_Ea

3. Metrics in Prometheus Format: $ curl -s http://127.0.0.1:2020/api/v1/metrics/prometheus

W8oZ0DjXv04SwTZI0WjD17ecTIVGXdCae4vmYMEN

4. Connecting Prometheus to Fluent Bit Metrics end-point

sh_V1b4prMk3sS89MeRhvCkC1_KIIdna6r-xykrT

New Enterprise output connectors

Output connectors are an important piece of the logging pipeline; as part of 0.13 release we are adding the following plugins:

  • Apache Kafka

  • Microsoft Azure

  • Splunk

Meet Fluentd and Fluent Bit maintainers at KubeCon+CloudNativeCon Europe 2018!

Masahiro Nakagawa and Eduardo Silva, maintainers of Fluentd and Fluent Bit, will be at KubeCon presenting about the projects, engaging with the community and discussing roadmaps!, join us the conversation!  Check out the schedule:

Also don’t forget to stop by the CNCF booth in the exhibitors hall!

Eduardo Silva

Eduardo Silva is a Software Engineer at Treasure Data, he is part of the Open Source Fluentd Engineering team. He is passionate about scalability, performance and logging. One of his primary roles at Treasure Data is to maintain and develop Fluent Bit, a lightweight log processor for Cloud Native environments.

Learn more at at KubeCon + CloudNativeCon EU, May 2-4, 2018 in Copenhagen, Denmark.

Where Is Serverless Computing Headed?

“Things are all moving very, very fast.”

That was one of the big takeaways from my conversation at the Open Source Leadership Summit with former RedMonk analyst Fintan Ryan last month. We were talking about the state of the serverless market. (Depending on who you ask, serverless is either the same thing as, or conceptually related to, Function-as-a-service.)

In Ryan’s view, there are two different aspects to serverless. The first, he says, is “essentially a programming model which allows you to deal with event-driven architectures and event-driven applications. What we actually mean is there’s an awful lot of small events that are generating things that give you an ability to deal with each thing individually in terms of very small functions.”

Read more at OpenSource.com

Speak at Open Networking Summit Europe – Submit by June 24

Open Networking Summit Europe (ONS EU) is the first combined Technical and Business Networking conference for Carriers, Cloud and Enterprises in Europe. The call for proposals for ONS EU 2018 is now open, and we invite you to share your expertise

Share your knowledge with over 700 architects, developers, and thought leaders paving the future of network integration, acceleration and deployment. Proposals are due Sunday, June 24, 2018.

Based on feedback we received at Open Networking Summit North America 2018, our restructured agenda will include project-based technical sessions as well.

Read more at The Linux Foundation

How to Get a Core Dump for a Segfault on Linux

This week at work I spent all week trying to debug a segfault. I’d never done this before, and some of the basic things involved (get a core dump! find the line number that segfaulted!) took me a long time to figure out. So here’s a blog post explaining how to do those things!

At the end of this blog post, you should know how to go from “oh no my program is segfaulting and I have no idea what is happening” to “well I know what its stack / line number was when it segfaulted at at least!“.

what’s a segfault?

A “segmentation fault” is when your program tries to access memory that it’s not allowed to access, or tries to. This can be caused by:

  • trying to dereference a null pointer (you’re not allowed to access the memory address 0)
  • trying to dereference some other pointer that isn’t in your memory

Read more at Julia Evans

How to Share Files Between Linux and Windows

Many people today work on mixed networks, with both Linux and Windows systems playing important roles. Sharing files between the two can be critical at times and is surprisingly easy with the right tools. With fairly little effort, you can copy files from Windows to Linux or Linux to Windows. In this post, we’ll look at what is needed to configure your Linux and Windows system to allow you to easily move files from one OS to the other.

Copying files between Linux and Windows

The first step toward moving files between Windows and Linux is to download and install a tool such as PuTTY’s pscp. You can get PuTTY from putty.org and set it up on your Windows system easily. 

Read more at NetworkWorld

Crostini Linux Container Apps Getting Full Native Treatment on Chromebooks

Another day, another Crostini feature comes to light. So far, we have the Linux Terminal installer, Files app integration, and Material Design cues already rounding out the Linux app experience. As we continue to uncover clues by the day, it seems development of the Crostini Project is full steam ahead today is no different. Each clue we uncover continues to push the entire experience closer to something I believe will be delivered to developers and general users alike.

There are multiple commits around this same theme: handling app icons for Linux apps on your Chromebook. 

Read more at ChromeUnboxed

Data Protection for Containers: Part I, Backup

 How do you ensure data is properly backed up and recoverable according to current policies on a Kubernetes cluster?

Traditional agent-based backup software won’t work natively with a container orchestrator such as Kubernetes. A Persistent Volume (PV) may be attached to any host at any given time in the cluster. Having a backup agent hogging the mount path on the host will lead to unpredictable behavior and most certainly failed backups. Applying the traditional backup paradigm to the containerized application paradigm will simply not work. Backup schemes need to be consumed as a data service provided by the cluster orchestrator and the underlying storage infrastructure. In this blog you’ll learn how HPE Nimble Storage provide these data protection services for Kubernetes and how cluster administrators, traditional storage architects and application owners that are part of a DevOps team may design and consume these data protection services.

Before we dig in, the very loaded word “Backup” needs to be defined with a touch of the 21st century. I’m using the define: operator on Google search to help me…

Read more at HPE

This Week in Open Source News: What’s Ahead for Node.js, Chrome OS Terminal App Feat. Linux Support & More

This week in Linux and open source headlines, Mark Hinkle of Node.js Foundation shares what he’s excited for in regards to the platform this year and more. Read on and stay open-source-informed!

“Executive Director of the Node.js Foundation, Mark Hinkle provides commentary on the growth of Node.js in general, how the Node.js Foundation works with the community and what he is most excited about this year with Node.js.”

The Future of Node.js: Q&A with Mark Hinkle– App Developer Magazine

“The interesting part [about] blockchain [is that] a combination of capabilities in computing, connectivity and cryptography, has applications not only in the financial world but in any transactional environment.”

How the Blockchain Could Secure Our Identities– Tech Central

New Linux Foundation AI organization will “strive to make these critical new technologies available to developers and data scientists everywhere.” 

Linux Launches Deep Learning Foundation For Open Source Growth In AI– Analytics India Magazine

Microsoft’s use of a custom Linux kernel is revealing in several ways, writes Jack M. Germain.

Microsoft Calls On Linux for Its New IoT Security Platform– LinuxInsider

“Coming full circle, Chrome OS could soon run Linux software somewhat directly, opening the OS and Chromebooks to use cases beyond education or enterprise.”

Chrome OS Terminal App Hints at Upcoming Linux Support– SlashGear

How to Compile a Linux Kernel

Once upon a time the idea of upgrading the Linux kernel sent fear through the hearts of many a user. Back then, the process of upgrading the kernel involved a lot of steps and even more time. Now, installing a new kernel can be easily handled with package managers like apt. With the addition of certain repositories, you can even easily install experimental or specific kernels (such as real-time kernels for audio production) without breaking a sweat.

Considering how easy it is to upgrade your kernel, why would you bother compiling one yourself? Here are a few possible reasons:

  • You simply want to know how it’s done.

  • You need to enable or disable specific options into a kernel that simply aren’t available via the standard options.

  • You want to enable hardware support that might not be found in the standard kernel.

  • You’re using a distribution that requires you compile the kernel.

  • You’re a student and this is an assignment.

Regardless of why, knowing how to compile a Linux kernel is very useful and can even be seen as a right of passage. When I first compiled a new Linux kernel (a long, long time ago) and managed to boot from said kernel, I felt a certain thrill coursing through my system (which was quickly crushed the next time I attempted and failed).
With that said, let’s walk through the process of compiling a Linux kernel. I’ll be demonstrating on Ubuntu 16.04 Server. After running through a standard sudo apt upgrade, the installed kernel is 4.4.0-121. I want to upgrade to kernel 4.17. Let’s take care of that.

A word of warning: I highly recommend you practice this procedure on a virtual machine. By working with a VM, you can always create a snapshot and back out of any problems with ease. DO NOT upgrade the kernel this way on a production machine… not until you know what you’re doing.

Downloading the kernel

The first thing to do is download the kernel source file. This can be done by finding the URL of the kernel you want to download (from Kernel.org). Once you have the URL, download the source file with the following command (I’ll demonstrate with kernel 4.17 RC2):

wget https://git.kernel.org/torvalds/t/linux-4.17-rc2.tar.gz

While that file is downloading, there are a few bits to take care of.

Installing requirements

In order to compile the kernel, we’ll need to first install a few requirements. This can be done with a single command:

sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc flex libelf-dev bison

Do note: You will need at least 12GB of free space on your local drive to get through the kernel compilation process. So make sure you have enough space.

Extracting the source

From within the directory housing our newly downloaded kernel, extract the kernel source with the command:

tar xvzf linux-4.17-rc2.tar.gz

Change into the newly created directory with the command cd linux-4.17-rc2.

Configuring the kernel

Before we actually compile the kernel, we must first configure which modules to include. There is actually a really easy way to do this. With a single command, you can copy the current kernel’s config file and then use the tried and true menuconfig command to make any necessary changes. To do this, issue the command:

cp /boot/config-$(uname -r) .config

Now that you have a configuration file, issue the command make menuconfig. This command will open up a configuration tool (Figure 1) that allows you to go through every module available and enable or disable what you need or don’t need.

Figure 1: The make menuconfig in action.

It is quite possible you might disable a critical portion of the kernel, so step through menuconfig with care. If you’re not sure about an option, leave it alone. Or, better yet, stick with the configuration we just copied from the running kernel (as we know it works). Once you’ve gone through the entire list (it’s quite long), you’re ready to compile!

Compiling and installing

Now it’s time to actually compile the kernel. The first step is to compile using the make command. So issue make and then answer the necessary questions (Figure 2). The questions asked will be determined by what kernel you’re upgrading from and what kernel you’re upgrading to. Trust me when I say there’s a ton of questions to answer, so give yourself plenty of time here.

Figure 2: Answering the questions for the make command.

After answering the litany of questions, you can then install the modules you’ve enabled with the command:

make modules_install

Once again, this command will take some time, so either sit back and watch the output, or go do something else (as it will not require your input). Chances are, you’ll want to undertake another task (unless you really enjoy watching output fly by in a terminal).

Now we install the kernel with the command:

sudo make install

Again, another command that’s going to take a significant amount of time. In fact, the make install command will take even longer than the make modules_install command. Go have lunch, configure a router, install Linux on a few servers, or take a nap.

Enable the kernel for boot

Once the make install command completes, it’s time to enable the kernel for boot. To do this, issue the command:

sudo update-initramfs -c -k 4.17-rc2

Of course, you would substitute the kernel number above for the kernel you’ve compiled. When that command completes, update grub with the command:

sudo update-grub

You should now be able to restart your system and select the newly installed kernel.

Congratulations!

You’ve compiled a Linux kernel! It’s a process that may take some time; but, in the end, you’ll have a custom kernel for your Linux distribution, as well as an important skill that many Linux admins tend to overlook.

Learn more about Linux through the free “Introduction to Linux” course from The Linux Foundation and edX.

Extending Kubernetes API for Complex Stateful Applications using Operator

Conventional wisdom says you can’t run a database in a container because “Containers are stateless!” or “Databases are pointless without state!” However, this is not true any longer. We’ve been missing the right technology to support database running in a container.

Then came Kubernetes 1.5, which includes the new StatefulSet API object (in older versions, StatefulSet was known as PetSet). With StatefulSets, Kubernetes makes it easier to run stateful workloads such as Couchbase Server, a NoSQL database.

Stateful Containers

Kubernetes StatefulSets gives you a set of resources to deal with stateful containers, such as: volumes, stable network ids, ordinal indexes from 0 to N, etc. Volumes are one of the key features that allow us to run stateful applications on top of Kubernetes; let’s see the two main types currently supported:

Ephemeral storages volumes

The behavior of ephemeral storages is different than what you are used to in Docker. In Kubernetes, the volume outlives any containers that run within the Pod, and the data is preserved across container restarts. But if the Pod getskilled, the volume is automatically removed.

Persistent storage volumes

In a persistent storage, as the name suggests, the data lifetime is independent of the Pod’s lifetime. So, even when the Pod dies or is moved to another node, that data will still persist until it is explicitly deleted by the user. In those kinds of volumes, the data is typically stored  remotely.

We are looking forward for Kubernetes to support Local Persistent Storages as it will definitely be the best fit for running databases, but in the meantime, we use ephemeral storages by default for Couchbase Server. At this point, you might wonder why we are using ephemeral storages instead of the persistent ones. Not surprisingly, there are many reasons for that:

  • Ephemeral storages are faster and cheaper than persistent; it would require more infrastructure/networking to use persistent storages as you need to send the data back and forth

  • K8s 1.9 introduced Raw Block Support, which allows you to access physical disks in your VM instance to use it in your application

  • Maintain networked storage systems is not trivial

  • You can always try to reboot the container first instead of killing the whole Pod: Ex (kubectl exec POD_NAME -c CONTAINER_NAME reboot) 

  • You can configure the database to automatically replicate your data, so even if N Pods dies, no data will be lost

  • Part of K8s job is to run Pods in different racks to avoid massive failures

However, there are a few scenarios where using Remote Persistent Storages would be worth the extra latency cost, like in massive databases for instance, when the rebalancing process takes several minutes to finish. That is why we also will add support for Remote Persistent Storages for Couchbase Server.

One of the downsides of Statefulsets is the limited management. This is why we decided to extend the Kubernetes API through the use of a Custom Resource Definition (CRD), which allows us to create a custom native resource in Kubernetes similar to a StatefulSet or a Deployment, but designed specifically for managing Couchbase instances.

Great! So, with StatefulSets/CRDs we have all the hardware operations arranged, but there is just a “small” thing missing here: what about the state of the application itself? In a database, for instance, adding a new node to the cluster is not nearly enough.  You would still be required to trigger some processes, such as rebalancing to move/replicate some of the data to the newly added node to make it fully operational. That is exactly why K8s Operators joined the game.

Kubernetes Operators

Kubernetes 1.7 has added an important feature called Custom Controllers.  In summary, it enables developers to extend and add new functionalities, replace existing ones (like replacing kube-proxy for instance), and of course, automate administration tasks as if they were a native Kubernetes component.

An Operator is nothing more than a set of application-specific custom controllers. So, why is it a game changer? Well, controllers have direct access to Kubernetes API, which means they can monitor the cluster, change pods/services, scale up/down, and call endpoints of the running applications, all according to custom rules written inside those controllers.

To illustrate this behavior, let’s see how Couchbase’s Operator works when a Pod gets killed:

UnQbaCait9W3h5f0NNDAs8SRdbG26WGpcXhfCcVG

As you can see in the figure above, the Operator monitors and analyzes the cluster, and based on a set of parameters, trigger a series of actions to achieve a desired state. This reconciliation process is all over the place in K8s. But not all actions are equal; in our example, we have two distinct categories:

  • Infrastructure – add a new node to the cluster: The operator requests via Kubernetes API to launch a new Pod running Couchbase Server.

  • Domain Specific – add node to cluster/ trigger data rebalancing: The operator knows how Couchbase works and calls the correct rest endpoint to add the new node to the cluster and trigger data rebalancing.

That is the real power of Operators: they allow you to write an application to fully manage another, and guess which kind stateful applications are the hardest to manage? You are right: Databases.

Developers have always expected databases to work out-of-the-box, when in fact, they historically are exactly the opposite. We even have a specific name for the person responsible for taking care of the database: our beloved DBAs.

Couchbase’s Operator was created as an effort change this scenario and make databases easy to manage without locking you to a specific cloud vendor. Currently, it supports automated cluster provisioning, elastic scalability, auto recovery, logging and access to the web console, but many more features are coming in the future. If you want to read more about it, please check out this article or refer to Couchbase’s official documentation here.

Golk1BwrvQ9Vz6rIGVtxwl448CCOJx65528L81dh

I also have to mention that It is the very first official operator launched for a database, although there are already some small community projects trying to build operators for MySQL, Postgres and other databases.

The Operator’s ecosystem is growing quickly;  rook for example, lets you deploy something very similar to AWS S3. The Apache Kafka operator is coming soon, and with so many other initiatives out there, we expect a major boost in the number of operators in the upcoming months now that all major cloud providers supports K8s.

Finally, Kubernetes provides a cloud-agnostic application deployment and management. It is so powerful that it might lead us to treat cloud providers almost like a commodity, as you will be able to migrate freely between them.

In the future, choosing a cloud provider could be just a matter of which one offers the best performance/cost.

Anil Kumar

As Director of Product Management at Couchbase, Anil Kumar is responsible for product strategy, development, and delivery of Couchbase Data Platform offerings. Prior to joining Couchbase, Anil spent several years working at Microsoft in the Entertainment division and most recently in the Windows and Windows Live division.

For similar topics on Kubernetes, consider attending KubeCon + CloudNativeCon EU, May 2-4, 2018 in Copenhagen, Denmark.