2014-09-28

Kubernetes 试玩

创建 web server Docker image

[root@iZ28rwzcvjoZ mywebcontainer]# vim Dockerfile
[root@iZ28rwzcvjoZ mywebcontainer]# docker build -t webwithdb .
Sending build context to Docker daemon 14.85 kB
Sending build context to Docker daemon
Step 0 : FROM centos:latest
latest: Pulling from docker.io/centos
f1b10cd84249: Pull complete
c852f6d61e65: Pull complete
7322fbe74aa5: Already exists
docker.io/centos:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:57554136c655abb33ecb7bb790b1db0279668d3763c3b81f31bc6c4e60e4a1f3
Status: Downloaded newer image for docker.io/centos:latest
 ---> 7322fbe74aa5
Step 1 : USER root
 ---> Running in 3d5012500496
 ---> 78c81ca96256
Removing intermediate container 3d5012500496
Step 2 : MAINTAINER Apache
 ---> Running in 1d84f7786d8b
 ---> ca1e0cf9c2dc
Removing intermediate container 1d84f7786d8b
Step 3 : RUN yum -y install deltarpm yum-utils --disablerepo=*-eus-* --disablerepo=*-htb-*     --disablerepo=*-ha-* --disablerepo=*-rt-* --disablerepo=*-lb-* --disablerepo=*-rs-* --disablerepo=*-sap-*
 ---> Running in 9c8efd9d1aba
Loaded plugins: fastestmirror
Determining fastest mirrors
 * base: mirrors.zju.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.zju.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package deltarpm.x86_64 0:3.6-3.el7 will be installed
---> Package yum-utils.noarch 0:1.1.31-29.el7 will be installed
--> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-29.el7.noarch
--> Running transaction check
---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed
--> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch
--> Running transaction check
---> Package python-chardet.noarch 0:2.2.1-1.el7_1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package               Arch          Version               Repository      Size
================================================================================
Installing:
 deltarpm              x86_64        3.6-3.el7             base            82 k
 yum-utils             noarch        1.1.31-29.el7         base           112 k
Installing for dependencies:
 python-chardet        noarch        2.2.1-1.el7_1         updates        227 k
 python-kitchen        noarch        1.1.1-5.el7           base           267 k

Transaction Summary
================================================================================
Install  2 Packages (+2 Dependent packages)

Total download size: 688 k
Installed size: 3.0 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/deltarpm-3.6-3.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for deltarpm-3.6-3.el7.x86_64.rpm is not installed
Public key for python-chardet-2.2.1-1.el7_1.noarch.rpm is not installed
--------------------------------------------------------------------------------
Total                                              1.0 MB/s | 688 kB  00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-1.1503.el7.centos.2.8.x86_64 (@CentOS)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python-chardet-2.2.1-1.el7_1.noarch                          1/4
  Installing : python-kitchen-1.1.1-5.el7.noarch                            2/4
  Installing : yum-utils-1.1.31-29.el7.noarch                               3/4
  Installing : deltarpm-3.6-3.el7.x86_64                                    4/4
  Verifying  : python-chardet-2.2.1-1.el7_1.noarch                          1/4
  Verifying  : python-kitchen-1.1.1-5.el7.noarch                            2/4
  Verifying  : yum-utils-1.1.31-29.el7.noarch                               3/4
  Verifying  : deltarpm-3.6-3.el7.x86_64                                    4/4

Installed:
  deltarpm.x86_64 0:3.6-3.el7          yum-utils.noarch 0:1.1.31-29.el7

Dependency Installed:
  python-chardet.noarch 0:2.2.1-1.el7_1   python-kitchen.noarch 0:1.1.1-5.el7

Complete!
 ---> 9f777380ec2b
Removing intermediate container 9c8efd9d1aba
Step 4 : RUN yum-config-manager --disable *-eus-* *-htb-* *-ha-* *-rt-* *-lb-* *-rs-* *-sap-* > /dev/null
 ---> Running in 10ccc63d064f
 ---> 2f1ad4b9999b
Removing intermediate container 10ccc63d064f
Step 5 : RUN yum update -y
 ---> Running in fd7a49e0262c
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.zju.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.zju.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package iputils.x86_64 0:20121221-6.el7 will be updated
---> Package iputils.x86_64 0:20121221-6.el7_1.1 will be an update
---> Package libuser.x86_64 0:0.60-5.el7 will be updated
---> Package libuser.x86_64 0:0.60-7.el7_1 will be an update
---> Package nss.x86_64 0:3.18.0-2.2.el7_1 will be updated
---> Package nss.x86_64 0:3.19.1-3.el7_1 will be an update
---> Package nss-sysinit.x86_64 0:3.18.0-2.2.el7_1 will be updated
---> Package nss-sysinit.x86_64 0:3.19.1-3.el7_1 will be an update
---> Package nss-tools.x86_64 0:3.18.0-2.2.el7_1 will be updated
---> Package nss-tools.x86_64 0:3.19.1-3.el7_1 will be an update
---> Package nss-util.x86_64 0:3.18.0-1.el7_1 will be updated
---> Package nss-util.x86_64 0:3.19.1-1.el7_1 will be an update
---> Package openssl-libs.x86_64 1:1.0.1e-42.el7.8 will be updated
---> Package openssl-libs.x86_64 1:1.0.1e-42.el7.9 will be an update
---> Package python.x86_64 0:2.7.5-16.el7 will be updated
---> Package python.x86_64 0:2.7.5-18.el7_1.1 will be an update
---> Package python-libs.x86_64 0:2.7.5-16.el7 will be updated
---> Package python-libs.x86_64 0:2.7.5-18.el7_1.1 will be an update
---> Package tzdata.noarch 0:2015d-1.el7 will be updated
---> Package tzdata.noarch 0:2015e-1.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch         Version                    Repository     Size
================================================================================
Updating:
 iputils            x86_64       20121221-6.el7_1.1         updates       152 k
 libuser            x86_64       0.60-7.el7_1               updates       398 k
 nss                x86_64       3.19.1-3.el7_1             updates       846 k
 nss-sysinit        x86_64       3.19.1-3.el7_1             updates        51 k
 nss-tools          x86_64       3.19.1-3.el7_1             updates       478 k
 nss-util           x86_64       3.19.1-1.el7_1             updates        70 k
 openssl-libs       x86_64       1:1.0.1e-42.el7.9          updates       949 k
 python             x86_64       2.7.5-18.el7_1.1           updates        86 k
 python-libs        x86_64       2.7.5-18.el7_1.1           updates       5.6 M
 tzdata             noarch       2015e-1.el7                updates       432 k

