Docker Cookbook



Download 6,31 Mb.
Pdf ko'rish
bet119/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   115   116   117   118   119   120   121   122   ...   260
Bog'liq
Docker Cookbook

138 | Chapter 5: Kubernetes


5.4 Starting Containers on a Kubernetes Cluster with Pods
Problem
You know how to start containers by using the Docker command-line interface. Now
you would like to use Kubernetes to schedule your containers in a cluster.
Solution
You have a Kubernetes cluster available to you, either through 
Recipe 5.3
 or 
Recipe
5.9
 or a public cloud provider like Google Container Engine. In addition, you have
downloaded the Kubernetes client 
kubectl
and it is set up to use your cluster end‐
point with the appropriate authentication (see 
Recipe 5.15
).
As explained in 
Recipe 5.1
, containers are scheduled as a group by defining pods.
Therefore, to start your first container, you need to write a pod definition in JSON or
YAML and use the 
kubectl
client to submit it to the Kubernetes API server.
Let’s start with a fun example and run the 2048 game. A Docker image is available on
the 
Docker Hub
, and I will leave it to you to check out the Dockerfile. Save the YAML
file shown here as 
2048.yaml
:
apiVersion: v1
kind: Pod
metadata:
name: 
"2048"
spec:
containers:
- image: cpk1224/docker-2048
name: 
"2048"
ports:
- containerPort: 80
hostPort: 80
You can now submit it to your cluster:
$ kubectl create -f 2048.yaml
pods/2048
Once the image is downloaded, the container will start running. You should be able
to use your browser and open the 2048 game on the IP of the host that is running it.
You will need to open any firewall rules that may prevent you from doing so.
Discussion
The YAML file specifies the API version (i.e., 
v1
) and the kind of object it defines
(i.e., pod). Then some metadata needs to be set to specify a name for this pod. In this
example, a single container is started, but there could be several. All would be defined

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   115   116   117   118   119   120   121   122   ...   260




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish