————安装dashboard————
http://docs.minunix.com/docker/kubernetes-dashboard.yaml 下载
http://www.jb51.net/article/94343.htm 案例

删除原有pod

[root@k8s_master dockerconfig]# kubectl get pods –all-namespaces 确认pod名字
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system kubernetes-dashboard-latest-3447225518-f39cr 0/1 ContainerCreating 0 9h
[root@k8s_master dockerconfig]# kubectl delete pod kubernetes-dashboard-latest-3447225518-f39cr –namespace=kube-system
pod "kubernetes-dashboard-latest-3447225518-f39cr" deleted
curl -o kubernetes-dashboard.yaml http://docs.minunix.com/docker/kubernetes-dashboard.yaml

镜像先用 docker search kubernetes-dashboard 进行搜索,确认版本后
docker pull xxxx
docker images 查看需要的,再写入配置文件

下载后修改
– –apiserver-host=http://192.168.98.18:8080 ## 请修改为自己的kebu-apiserver
Image: docker.io/rainf/kubernetes-dashboard-amd64

[root@master dockerconfig]# kubectl create -f kubernetes-dashboard.yaml
deployment "kubernetes-dashboard" created
service "kubernetes-dashboard" created

[

root@master dockerconfig]# kubectl get service
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes 192.168.142.1 <none> 443/TCP 14h
nginx-service 192.168.142.65 <nodes> 80:30001/TCP 1h
[root@master dockerconfig]# kubectl get pods –namespace=kube-system
NAME READY STATUS RESTARTS AGE
kubernetes-dashboard-334721719-k4dn9 1/1 Running–运行中 0 42s
kubernetes-dashboard-latest-3447225518-gk7br 0/1 ImagePullBackOff 0 17m
删除,有需要可以执行
[root@master dockerconfig]#kubectl delete -f kubernetes-dashboard.yaml
查看dashboard信息

[root@master dockerconfig]# kubectl describe pods kubernetes-dashboard-334721719-k4dn9 –namespace=kube-system

查看PODS详细信息的命令
Name: kubernetes-dashboard-334721719-k4dn9
Namespace: kube-system
Node: 192.168.142.138/192.168.142.138
Start Time: Thu, 18 Jan 2018 21:16:01 -0500
Labels: app=kubernetes-dashboard
pod-template-hash=334721719
Status: Running
IP: 172.17.13.3
Controllers: ReplicaSet/kubernetes-dashboard-334721719
Containers:
kubernetes-dashboard:
Container ID: docker://e376142b498b342099a655bcb02ba03a95a049c693750d0a1e8c547f7d127206
Image: daocloud.io/minunix/kubernetes-dashboard-amd64:v1.1.1
Image ID: docker-pullable://daocloud.io/minunix/kubernetes-dashboard-amd64@sha256:7fd7fd0e1aa84aecb62d62c10df0e8c4ed9cd80c538851962f058d708df06595
Port: 9090/TCP
Args:
–apiserver-host=http://192.168.142.128:8080
State: Running
Started: Thu, 18 Jan 2018 21:16:12 -0500
Ready: True
Restart Count: 0
Liveness: http-get http://:9090/ delay=30s timeout=30s period=10s #success=1 #failure=3
Volume Mounts: <none>
Environment Variables: <none>
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
No volumes.
QoS Class: BestEffort
Tolerations: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
——— ——– —– —- ————- ——– —— ——-
2m 2m 1 {default-scheduler } Normal Scheduled Successfully assigned kubernetes-dashboard-334721719-k4dn9 to 192.168.142.138
2m 2m 1 {kubelet 192.168.142.138} spec.containers{kubernetes-dashboard} Normal Pulling pulling image "daocloud.io/minunix/kubernetes-dashboard-amd64:v1.1.1"
2m 2m 2 {kubelet 192.168.142.138} Warning MissingClusterDNS kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to DNSDefault policy.
2m 2m 1 {kubelet 192.168.142.138} spec.containers{kubernetes-dashboard} Normal Pulled Successfully pulled image "daocloud.io/minunix/kubernetes-dashboard-amd64:v1.1.1"
2m 2m 1 {kubelet 192.168.142.138} spec.containers{kubernetes-dashboard} Normal Created Created container with docker id e376142b498b; Security:[seccomp=unconfined]
2m 2m 1 {kubelet 192.168.142.138} spec.containers{kubernetes-dashboard} Normal Started Started container with docker id e376142b498b
[root@master dockerconfig]#