Transaction Summary
================================================================================
Upgrade  10 Packages

Total download size: 9.0 M
Downloading packages:
Delta RPMs reduced 8.9 M of updates to 1.6 M (81% saved)
/usr/share/doc/iputils-20121221/README.bonding: No such file or directory
cannot reconstruct rpm from disk files
/usr/share/man/man1/certutil.1.gz: No such file or directory
cannot reconstruct rpm from disk files
Finishing delta rebuilds of 8 package(s) (8.8 M)
/usr/share/locale/bs/LC_MESSAGES/libuser.mo: No such file or directory
cannot reconstruct rpm from disk files
/usr/share/doc/python-2.7.5/LICENSE: No such file or directory
cannot reconstruct rpm from disk files
/usr/share/doc/openssl-libs-1.0.1e/LICENSE: No such file or directory
cannot reconstruct rpm from disk files
/usr/share/man/man5/cert8.db.5.gz: No such file or directory
cannot reconstruct rpm from disk files
/usr/share/doc/tzdata-2015d/README: No such file or directory
cannot reconstruct rpm from disk files
/usr/share/doc/python-libs-2.7.5/LICENSE: No such file or directory
cannot reconstruct rpm from disk files
Some delta RPMs failed to download or rebuild. Retrying..
--------------------------------------------------------------------------------
Total                                              817 kB/s |  11 MB  00:13
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : nss-util-3.19.1-1.el7_1.x86_64                              1/20
  Updating   : nss-sysinit-3.19.1-3.el7_1.x86_64                           2/20
  Updating   : nss-3.19.1-3.el7_1.x86_64                                   3/20
  Updating   : 1:openssl-libs-1.0.1e-42.el7.9.x86_64                       4/20
  Updating   : python-libs-2.7.5-18.el7_1.1.x86_64                         5/20
  Updating   : python-2.7.5-18.el7_1.1.x86_64                              6/20
  Updating   : iputils-20121221-6.el7_1.1.x86_64                           7/20
  Updating   : nss-tools-3.19.1-3.el7_1.x86_64                             8/20
  Updating   : tzdata-2015e-1.el7.noarch                                   9/20
  Updating   : libuser-0.60-7.el7_1.x86_64                                10/20
  Cleanup    : nss-tools-3.18.0-2.2.el7_1.x86_64                          11/20
  Cleanup    : nss-sysinit-3.18.0-2.2.el7_1.x86_64                        12/20
  Cleanup    : nss-3.18.0-2.2.el7_1.x86_64                                13/20
  Cleanup    : iputils-20121221-6.el7.x86_64                              14/20
  Cleanup    : python-2.7.5-16.el7.x86_64                                 15/20
  Cleanup    : tzdata-2015d-1.el7.noarch                                  16/20
  Cleanup    : python-libs-2.7.5-16.el7.x86_64                            17/20
  Cleanup    : 1:openssl-libs-1.0.1e-42.el7.8.x86_64                      18/20
  Cleanup    : nss-util-3.18.0-1.el7_1.x86_64                             19/20
  Cleanup    : libuser-0.60-5.el7.x86_64                                  20/20
  Verifying  : 1:openssl-libs-1.0.1e-42.el7.9.x86_64                       1/20
  Verifying  : nss-3.19.1-3.el7_1.x86_64                                   2/20
  Verifying  : python-libs-2.7.5-18.el7_1.1.x86_64                         3/20
  Verifying  : nss-sysinit-3.19.1-3.el7_1.x86_64                           4/20
  Verifying  : python-2.7.5-18.el7_1.1.x86_64                              5/20
  Verifying  : iputils-20121221-6.el7_1.1.x86_64                           6/20
  Verifying  : nss-tools-3.19.1-3.el7_1.x86_64                             7/20
  Verifying  : nss-util-3.19.1-1.el7_1.x86_64                              8/20
  Verifying  : libuser-0.60-7.el7_1.x86_64                                 9/20
  Verifying  : tzdata-2015e-1.el7.noarch                                  10/20
  Verifying  : iputils-20121221-6.el7.x86_64                              11/20
  Verifying  : python-2.7.5-16.el7.x86_64                                 12/20
  Verifying  : nss-3.18.0-2.2.el7_1.x86_64                                13/20
  Verifying  : python-libs-2.7.5-16.el7.x86_64                            14/20
  Verifying  : nss-tools-3.18.0-2.2.el7_1.x86_64                          15/20
  Verifying  : tzdata-2015d-1.el7.noarch                                  16/20
  Verifying  : nss-sysinit-3.18.0-2.2.el7_1.x86_64                        17/20
  Verifying  : 1:openssl-libs-1.0.1e-42.el7.8.x86_64                      18/20
  Verifying  : nss-util-3.18.0-1.el7_1.x86_64                             19/20
  Verifying  : libuser-0.60-5.el7.x86_64                                  20/20

