Docker Cookbook


Using Cluster IP Services for Dynamic Linking of



Download 6,31 Mb.
Pdf ko'rish
bet124/260
Sana21.04.2022
Hajmi6,31 Mb.
#570749
1   ...   120   121   122   123   124   125   126   127   ...   260
Bog'liq
Docker Cookbook

5.8 Using Cluster IP Services for Dynamic Linking of
Containers
Problem
You want to 
link
containers across multiple hosts in your cluster instead of running
multiple containers per pod. This is the more cloud-native way of designing an appli‐
146 | Chapter 5: Kubernetes


cation, where layers that can scale and can operate separately from each other run as
separate replication controllers.
Solution
In 
Recipe 5.7
, you started WordPress by running the MySQL and WordPress contain‐
ers in a single pod. The two containers started on the same host. You took advantage
of the fact that a pod has a single IP address to set the WordPress MySQL host to
localhost
. However, you could imagine running a replicated MySQL service and/or
a replicated WordPress frontend. This would mean that the containers would run on
different hosts in the cluster.
Kubernetes services are smart proxies that keep track of changes in pod cluster allo‐
cation and update their port mapping dynamically when pods get rescheduled.
A better way of running our canonical WordPress example would be to run MySQL
as a single pod or replication controller (glancing over the issues with database repli‐
cation and data persistence) and then exposing this MySQL service through a Kuber‐
netes service definition.
The replication controller would look something like this:
apiVersion: v1
kind: ReplicationController
metadata:
name: wp-mysql
spec:
replicas: 1
selector:
tier: wp-mysql
template:
metadata:
labels:
tier: wp-mysql
spec:
containers:
- name: mysql
image: mysql
ports:
- containerPort: 3306
env:
- name: MYSQL_ROOT_PASSWORD
value: wordpressdocker
- name: MYSQL_DATABASE
value: wordpress
- name: MYSQL_USER
value: wordpress
- name: MYSQL_PASSWORD
value: wordpresspwd

Download 6,31 Mb.

Do'stlaringiz bilan baham:
1   ...   120   121   122   123   124   125   126   127   ...   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