分类

链接

2019 年 6 月
 12
3456789
10111213141516
17181920212223
24252627282930

近期文章

热门标签

新人福利,免费薅羊毛

现在位置:    首页 > Docker > 正文
共享办公室出租
Kubernetes 1.8.6 集群部署–部署Web UI界面
Docker 暂无评论 阅读(389)

安装DNS插件

在 Master节点 上进行安装操作

下载安装文件

<span class="hljs-meta">#</span><span class="bash"> <span class="hljs-built_in">cd</span></span>
<span class="hljs-meta">#</span><span class="bash"> wget https://github.com/kubernetes/kubernetes/releases/download/v1.8.6/kubernetes.tar.gz</span>
<span class="hljs-meta">#</span><span class="bash"> tar xzvf kubernetes.tar.gz</span>
<span class="hljs-meta">
#</span><span class="bash"> <span class="hljs-built_in">cd</span> /root/kubernetes/cluster/addons/dns</span>
<span class="hljs-meta">#</span><span class="bash"> mv  kubedns-svc.yaml.sed kubedns-svc.yaml</span>
<span class="hljs-meta">
#</span><span class="bash"><span class="zh-hans">把文件中</span><span class="hljs-variable">$DNS_SERVER_IP</span><span class="zh-hans">替换成</span>10.254.0.2</span>
<span class="hljs-meta">#</span><span class="bash"> sed -i <span class="hljs-string">'s/$DNS_SERVER_IP/10.254.0.2/g'</span> ./kubedns-svc.yaml</span>
<span class="hljs-meta">
#</span><span class="bash"> mv ./kubedns-controller.yaml.sed ./kubedns-controller.yaml</span>
<span class="hljs-meta">
#</span><span class="bash"><span class="zh-hans">把</span><span class="hljs-variable">$DNS_DOMAIN</span><span class="zh-hans">替换成</span>cluster.local</span>
<span class="hljs-meta">#</span><span class="bash"> sed -i <span class="hljs-string">'s/$DNS_DOMAIN/cluster.local/g'</span> ./kubedns-controller.yaml</span>
<span class="hljs-meta">
#</span><span class="bash"> ls *.yaml</span>
kubedns-cm.yaml  kubedns-controller.yaml  kubedns-sa.yaml  kubedns-svc.yaml

[root@master1 dns]# kubectl create -f .
configmap "kube-dns" created
deployment "kube-dns" created
serviceaccount "kube-dns" created
service "kube-dns" created

部署 dashboard 插件

master节点部署

新增部署配置文件

需要2个文件。

文件一

dashboard.yaml:
<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">v1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">ServiceAccount</span>
<span class="hljs-attr">metadata:</span>
<span class="hljs-attr">  name:</span> <span class="hljs-string">kubernetes-dashboard</span>
<span class="hljs-attr">  namespace:</span> <span class="hljs-string">kube-system</span>
<span class="hljs-meta">---</span>
<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">rbac.authorization.k8s.io/v1beta1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">ClusterRoleBinding</span>
<span class="hljs-attr">metadata:</span>
<span class="hljs-attr">  name:</span> <span class="hljs-string">kubernetes-dashboard</span>
<span class="hljs-attr">  labels:</span>
<span class="hljs-attr">    k8s-app:</span> <span class="hljs-string">kubernetes-dashboard</span>
<span class="hljs-attr">roleRef:</span>
<span class="hljs-attr">  apiGroup:</span> <span class="hljs-string">rbac.authorization.k8s.io</span>
<span class="hljs-attr">  kind:</span> <span class="hljs-string">ClusterRole</span>
<span class="hljs-attr">  name:</span> <span class="hljs-string">cluster-admin</span>
<span class="hljs-attr">subjects:</span>
<span class="hljs-attr">- kind:</span> <span class="hljs-string">ServiceAccount</span>
<span class="hljs-attr">  name:</span> <span class="hljs-string">kubernetes-dashboard</span>
<span class="hljs-attr">  namespace:</span> <span class="hljs-string">kube-system</span>
<span class="hljs-meta">---</span>
<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">extensions/v1beta1</span>
<span class="hljs-attr">kind:</span> <span class="hljs-string">Deployment</span>
<span class="hljs-attr">metadata:</span>
<span class="hljs-attr">  name:</span> <span class="hljs-string">kubernetes-dashboard</span>
<span class="hljs-attr">  namespace:</span> <span class="hljs-string">kube-system</span>
<span class="hljs-attr">  labels:</span>
<span class="hljs-attr">    k8s-app:</span> <span class="hljs-string">kubernetes-dashboard</span>
    <span class="hljs-string">kubernetes.io/cluster-service:</span> <span class="hljs-string">"true"</span>
    <span class="hljs-string">addonmanager.kubernetes.io/mode:</span> <span class="hljs-string">Reconcile</span>
