Konceptet bazë
Grup Kubernetes
Instalimi
Testoni serverin tuaj Kubernetes
Shembull: Vendosja e një rrjeti Selenium duke përdorur Kubernetes
Vetë-shërimi
Shkallëzimi i rrjetit tuaj të selenit
Kubernetes është një platformë me burim të hapur e zhvilluar nga Google për menaxhimin e aplikacioneve me kontejnerë nëpër një grup serverësh. Ai bazohet në një dekadë e gjysmë përvojë që Google ka me drejtimin e grupeve të kontejnerëve në shkallë , dhe u ofron zhvilluesve infrastrukturën e stilit të Google, duke shfrytëzuar projektet më të mira me burim të hapur, të tilla si:
- Docker : një teknologji e kontejnerëve të aplikimit.
- Etcd : një dyqan të dhënash me vlerë kyçe të shpërndarë që menaxhon informacionin në të gjithë grupin dhe ofron zbulimin e shërbimit.
- Flannel : një pëlhurë e mbivendosur e rrjetit që mundëson lidhjen e kontejnerëve nëpër serverë të shumtë.
Kubernetes i lejon zhvilluesit të përcaktojnë infrastrukturën e tyre të aplikacionit në mënyrë deklarative përmes skedarëve dhe abstraksioneve YAML si Pods, RC dhe Shërbimet (më shumë për këtë më vonë) dhe siguron që grupi themelor të përputhet me gjendjen e përcaktuar nga përdoruesi në çdo kohë.
Disa nga veçoritë e tij përfshijnë:
- Planifikimi automatik i burimeve të sistemit dhe vendosja automatike e kontejnerëve të aplikacionit nëpër një grup.
- Shkallëzimi i aplikacioneve në fluturim me një komandë të vetme.
- Përditësimet e vazhdueshme me kohë joproduktive.
- Vetë-shërimi: riprogramimi automatik i një aplikacioni nëse serveri dështon, rinisja automatike e kontejnerëve, kontrollet shëndetësore.
Kalo përpara te Instalimi nëse tashmë e njeh Kubernetes.
Konceptet bazë
Kubernetes ofron abstraksionet e mëposhtme (njësi logjike) për zhvilluesit:
- Bishtajat.
- Kontrollorët e përsëritjes.
- Etiketat.
- Shërbimet.
Bishtajat
Është njësia bazë e ngarkesave të Kubernetes. Një pod modelon një "host logjik" specifik të aplikacionit në një mjedis të kontejneruar. Në terma laikë, ai modelon një grup aplikacionesh ose shërbimesh që përdoreshin në të njëjtin server në botën e para-kontejnerëve. Kontejnerët brenda një pod ndajnë të njëjtën hapësirë të emrave të rrjetit dhe mund të ndajnë gjithashtu vëllime të dhënash.
Kontrollorët e përsëritjes
Pods janë të shkëlqyera për grupimin e kontejnerëve të shumtë në njësi logjike të aplikimit, por ato nuk ofrojnë përsëritje ose riprogramim në rast të dështimit të serverit.
Këtu vjen i dobishëm një kontrollues replikimi ose RC. Një RC siguron që një numër pods i një shërbimi të caktuar të funksionojë gjithmonë nëpër grup.
Etiketat
Ato janë meta të dhëna me vlerë kyçe që mund t'i bashkëngjiten çdo burimi të Kubernetes (pods, RC, shërbime, nyje, ...).
Shërbimet
Pods dhe kontrollorët e replikimit janë të shkëlqyeshëm për vendosjen dhe shpërndarjen e aplikacioneve nëpër një grup, por podet kanë IP kalimtare që ndryshojnë pas riprogramimit ose rinisjes së kontejnerit.
Një shërbim Kubernetes ofron një pikë përfundimtare të qëndrueshme (lidhje fikse IP + porta virtuale me serverët pritës) për një grup pods të menaxhuara nga një kontrollues replikimi.
Grup Kubernetes
Në formën e tij më të thjeshtë, një grup Kubernetes përbëhet nga dy lloje nyjesh:
- 1 mjeshtër Kubernetes.
- N nyje Kubernetes.
Mjeshtër Kubernetes
Masteri Kubernetes është njësia e kontrollit të të gjithë grupit.
Përbërësit kryesorë të masterit janë:
- Etcd: një dyqan të dhënash në dispozicion globalisht që ruan informacione rreth grupit dhe shërbimeve dhe aplikacioneve që funksionojnë në grup.
- Serveri Kube API: ky është qendra kryesore e menaxhimit të grupit Kubernetes dhe ekspozon një ndërfaqe RESTful.
- Menaxheri i kontrolluesit: trajton riprodhimin e aplikacioneve të menaxhuara nga kontrollorët e riprodhimit.
- Scheduler: gjurmon përdorimin e burimeve në të gjithë grupin dhe cakton ngarkesat e punës në përputhje me rrethanat.
Nyja Kubernetes
Nyja Kubernetes janë serverë punëtorë që janë përgjegjës për ekzekutimin e pods.
Përbërësit kryesorë të një nyje janë:
- Docker: një demon që drejton kontejnerët e aplikacioneve të përcaktuara në pods.
- Kubelet: një njësi kontrolli për pods në një sistem lokal.
- Kube-proxy: një përfaqësues i rrjetit që siguron rrugëtim të saktë për shërbimet e Kubernetes.
Instalimi
Në këtë udhëzues, ne do të krijojmë një grup me 3 nyje duke përdorur serverët CentOS 7:
- 1 mjeshtër Kubernetes (kube-master)
- 2 nyje Kubernetes (kube-node1, kube-node2)
Mund të shtoni sa më shumë nyje shtesë që dëshironi më vonë duke ndjekur të njëjtën procedurë instalimi për nyjet Kubernetes.
Të gjitha nyjet
Konfiguro emrat e hosteve dhe /etc/hosts:
# /etc/hostname
kube-master
# or kube-node1, kube-node2
# append to /etc/hosts
replace-with-master-server-ip kube-master
replace-with-node1-ip kube-node1
replace-with-node2-ip kube-node2
Çaktivizo murin e zjarrit:
systemctl disable firewalld
systemctl stop firewalld
Mjeshtër Kubernetes
Instaloni paketat kryesore të Kubernetes:
yum install etcd kubernetes-master
Konfigurimi:
# /etc/etcd/etcd.conf
# leave rest of the lines unchanged
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_LISTEN_PEER_URLS="http://localhost:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://0.0.0.0:2379"
# /etc/kubernetes/config
# leave rest of the lines unchanged
KUBE_MASTER="--master=http://kube-master:8080"
# /etc/kubernetes/apiserver
# leave rest of the lines unchanged
KUBE_API_ADDRESS="--address=0.0.0.0"
KUBE_ETCD_SERVERS="--etcd_servers=http://kube-master:2379"
Filloni etj.
systemctl start etcd
Instaloni dhe konfiguroni pëlhurën e rrjetit të mbivendosjes Flannel (kjo është e nevojshme në mënyrë që kontejnerët që funksionojnë në serverë të ndryshëm të mund të shohin njëri-tjetrin):
yum install flannel
Krijo një skedar konfigurimi Flannel ( flannel-config.json):
{
"Network": "10.20.0.0/16",
"SubnetLen": 24,
"Backend": {
"Type": "vxlan",
"VNI": 1
}
}
Vendosni konfigurimin Flannel në serverin Etcd:
etcdctl set coreos.com/network/config < flannel-config.json
Drejtoni Flannel në serverin Etcd:
# /etc/sysconfig/flanneld
FLANNEL_ETCD="http://kube-master:2379"
Aktivizo shërbimet në mënyrë që ato të fillojnë në nisje:
systemctl enable etcd
systemctl enable kube-apiserver
systemctl enable kube-controller-manager
systemctl enable kube-scheduler
systemctl enable flanneld
Rinisni serverin.
Nyja Kubernetes
Instaloni paketat e nyjeve Kubernetes:
yum install docker kubernetes-node
Dy hapat e ardhshëm do të konfigurojnë Docker për të përdorur mbivendosje për performancë më të mirë. Për më shumë informacion vizitoni këtë postim në blog :
Fshini dosjen aktuale të ruajtjes së dokerit:
systemctl stop docker
rm -rf /var/lib/docker
Change configuration files:
# /etc/sysconfig/docker
# leave rest of lines unchanged
OPTIONS='--selinux-enabled=false'
# /etc/sysconfig/docker
# leave rest of lines unchanged
DOCKER_STORAGE_OPTIONS=-s overlay
Configure kube-node1 to use our previously configured master:
# /etc/kubernetes/config
# leave rest of lines unchanged
KUBE_MASTER="--master=http://kube-master:8080"
# /etc/kubernetes/kubelet
# leave rest of the lines unchanged
KUBELET_ADDRESS="--address=0.0.0.0"
# comment this line, so that the actual hostname is used to register the node
# KUBELET_HOSTNAME="--hostname_override=127.0.0.1"
KUBELET_API_SERVER="--api_servers=http://kube-master:8080"
Install and configure Flannel overlay network fabric (again - this is needed so that containers running on different servers can see each other):
yum install flannel
Point Flannel to the Etcd server:
# /etc/sysconfig/flanneld
FLANNEL_ETCD="http://kube-master:2379"
Enable services:
systemctl enable docker
systemctl enable flanneld
systemctl enable kubelet
systemctl enable kube-proxy
Reboot the server.
Test your Kubernetes server
After all of the servers have rebooted, check if your Kubernetes cluster is operational:
[root@kube-master ~]# kubectl get nodes
NAME LABELS STATUS
kube-node1 kubernetes.io/hostname=kube-node1 Ready
kube-node2 kubernetes.io/hostname=kube-node2 Ready
Example: Deploying a Selenium grid using Kubernetes
Selenium is a framework for automating browsers for testing purposes. It's a powerful tool of the arsenal of any web developer.
Selenium grid enables scalable and parallel remote execution of tests across a cluster of Selenium nodes that are connected to a central Selenium hub.
Since Selenium nodes are stateless themselves and the amount of nodes we run is flexible, depending on our testing workloads, this is a perfect candidate application to be deployed on a Kubernetes cluster.
In the next section, we'll deploy a grid consisting of 5 application containers:
- 1 central Selenium hub that will be the remote endpoint to which our tests will connect.
- 2 Selenium nodes running Firefox.
- 2 Selenium nodes running Chrome.
Deployment strategy
To automatically manage replication and self-healing, we'll create a Kubernetes replication controller for each type of application container we listed above.
To provide developers who are running tests with a stable Selenium hub endpoint, we'll create a Kubernetes service connected to the hub replication controller.
Selenium hub
Replication controller
# selenium-hub-rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: selenium-hub
spec:
replicas: 1
selector:
name: selenium-hub
template:
metadata:
labels:
name: selenium-hub
spec:
containers:
- name: selenium-hub
image: selenium/hub
ports:
- containerPort: 4444
Deployment:
[root@kube-master ~]# kubectl create -f selenium-hub-rc.yaml
replicationcontrollers/selenium-hub
[root@kube-master ~]# kubectl get rc
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
selenium-hub selenium-hub selenium/hub name=selenium-hub 1
[root@kube-master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
selenium-hub-pilc8 1/1 Running 0 50s
[root@kube-master ~]# kubectl describe pod selenium-hub-pilc8
Name: selenium-hub-pilc8
Namespace: default
Image(s): selenium/hub
Node: kube-node2/45.63.16.92
Labels: name=selenium-hub
Status: Running
Reason:
Message:
IP: 10.20.101.2
Replication Controllers: selenium-hub (1/1 replicas created)
Containers:
selenium-hub:
Image: selenium/hub
State: Running
Started: Sat, 24 Oct 2015 16:01:39 +0000
Ready: True
Restart Count: 0
Conditions:
Type Status
Ready True
Events:
FirstSeen LastSeen Count From SubobjectPath Reason Message
Sat, 24 Oct 2015 16:01:02 +0000 Sat, 24 Oct 2015 16:01:02 +0000 1 {scheduler } scheduled Successfully assigned selenium-hub-pilc8 to kube-node2
Sat, 24 Oct 2015 16:01:05 +0000 Sat, 24 Oct 2015 16:01:05 +0000 1 {kubelet kube-node2} implicitly required container POD pulled Successfully pulled Pod container image "gcr.io/google_containers/pause:0.8.0"
Sat, 24 Oct 2015 16:01:05 +0000 Sat, 24 Oct 2015 16:01:05 +0000 1 {kubelet kube-node2} implicitly required container POD created Created with docker id 6de00106b19c
Sat, 24 Oct 2015 16:01:05 +0000 Sat, 24 Oct 2015 16:01:05 +0000 1 {kubelet kube-node2} implicitly required container POD started Started with docker id 6de00106b19c
Sat, 24 Oct 2015 16:01:39 +0000 Sat, 24 Oct 2015 16:01:39 +0000 1 {kubelet kube-node2} spec.containers pulled Successfully pulled image "selenium/hub"
Sat, 24 Oct 2015 16:01:39 +0000 Sat, 24 Oct 2015 16:01:39 +0000 1 {kubelet kube-node2} spec.containers created Created with docker id 7583cc09268c
Sat, 24 Oct 2015 16:01:39 +0000 Sat, 24 Oct 2015 16:01:39 +0000 1 {kubelet kube-node2} spec.containers started Started with docker id 7583cc09268c
Këtu mund të shohim se Kubernetes ka vendosur kontejnerin tim me qendër seleniumi në kube-node2.
Shërbimi
# selenium-hub-service.yaml
apiVersion: v1
kind: Service
metadata:
name: selenium-hub
spec:
type: NodePort
ports:
- port: 4444
protocol: TCP
nodePort: 30000
selector:
name: selenium-hub
Vendosja:
[root@kube-master ~]# kubectl create -f selenium-hub-service.yaml
You have exposed your service on an external port on all nodes in your
cluster. If you want to expose this service to the external internet, you may
need to set up firewall rules for the service port(s) (tcp:30000) to serve traffic.
See http://releases.k8s.io/HEAD/docs/user-guide/services-firewalls.md for more details.
services/selenium-hub
[root@kube-master ~]# kubectl get services
NAME LABELS SELECTOR IP(S) PORT(S)
kubernetes component=apiserver,provider=kubernetes <none> 10.254.0.1 443/TCP
selenium-hub <none> name=selenium-hub 10.254.124.73 4444/TCP
Pas vendosjes së shërbimit, ai do të jetë i arritshëm nga:
- Çdo nyje Kubernetes, nëpërmjet IP-së virtuale 10.254.124.73 dhe portit 4444.
- Rrjetet e jashtme, nëpërmjet IP-ve publike të çdo nyje Kubernetes, në portin 30000.

(duke përdorur IP-në publike të një nyje tjetër Kubernetes)
Nyjet e selenit
Kontrolluesi i riprodhimit të nyjeve Firefox:
# selenium-node-firefox-rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: selenium-node-firefox
spec:
replicas: 2
selector:
name: selenium-node-firefox
template:
metadata:
labels:
name: selenium-node-firefox
spec:
containers:
- name: selenium-node-firefox
image: selenium/node-firefox
ports:
- containerPort: 5900
env:
- name: HUB_PORT_4444_TCP_ADDR
value: "replace_with_service_ip"
- name: HUB_PORT_4444_TCP_PORT
value: "4444"
Vendosja:
Replace replace_with_service_ipnë selenium-node-firefox-rc.yamlme aktuale Selenium shpërndarës shërbimit IP, në këtë rast 10.254.124.73.
[root@kube-master ~]# kubectl create -f selenium-node-firefox-rc.yaml
replicationcontrollers/selenium-node-firefox
[root@kube-master ~]# kubectl get rc
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
selenium-hub selenium-hub selenium/hub name=selenium-hub 1
selenium-node-firefox selenium-node-firefox selenium/node-firefox name=selenium-node-firefox 2
[root@kube-master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
selenium-hub-pilc8 1/1 Running 1 1h
selenium-node-firefox-lc6qt 1/1 Running 0 2m
selenium-node-firefox-y9qjp 1/1 Running 0 2m
[root@kube-master ~]# kubectl describe pod selenium-node-firefox-lc6qt
Name: selenium-node-firefox-lc6qt
Namespace: default
Image(s): selenium/node-firefox
Node: kube-node2/45.63.16.92
Labels: name=selenium-node-firefox
Status: Running
Reason:
Message:
IP: 10.20.101.3
Replication Controllers: selenium-node-firefox (2/2 replicas created)
Containers:
selenium-node-firefox:
Image: selenium/node-firefox
State: Running
Started: Sat, 24 Oct 2015 17:08:37 +0000
Ready: True
Restart Count: 0
Conditions:
Type Status
Ready True
Events:
FirstSeen LastSeen Count From SubobjectPath Reason Message
Sat, 24 Oct 2015 17:08:13 +0000 Sat, 24 Oct 2015 17:08:13 +0000 1 {scheduler } scheduled Successfully assigned selenium-node-firefox-lc6qt to kube-node2
Sat, 24 Oct 2015 17:08:13 +0000 Sat, 24 Oct 2015 17:08:13 +0000 1 {kubelet kube-node2} implicitly required container POD pulled Pod container image "gcr.io/google_containers/pause:0.8.0" already present on machine
Sat, 24 Oct 2015 17:08:13 +0000 Sat, 24 Oct 2015 17:08:13 +0000 1 {kubelet kube-node2} implicitly required container POD created Created with docker id cdcb027c6548
Sat, 24 Oct 2015 17:08:13 +0000 Sat, 24 Oct 2015 17:08:13 +0000 1 {kubelet kube-node2} implicitly required container POD started Started with docker id cdcb027c6548
Sat, 24 Oct 2015 17:08:36 +0000 Sat, 24 Oct 2015 17:08:36 +0000 1 {kubelet kube-node2} spec.containers pulled Successfully pulled image "selenium/node-firefox"
Sat, 24 Oct 2015 17:08:36 +0000 Sat, 24 Oct 2015 17:08:36 +0000 1 {kubelet kube-node2} spec.containers created Created with docker id 8931b7f7a818
Sat, 24 Oct 2015 17:08:37 +0000 Sat, 24 Oct 2015 17:08:37 +0000 1 {kubelet kube-node2} spec.containers started Started with docker id 8931b7f7a818
[root@kube-master ~]# kubectl describe pod selenium-node-firefox-y9qjp
Name: selenium-node-firefox-y9qjp
Namespace: default
Image(s): selenium/node-firefox
Node: kube-node1/185.92.221.67
Labels: name=selenium-node-firefox
Status: Running
Reason:
Message:
IP: 10.20.92.3
Replication Controllers: selenium-node-firefox (2/2 replicas created)
Containers:
selenium-node-firefox:
Image: selenium/node-firefox
State: Running
Started: Sat, 24 Oct 2015 17:08:13 +0000
Ready: True
Restart Count: 0
Conditions:
Type Status
Ready True
Events:
FirstSeen LastSeen Count From SubobjectPath Reason Message
Sat, 24 Oct 2015 17:08:13 +0000 Sat, 24 Oct 2015 17:08:13 +0000 1 {scheduler } scheduled Successfully assigned selenium-node-firefox-y9qjp to kube-node1
Sat, 24 Oct 2015 17:08:13 +0000 Sat, 24 Oct 2015 17:08:13 +0000 1 {kubelet kube-node1} implicitly required container POD pulled Pod container image "gcr.io/google_containers/pause:0.8.0" already present on machine
Sat, 24 Oct 2015 17:08:13 +0000 Sat, 24 Oct 2015 17:08:13 +0000 1 {kubelet kube-node1} implicitly required container POD created Created with docker id ea272dd36bd5
Sat, 24 Oct 2015 17:08:13 +0000 Sat, 24 Oct 2015 17:08:13 +0000 1 {kubelet kube-node1} implicitly required container POD started Started with docker id ea272dd36bd5
Sat, 24 Oct 2015 17:08:13 +0000 Sat, 24 Oct 2015 17:08:13 +0000 1 {kubelet kube-node1} spec.containers created Created with docker id 6edbd6b9861d
Sat, 24 Oct 2015 17:08:13 +0000 Sat, 24 Oct 2015 17:08:13 +0000 1 {kubelet kube-node1} spec.containers started Started with docker id 6edbd6b9861d
Siç mund ta shohim, Kubernetes ka krijuar 2 kopje të tyre selenium-firefox-nodedhe i ka shpërndarë në të gjithë grupin. Pod selenium-node-firefox-lc6qtështë në kube-node2, ndërsa pod selenium-node-firefox-y9qjpështë në kube-node1.
Ne përsërisim të njëjtin proces për nyjet tona Selenium Chrome.
Kontrolluesi i përsëritjes së nyjeve të kromit:
# selenium-node-chrome-rc.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: selenium-node-chrome
labels:
app: selenium-node-chrome
spec:
replicas: 2
selector:
app: selenium-node-chrome
template:
metadata:
labels:
app: selenium-node-chrome
spec:
containers:
- name: selenium-node-chrome
image: selenium/node-chrome
ports:
- containerPort: 5900
env:
- name: HUB_PORT_4444_TCP_ADDR
value: "replace_with_service_ip"
- name: HUB_PORT_4444_TCP_PORT
value: "4444"
Vendosja:
[root@kube-master ~]# kubectl create -f selenium-node-chrome-rc.yaml
replicationcontrollers/selenium-node-chrome
[root@kube-master ~]# kubectl get rc
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
selenium-hub selenium-hub selenium/hub name=selenium-hub 1
selenium-node-chrome selenium-node-chrome selenium/node-chrome app=selenium-node-chrome 2
selenium-node-firefox selenium-node-firefox selenium/node-firefox name=selenium-node-firefox 2
[root@kube-master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
selenium-hub-pilc8 1/1 Running 1 1h
selenium-node-chrome-9u1ld 1/1 Running 0 1m
selenium-node-chrome-mgi52 1/1 Running 0 1m
selenium-node-firefox-lc6qt 1/1 Running 0 11m
selenium-node-firefox-y9qjp 1/1 Running 0 11m
Duke përfunduar
Në këtë udhëzues, ne kemi ngritur një grup të vogël Kubernetes me 3 serverë (1 kontrollues kryesor + 2 punëtorë).
Duke përdorur pods, RC dhe një shërbim, ne kemi vendosur me sukses një Grid Selenium të përbërë nga një qendër qendrore dhe 4 nyje, duke u mundësuar zhvilluesve të kryejnë 4 teste të njëkohshme Selenium në të njëjtën kohë në grup.
Kubernetes planifikoi automatikisht kontejnerët në të gjithë grupin.
![Fillimi me Kubernetes në CentOS 7 Fillimi me Kubernetes në CentOS 7]()
Vetë-shërimi
Kubernetes riplanifikon automatikisht pod-et në serverë të shëndetshëm nëse një ose më shumë serverë tanë nuk funksionojnë. Në shembullin tim, kube-node2 aktualisht po ekzekuton podin shpërndarës Selenium dhe 1 pod nyje Selenium Firefox.
[root@kube-node2 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5617399f146c selenium/node-firefox "/opt/bin/entry_poin 5 minutes ago Up 5 minutes k8s_selenium-node-firefox.46e635d8_selenium-node-firefox-zmj1r_default_31c89517-7a75-11e5-8648-5600001611e0_baae8e00
185230a3b431 gcr.io/google_containers/pause:0.8.0 "/pause" 5 minutes ago Up 5 minutes k8s_POD.3805e8b7_selenium-node-firefox-zmj1r_default_31c89517-7a75-11e5-8648-5600001611e0_40f809df
fdd5834c249d selenium/hub "/opt/bin/entry_poin About an hour ago Up About an hour k8s_selenium-hub.cb8bf0ed_selenium-hub-pilc8_default_6c98c1ff-7a68-11e5-8648-5600001611e0_5765e2c9
00e4ccb0bda8 gcr.io/google_containers/pause:0.8.0 "/pause" About an hour ago Up About an hour k8s_POD.3b3ee8b9_selenium-hub-pilc8_default_6c98c1ff-7a68-11e5-8648-5600001611e0_8398ac33
Ne do të simulojmë dështimin e serverit duke mbyllur kube-node2. Pas disa minutash, duhet të shihni që kontejnerët që funksiononin në kube-node2 janë riplanifikuar në kube-node1, duke siguruar ndërprerje minimale të shërbimit.
[root@kube-node1 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5bad5f582698 selenium/hub "/opt/bin/entry_poin 19 minutes ago Up 19 minutes k8s_selenium-hub.cb8bf0ed_selenium-hub-hycf2_default_fe9057cf-7a76-11e5-8648-5600001611e0_ccaad50a
dd1565a94919 selenium/node-firefox "/opt/bin/entry_poin 20 minutes ago Up 20 minutes k8s_selenium-node-firefox.46e635d8_selenium-node-firefox-g28z5_default_fe932673-7a76-11e5-8648-5600001611e0_fc79f977
2be1a316aa47 gcr.io/google_containers/pause:0.8.0 "/pause" 20 minutes ago Up 20 minutes k8s_POD.3805e8b7_selenium-node-firefox-g28z5_default_fe932673-7a76-11e5-8648-5600001611e0_dc204ad2
da75a0242a9e gcr.io/google_containers/pause:0.8.0 "/pause" 20 minutes ago Up 20 minutes k8s_POD.3b3ee8b9_selenium-hub-hycf2_default_fe9057cf-7a76-11e5-8648-5600001611e0_1b10c0e7
c611b68330de selenium/node-firefox "/opt/bin/entry_poin 33 minutes ago Up 33 minutes k8s_selenium-node-firefox.46e635d8_selenium-node-firefox-8ylo2_default_31c8a8f3-7a75-11e5-8648-5600001611e0_922af821
828031da6b3c gcr.io/google_containers/pause:0.8.0 "/pause" 33 minutes ago Up 33 minutes k8s_POD.3805e8b7_selenium-node-firefox-8ylo2_default_31c8a8f3-7a75-11e5-8648-5600001611e0_289cd555
caf4e725512e selenium/node-chrome "/opt/bin/entry_poin 46 minutes ago Up 46 minutes k8s_selenium-node-chrome.362a34ee_selenium-node-chrome-mgi52_default_392a2647-7a73-11e5-8648-5600001611e0_3c6e855a
409a20770787 selenium/node-chrome "/opt/bin/entry_poin 46 minutes ago Up 46 minutes k8s_selenium-node-chrome.362a34ee_selenium-node-chrome-9u1ld_default_392a15a4-7a73-11e5-8648-5600001611e0_ac3f0191
7e2d942422a5 gcr.io/google_containers/pause:0.8.0 "/pause" 47 minutes ago Up 47 minutes k8s_POD.3805e8b7_selenium-node-chrome-9u1ld_default_392a15a4-7a73-11e5-8648-5600001611e0_f5858b73
a3a65ea99a99 gcr.io/google_containers/pause:0.8.0 "/pause" 47 minutes ago Up 47 minutes k8s_POD.3805e8b7_selenium-node-chrome-mgi52_default_392a2647-7a73-11e5-8648-5600001611e0_20a70ab6
Shkallëzimi i rrjetit tuaj të selenit
Shkallëzimi i rrjetit tuaj Selenium është shumë i lehtë me Kubernetes. Imagjinoni që në vend të 2 nyjeve të Firefox-it, do të doja të ekzekutoja 4. Rritja e shkallës mund të bëhet me një komandë të vetme:
[root@kube-master ~]# kubectl scale rc selenium-node-firefox --replicas=4
scaled
[root@kube-master ~]# kubectl get rc
CONTROLLER CONTAINER(S) IMAGE(S) SELECTOR REPLICAS
selenium-hub selenium-hub selenium/hub name=selenium-hub 1
selenium-node-chrome selenium-node-chrome selenium/node-chrome app=selenium-node-chrome 2
selenium-node-firefox selenium-node-firefox selenium/node-firefox name=selenium-node-firefox 4
[root@kube-master ~]# kubectl get pods
NAME READY STATUS RESTARTS AGE
selenium-hub-pilc8 1/1 Running 1 1h
selenium-node-chrome-9u1ld 1/1 Running 0 14m
selenium-node-chrome-mgi52 1/1 Running 0 14m
selenium-node-firefox-8ylo2 1/1 Running 0 40s
selenium-node-firefox-lc6qt 1/1 Running 0 24m
selenium-node-firefox-y9qjp 1/1 Running 0 24m
selenium-node-firefox-zmj1r 1/1 Running 0 40s
![Fillimi me Kubernetes në CentOS 7 Fillimi me Kubernetes në CentOS 7]()