Updated:
  iputils.x86_64 0:20121221-6.el7_1.1     libuser.x86_64 0:0.60-7.el7_1
  nss.x86_64 0:3.19.1-3.el7_1             nss-sysinit.x86_64 0:3.19.1-3.el7_1
  nss-tools.x86_64 0:3.19.1-3.el7_1       nss-util.x86_64 0:3.19.1-1.el7_1
  openssl-libs.x86_64 1:1.0.1e-42.el7.9   python.x86_64 0:2.7.5-18.el7_1.1
  python-libs.x86_64 0:2.7.5-18.el7_1.1   tzdata.noarch 0:2015e-1.el7

Complete!
 ---> 5e58dc8ee7fc
Removing intermediate container fd7a49e0262c
Step 6 : RUN yum install httpd procps-ng MySQL-python -y
 ---> Running in ae877dc99990
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.zju.edu.cn
 * extras: mirrors.aliyun.com
 * updates: mirrors.zju.edu.cn
Package procps-ng-3.3.10-3.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package MySQL-python.x86_64 0:1.2.3-11.el7 will be installed
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: MySQL-python-1.2.3-11.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: MySQL-python-1.2.3-11.el7.x86_64
---> Package httpd.x86_64 0:2.4.6-31.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-31.el7.centos for package: httpd-2.4.6-31.el7.centos.x86_64
--> Processing Dependency: system-logos >= 7.92.1-1 for package: httpd-2.4.6-31.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-31.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-31.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-31.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-3.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.el7 will be installed
---> Package centos-logos.noarch 0:70.0.6-2.el7.centos will be installed
---> Package httpd-tools.x86_64 0:2.4.6-31.el7.centos will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
---> Package mariadb-libs.x86_64 1:5.5.41-2.el7_0 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch         Version                    Repository     Size
================================================================================
Installing:
 MySQL-python       x86_64       1.2.3-11.el7               base           82 k
 httpd              x86_64       2.4.6-31.el7.centos        base          2.7 M
Installing for dependencies:
 apr                x86_64       1.4.8-3.el7                base          103 k
 apr-util           x86_64       1.5.2-6.el7                base           92 k
 centos-logos       noarch       70.0.6-2.el7.centos        updates        21 M
 httpd-tools        x86_64       2.4.6-31.el7.centos        base           79 k
 mailcap            noarch       2.1.41-2.el7               base           31 k
 mariadb-libs       x86_64       1:5.5.41-2.el7_0           base          754 k

Transaction Summary
================================================================================
Install  2 Packages (+6 Dependent packages)

Total download size: 25 M
Installed size: 36 M
Downloading packages:
--------------------------------------------------------------------------------
Total                                              2.3 MB/s |  25 MB  00:11
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : apr-1.4.8-3.el7.x86_64                                       1/8
  Installing : apr-util-1.5.2-6.el7.x86_64                                  2/8
  Installing : httpd-tools-2.4.6-31.el7.centos.x86_64                       3/8
  Installing : mailcap-2.1.41-2.el7.noarch                                  4/8
  Installing : 1:mariadb-libs-5.5.41-2.el7_0.x86_64                         5/8
  Installing : centos-logos-70.0.6-2.el7.centos.noarch                      6/8
  Installing : httpd-2.4.6-31.el7.centos.x86_64                             7/8
  Installing : MySQL-python-1.2.3-11.el7.x86_64                             8/8
  Verifying  : centos-logos-70.0.6-2.el7.centos.noarch                      1/8
  Verifying  : apr-1.4.8-3.el7.x86_64                                       2/8
  Verifying  : httpd-tools-2.4.6-31.el7.centos.x86_64                       3/8
  Verifying  : MySQL-python-1.2.3-11.el7.x86_64                             4/8
  Verifying  : apr-util-1.5.2-6.el7.x86_64                                  5/8
  Verifying  : 1:mariadb-libs-5.5.41-2.el7_0.x86_64                         6/8
  Verifying  : mailcap-2.1.41-2.el7.noarch                                  7/8
  Verifying  : httpd-2.4.6-31.el7.centos.x86_64                             8/8

Installed:
  MySQL-python.x86_64 0:1.2.3-11.el7     httpd.x86_64 0:2.4.6-31.el7.centos

Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7
  apr-util.x86_64 0:1.5.2-6.el7
  centos-logos.noarch 0:70.0.6-2.el7.centos
  httpd-tools.x86_64 0:2.4.6-31.el7.centos
  mailcap.noarch 0:2.1.41-2.el7
  mariadb-libs.x86_64 1:5.5.41-2.el7_0

