Kubernetes provides a complete environment to design and produce service-based and scalable applications. It manages everything from container healing to load balancing, discovery, and grouping, keeping you carefree about them. The design is modern, different, scalable, and elegant, and the usage of APIs is a pleasure. When encountering a new infrastructure platform, it is important to monitor and troubleshoot it initially. Same function Sysdig performs for you.

What is Sysdig?

Sysdig provides complete visibility into Kubernetes throughout the entire Sysdig product line. It is the only monitoring platform designed from the bottom level to support microservices and containers. It includes Sysdig cloud, CLI system exploration tool, out open-source, and sysdig. By design, sysdig manages everything, starting from system calls to events collecting directly from Linux Kernel. It singles handily performs everything that a Wireshark, Isof, iftop, htop, tcpdump, and strace does, which implies one tool instead of six.

Moreover, Sysdig is familiar with the entire Kubernetes cluster hierarchy, starting from handling labels, services, and namespaces to managing containers while having your back when you need to troubleshoot these microservices on Linux. Despite being a command-line tool, Sysdig provides a Ncurses user interface to allow monitoring the data and information easily.

All in all, Sysdig is your go-to tool for all kinds of Kubernetes development as it allows you to monitor and troubleshoot your code easily. Let us use Sysdig.

Prerequisite

Let us install Sysdig on the Ubuntu 20.04 Server. You can easily install Sysdig into either Red Hat or Debian based distribution. However, you’ll need an Ubuntu server and a user with sudo access. Moreover, you must have a runtime engine to deploy and monitor containers. We will be explaining the detailed WordPress deployment in Sysdig with the Docker engine. So, let’s start the minikube to prepare your system for Kubernetes deployment. Just type in ‘minikube start’ in your command line window, and you are good to go. Have a look at the system output:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-623.png" data-lazy- height="122" src="data:image/svg xml,” width=”723″>

After successfully starting minikube, your system is ready to install Sysdig, so let us install it. Quickly log in to your Ubuntu server and provide the following command:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-624.png" data-lazy- height="165" src="data:image/svg xml,” width=”737″>

The system will connect with the amazon AWS server to download and install Sysdig into your Ubuntu server. With the newest Sysdig version, it will install all of the requirements. You can observe that in the above output as well.

How to Deploy a WordPress Docker Container?

Now is the time to deploy something that can monitor and troubleshoot the installed Sysdig, and we are starting with deploying a WordPress Docker container. Follow the steps given below so that you won’t miss anything:

First thing first, get the mariadb container. Type in the following command into your CLI to pull the mariadb container:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-625.png" data-lazy- height="307" src="data:image/svg xml,” width=”737″>

Note that the pull is complete, and the status is latest which means the latest version of mariadb is successfully pulled from the library.

Use the following commands to create multiple folders that hold up all the WordPress data.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-626.png" data-lazy- height="45" src="data:image/svg xml,” width=”727″>

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-627.png" data-lazy- height="39" src="data:image/svg xml,” width=”724″>

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-628.png" data-lazy- height="38" src="data:image/svg xml,” width=”707″>

Now that everything is ready, let’s create a mariadb container with the command given below:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-629.png" data-lazy- height="88" src="data:image/svg xml,” width=”735″>

Note that there are two passwords given, PWORD1 and PWORD2, which are unique as well as strong passwords.

The next step is to pull the latest edition of WordPress with the following command:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-630.png" data-lazy- height="472" src="data:image/svg xml,” width=”728″>

Note that the WordPress pull from the library is complete, and the status is the latest, interpreting that the latest version of WordPress has been successfully pulled from the library.

The WordPress container must be deployed as the final step. You must enter the PWORD2 that you created in the previous step here. Moreover, you can request access to port 8081 now and complete the installation of WordPress.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-631.png" data-lazy- height="155" src="data:image/svg xml,” width=”731″>

Now that WordPress is installed successfully and we have something to look at let’s learn to use Sysdig.

How to Use Sysdig?

Here we use the ncurse CLI, so sysdig is replaced with csysdig. We will be using six different commands to monitor and troubleshoot csysdig.

Let’s see how many and what containers are running currently.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-632.png" data-lazy- height="26" src="data:image/svg xml,” width=”725″>

We have deployed only mariadb and WordPress, so it should list them both. The listing also provides the details like Container ID, the engine being used, files, resident memory, virtual memory, threads, the number of associated processes, and CPU usage.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-633.png" data-lazy- height="531" src="data:image/svg xml,” width=”721″>

Now, let’s see all the processes associated with a container.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-634.png" data-lazy- height="44" src="data:image/svg xml,” width=”732″>

This will list the following things:

  • Process ID – PID
  • Parent PID – PPID
  • Virtual PID – VPID
  • CPU used
  • USER name
  • Virtual memory – VIRT
  • Resident memory – RES
  • FILE used
  • Total network used – NET
  • Container name
  • Command used

See the detailed output below:

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-635.png" data-lazy- height="524" src="data:image/svg xml,” width=”725″>

Suppose you get befuddled with a huge amount of information and cannot find what you are looking for. In that case, you can also choose to view information associated with a particular container.

View all the information that is linked with only the WordPress container.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-636.png" data-lazy- height="122" src="data:image/svg xml,” width=”730″>

Now, you only see the five things specifically associated with WordPress.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-637.png" data-lazy- height="276" src="data:image/svg xml,” width=”729″>

Check the net I/O of the WordPress container.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-638.png" data-lazy- height="114" src="data:image/svg xml,” width=”739″>

Again, it listed only five things specifically associated with WordPress.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-639.png" data-lazy- height="121" src="data:image/svg xml,” width=”735″>

Remember that the above command will only give you data when there is actual network traffic.

View the file associated with WordPress container I/O.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-640.png" data-lazy- height="77" src="data:image/svg xml,” width=”730″>

Again, this command also shows data only when the files are used.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-641.png" data-lazy- height="74" src="data:image/svg xml,” width=”737″>

Switch the view mode in sysdig with the ‘sudo cysydig’ command.

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-642.png" data-lazy- height="70" src="data:image/svg xml,” width=”735″>

<img data-lazy- data-lazy-src="https://kirelos.com/wp-content/uploads/2022/04/echo/word-image-643.png" data-lazy- height="484" src="data:image/svg xml,” width=”728″>

Conclusion:

In this article, we have used two powerful tools: csysdig and sysdig. These tools allow us to monitor and troubleshoot the container deployments from CLI. Each and every step to utilising and installing this tool has been explained in detail for our readers.

About the author

<img alt="" data-lazy-src="https://secure.gravatar.com/avatar/d014e3711df41253029f4d4199698df8?s=112&r=g" data-lazy- height="112" src="data:image/svg xml,” width=”112″>

Kalsoom Bibi

Hello, I am a freelance writer and usually write for Linux and other technology related content