Tag Archives: linux

Introduction to YAML: Creating a Kubernetes Deployment | Linux.com


There’s an easier and more useful way to use Kubernetes to spin up resources outside of the command line: creating configuration files using YAML. In this article, we’ll look at how YAML works and use it to define first a Kubernetes Pod, and then a Kubernetes Deployment.

YAML Basics

It’s difficult to escape YAML if you’re doing anything related to many software fields — particularly Kubernetes, SDN, and OpenStack. YAML, which stands for Yet Another Markup Language, or YAML Ain’t Markup Language (depending who you ask) is a human-readable text-based format for specifying configuration-type information. For example, in this article, we’ll pick apart the YAML definitions for creating first a Pod, and then a Deployment.

Using YAML for K8s definitions gives you a number of advantages, including:

  • Convenience: You’ll no longer have to add all of your parameters to the command line
  • Maintenance: YAML files can be added to source control, so you can track changes
  • Flexibility: You’ll be able to create much more complex structures using YAML than you can on the command line

YAML is a superset of JSON, which means that any valid JSON file is also a valid YAML file. So on the one hand, if you know JSON and you’re only ever going to write your own YAML (as opposed to reading other people’s) you’re all set. On the other hand, that’s not very likely, unfortunately. Even if you’re only trying to find examples on the web, they’re most likely in (non-JSON) YAML, so we might as well get used to it.  Still, there may be situations where the JSON format is more convenient, so it’s good to know that it’s available to you.

Read more at CNCF

Some Additional Chrome vs. Firefox Benchmarks With WebRender, 67 Beta / 68 Alpha


DESKTOP --

A few days ago I posted some Chrome vs. Firefox benchmarks using the latest Linux builds. Some readers suggested Firefox could be more competitive if forcing WebRender usage and/or moving to the latest nightly builds, so here are some complementary data sets looking at such combinations.

In addition to Firefox 66 stable and Chrome 73 stable, here are results when using Firefox 67 Beta 4 and Firefox 68 Alpha 1 as the latest at the time of testing. In addition to testing those two development channels, additional runs were done on each of them after forcing WebRender with the “MOZ_ACCELERATED=1 MOZ_WEBRENDER=1” environment variables.

Here are the benchmark results via the Phoronix Test Suite:

In the case of ARES-6, Firefox 67 Beta 4 is faster than Firefox 66 stable while Firefox 68 was slightly slower. But Firefox still wasn’t competing with Chrome in this benchmark.

In the old Octane browser benchmark, the newer releases came in a little bit slower than Firefox 66 stable.

WebXPRT is the lone test where Firefox beats out Google Chrome 73 and there wasn’t any benefit to the newer releases.

With Basemark, Firefox is still a great deal behind Chrome.

The MotionMark benchmark with it being focused on the graphics performance is a benchmark where WebRender is stressed and does pay off albeit still doesn’t make it as fast as Google Chrome.

There wasn’t much difference out of the Speedometer web browser benchmark.

Lastly is a look at the geometric mean of the benchmarks carried out. Personally, as a devout Firefox user going back to the Firebird/Phoenix days, this is sad to see albeit are seeing similar results on other Linux desktop systems too between Chrome and Firefox. If any premium supporters have any other web browser benchmark requests, be sure to let me know.


Tutorial: Tap the Hidden Power of Your Bash Command History | Linux.com


Last month I wrote about combining a series of Unix commands using pipes. But there are times where you don’t even need pipes to turn a carefully-chosen series of commands into a powerful and convenient home-grown utility. …

The echo command repeats whatever text is entered after it, for example. I’d just never found it particularly useful, since it always seemed to be more trouble than it’s worth. Sure, echo was handy for adding decorations to output.

echo "--------------------------" ; date ; echo "--------------------------"
--------------------------
Thu Feb 28 01:25:46 UTC 2019
--------------------------

But if you have to type in all those decorations in the first place, you’re not really saving any time.

What I’d really wanted (instead of echo) was a command to drop me back into that one deep-down subdirectory where I was doing most of my work. Something that was shorter than

cd ~/subdirectory/subdirectory/subdirectory/subdirectory/subdirectory

Yes, there’s a command that lets you change back to your last-used directory.

cd 

Read more at The New Stack

NVIDIA Releases Nsight Graphics 2019.2 With Vulkan Profiling Support


NVIDIA --

Released for GDC/GTC week was Nsight Graphics 2019.2, the proprietary cross-platform, closed-source utility tool for debugging, profiling, and analyzing Direct3D, OpenGL, and other GPU-accelerated APIs.

With this week’s Nsight Graphics 2019.2 release they finally have added Vulkan profiling support. This support allows inspecting GPU performance metrics under Vulkan workloads within the program’s Range Profiler. Other new additions include improvements for running Steam games on Linux, a feedback button, and enhancements to the accelerated structure viewer and API inspector.

For Windows developers there is also improved DirectX Raytracing (DXR) and other additions around Direct3D 12.

More details on Nsight Graphics 2019.2 via developer.nvidia.com.

Nsight Graphics is a great and powerful tool albeit closed-source. AMD meanwhile continues offering their own developer tool-set as open-source like this week’s updates to the Radeon GPU Analyzer and other components.


Today is a Good Day to Learn Python | Linux.com


Get started learning Python with this tutorial from our archives.

The cool thing about Linux and FOSS is also an aggravating thing, which is that sometimes there’s too much of a good thing. There is such an abundance of goodies that it can be overwhelming. So I am here to help you decide which programming language you should learn next, and that is Python. Oh, yes, it is.