Complete!
 ---> eb6b83a35543
Removing intermediate container ae877dc99990
Step 7 : ADD action /var/www/cgi-bin/action
 ---> 0c5f9080e46d
Removing intermediate container 7518f4cfc6c1
Step 8 : RUN echo "PassEnv DB_SERVICE_SERVICE_HOST" >> /etc/httpd/conf/httpd.conf
 ---> Running in 496ef2cdbd58
 ---> f8c11f280e02
Removing intermediate container 496ef2cdbd58
Step 9 : RUN chown root:apache /var/www/cgi-bin/action
 ---> Running in d8a19119f700
 ---> 60714b3b541a
Removing intermediate container d8a19119f700
Step 10 : RUN chmod 755 /var/www/cgi-bin/action
 ---> Running in c958cd101150
 ---> 735cc1ef2ac2
Removing intermediate container c958cd101150
Step 11 : RUN echo "The Web Server is Running" > /var/www/html/index.html
 ---> Running in 42e127cfe86a
 ---> be9eece48787
Removing intermediate container 42e127cfe86a
Step 12 : EXPOSE 80
 ---> Running in 2f468aff1ae7
 ---> b1a18686cee1
Removing intermediate container 2f468aff1ae7
Step 13 : CMD -D FOREGROUND
 ---> Running in 06ea5c862299
 ---> ff9732ad960a
Removing intermediate container 06ea5c862299
Step 14 : ENTRYPOINT /usr/sbin/httpd
 ---> Running in 6eb0376127bf
 ---> d125219fa28d
Removing intermediate container 6eb0376127bf
Successfully built d125219fa28d
[root@iZ28rwzcvjoZ mywebcontainer]#

Kubernetes 安装


[root@iZ28rwzcvjoZ ~]# yum install kubernetes etcd
Loaded plugins: langpacks
base                                                                                                                                                                        | 3.6 kB  00:00:00
epel                                                                                                                                                                        | 4.4 kB  00:00:00
extras                                                                                                                                                                      | 3.4 kB  00:00:00
updates                                                                                                                                                                     | 3.4 kB  00:00:00
(1/6): base/7/x86_64/group_gz                                                                                                                                               | 154 kB  00:00:00
(2/6): extras/7/x86_64/primary_db                                                                                                                                           |  62 kB  00:00:00
(3/6): epel/x86_64/group_gz                                                                                                                                                 | 169 kB  00:00:00
(4/6): updates/7/x86_64/primary_db                                                                                                                                          | 2.5 MB  00:00:00
(5/6): epel/x86_64/primary_db                                                                                                                                               | 3.7 MB  00:00:01
(6/6): base/7/x86_64/primary_db                                                                                                                                             | 5.1 MB  00:00:01
(1/2): epel/x86_64/updateinfo                                                                                                                                               | 443 kB  00:00:00
(2/2): epel/x86_64/pkgtags                                                                                                                                                  | 1.6 MB  00:00:00
Resolving Dependencies
--> Running transaction check
---> Package etcd.x86_64 0:2.0.11-2.el7 will be installed
---> Package kubernetes.x86_64 0:0.17.1-4.el7 will be installed
--> Processing Dependency: kubernetes-node = 0.17.1-4.el7 for package: kubernetes-0.17.1-4.el7.x86_64
--> Processing Dependency: kubernetes-master = 0.17.1-4.el7 for package: kubernetes-0.17.1-4.el7.x86_64
--> Running transaction check
---> Package kubernetes-master.x86_64 0:0.17.1-4.el7 will be installed
---> Package kubernetes-node.x86_64 0:0.17.1-4.el7 will be installed
--> Processing Dependency: docker for package: kubernetes-node-0.17.1-4.el7.x86_64
--> Running transaction check
---> Package docker.x86_64 0:1.6.2-14.el7.centos will be installed
--> Processing Dependency: selinux-policy >= 3.13.1-23 for package: docker-1.6.2-14.el7.centos.x86_64
--> Processing Dependency: docker-selinux >= 1.6.2-14.el7.centos for package: docker-1.6.2-14.el7.centos.x86_64
--> Processing Dependency: device-mapper-libs >= 7:1.02.90-1 for package: docker-1.6.2-14.el7.centos.x86_64
--> Running transaction check
---> Package device-mapper-libs.x86_64 7:1.02.84-14.el7 will be updated
--> Processing Dependency: device-mapper-libs = 7:1.02.84-14.el7 for package: 7:device-mapper-1.02.84-14.el7.x86_64
---> Package device-mapper-libs.x86_64 7:1.02.93-3.el7_1.1 will be an update
---> Package docker-selinux.x86_64 0:1.6.2-14.el7.centos will be installed
--> Processing Dependency: selinux-policy-targeted >= 3.13.1-23 for package: docker-selinux-1.6.2-14.el7.centos.x86_64
--> Processing Dependency: selinux-policy-base >= 3.13.1-23 for package: docker-selinux-1.6.2-14.el7.centos.x86_64
--> Processing Dependency: policycoreutils-python for package: docker-selinux-1.6.2-14.el7.centos.x86_64
---> Package selinux-policy.noarch 0:3.12.1-153.el7_0.11 will be updated
---> Package selinux-policy.noarch 0:3.13.1-23.el7_1.8 will be an update
--> Running transaction check
---> Package device-mapper.x86_64 7:1.02.84-14.el7 will be updated
--> Processing Dependency: device-mapper = 7:1.02.84-14.el7 for package: 7:device-mapper-event-1.02.84-14.el7.x86_64
---> Package device-mapper.x86_64 7:1.02.93-3.el7_1.1 will be an update
---> Package policycoreutils-python.x86_64 0:2.2.5-15.el7 will be installed
--> Processing Dependency: policycoreutils = 2.2.5-15.el7 for package: policycoreutils-python-2.2.5-15.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.1.10-1 for package: policycoreutils-python-2.2.5-15.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.2.5-15.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.2.5-15.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.2.5-15.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.2.5-15.el7.x86_64
--> Processing Dependency: libcgroup for package: policycoreutils-python-2.2.5-15.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.2.5-15.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.2.5-15.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.2.5-15.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.2.5-15.el7.x86_64
---> Package selinux-policy-targeted.noarch 0:3.12.1-153.el7_0.11 will be updated
---> Package selinux-policy-targeted.noarch 0:3.13.1-23.el7_1.8 will be an update
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.4.1-5.el7 will be installed
--> Processing Dependency: audit-libs = 2.4.1-5.el7 for package: audit-libs-python-2.4.1-5.el7.x86_64
---> Package checkpolicy.x86_64 0:2.1.12-6.el7 will be installed
---> Package device-mapper-event.x86_64 7:1.02.84-14.el7 will be updated
---> Package device-mapper-event.x86_64 7:1.02.93-3.el7_1.1 will be an update
--> Processing Dependency: device-mapper-event-libs = 7:1.02.93-3.el7_1.1 for package: 7:device-mapper-event-1.02.93-3.el7_1.1.x86_64
---> Package libcgroup.x86_64 0:0.41-8.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.1.10-16.el7 will be installed
---> Package policycoreutils.x86_64 0:2.2.5-11.el7_0.1 will be updated
---> Package policycoreutils.x86_64 0:2.2.5-15.el7 will be an update
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.7-46.el7 will be installed
--> Running transaction check
---> Package audit-libs.x86_64 0:2.3.3-4.el7 will be updated
--> Processing Dependency: audit-libs = 2.3.3-4.el7 for package: audit-2.3.3-4.el7.x86_64
---> Package audit-libs.x86_64 0:2.4.1-5.el7 will be an update
---> Package device-mapper-event-libs.x86_64 7:1.02.84-14.el7 will be updated
---> Package device-mapper-event-libs.x86_64 7:1.02.93-3.el7_1.1 will be an update
--> Running transaction check
---> Package audit.x86_64 0:2.3.3-4.el7 will be updated
---> Package audit.x86_64 0:2.4.1-5.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================================================================
 Package                                                  Arch                                   Version                                             Repository                               Size
