一、Kubernetes集群环境
请参考Kubernetes--学习笔记-安装配置和服务部署-2
https://cnodejs.org/topic/57aa945c476898b472247d90
二,创建kubernetes-dashboard.yaml
在master服务器上创建kubernetes-dashboard.yaml文件,并输入以下内容:
-
# Copyright 2015 Google Inc. All Rights Reserved.
-
#
-
# Licensed under the Apache License, Version 2.0 (the "License");
-
# you may not use this file except in compliance with the License.
-
# You may obtain a copy of the License at
-
#
-
# http://www.apache.org/licenses/LICENSE-2.0
-
#
-
# Unless required by applicable law or agreed to in writing, software
-
# distributed under the License is distributed on an "AS IS" BASIS,
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
# See the License for the specific language governing permissions and
-
# limitations under the License.
-
-
# Configuration to deploy release version of the Dashboard UI.
-
#
-
# Example usage: kubectl create -f <this_file>
-
-
kind: Deployment
-
apiVersion: extensions/v1beta1
-
metadata:
-
labels:
-
app: kubernetes-dashboard
-
version: v1. 1.0
-
name: kubernetes-dashboard
-
namespace: kube- system
-
spec:
-
replicas: 1
-
selector:
-
matchLabels:
-
app: kubernetes-dashboard
-
template:
-
metadata:
-
labels:
-
app: kubernetes-dashboard
-
spec:
-
containers:
-
- name: kubernetes-dashboard
-
image: docker.io/mritd/kubernetes-dashboard-amd64
-
imagePullPolicy: Always
-
ports:
-
- containerPort: 9090
-
protocol: TCP
-
args:
-
# Uncomment the following line to manually specify Kubernetes API server Host
-
# If not specified, Dashboard will attempt to auto discover the API server and connect
-
# to it. Uncomment only if the default does not work.
-
- --apiserver-host= 10.11. 3.56: 8080
-
livenessProbe:
-
httpGet:
-
path: /
-
port: 9090
-
initialDelaySeconds: 30
-
timeoutSeconds: 30
-
---
-
kind: Service
-
apiVersion: v1
-
metadata:
-
labels:
-
app: kubernetes-dashboard
-
name: kubernetes-dashboard
-
namespace: kube-system
-
spec:
-
type: NodePort
-
ports:
-
- port: 80
修改以下几项:
image: docker.io/mritd/kubernetes-dashboard-amd64 # 这个镜像在创建之前已docker pull 下载下来,避免网络失败
- --apiserver-host=10.11.3.56:8080 # 这里改成master这的ip地址,不能用master服务器名称,否则会报错失败
执行以下命令创建kubernetes-dashboard:
systemctl create -f kubernetes-dashboard.yaml
创建完成后,查看Pods和Service的详细信息:
-
[root@master cloud] # kubectl get pods --all-namespaces
-
NAMESPACE NAME READY STATUS RESTARTS AGE
-
default nginx-pod 1/ 1 Running 0 5h
-
kube- system kubernetes-dashboard- 350055417-wf8j1 1/ 1 Running 0 44 m
-
[root@master cloud] #
-
[root@master cloud] # kubectl describe pods/kubernetes-dashboard-350055417-wf8j1 --namespace="kube-system"
-
Name: kubernetes-dashboard -350055417-wf8j1
-
Namespace: kube-system
-
Node: node -1/ 10.11 .3 .61
-
Start Time: Wed, 17 Jan 2018 08: 07: 38 + 0100
-
Labels: app=kubernetes-dashboard
-
pod-template-hash= 350055417
-
Status: Running
-
IP: 172.17 .0 .3
-
Controllers: ReplicaSet/kubernetes-dashboard -350055417
-
Containers:
-
kubernetes-dashboard:
-
Container ID: docker:// 4fab3e7e09bbd80546aec6f3569b3a59723ef983356e59428879fe06e3359861
-
Image: docker.io/mritd/kubernetes-dashboard-amd64
-
Image ID: docker-pullable://docker.io/mritd/kubernetes-dashboard-amd64@sha256: 377d905c758d08674fd434e567fbfb4411f64a52090d0de7f64fd70b72b2fbeb
-
Port: 9090/TCP
-
Args:
-
--apiserver-host= 10.11 .3 .56: 8080
-
State: Running
-
Started: Wed, 17 Jan 2018 08: 07: 43 + 0100
-
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
-
--------- -------- ----- ---- ------------- -------- ------ -------
-
46m 46m 1 {default-scheduler } Normal Scheduled Successfully assigned kubernetes-dashboard -350055417-wf8j1 to node -1
-
46m 46m 1 {kubelet node -1} spec.containers{kubernetes-dashboard} Normal Pulling pulling image "docker.io/mritd/kubernetes-dashboard-amd64"
-
46m 46m 2 {kubelet node -1} Warning MissingClusterDNS kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to DNSDefault policy.
-
46m 46m 1 {kubelet node -1} spec.containers{kubernetes-dashboard} Normal Pulled Successfully pulled image "docker.io/mritd/kubernetes-dashboard-amd64"
-
46m 46m 1 {kubelet node -1} spec.containers{kubernetes-dashboard} Normal Created Created container with docker id 4fab3e7e09bb; Security:[seccomp=unconfined]
-
46m 46m 1 {kubelet node -1} spec.containers{kubernetes-dashboard} Normal Started Started container with docker id 4fab3e7e09bb
-
[root@master cloud] #
查看service 信息:
-
[root@master cloud] # kubectl describe service/kubernetes-dashboard --namespace="kube-system"
-
Name: kubernetes-dashboard
-
Namespace: kube- system
-
Labels: app=kubernetes-dashboard
-
Selector: app=kubernetes-dashboard
-
Type: NodePort
-
IP: 10.254. 85.224
-
Port: <unset> 80/TCP
-
NodePort: <unset> 30943/TCP
-
Endpoints: 172.17. 0. 3: 9090
-
Session Affinity: None
-
No events.
-
[root@master cloud] #
从kubernetes-dashboard的service详细信息可以看到,该service绑定到了Node节点的30943端口上。现在,通过浏览器访问该端口就能看到Kubernetes的Web UI:
参考链接:
http://blog.csdn.net/u013760355/article/details/70161982
http://blog.csdn.net/zjysource/article/details/52086835
https://blog.csdn.net/harris135/article/details/79086221