Why Python? I like it because it is clean and straightforward. It’s a great introduction to object-oriented languages. The Python world is beginner-friendly and, as a general-purpose language, Python can be used for all sorts of things: quick simple scripts, games, Web development, Raspberry Pi — anything you want. It is also in demand by employers if you’re thinking of a career.

There are numerous excellent Python books and tons of online documentation. I want to show off Python’s coolness for beginners so you will get excited and go “Yes! I too must love Python!”

But what about all the other languages? Don’t worry, they won’t get lonesome, and everything you learn in Python is applicable to many other languages as well.

What Stuff Means

I think most of us learn terminology better with hands-on exercises, but there are four things to know from the start.

The first is Python is strongly typed. As you study Python, you will see this repeated a gazillion times. What does this even mean? Who uses a typewriter? Fortunately, it has nothing to do with typewriters, but rather with how Python handles data types. All computer programs are made of two things: data, and operating on that data. Data comes in different types, and the types determine how your programming language will handle them. Data types include characters or strings, which are literal numbers and letters, like names and addresses; integers and floating point numbers that are used in calculations; Boolean values (true/false); and arrays, which are lists of data of all the same data types.

Python enforces data types and relies on you to define them. Weakly typed languages decide for themselves what your data types are, so the data type can change depending on context.

For example, most any programming language will add the integers 1 + 2 + 3. A weakly typed language may also let you add integers and text strings, for example 5 + helloworld. If you try to do this in Python, your code will fail and you will get an error message. Weakly typed languages don’t do this randomly; this is a feature intended to add speed and flexibility by not requiring you to define your data types.

However, weak typing can lead to strange errors. One of the most common errors involves converting strings of numbers to integers when you really want them to be a literal string, like 221B Baker Street, 10,000 Maniacs, or 23andMe. In my modest opinion, it is better to learn the discipline and structure of a strongly typed language, and then try out weakly typed languages after you have experience and good grounding in the basics.

The second thing to know is what the heck is object oriented programming (OOP)? An object is a clump of data and procedures grouped into a single reusable entity. If you were coding a car racing game you might have a car object, an obstacle object, and a driver object. So, you say, objects are just like functions, right? Yes. If you already understand how to organize code into properly grouped functions and variables, then you already understand OOP. There are finer points to OOP such as classes, inheritance, and polymorphism; again, if you think in terms of sensible organization these things are easier to understand.

Third, white space has meaning in Python. You have to get your white spaces right or your code won’t work.

Fourth, Python is an interpreted language. You don’t have to compile and link your Python programs. If you’re experienced with the Bash shell, then you already know about interpreted languages, how fast they are to code in, and how you can test out your programs interactively before writing them into a script.

The downside to interpreted languages is the overhead of the interpreter. Usually, programs written in compiled languages run faster. However, you can link your Python programs to functions written in many other languages, including C/C++, Lisp, Fortran, Java, and Perl, and many more so you can mix and match to get the results you want.

Try It

Python is included in most Linux distributions, and usually the python package installs the base components and Python command interpreter. The text in bold is what you type.

$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> help()

Welcome to Python 2.7!  This is the online help utility.

If this is your first time using Python, you should definitely check out
the tutorial on the Internet at http://docs.python.org/2.7/tutorial/.

Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules.  To quit this help utility and
return to the interpreter, just type "quit".

To get a list of available modules, keywords, or topics, type "modules",
"keywords", or "topics".  Each module also comes with a one-line summary
of what it does; to list the modules whose summaries contain a given word
such as "spam", type "modules spam".

help> topics

Here is a list of available topics.  Enter any topic name to get more help.

ASSERTION  DEBUGGING LITERALS SEQUENCEMETHODS2
ASSIGNMENT DELETION  LOOPING  SEQUENCES
[...]
help> quit

Of course we must do the traditional Hello World! Strings must be enclosed in single or double quotes.

>>> 'Hello, world!'
'Hello, world!'
>>> hell = "Hello, world!"
>>> hell
'Hello, world!'

Now create the simplest possible Python script, save it as hello.py, and run it from your normal Linux shell:

#!/usr/bin/python

print "Hello World!";

carla@studio:~$ python hello.py
Hello World!

Let’s go back to the Python interpreter and play with data types.

>>> 2 + 2
4
>>> 2 + foo
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'foo' is not defined
>>> foo = 5
>>> 2 + foo
7

Now try a short interactive script. It asks you to input your age, responds according to the age you type, and checks if your response is in the correct data type. This is a great little script to tweak in different ways. For example, you could limit the acceptable age range, limit the number of incorrect tries, and get creative with your responses. Note that raw_input is for Python 2.x, and 3.x uses input.

Watch your indentation; the indented lines must be four spaces. If you are using a proper code editor, it should take care of this for you.

#!/usr/bin/python

while True:
    try:
        age = int(raw_input("Please enter your age: "))
    except ValueError:
        print("I'm so very sorry, that does not compute. Please try again.")
        continue
    else:
        break
if age >= 18: 
    print("Very good, you are old enough to know better, but not too old to do it anyway.")
else:
    print("Sorry, come back when you're 18 and try again.")

Modules and Learning

There are a great number of Python modules, and you can learn to write your own. The key to writing good Python programs and making them do what you want is learning where to find modules. Start at Python.org because of the abundant documentation and good organization. Plan to spend a lot of time here, because it contains the best and authoritative information. It even has an interactive shell you can practice with.

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