===================================================================================================================================================================================================
Installing:
 etcd                                                     x86_64                                 2.0.11-2.el7                                        extras                                  2.9 M
 kubernetes                                               x86_64                                 0.17.1-4.el7                                        extras                                   19 k
Installing for dependencies:
 audit-libs-python                                        x86_64                                 2.4.1-5.el7                                         base                                     69 k
 checkpolicy                                              x86_64                                 2.1.12-6.el7                                        base                                    247 k
 docker                                                   x86_64                                 1.6.2-14.el7.centos                                 extras                                  7.6 M
 docker-selinux                                           x86_64                                 1.6.2-14.el7.centos                                 extras                                   55 k
 kubernetes-master                                        x86_64                                 0.17.1-4.el7                                        extras                                   14 M
 kubernetes-node                                          x86_64                                 0.17.1-4.el7                                        extras                                   11 M
 libcgroup                                                x86_64                                 0.41-8.el7                                          base                                     64 k
 libsemanage-python                                       x86_64                                 2.1.10-16.el7                                       base                                     94 k
 policycoreutils-python                                   x86_64                                 2.2.5-15.el7                                        base                                    434 k
 python-IPy                                               noarch                                 0.75-6.el7                                          base                                     32 k
 setools-libs                                             x86_64                                 3.3.7-46.el7                                        base                                    485 k
Updating for dependencies:
 audit                                                    x86_64                                 2.4.1-5.el7                                         base                                    234 k
 audit-libs                                               x86_64                                 2.4.1-5.el7                                         base                                     80 k
 device-mapper                                            x86_64                                 7:1.02.93-3.el7_1.1                                 updates                                 209 k
 device-mapper-event                                      x86_64                                 7:1.02.93-3.el7_1.1                                 updates                                 159 k
 device-mapper-event-libs                                 x86_64                                 7:1.02.93-3.el7_1.1                                 updates                                 151 k
 device-mapper-libs                                       x86_64                                 7:1.02.93-3.el7_1.1                                 updates                                 259 k
 policycoreutils                                          x86_64                                 2.2.5-15.el7                                        base                                    802 k
 selinux-policy                                           noarch                                 3.13.1-23.el7_1.8                                   updates                                 356 k
 selinux-policy-targeted                                  noarch                                 3.13.1-23.el7_1.8                                   updates                                 3.9 M

Transaction Summary
===================================================================================================================================================================================================
Install  2 Packages (+11 Dependent packages)
Upgrade             (  9 Dependent packages)

