Professional Documents
Culture Documents
Deploy Container Applications Using Kubernetes: Implementations with microk8s and AWS EKS Shiva Subramanian full chapter instant download
Deploy Container Applications Using Kubernetes: Implementations with microk8s and AWS EKS Shiva Subramanian full chapter instant download
Deploy Container Applications Using Kubernetes: Implementations with microk8s and AWS EKS Shiva Subramanian full chapter instant download
https://ebookmass.com/product/a-complete-guide-to-devops-with-
aws-deploy-build-and-scale-services-with-aws-tools-and-
techniques-osama-mustafa/
https://ebookmass.com/product/kubernetes-programming-with-go-
programming-kubernetes-clients-and-operators-using-go-and-the-
kubernetes-api-1st-edition-philippe-martin/
https://ebookmass.com/product/kubernetes-programming-with-go-
programming-kubernetes-clients-and-operators-using-go-and-the-
kubernetes-api-1st-edition-philippe-martin-2/
https://ebookmass.com/product/designing-applications-for-google-
cloud-platform-create-and-deploy-applications-using-java-
ashutosh-shashi/
Serverless Web Applications with AWS Amplify: Build
Full-Stack Serverless Applications Using Amazon Web
Services Akshat Paul
https://ebookmass.com/product/serverless-web-applications-with-
aws-amplify-build-full-stack-serverless-applications-using-
amazon-web-services-akshat-paul/
https://ebookmass.com/product/getting-started-with-containers-in-
azure-deploy-secure-cloud-applications-using-terraform-2nd-
edition-shimon-ifrah/
https://ebookmass.com/product/getting-started-with-containers-in-
azure-deploy-secure-cloud-applications-using-terraform-2nd-
edition-shimon-ifrah-2/
https://ebookmass.com/product/getting-started-with-angular-
create-and-deploy-angular-applications-1st-edition-victor-hugo-
garcia/
https://ebookmass.com/product/observability-with-grafana-monitor-
control-and-visualize-your-kubernetes-and-cloud-platforms-using-
the-lgtm-stack-rob-chapman/
CHAPTER 1
Dependency Hell
Anyone who has installed Microsoft runtime libraries on a Windows VM running
multiple applications or had to upgrade a package system in Linux can tell you how
complex this can be.
Ever since computers made it into the business applications’ world, supporting
real-world applications and problem solving, there has always been the problem of
dependencies among the various components, both hardware and software, that
comprise the application stack.
The technical stack the application software is written on, for example, Java, has
versions; this Java version is designed to run on top of a specified set of runtime libraries,
which in turn run on top of an operating system; this specified operating system runs
on top of a specified hardware device. Any changes and updates for security and feature
enhancements must take into account the various interconnects, and when one breaks
compatibility, we enter the dependency hell.
1
© Shiva Subramanian 2023
S. Subramanian, Deploy Container Applications Using Kubernetes,
https://doi.org/10.1007/978-1-4842-9277-8_1
Chapter 1 From VMs to Containers
This task of updating system components was even more complicated when IT
systems were vertically scaled, where there was one underlying operating system and
many applications that ran on top of it. Each application might come with its own runtime
library requirements; an OS upgrade might not be compatible with the dependencies of
some applications running on top, creating technical debt and operational complexity.
The VM Way
Task: Suppose the developers have developed a static website which they have asked
you to host in your production environment.
As a seasoned systems engineer or administrator, you know how to do this. Easy!, you
say. I’ll create a VM, deploy a web server, and voilà! But what’s the fun in that? However,
let us still deploy the static website the traditional way and the container way. This way,
we will learn the similarities and differences between the two approaches. Thus
2
Chapter 1 From VMs to Containers
Note There are several virtual machine technologies available, such as the cloud,
ESXi host, VMware Workstation, Parallels, KVM, etc. Instructions for installing the
Linux operating system will vary widely depending on the virtualization software in
use; thus, we assume that the systems engineer/administrator is familiar with their
workstation setup.
lsb_release -s -d
Note The author has chosen to list plain command(s) only at the top of the listings
and the executed output and results right below it, making it easy to differentiate
between the command and the author’s illustrated outputs as shown in Listing 1-1.
3
Chapter 1 From VMs to Containers
lsb_release -s -d
shiva@wks01:~$ lsb_release -s -d
Ubuntu 22.04 LTS
shiva@wks01:~$
The package name for nginx is just nginx; thus, we will install
nginx using the standard package manager command as shown in
Listing 1-3.
4
Chapter 1 From VMs to Containers
Note <SNIP> in the output section indicates the sections of the output snipped
out of the listing to maintain brevity; it does not impact the concepts we are
learning.
5
Chapter 1 From VMs to Containers
Please note that your mileage may vary with respect to the
output messages due to variations in installed editions of the
operating system.
This marks the end of step 2, which is installing the web server;
now on to step 3.
Listing 1-5. Browsing to the nginx default website using the command line
curl localhost
6
Chapter 1 From VMs to Containers
Enter Containers
Welcome to the wonderful world of containers.
Containers solve both of the major problems associated with the VM way:
7
Chapter 1 From VMs to Containers
Here, the term image refers to the binary format or artifact of the
technology container.
1
https://cloud.google.com/containers
8
Chapter 1 From VMs to Containers
each application in its own container as the resource required to run a container is
very minimal; you will not be conserving any resources and will be reintroducing the
dependency management complexity that got us here in the first place!
Summary
In this chapter, we learned about two of the major problems associated with deploying
and managing an application and how containers promise to solve both the problems,
enabling systems engineers to reduce complexity while increasing efficiency, scalability,
and reliability of hosting applications via containers.
In the next chapter, we will deploy a simple static application via container
technology, realizing for ourselves how easy it is to deploy and manage applications
deployed via containers.
9
CHAPTER 2
Container Hello-World
Continuing from where we left off in the VM world, the goal of this chapter is to set up
container technology in our workstation and run our first container, hello-world, and
nginx web server, using docker with the intent to learn the basics of containers.
Docker Technology
When we say containers, for many, Docker comes to mind, and with a good reason.
Docker is a popular container technology that allows for users and developers to
build and run containers. Since it is a good starting point and allows us to understand
containers better, let us build and run a few containers based on docker technology
before branching out into the world of Kubernetes.
11
© Shiva Subramanian 2023
S. Subramanian, Deploy Container Applications Using Kubernetes,
https://doi.org/10.1007/978-1-4842-9277-8_2
Chapter 2 Container Hello-World
The astute reader will notice and ask: Why do we need a VM still? I thought we were
going with containers. The short answer is, yes, we still need a host machine to provide
compute, that is, the CPU, memory, and disk, for the containers to run; however, the
VM can be replaced with special-purpose host OSes that can be stripped down to a bare
minimum; we will learn more about compute nodes and observe these in later chapters.
First, let us install the docker package onto our workstation as shown in Listing 2-1.
12
Chapter 2 Container Hello-World
Scanning processes...
Scanning linux images...
Running kernel seems to be up-to-date.
No services need to be restarted.
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
shiva@wks01:~$
The Docker package is installed; to confirm the same, run the command shown in
Listing 2-2.
dpkg -l docker.io
Note Highlights in the output show the key elements we are looking for in the
output section.
13
Chapter 2 Container Hello-World
shiva@wks01:~$
Notice docker is in active (running) state; this is good. We can now set this user up
for using docker.
14
Chapter 2 Container Hello-World
Note Unless noted otherwise, remarks starting with # are NOT part of the system
output; it is used by the author to highlight something being present or not present
as a form of explanation.
For this to take effect, you can log out and log back in or add the newly added group
to the current session by using the command shown in Listing 2-5.
Listing 2-5. Changing the acting primary group for the regular user
newgrp docker
Before proceeding, we need to verify the group docker shows up in our session; we
can do that by executing the command shown in Listing 2-6.
id
shiva@wks01:~$ id
uid=1000(shiva) gid=112(docker) groups=112(docker),4(adm),24(cdrom),
27(sudo),30(dip),46(plugdev),110(lxd),1000(shiva)
shiva@wks01:~$
15
Chapter 2 Container Hello-World
At this point, we have met the first prerequisite of installing and running the CRI.
Now that we have installed the container runtime and the service is running,
we need an image to run. This act of running an image using a container runtime is
generally known as container, and the process of packaging an application to run inside
the container is generally known as containerizing an application. More on that later.
A simple hello-world application exists for the container world also; let us run that to
make sure our setup is working properly before moving ahead.
Container Hello-World
Run the command to start our first container as shown in Listing 2-7. What this
command does is it instructs docker to find and run a container named hello-world; not
to worry, if this image is not present, docker is smart enough to download this image
from its default container repository and then run it. More on container repositories in
later chapters.
16
Chapter 2 Container Hello-World
4. The Docker daemon streamed that output to the Docker client, which sent
it to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
shiva@wks01:~$
Notice, right below the status: line, the output says “Hello from Docker!”. This
confirms our docker setup is functioning correctly. The description from the output
further elaborates what happened in the background. Docker service pulled the image
from Docker Hub and ran it. Container images are stored in container repos and are
“pulled” by the runtime as necessary. More on container repos later.
Congratulations! You just ran your first container!
Now that we have our workstation set up, we can now run the nginx container using
the command shown in Listing 2-8. In this command, first we are stopping the nginx
that’s running on the Linux workstation we started in Chapter 1, then we are asking
docker to run the nginx container and map localhost port 80 to container port 80.
If the container image is not locally found, docker automatically downloads it and
then runs it.
The port 80 mapping is so we can access container port 80 from the localhost,
meaning our Linux workstation, on port 80.
Currently, we are just using all defaults; we can change the mapped ports, etc.; more
on this later.
Have two terminal windows open and run the command in one window; run the
sudo and docker commands shown in Listing 2-8 in one window and run the curl
command shown in Listing 2-9 in another window.
17
Chapter 2 Container Hello-World
18
Chapter 2 Container Hello-World
Notice how the docker launched the nginx container; the container then started the
nginx worker threads; docker would have also mapped port 80 so that we can access the
default website. We can do that using curl on terminal 2, which we opened earlier, as
shown in Listing 2-9.
Notice how easy that was; in one command, we were able to deploy the static
website, the task that required a full VM install as we did in the previous chapter. The
memory and disk footprint is also very small when compared to a full VM. You can now
press CTRL+C on the terminal running the docker run command.
19
Chapter 2 Container Hello-World
Summary
In this chapter, you learned how to set up your workstation to begin working with
containers, installed Docker, and ran your first two container applications – the hello-
world container and a web server – using the stock nginx container image, as well as
how to map a port on the container to your local workstation so that you can access the
services the container is providing.
In the next chapter, we’ll begin building on what you have learned so far, expanding
on learning more container basic commands and concepts using Docker.
Your Turn
Whatever your workstation flavor is, ensure docker is set up and running like we have
done here as well as run the two sample containers and ensure we receive the expected
results. The next chapters build on what we have set up here.
20
Another random document with
no related content on Scribd:
Már nem tudom biztosan, hogyan akadtam akkor össze az ódon
kikötővárosban, a «Barlang»-ban Peninával és társaival. Amaz üres
éjjelek egyikén volt, amelyek sivárságban és vágyódásban és
végeszakadatlan, értelem és cél nélkül való nyugtalan ide-
odajárkálásban telhetnek el és amelyeket mindenki ismer, aki
idegenben ifjú évei tanácstalansága miatt szenvedett. Hogy
ifjúságunk magárahagyatottsága áldássá váljék, erő kell hozzá és
valami cél, a fejlődés tervtelen éveiben ez a magárahagyatottság a
legjobbak közül is nem egyre nézve végzetessé vált.
Kis Penina, virág az utca porában, nem foglak elfeledni, tündöklő
ékesség lelkem ruháján. Kedves a nap, amelyen megtaláltalak és
elhagytalak, hogy többé el ne veszítselek. Emlékezetem kertjében
tovább virulsz, pedig nem ápollak, nem is gondozlak. Sőt megtörtént,
hogy hosszú időre elvesztél emlékezetemből, jó napokban vagy
veszedelmes jólétben, amelyet mulandó dolgok adhatnak nekünk.
De hideg szélben, vészes és zord úton megnyugtatásomul,
békességemül ismét érzem illatodat a lelkemben. Vannak a léleknek
virágai, amelyek csak akkor nőnek, virulnak és illatoznak, ha a szél
és a fény áthatol az összetépett kabát rongyain, selyem és prém
alatt elhervadnak és ha ápolt kéz gondozza őket, elszárad a kelyhük.
Ilyen virágok kedvéért rohantam mindig újra a vándorlás
bizonytalanságába és békétlenségébe. A magányosság
elégedetlenségében lakozik a legtisztább remény, az egyik a
csendből hallja ki Isten szavát, a másik inkább a viharból, sőt van
ember, aki csak külső viharban leli meg belső nyugalmát. Sokaknak
a jelenségek értelmébe való hosszú szemlélődő elmerülés után
villan meg valamelyik életigazságuk fénye, másoknak ellenben
hirtelen egész lényük megrázkodtatásában nyilvánul meg, itt szelid
mosolynak enged az akadály, amott könnyek árja omlik és az
eltakart fenékről elmossa a zavarodottságot és lényünk szerint az
enyhe fény vagy az égő áram csábit bennünket. De nem mindig a
megismerés a végső cél? Ha másképpen tudjátok, oktassatok ki. Én
úgy láttam, hogy a világon minden nemes harc a megismerésért
folyik, mert ez ad erőt nagy áldozatra és biztositja az egyetértést.
A késő éjben messziről halvány fényt láttam az utcán. Feléje
tartottam, mert magához csalogatott, de egyszersmind bizonyos
kellemetlen érzést is okozott. Akkoriban egy timármesternél
dolgoztam, aki nem mintha valóban szüksége lett volna reám,
hanem inkább szánalomból időnként alkalmazott, hogy végre némi
rendet teremtsen könyvei és irományai közt. Időközben meg kellett
látogatnom üzletfeleit, különböző megbizásokat végeztem és
bevásároltam a számára. Még nem voltam húsz éves.
Az a társaság, amelyet éjjel a «Barlang»-ban, ebben a legutolsó
lebujban találtam, sokáig lekötötte érdeklődésemet és ez betöltötte
életemet. Külsőleg kevéssé különbözhettem azoktól a fickóktól, akik
közé keveredtem, bár volt még valami pénzem, de a ruhám eléggé
szegényes volt. Minden akadékoskodás nélkül fogadtak maguk
közé, mint ahogyan azok az emberek szokták, akik egészen jól
tudják, hogy nem egykönnyen akad ember, akinek még nagyobb
elnézésre van szükségük, mint maguknak. Köztük ült Penina,
vérvörös kartonbluz volt rajta, világos haján színtelen kendő és
különös szeme szürke volt és kissé ferde. Nagy szája a sóvárgás és
szomorúság szenvedő kifejezésével, az ajak minden ivelése nélkül,
széles volt és egyenes, mintha erős ecsetvonással festették volna és
csaknem színtelenül illeszkedett bele keskeny állába. Arca, mint
egész lénye egyszerre megragadta az érzékeket és fájdalmas
édességében mégis valami elpusztított fönség volt, valami távoli,
világos ég tükröződött benne.
Félreismerhetetlen hajlandósággal az odaadásra ült, csaknem
feküdt egy karcsú legény mellett, akiről nem tudtam levenni a
szememet, bár gúnyosan lekicsinylő tekintete elárulta, hogy nem
akar rólam tudni és már rövid idő mulva leplezetlenül kimutatta
megvetését. De arca annyira tele volt gonosz, kemény élettel, olyan
komor, szép és hetyke egyszersmind, hogy majd gonosztevőnek tünt
föl, majd fiatal uralkodónak, aki itt romlásnak és megalázásnak tette
ki a méltóságát. Kubas volt a neve.
Egészen pontosan nem tudtam fölismerni, kikkel volt
tulajdonképpen dolgom ebben a társaságban, egyet azonban hamar
megláttam: könnyen vették az életet. Ámbár csupa fiatalember volt
együtt, a korán tapasztalatot szerzett emberek dacos fölsőbbségével
viselkedtek, szemtelen biztosságot mutattak, hallgatások ravasz volt
és öntudatos, egykedvűen vették gonoszságukat és vakmerőségük
tele volt megvetéssel a polgári társaság jogai iránt, amelyet
gyűlöltek. Mert az utca korán edz és érlel, nevelése senkit sem
kényeztet el és zavaros hullámaiban gyakorlottabb úszók vannak,
mint a biztosított életviszonyok csöndes árjában. Fiatalságában
tetterősebbnek, vakmerőbbnek és életrevalóbbnak bizonyult nem
egy ezek közül az elzüllött legények közül, mint sokan, akik hasznos
óvatosságuk szegénysége miatt sohasem lettek emberek, akik nem
mennek ugyan tönkre, de nem is állnak meg a maguk erejéből.
Néhány nap mulva, amikor egymagamban ültem, Kubas odajött
hozzám és ezt kérdezte:
– Mit akarsz itt nálunk?
– Nem tudom.
– Nekem mondod? Peninát akarod.
Rettenetesen megijedtem, de Kubas megrendíthetetlenül
nyugodt volt. Becsmérlőleg nevetett és kiváncsian nézett reám.
– Nem akarom őt, – feleltem.
– Dehogy nem akarod. Meg is kaphatod, de ne ajánljál neki
pénzt, nagyon érzékeny. A pénzt nekem adhatod.
Érzelmeimet nem tudtam rendezni, megrohantak, mint
vadászkutyák a vadat. Szeme észrevette legtitkosabb óhajaimat,
amelyeket magamnak sem mertem bevallani és megláttam benne,
hogy gyalázatosan visszaél velük és bepiszkolva
megszentségteleníti őket. Szeme egyszersmind fenyegetődzött,
csak az a kivánság lelkesítette, hogy beleegyezésemet hallja. Ez a
követelés volt a leghatalmasabb e pillanatban, nekem támadt és
védekeztem ellene, amikor ezt mondtam:
– Penina téged szeret.
És hirtelen hatása alatt mindannak, amit szemem a legutóbbi
napokban forró csodálattal, szánalommal és haraggal látott,
folytattam:
– Tiéd ő egész szívével, lelke legmélyéből. Ha beszélsz, reszket
a figyelemtől, ha elmégy, elhal és föllélekzik, visszatér beléje az élet,
ha visszajösz. Az árnyékod ő, betakar a szeretetével, amely
áhitatosabb bármely imádságnál. Amikor egyszer megütötted,
reszketett meghatottságában, mert durvaságodban csak azt látta,
hogy törődsz vele … és most… azt mondod nekem…
Kubas kiváncsian vizsgált. Halvány, gonosz arcán semmi
elfogultság nem látszott. Ez az ember valóban gonosz volt,
gonosznak született, az volt hiúság és megbánás nélkül. Gonosz volt
legbelsőbb hajlamánál fogva csak magáért a gonoszságáért, nem
bánatból vagy bosszúérzetből, nem is csalódásból vagy
elkeseredésből, csak legsajátosabb énjének engedelmeskedett és a
gonoszságban egyszerű volt és erős. Megértettem, hogy Penina az
élettől való félelemtől megborzadva egészen odaadta magát neki.
Ezt a félelmet csak az ifjúság ismeri, amely még azt hiszi, hogy a lét
elemei valami titkos igazságosztás jóakaratától függnek. Most
értettem meg először a gonoszságot, amely eredetére és értelmére
nézve a napi jelenségek hiábavalóságától egészen a vallás
miszteriumáig örökre titok marad nekünk embereknek.
Kubas gondolkodott.
– Te bolond, hiszen ha nem úgy volna, ahogyan mondod, nem
ajánlhatnám föl neked. Azt hiszed különben, hogy valami ujság ez
neki? Utólag fizethetsz. Nos?
Az után, amit mondtam, biztos volt ellenszolgáltatásomról, mert a
gonoszok sokkal tisztábban ismerik föl az érzés őszinteségét vagy
hamisságát, mint ahogyan az érző emberek a gonoszság örvényeit
egész mélységükben csak megérteni merészelhetnék is.
Mivel hallgattam, Kubas hirtelen és anélkül, hogy megkötöttük
volna az üzletet, fölkelt. Amikor az ivószobából távoztam, láttam,
hogy szép, kemény, élesráncú arcával egy darab papirosra hajolva a
gázláng szegényes vilgításánál firkálgat valamit. Penina nem volt ott,
a sötét kapualjban a kijáratnál találkoztam vele.
– Gyere velem, – mondtam, – csak egy pillanatra.
– Benn van Kubas? – kérdezte alt hangján.
Kisebbnek láttam, mint máskor, az utcai halvány fény ráesett
szánandó gyermekvállára és úgy látszott, hogy fázott nyomorúságos
ruhájában, amely izgatóan mutatta testének formáit. Ősz is volt már
és az alkonyatban falevelet és papirdarabokat kergetett az utcán a
szél.
– Később is ott lesz még. Kérlek, gyere, kérlek.
Habozva jött velem, minden együttérzés nélkül. Egy lámpánál
megállott és kérdő tekintettel nézett föl reám. Összeszedtem
magamat:
– Penina, szegény kis Penina… ez a Kubas…
– Hallgass!
Szava ütött és úgy talált, mint valami kéz a sötét levegőből. Én
ostoba, aki szánalmat mertem mutatni a szeretetnek és megvetést a
tárgyának. Egyetlen szót sem tudtam többé mondani, se szegényt,
se gazdagot, megrendülve és tehetetlenül állottam az utcai szélben
és nem volt gondolatom. Csak az az egy tudat gyötört a
kínszenvedésig: nem fogom legyőzni az életet, nem fogok rajta
uralkodni.
Penina vizsgálódva, csaknem kutató szomorúsággal rám nézett
és hirtelen, mintha valami régen elvesztettet fedezett volna föl
arcvonásaimban, elfordította a fejét és lerázva a kezemet válláról,
homlokával nekidőlt a vas lámpaoszlopnak és sírt. Arcát nem takarta
el a kezével, sírt, mint ahogyan sötét felhőből zápor zuhog a földre.
– Hát így van, – mondta lassan, amikor lecsillapodott. – Ne gyere
többé közénk. Hallod? A te utad a világosságba vigyen.
Elfutott és eltűnt a szemem elől a régi kapú sötét torkában, a
melyen korcsmacégér fölött kicsiny, vöröses fényű lámpa égett.
Soha sem láttam többé.
De míg mi el vagyunk telve becsületességünk látszólagos
gazdagságával, addig talán a világ örök lelkiismerete kimondta az
irgalom megváltó szavát Peninára, akinek tisztasága elvesztett
egéért omlott égő könnye minden bűnt kimosott lelke ruhájából.
Csak sokkal később életem folyamán, amikor megkezdődött
gondolataim harca az egyetlen, a nagy megváltás szóért, állott
Penina ismét mellém és könnyeit, mint valami fénylő követ,
odanyujtotta kétkedésem sötétségébe.
NEGYEDIK FEJEZET.
Az első vacsora.