在node1上查看docker信息

[root@k8s_node1 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e376142b498b daocloud.io/minunix/kubernetes-dashboard-amd64:v1.1.1 "/dashboard –port=90" 4 minutes ago Up 4 minutes k8s_kubernetes-dashboard.b582b075_kubernetes-dashboard-334721719-k4dn9_kube-system_b1c339df-fcbe-11e7-a898-000c29027e38_040bd918
217259971f68 registry.access.redhat.com/rhel7/pod-infrastructure:latest "/usr/bin/pod" 4 minutes ago Up 4 minutes k8s_POD.28c50bab_kubernetes-dashboard-334721719-k4dn9_kube-system_b1c339df-fcbe-11e7-a898-000c29027e38_71496fa5
4773c9fc3ead registry.access.redhat.com/rhel7/pod-infrastructure:latest "/usr/bin/pod" 21 minutes ago Up 21 minutes k8s_POD.28c50bab_kubernetes-dashboard-latest-3447225518-gk7br_kube-system_60816c6e-fcbc-11e7-a898-000c29027e38_94bd5ef7
[root@k8s_node1 ~]#

查看对外端口
[root@master dockerconfig]# kubectl get service –namespace=kube-system
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes-dashboard 192.168.142.252 <nodes>–在node 80:30949/TCP 10m
[root@master dockerconfig]#

通过页面访问
http://192.168.142.138:30949/#/pod/default/nginx-pod 直接访问node1的地址

http://192.168.142.128:8080/api/v1/proxy/namespaces/kube-system/services/kubernetes-dashboard/#/workload 通过master访问

———-使用dashboard进行APP部署————

新建 appname(helloworld)—image(nginx)—-extend—port(80)–targetport(80) –确定

[root@master dockerconfig]# kubectl get service –namespace=kube-system ——-查看对外端口
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
helloworld 192.168.142.153 <pending> 80:31675—端口/TCP 5m
kubernetes-dashboard 192.168.142.252 <nodes> 80:30949/TCP 1h
[root@master dockerconfig]#

测试一下
[root@master dockerconfig]# curl k8s_node1:31675
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
</html> ——-成功
[root@master dockerconfig]#

————进行mysql部署————

前面是一样
[root@master dockerconfig]# kubectl describe pods –namespace=database
Name: mysqltest-7ctnt
Namespace: database
Node: 192.168.142.128/192.168.142.128
Start Time: Thu, 18 Jan 2018 23:14:19 -0500
Labels: app=mysqltest
Status: Pending
IP:
Controllers: ReplicationController/mysqltest
Containers:
mysqltest:
Container ID:
Image: mysql
Image ID:
Port:
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count: 0
Volume Mounts: <none>
Environment Variables: <none>
Conditions:
Type Status
Initialized True
Ready False
PodScheduled True
No volumes.
QoS Class: BestEffort
Tolerations: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
——— ——– —– —- ————- ——– —— ——-
2m 2m 1 {default-scheduler } Normal Scheduled Successfully assigned mysqltest-7ctnt to 192.168.142.128
2m 2m 1 {kubelet 192.168.142.128} Warning MissingClusterDNS kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to DNSDefault policy.
2m 2m 1 {kubelet 192.168.142.128} spec.containers{mysqltest} Normal Pulling pulling image "mysql"
[root@master dockerconfig]# kubectl get pods –namespace=database

[root@master ~]# kubectl describe pods –namespace=database
Name: mysqltest-7ctnt
Namespace: database
Node: 192.168.142.128/192.168.142.128
Start Time: Thu, 18 Jan 2018 23:14:19 -0500
Labels: app=mysqltest
Status: Running
IP: 172.17.72.3
Controllers: ReplicationController/mysqltest
Containers:
mysqltest:
Container ID: docker://c7697c1c17742628c0fe5ee8ff8b0405866c5d0542e76e542e2863537bea985d
Image: mysql
Image ID: docker-pullable://docker.io/mysql@sha256:7cdb08f30a54d109ddded59525937592cb6852ff635a546626a8960d9ec34c30
Port:
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: Error
Exit Code: 1
Started: Thu, 18 Jan 2018 23:38:33 -0500
Finished: Thu, 18 Jan 2018 23:38:35 -0500
Ready: False
Restart Count: 8
Volume Mounts: <none>
Environment Variables: <none>
Conditions:
Type Status
Initialized True
Ready False
PodScheduled True
No volumes.
QoS Class: BestEffort
Tolerations: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
——— ——– —– —- ————- ——– —— ——-
26m 26m 1 {default-scheduler } Normal Scheduled Successfully assigned mysqltest-7ctnt to 192.168.142.128
19m 19m 1 {kubelet 192.168.142.128} spec.containers{mysqltest} Normal Created Created container with docker id 1face8a8e311; Security:[seccomp=unconfined]
19m 19m 1 {kubelet 192.168.142.128} spec.containers{mysqltest} Normal Started Started container with docker id 1face8a8e311
19m 19m 1 {kubelet 192.168.142.128} spec.containers{mysqltest} Normal Created Created container with docker id e14e935fc888; Security:[seccomp=unconfined]
19m 19m 1 {kubelet 192.168.142.128} spec.containers{mysqltest} Normal Started Started container with docker id e14e935fc888
19m 19m 2 {kubelet 192.168.142.128} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "mysqltest" with CrashLoopBackOff: "Back-off 10s restarting failed container=mysqltest pod=mysqltest-7ctnt_database(385572de-fccf-11e7-a898-000c29027e38)"

这个错误基本上是 环境变量的问题在kubernetes dashboard上增加环境变为

mysqltest1
Image:
mysql
Environment variables:
MYSQL_ROOT_PASSWORD: 123456 —加这个就好了

———-wordpress部署测试———–
wordpresstest
Image:
wordpress
Environment variables:
WORDPRESS_DB_HOST: 192.168.142.138:32052
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: 123456
WORDPRESS_DB_NAME: wordpress

kubernetes 展示的信息

Details
Name:
wordpresstest
Namespace:
database
Label selector:
app: wordpresstest
Labels:
app: wordpresstest
Images:
wordpress
Status
Pods:
1 running
Services
Name
Labels
Cluster IP
Internal endpoints
External endpoints
timelapse
wordpresstest
app: wordpresstest
192.168.142.168
wordpresstest.database:80 TCP —–内部端口
wordpresstest.database:32566 TCP——对外端口

more_vert
Pods
Name
Status
Restarts
Age
Cluster IP
CPU (cores)
Memory (bytes)
check_circle
wordpresstest-c7d70
Running
0
55 minutes
172.17.72.9

测试一下
[root@master ~]# curl http://192.168.142.138:32566/ |less
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 53462 0 53462 0 0 321k 0 –:–:– –:–:– –:–:– 322k

正常

———-DOCKER加速器测试————-
http://guide.daocloud.io/dcs/docker-9153151.html 测试一下

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://b2ae5821.m.daocloud.io

运行后重启docker报错
[root@k8s_node1 ~]# systemctl status docker
● docker.service – Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/docker.service.d
└─flannel.conf
Active: failed (Result: exit-code) since Thu 2018-01-18 23:25:07 EST; 32s ago
Docs: http://docs.docker.com
Process: 46222 ExecStart=/usr/bin/dockerd-current –add-runtime docker-runc=/usr/libexec/docker/docker-runc-current –default-runtime=docker-runc –exec-opt native.cgroupdriver=systemd –userland-proxy-path=/usr/libexec/docker/docker-proxy-current $OPTIONS $DOCKER_STORAGE_OPTIONS $DOCKER_NETWORK_OPTIONS $ADD_REGISTRY $BLOCK_REGISTRY $INSECURE_REGISTRY $REGISTRIES (code=exited, status=1/FAILURE)
Main PID: 46222 (code=exited, status=1/FAILURE)

Jan 18 23:25:07 k8s_node1 systemd[1]: Starting Docker Application Container Engine…
Jan 18 23:25:07 k8s_node1 dockerd-current[46222]: time="2018-01-18T23:25:07-05:00" level=fatal msg="unable to configure the Docker daemon with file /etc/…string\n"
Jan 18 23:25:07 k8s_node1 systemd[1]: docker.service: main process exited, code=exited, status=1/FAILURE
Jan 18 23:25:07 k8s_node1 systemd[1]: Failed to start Docker Application Container Engine.
Jan 18 23:25:07 k8s_node1 systemd[1]: Unit docker.service entered failed state.
Jan 18 23:25:07 k8s_node1 systemd[1]: docker.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

原因是脚本修改 vim /etc/docker/daemon.json 有问题需要手动修改

——–daemon.json修改如下——-
{"registry-mirrors": ["http://b2ae5821.m.daocloud.io"], "insecure-registries": []
}
———daemon.jason修改完成————

查状态正常
[root@k8s_node1 ~]# systemctl status docker
● docker.service – Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/docker.service.d
└─flannel.conf
Active: active (running) since Thu 2018-01-18 23:28:38 EST; 1min 43s ago
Docs: http://docs.docker.com
Main PID: 48542 (dockerd-current)

———–查看pod在哪个node上——–
[root@k8s_master ~]# kubectl get pods -o wide –namespace=database
NAME READY STATUS RESTARTS AGE IP NODE—-就是这个你懂的
httpdtest-1nv30 1/1 Running 3 23h 172.17.72.5 192.168.142.128
mysqltest1-w7fjr 1/1 Running 3 23h 172.17.72.3 192.168.142.128
nginxtest2-3247366770-2kqlc 1/1 Running 0 13h 172.17.13.5 192.168.142.138
nginxtest2-3247366770-5jfrv 1/1 Running 0 13h 172.17.13.4 192.168.142.138
nginxtest2-3247366770-6bs0t 1/1 Running 0 13h 172.17.13.6 192.168.142.138
redisteset-5b993 1/1 Running 1 14h 172.17.13.2 192.168.142.138
wordpresstest-c7d70 1/1 Running 3 22h 172.17.72.2 192.168.142.128
[root@k8s_master ~]#

[root@k8s_master ~]# kubectl get -h ——-其它的问它

——–进行拉取测试————

速度叼爆了
[root@k8s_node1 ~]# docker pull wordpress
Using default tag: latest
Trying to pull repository docker.io/library/wordpress …
latest: Pulling from docker.io/library/wordpress

75651f247827: Pull complete
dbcf8fd0150f: Pull complete
de80263f26f0: Pull complete
65be8ad4c5fd: Pull complete
239d5fed0dda: Pull complete
5ab39b683a9f: Pull complete
4a3f54f2d93a: Pull complete
28c970ad99e9: Pull complete
5d1e20c7c396: Pull complete
05f877a23903: Pull complete
e0a5c61bdaa6: Pull complete
d27d2d70a072: Pull complete
ba039fef4b7e: Pull complete
fd026e22f5c3: Pull complete
a523c6d55ab4: Pull complete
025590874132: Pull complete
2d4bd5336aa0: Pull complete
c014b4d902ee: Pull complete
Digest: sha256:73d85a7ae83ea7240090c3a52dbf176d610df2480c75c9e7fed8dba7e3d5154e

wget https://rawgit.com/kubernetes/dashboard/master/src/deploy/kubernetes-dashboard.yaml

kubectl create -f kubernetes-dashboard.yaml

kubectl delete -f kubernetes-dashboard.yaml

kubectl create -f kubernetes-dashboard.yaml

kubectl get namespace

转载于:https://blog.51cto.com/douya/2141036

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