Total download size: 44 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/22): audit-libs-2.4.1-5.el7.x86_64.rpm                                                                                                                                   |  80 kB  00:00:00
(2/22): audit-2.4.1-5.el7.x86_64.rpm                                                                                                                                        | 234 kB  00:00:00
(3/22): audit-libs-python-2.4.1-5.el7.x86_64.rpm                                                                                                                            |  69 kB  00:00:00
(4/22): checkpolicy-2.1.12-6.el7.x86_64.rpm                                                                                                                                 | 247 kB  00:00:00
(5/22): device-mapper-1.02.93-3.el7_1.1.x86_64.rpm                                                                                                                          | 209 kB  00:00:00
(6/22): device-mapper-event-1.02.93-3.el7_1.1.x86_64.rpm                                                                                                                    | 159 kB  00:00:00
(7/22): device-mapper-event-libs-1.02.93-3.el7_1.1.x86_64.rpm                                                                                                               | 151 kB  00:00:00
(8/22): device-mapper-libs-1.02.93-3.el7_1.1.x86_64.rpm                                                                                                                     | 259 kB  00:00:00
(9/22): docker-selinux-1.6.2-14.el7.centos.x86_64.rpm                                                                                                                       |  55 kB  00:00:00
(10/22): etcd-2.0.11-2.el7.x86_64.rpm                                                                                                                                       | 2.9 MB  00:00:00
(11/22): kubernetes-0.17.1-4.el7.x86_64.rpm                                                                                                                                 |  19 kB  00:00:00
(12/22): docker-1.6.2-14.el7.centos.x86_64.rpm                                                                                                                              | 7.6 MB  00:00:01
(13/22): libcgroup-0.41-8.el7.x86_64.rpm                                                                                                                                    |  64 kB  00:00:00
(14/22): libsemanage-python-2.1.10-16.el7.x86_64.rpm                                                                                                                        |  94 kB  00:00:00
(15/22): policycoreutils-python-2.2.5-15.el7.x86_64.rpm                                                                                                                     | 434 kB  00:00:00
(16/22): python-IPy-0.75-6.el7.noarch.rpm                                                                                                                                   |  32 kB  00:00:00
(17/22): policycoreutils-2.2.5-15.el7.x86_64.rpm                                                                                                                            | 802 kB  00:00:00
(18/22): setools-libs-3.3.7-46.el7.x86_64.rpm                                                                                                                               | 485 kB  00:00:00
(19/22): selinux-policy-3.13.1-23.el7_1.8.noarch.rpm                                                                                                                        | 356 kB  00:00:00
(20/22): selinux-policy-targeted-3.13.1-23.el7_1.8.noarch.rpm                                                                                                               | 3.9 MB  00:00:00
(21/22): kubernetes-master-0.17.1-4.el7.x86_64.rpm                                                                                                                          |  14 MB  00:00:02
(22/22): kubernetes-node-0.17.1-4.el7.x86_64.rpm                                                                                                                            |  11 MB  00:00:02
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                              9.3 MB/s |  44 MB  00:00:04
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : 7:device-mapper-1.02.93-3.el7_1.1.x86_64                                                                                                                                       1/31
  Updating   : 7:device-mapper-libs-1.02.93-3.el7_1.1.x86_64                                                                                                                                  2/31
  Updating   : audit-libs-2.4.1-5.el7.x86_64                                                                                                                                                  3/31
  Updating   : policycoreutils-2.2.5-15.el7.x86_64                                                                                                                                            4/31
  Updating   : selinux-policy-3.13.1-23.el7_1.8.noarch                                                                                                                                        5/31
  Updating   : selinux-policy-targeted-3.13.1-23.el7_1.8.noarch                                                                                                                               6/31
  Installing : audit-libs-python-2.4.1-5.el7.x86_64                                                                                                                                           7/31
  Updating   : 7:device-mapper-event-libs-1.02.93-3.el7_1.1.x86_64                                                                                                                            8/31
  Installing : kubernetes-master-0.17.1-4.el7.x86_64                                                                                                                                          9/31
  Installing : libsemanage-python-2.1.10-16.el7.x86_64                                                                                                                                       10/31
  Installing : python-IPy-0.75-6.el7.noarch                                                                                                                                                  11/31
  Installing : libcgroup-0.41-8.el7.x86_64                                                                                                                                                   12/31
  Installing : setools-libs-3.3.7-46.el7.x86_64                                                                                                                                              13/31
  Installing : checkpolicy-2.1.12-6.el7.x86_64                                                                                                                                               14/31
  Installing : policycoreutils-python-2.2.5-15.el7.x86_64                                                                                                                                    15/31
  Installing : docker-selinux-1.6.2-14.el7.centos.x86_64                                                                                                                                     16/31
  Installing : docker-1.6.2-14.el7.centos.x86_64                                                                                                                                             17/31
  Installing : kubernetes-node-0.17.1-4.el7.x86_64                                                                                                                                           18/31
  Installing : kubernetes-0.17.1-4.el7.x86_64                                                                                                                                                19/31
  Updating   : 7:device-mapper-event-1.02.93-3.el7_1.1.x86_64                                                                                                                                20/31
  Updating   : audit-2.4.1-5.el7.x86_64                                                                                                                                                      21/31
  Installing : etcd-2.0.11-2.el7.x86_64                                                                                                                                                      22/31
  Cleanup    : selinux-policy-targeted-3.12.1-153.el7_0.11.noarch                                                                                                                            23/31
