在master节点上创建dashboard,在创建dashborad的时候,会在node节点上pull一个kubernetes-dashboard-amd64的镜像,然后在node节点上使用该镜像创建一个container,
1.1 查看namespace
使用kubectl get namespace命令可以获取到,这个版本的kubernets默认有kube-system的namespace,如果没有的话,可以使用下面的脚本进行创建,
kubernetes-namespace.jason文件的内容如下:
{
"kind":
"Namespace",
"apiVersion":
"v1",
"metadata": {
"name":
"kube-system"
}
}
使用kubectl
create -f kubernetes-namespace.jason创建kube-system命名空间。
1.2 dashboard的搭建
1.2.1 dashboard的搭建
创建kubernetes-dashboard.yaml文件,该文件用于创建dashboard。
-
cat 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.1
-
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: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.6.0
-
imagePullPolicy: IfNotPresent
-
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=http://10.9.178.109:8080 ## 请修改为自己的kebu-apiserver
-
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
-
targetPort: 9090
-
selector:
-
app: kubernetes-dashboard
上面文件中image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.6.0 这里使用的从google下载的镜像,生成container,如果被墙了,可以使用国内的镜像库下载后使用,这里使用有两种方法:第一种:下载下来后,配置kubernetes-dashboard.yaml文件中的 images为pull下来的name,第二种:是把下载下来的image
docker tag成 gcr.io/google_containers/kubernetes-dashboard-amd64 这样就不需要进行专门的指定。
例如下面的方法:
docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0
docker tag
registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0
gcr.io/google_containers/pause-amd64:3.0
上面的文件中需要指定-
--apiserver-host为master节点的ip地址。
2.2.2 创建kubernetes-dashboard
根据上面的文件使用kubectl create -f kubernetes-dashboard.yaml 命令创建dashboard,
[root@10-9-178-109 k8s]# kubectl create -f kubernetes-dashboard.yaml
deployment "kubernetes-dashboard" created
service "kubernetes-dashboard" created
创建完成后使用kubectl get pod --namespace="kube-system" 查看器状态,
使用kubectl
describe pods kubernetes-dashboard-2098749498-w3vl9 --namespace=kube-system命令可以查看运行的状态:
-
Name: kubernetes-dashboard-2098749498-w3vl9
-
Namespace: kube-system
-
Node: 10.9.106.37/10.9.106.37
-
Start Time: Mon, 07 Aug 2017 11:09:22 +0800
-
Labels: app=kubernetes-dashboard
-
pod-template-hash=2098749498
-
Annotations: kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"kube-system","name":"kubernetes-dashboard-2098749498","uid":"cfa92117-7b1d-11e7-a...
-
Status: Running
-
IP: 192.168.72.2
-
Created By: ReplicaSet/kubernetes-dashboard-2098749498
-
Controlled By: ReplicaSet/kubernetes-dashboard-2098749498
-
Containers:
-
kubernetes-dashboard:
-
Container ID: docker://13da640b3958032ae1565fbeed51003f906537206f191f514ac490492d0e9f79
-
Image: gcr.io/google_containers/kubernetes-dashboard-amd64:v1.6.0
-
Image ID: docker://sha256:416701f962f2f18e393d63e3840f7a3cda6da144e09692ccbf780f7f8bd0ef3f
-
Port: 9090/TCP
-
Args:
-
--apiserver-host=
-
State: Running
-
Started: Mon, 07 Aug 2017 11:09:23 +0800
-
Ready: True
-
Restart Count: 0
-
Liveness: http-get delay=30s timeout=30s period=10s #success=1 #failure=3
-
Environment:
-
Mounts:
-
Conditions:
-
Type Status
-
Initialized True
-
Ready True
-
PodScheduled True
-
Volumes:
-
QoS Class: BestEffort
-
Node-Selectors:
-
Tolerations:
-
Events:
-
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
-
--------- -------- ----- ---- ------------- -------- ------ -------
-
2m 2m 1 default-scheduler Normal Scheduled Successfully assigned kubernetes-dashboard-2098749498-w3vl9 to 10.9.106.37
-
2m 2m 1 kubelet, 10.9.106.37 spec.containers{kubernetes-dashboard} Normal Pulled Container image "gcr.io/google_containers/kubernetes-dashboard-amd64:v1.6.0" already present on machine
-
2m 2m 1 kubelet, 10.9.106.37 spec.containers{kubernetes-dashboard} Normal Created Created container
-
2m 2m 1 kubelet, 10.9.106.37 spec.containers{kubernetes-dashboard} Normal Started Started container
-
2m 1m 6 kubelet, 10.9.106.37 Warning MissingClusterDNS kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst
创建成功后在node节点,可以看到启动了两个container
使用kubectl describe service kubernetes-dashboard --namespace="kube-system"命令可以查看到node节点的信息,其中192.168.72.2的IP地址为
在node节点上使用gcr.io/google_containers/pause-amd64:3.0镜像 启动的container的ip地址为 192.168.72.2,这个就是基础镜像的ip地址,根据etcd和flanneld分配的,在master的节点上可以ping通这个ip地址,这里其实相当于在两台host上,使用etcd和flanneld搭建了一个跨主机的vxlan的overlay网络。使用pause-amd64镜像生成的container,作为基础镜像,在node节点上其余的container使用docker的 container网络模型共享网络。
在node节点上docker
inspect 13da640b3958 可以看到kubernetes-dashboard-amd64的网络模式为container,这里的container的id为 192.178.72.2的container
保证在master节点上能ping通node节点上的pause-amd64生成的container后,可以在浏览器重输入:master
public ip + 8080/ui 例如:后,可以出现久违的kubernetes的页面信息。
阅读(6091) | 评论(0) | 转发(0) |