<span class="hljs-attr">spec:</span>
<span class="hljs-attr">  selector:</span>
<span class="hljs-attr">    matchLabels:</span>
<span class="hljs-attr">      k8s-app:</span> <span class="hljs-string">kubernetes-dashboard</span>
<span class="hljs-attr">  template:</span>
<span class="hljs-attr">    metadata:</span>
<span class="hljs-attr">      labels:</span>
<span class="hljs-attr">        k8s-app:</span> <span class="hljs-string">kubernetes-dashboard</span>
<span class="hljs-attr">      annotations:</span>
        <span class="hljs-string">scheduler.alpha.kubernetes.io/critical-pod:</span> <span class="hljs-string">''</span>
<span class="hljs-attr">    spec:</span>
<span class="hljs-attr">      serviceAccountName:</span> <span class="hljs-string">kubernetes-dashboard</span>
<span class="hljs-attr">      containers:</span>
<span class="hljs-attr">      - name:</span> <span class="hljs-string">kubernetes-dashboard</span>
<span class="hljs-attr">        image:</span> <span class="hljs-string">registry.docker-cn.com/kubernetesdashboarddev/kubernetes-dashboard-amd64:head</span>
<span class="hljs-attr">        resources:</span>
<span class="hljs-attr">          limits:</span>
<span class="hljs-attr">            cpu:</span> <span class="hljs-number">100</span><span class="hljs-string">m</span>
<span class="hljs-attr">            memory:</span> <span class="hljs-number">300</span><span class="hljs-string">Mi</span>
<span class="hljs-attr">          requests:</span>
<span class="hljs-attr">            cpu:</span> <span class="hljs-number">100</span><span class="hljs-string">m</span>
<span class="hljs-attr">            memory:</span> <span class="hljs-number">100</span><span class="hljs-string">Mi</span>
<span class="hljs-attr">        ports:</span>
<span class="hljs-attr">        - containerPort:</span> <span class="hljs-number">9090</span>
<span class="hljs-attr">        livenessProbe:</span>
<span class="hljs-attr">          httpGet:</span>
<span class="hljs-attr">            path:</span> <span class="hljs-string">/</span>
<span class="hljs-attr">            port:</span> <span class="hljs-number">9090</span>
<span class="hljs-attr">          initialDelaySeconds:</span> <span class="hljs-number">30</span>
<span class="hljs-attr">          timeoutSeconds:</span> <span class="hljs-number">30</span>
<span class="hljs-attr">      tolerations:</span>
<span class="hljs-attr">      - key:</span> <span class="hljs-string">"CriticalAddonsOnly"</span>
<span class="hljs-attr">        operator:</span> <span class="hljs-string">"Exists"</span>

文件二:

dashboard-svc.yaml文件
<span class="hljs-attribute">apiVersion</span>: v1
<span class="hljs-attribute">kind</span>: Service
<span class="hljs-attribute">metadata</span>:
  <span class="hljs-attribute">name</span>: kubernetes-dashboard
  <span class="hljs-attribute">namespace</span>: kube-system
  <span class="hljs-attribute">labels</span>:
    <span class="hljs-attribute">k8s-app</span>: kubernetes-dashboard
    kubernetes.io/<span class="hljs-attribute">cluster-service</span>: <span class="hljs-string">"true"</span>
    addonmanager.kubernetes.io/<span class="hljs-attribute">mode</span>: Reconcile
<span class="hljs-attribute">spec</span>:
  <span class="hljs-attribute">selector</span>:
    <span class="hljs-attribute">k8s-app</span>: kubernetes-dashboard
  <span class="hljs-attribute">type</span>: NodePort
  <span class="hljs-attribute">ports</span>:
  - <span class="hljs-attribute">port</span>: <span class="hljs-number">9090</span>
    <span class="hljs-attribute">targetPort</span>: <span class="hljs-number">9090</span>
    <span class="hljs-attribute">nodePort</span>: <span class="hljs-number">8888</span>

给个吉利数字,因为这个端口来的太不容易了。。。

分别执行2个部署文件

kubectl create -f dashboard<span class="hljs-selector-class">.yaml</span>

