centos安装kubernetes1.3(二)
续k8s部署服务前,需要预习下docker命令docker基础命令docke pull nginx#下载nginx镜像docke push 192.168.161.117:5000/os/centos #上传本地制作的镜像到本地镜像库docker images #查看下载到本地的镜象docker tag 980e0e4c79ec 192.168.161.117:
续上文,在部署docker之前需要预习下docker命令
docker基础命令
docke pull nginx#下载nginx镜像
docke push 192.168.161.117:5000/os/centos #上传本地制作的镜像到本地镜像库
docker images #查看下载到本地的镜象
docker tag 980e0e4c79ec 192.168.161.117:5000/os/centos #将Image id镜像为980e0e4c79ec的镜像标记为192.168.161.117:5000/os/centos
docker run -it nginx /bin/bash #进入交互模式下的nginx容器,相当于一个小的linux系统,里面只安装了nginx
docker开启sshd
docker run -d -p 10022:22 centos_sshd /usr/sbin/sshd -D #使用 安装了sshd 的tomcentos_sshd镜像,启动时启动sshd服务。10022:22前者是宿主机的端口,后者是docker容器的端口
ssh 宿主机 -p 10022 #远程登录docker容器
搭建本地镜像库
docker pull registry #下载registry镜像,使用docker直接部署本地镜像库
docker run -d -p 5000:5000 registry ##以registry 镜像启动docker容器,搭建本地镜像库,监听5000端口
curl -X GET http://127.0.0.1:5000/v2/_catalog ##查看本地仓库已push镜像
部署k8s pod与service
2. ./kubectl create -f nginx_svc.json 或者kubectl expose deployment my-nginx --type=NodePort --name=my-nginx-serv
my-nginx-2494149703-7040i 1/1 Running 0 4d
my-nginx-2494149703-8cwj9 1/1 Running 2 4d
my-nginx-serv 10.10.10.112 <nodes> 8080/TCP 5d
Namespace: default
Node: 192.168.161.117/192.168.161.117
Start Time: Thu, 05 Jan 2017 14:52:26 +0800
Labels: pod-template-hash=2494149703
run=my-nginx
Status: Running
IP: 10.1.83.9
Controllers: ReplicaSet/my-nginx-2494149703
Containers:
my-nginx:
Container ID: docker://aa0540cabb114f6291399b1675f9e84fdb8baffcc8c64f1689f65ec63b5f8a49
Image: nginx
Image ID: docker://sha256:01f818af747d88b4ebca7cdabd0c581e406e0e790be72678d257735fad84a15f
Port: 80/TCP
State: Running
Started: Thu, 05 Jan 2017 14:52:29 +0800
Ready: True
Restart Count: 0
Environment Variables: <none>
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
No volumes.
QoS Tier: BestEffort
No events.
/
root@my-nginx-2494149703-7040i:/# ls
bin dev home lib64 mnt proc run srv tmp var
boot etc lib media opt root sbin sys usr
root@my-nginx-2494149703-7040i:/# ps -ef|grep nginx
root 1 0 0 Jan05 ? 00:00:00 nginx: master process nginx -g daemon off;
nginx 7 1 0 Jan05 ? 00:00:00 nginx: worker process
root 44 34 0 08:27 ? 00:00:00 grep nginx
root@my-nginx-2494149703-7040i:/# find / -name error.log
/var/log/nginx/error.log
更多推荐
所有评论(0)