warning: file /etc/selinux/targeted/modules/active/modules/vbetool.pp: remove failed: No such file or directory
warning: file /etc/selinux/targeted/modules/active/modules/pkcsslotd.pp: remove failed: No such file or directory
  Cleanup    : 7:device-mapper-event-1.02.84-14.el7.x86_64                                                                                                                                   24/31
  Cleanup    : selinux-policy-3.12.1-153.el7_0.11.noarch                                                                                                                                     25/31
  Cleanup    : policycoreutils-2.2.5-11.el7_0.1.x86_64                                                                                                                                       26/31
  Cleanup    : 7:device-mapper-event-libs-1.02.84-14.el7.x86_64                                                                                                                              27/31
  Cleanup    : 7:device-mapper-1.02.84-14.el7.x86_64                                                                                                                                         28/31
  Cleanup    : 7:device-mapper-libs-1.02.84-14.el7.x86_64                                                                                                                                    29/31
  Cleanup    : audit-2.3.3-4.el7.x86_64                                                                                                                                                      30/31
  Cleanup    : audit-libs-2.3.3-4.el7.x86_64                                                                                                                                                 31/31
  Verifying  : checkpolicy-2.1.12-6.el7.x86_64                                                                                                                                                1/31
  Verifying  : 7:device-mapper-libs-1.02.93-3.el7_1.1.x86_64                                                                                                                                  2/31
  Verifying  : audit-libs-2.4.1-5.el7.x86_64                                                                                                                                                  3/31
  Verifying  : setools-libs-3.3.7-46.el7.x86_64                                                                                                                                               4/31
  Verifying  : 7:device-mapper-1.02.93-3.el7_1.1.x86_64                                                                                                                                       5/31
  Verifying  : libcgroup-0.41-8.el7.x86_64                                                                                                                                                    6/31
  Verifying  : docker-selinux-1.6.2-14.el7.centos.x86_64                                                                                                                                      7/31
  Verifying  : etcd-2.0.11-2.el7.x86_64                                                                                                                                                       8/31
  Verifying  : policycoreutils-2.2.5-15.el7.x86_64                                                                                                                                            9/31
  Verifying  : python-IPy-0.75-6.el7.noarch                                                                                                                                                  10/31
  Verifying  : 7:device-mapper-event-libs-1.02.93-3.el7_1.1.x86_64                                                                                                                           11/31
  Verifying  : docker-1.6.2-14.el7.centos.x86_64                                                                                                                                             12/31
  Verifying  : policycoreutils-python-2.2.5-15.el7.x86_64                                                                                                                                    13/31
  Verifying  : selinux-policy-targeted-3.13.1-23.el7_1.8.noarch                                                                                                                              14/31
  Verifying  : kubernetes-node-0.17.1-4.el7.x86_64                                                                                                                                           15/31
  Verifying  : audit-libs-python-2.4.1-5.el7.x86_64                                                                                                                                          16/31
  Verifying  : kubernetes-0.17.1-4.el7.x86_64                                                                                                                                                17/31
  Verifying  : selinux-policy-3.13.1-23.el7_1.8.noarch                                                                                                                                       18/31
  Verifying  : libsemanage-python-2.1.10-16.el7.x86_64                                                                                                                                       19/31
  Verifying  : kubernetes-master-0.17.1-4.el7.x86_64                                                                                                                                         20/31
  Verifying  : 7:device-mapper-event-1.02.93-3.el7_1.1.x86_64                                                                                                                                21/31
  Verifying  : audit-2.4.1-5.el7.x86_64                                                                                                                                                      22/31
  Verifying  : audit-libs-2.3.3-4.el7.x86_64                                                                                                                                                 23/31
  Verifying  : audit-2.3.3-4.el7.x86_64                                                                                                                                                      24/31
  Verifying  : 7:device-mapper-event-1.02.84-14.el7.x86_64                                                                                                                                   25/31
  Verifying  : 7:device-mapper-libs-1.02.84-14.el7.x86_64                                                                                                                                    26/31
  Verifying  : selinux-policy-targeted-3.12.1-153.el7_0.11.noarch                                                                                                                            27/31
  Verifying  : 7:device-mapper-event-libs-1.02.84-14.el7.x86_64                                                                                                                              28/31
  Verifying  : selinux-policy-3.12.1-153.el7_0.11.noarch                                                                                                                                     29/31
  Verifying  : policycoreutils-2.2.5-11.el7_0.1.x86_64                                                                                                                                       30/31
  Verifying  : 7:device-mapper-1.02.84-14.el7.x86_64                                                                                                                                         31/31

Installed:
  etcd.x86_64 0:2.0.11-2.el7                                                                    kubernetes.x86_64 0:0.17.1-4.el7

Dependency Installed:
  audit-libs-python.x86_64 0:2.4.1-5.el7              checkpolicy.x86_64 0:2.1.12-6.el7            docker.x86_64 0:1.6.2-14.el7.centos        docker-selinux.x86_64 0:1.6.2-14.el7.centos
  kubernetes-master.x86_64 0:0.17.1-4.el7             kubernetes-node.x86_64 0:0.17.1-4.el7        libcgroup.x86_64 0:0.41-8.el7              libsemanage-python.x86_64 0:2.1.10-16.el7
  policycoreutils-python.x86_64 0:2.2.5-15.el7        python-IPy.noarch 0:0.75-6.el7               setools-libs.x86_64 0:3.3.7-46.el7