kubectl create -f dashboard-svc<span class="hljs-selector-class">.yaml</span>

如何访问?

[root@master1 dashboard]# kubectl get po -n kube-system -o wide
NAME                                    READY     STATUS    RESTARTS   AGE       IP             NODE
heapster<span class="hljs-number">-6</span>c6bb6b7f5<span class="hljs-number">-9</span>sskf               <span class="hljs-number">1</span>/<span class="hljs-number">1</span>       Running   <span class="hljs-number">3</span>          <span class="hljs-number">3</span>h        <span class="hljs-number">172.30</span><span class="hljs-number">.61</span><span class="hljs-number">.4</span>    <span class="hljs-number">192.168</span><span class="hljs-number">.161</span><span class="hljs-number">.162</span>
kube-dns<span class="hljs-number">-777</span>f78c558-fshmq               <span class="hljs-number">3</span>/<span class="hljs-number">3</span>       Running   <span class="hljs-number">15</span>         <span class="hljs-number">9</span>h        <span class="hljs-number">172.30</span><span class="hljs-number">.61</span><span class="hljs-number">.3</span>    <span class="hljs-number">192.168</span><span class="hljs-number">.161</span><span class="hljs-number">.162</span>
kubernetes-dashboard<span class="hljs-number">-8665</span>cd4dfb<span class="hljs-number">-2</span>ddd9   <span class="hljs-number">1</span>/<span class="hljs-number">1</span>       Running   <span class="hljs-number">0</span>          <span class="hljs-number">10</span>m       <span class="hljs-number">172.30</span><span class="hljs-number">.101</span><span class="hljs-number">.2</span>   <span class="hljs-number">192.168</span><span class="hljs-number">.161</span><span class="hljs-number">.163</span>
monitoring-grafana<span class="hljs-number">-8</span>f6f789f9-lp2zk      <span class="hljs-number">1</span>/<span class="hljs-number">1</span>       Running   <span class="hljs-number">0</span>          <span class="hljs-number">1</span>h        <span class="hljs-number">172.30</span><span class="hljs-number">.61</span><span class="hljs-number">.6</span>    <span class="hljs-number">192.168</span><span class="hljs-number">.161</span><span class="hljs-number">.162</span>
monitoring-influxdb<span class="hljs-number">-7</span>c77768d9<span class="hljs-number">-9</span>nbbv     <span class="hljs-number">1</span>/<span class="hljs-number">1</span>       Running   <span class="hljs-number">0</span>          <span class="hljs-number">1</span>h        <span class="hljs-number">172.30</span><span class="hljs-number">.61</span><span class="hljs-number">.5</span>    <span class="hljs-number">192.168</span><span class="hljs-number">.161</span><span class="hljs-number">.162</span>

首先查看一下部署的服务是否正常?

如上可以很清晰的看到 咱们部署的 kubernetes-dashboard 在 192.168.161.163 上面已经部署了。

那我们可以去访问下:

<span class="hljs-symbol">http:</span><span class="hljs-comment">//192.168.161.163:8888</span>

部署 heapster 插件

下载安装文件
<span class="hljs-comment"># wget https://github.com/kubernetes/heapster/archive/v1.5.0.tar.gz</span>

<span class="hljs-comment"># tar xzvf ./v1.5.0.tar.gz</span>

<span class="hljs-comment"># cd ./heapster-1.5.0/</span>

[root@master1 heapster-1.5.0]# kubectl create -f deploy/kube-config/influxdb/
deployment <span class="hljs-string">"monitoring-grafana"</span> created<span class="hljs-built_in">
service </span><span class="hljs-string">"monitoring-grafana"</span> created
serviceaccount <span class="hljs-string">"heapster"</span> created
deployment <span class="hljs-string">"heapster"</span> created<span class="hljs-built_in">
service </span><span class="hljs-string">"heapster"</span> created
deployment <span class="hljs-string">"monitoring-influxdb"</span> created<span class="hljs-built_in">
service </span><span class="hljs-string">"monitoring-influxdb"</span> created

[root@master1 heapster-1.5.0]#  kubectl create -f deploy/kube-config/rbac/heapster-rbac.yaml
clusterrolebinding <span class="hljs-string">"heapster"</span> created

登录dashboard

当然最后真的很想说,结果我非常满意,中间入了很多坑,耗费了很长时间,但最终还是一个人搞定了。

重点留在后面,顺便给大家说下,架构所涉及的镜像源均为google的,你们也懂的,被墙的不行不行的!在此我把所有的镜像换成了阿里的如下:

大家对照着自行修改!!

文中用到的服务安装包 我已经下载好 放在了云盘:

<span class="zh-hans">链接:</span>https:<span class="hljs-regexp">//</span>pan.baidu.com<span class="hljs-regexp">/s/</span><span class="hljs-number">1</span>RPUsippDee5C9tOnBkdlqg <span class="zh-hans">密码:</span>ckez

要是直接放在yaml文件中记得去掉 docker pull

gcr.io<span class="hljs-regexp">/google_containers/</span>kubernetes-dashboard-<span class="hljs-string">amd64:</span>v1<span class="hljs-number">.8</span><span class="hljs-number">.1</span>
docker pull registry.docker-cn.com<span class="hljs-regexp">/kubernetesdashboarddev/</span>kubernetes-dashboard-<span class="hljs-string">amd64:</span>head


gcr.io<span class="hljs-regexp">/google_containers/</span>k8s-dns-kube-dns-<span class="hljs-string">amd64:</span><span class="hljs-number">1.14</span><span class="hljs-number">.5</span>
docker pull registry.cn-hangzhou.aliyuncs.com<span class="hljs-regexp">/wonders/</span>k8s-dns-kube-dns-<span class="hljs-string">amd64:</span><span class="hljs-number">1.14</span><span class="hljs-number">.5</span>


gcr.io<span class="hljs-regexp">/google_containers/</span>heapster-grafana-<span class="hljs-string">amd64:</span>v4<span class="hljs-number">.4</span><span class="hljs-number">.3</span>
docker pull registry.cn-hangzhou.aliyuncs.com<span class="hljs-regexp">/inspur_research/</span>heapster-grafana-<span class="hljs-string">amd64:</span>v4<span class="hljs-number">.4</span><span class="hljs-number">.3</span>


gcr.io<span class="hljs-regexp">/google_containers/</span>heapster-<span class="hljs-string">amd64:</span>v1<span class="hljs-number">.4</span><span class="hljs-number">.2</span>
docker pull registry.cn-hangzhou.aliyuncs.com<span class="hljs-regexp">/inspur_research/</span>heapster-<span class="hljs-string">amd64:</span>v1<span class="hljs-number">.4</span><span class="hljs-number">.2</span>


gcr.io<span class="hljs-regexp">/google_containers/</span>heapster-influxdb-<span class="hljs-string">amd64:</span>v1<span class="hljs-number">.3</span><span class="hljs-number">.3</span>
docker pull registry.cn-hangzhou.aliyuncs.com<span class="hljs-regexp">/inspur_research/</span>heapster-influxdb-<span class="hljs-string">amd64:</span>v1<span class="hljs-number">.3</span><span class="hljs-number">.3</span>


gcr.io<span class="hljs-regexp">/google_containers/</span>k8s-dns-dnsmasq-nanny-<span class="hljs-string">amd64:</span><span class="hljs-number">1.14</span><span class="hljs-number">.5</span>
docker pull registry.cn-hangzhou.aliyuncs.com<span class="hljs-regexp">/inspur_research/</span>k8s-dns-dnsmasq-nanny-<span class="hljs-string">amd64:</span><span class="hljs-number">1.14</span><span class="hljs-number">.5</span>

网友贡献:

hub.c<span class="hljs-number">.163</span>.com<span class="hljs-regexp">/zhijiansd/</span>k8s-dns-kube-dns-<span class="hljs-string">amd64:</span><span class="hljs-number">1.14</span><span class="hljs-number">.5</span>

hub.c<span class="hljs-number">.163</span>.com<span class="hljs-regexp">/zhijiansd/</span>k8s-dns-dnsmasq-nanny-<span class="hljs-string">amd64:</span><span class="hljs-number">1.14</span><span class="hljs-number">.5</span>

hub.c<span class="hljs-number">.163</span>.com<span class="hljs-regexp">/zhijiansd/</span>k8s-dns-sidecar-<span class="hljs-string">amd64:</span><span class="hljs-number">1.14</span><span class="hljs-number">.5</span>

当然,还有广大的网友支持:(阿里镜像站)

https://dev.aliyun.com/search.html

 

 

原文地址:https://www.okay686.cn/982.html

============ 欢迎各位老板打赏~ ===========

本文版权归Bruce's Blog所有,转载引用请完整注明以下信息:
本文作者:Bruce
本文地址:Kubernetes 1.8.6 集群部署–部署Web UI界面 | Bruce's Blog

发表评论

留言无头像?