Dependency Updated:
  audit.x86_64 0:2.4.1-5.el7                            audit-libs.x86_64 0:2.4.1-5.el7                 device-mapper.x86_64 7:1.02.93-3.el7_1.1   device-mapper-event.x86_64 7:1.02.93-3.el7_1.1
  device-mapper-event-libs.x86_64 7:1.02.93-3.el7_1.1   device-mapper-libs.x86_64 7:1.02.93-3.el7_1.1   policycoreutils.x86_64 0:2.2.5-15.el7      selinux-policy.noarch 0:3.13.1-23.el7_1.8
  selinux-policy-targeted.noarch 0:3.13.1-23.el7_1.8

Complete!

  • 根据上述安装步骤可知, 安装 Kubernetes 的时候 Docker rpm 已经自动安装了

Check the services: Run the ss command to check which ports the services are running on:

# ss -tulnp | grep -E "(kube)|(etcd)"

[root@iZ28rwzcvjoZ ~]# ss -tulnp | grep -E "(kube)|(etcd)"
tcp    LISTEN     0      128            127.0.0.1:7001                  *:*      users:(("etcd",1334,5))
tcp    LISTEN     0      128            127.0.0.1:4001                  *:*      users:(("etcd",1334,6))
tcp    LISTEN     0      128            127.0.0.1:10248                 *:*      users:(("kubelet",1482,6))
tcp    LISTEN     0      128            127.0.0.1:10249                 *:*      users:(("kube-proxy",1367,3))
tcp    LISTEN     0      128            127.0.0.1:10250                 *:*      users:(("kubelet",1482,14))
tcp    LISTEN     0      128            127.0.0.1:10251                 *:*      users:(("kube-scheduler",1359,3))
tcp    LISTEN     0      128            127.0.0.1:10252                 *:*      users:(("kube-controller",1352,3))
tcp    LISTEN     0      128            127.0.0.1:2380                  *:*      users:(("etcd",1334,3))
tcp    LISTEN     0      128            127.0.0.1:10255                 *:*      users:(("kubelet",1482,12))
tcp    LISTEN     0      128            127.0.0.1:8080                  *:*      users:(("kube-apiserver",1345,6))
tcp    LISTEN     0      128                   :::57338                :::*      users:(("kube-proxy",1367,7))
tcp    LISTEN     0      128                   :::4194                 :::*      users:(("kubelet",1482,5))
tcp    LISTEN     0      128                   :::37895                :::*      users:(("kube-proxy",1367,8))
tcp    LISTEN     0      128                   :::7080                 :::*      users:(("kube-apiserver",1345,7))

Test the etcd service: Use the curl command as follows to check the etcd service:

[root@iZ28rwzcvjoZ ~]# curl -s -L http://localhost:4001/version
etcd 2.0.11

yaml 配置 pod

[root@iZ28rwzcvjoZ ~]# cat webserver-rc.yaml
id: "webserver-controller"
kind: "ReplicationController"
apiVersion: "v1beta1"
desiredState:
  replicas: 1
  replicaSelector:
    selectorname: "webserver"
  podTemplate:
    desiredState:
      manifest:
        version: "v1beta1"
        id: "webserver-controller"
        containers:
          - name: "apache-frontend"
            image: "webwithdb"
            ports:
              - containerPort: 80
                hostPort: 80
    labels:
      name: "webserver"
      selectorname: "webserver"
      uses: "db"
  labels:
    name: "webserver"
[root@iZ28rwzcvjoZ ~]# cat db-rc.yaml
id: "db-controller"
kind: "ReplicationController"
apiVersion: "v1beta1"
desiredState:
  replicas: 1
  replicaSelector:
    selectorname: "db"
  podTemplate:
    desiredState:
      manifest:
        version: "v1beta1"
        id: "db-controller"
        containers:
          - name: "db"
            image: "dbforweb"
            ports:
              - containerPort: 3306
                hostPort: 3306
    labels:
      name: "db"
      selectorname: "db"
  labels:
    name: "db"
[root@iZ28rwzcvjoZ ~]#

添加到 Kubernetes 管理中

[root@iZ28rwzcvjoZ ~]# kubectl create -f webserver-rc.yaml
replicationControllers/webserver-controller
[root@iZ28rwzcvjoZ ~]# kubectl create -f db-rc.yaml
replicationControllers/db-controller
[root@iZ28rwzcvjoZ ~]#

查看 pod 信息

[root@iZ28rwzcvjoZ ~]# kubectl get pods
POD                          IP        CONTAINER(S)      IMAGE(S)    HOST                  LABELS                                          STATUS    CREATED     MESSAGE
db-controller-ns7g9                                                  127.0.0.1/127.0.0.1   name=db,selectorname=db                         Pending   2 minutes
                                       db                dbforweb                                                                          Waiting               Image: dbforweb is not ready on the node
webserver-controller-oiqpe                                           127.0.0.1/127.0.0.1   name=webserver,selectorname=webserver,uses=db   Pending   2 minutes
                                       apache-frontend   webwithdb                                                                         Waiting               Image: webwithdb is not ready on the node

参考文献