首页 » 云自动化 » k8s » 正文

Kubernetes 1.8.6 集群部署–部署Web UI界面(七)

安装DNS插件

Master节点 上进行安装操作

下载安装文件

# cd
# wget https://github.com/kubernetes/kubernetes/releases/download/v1.8.6/kubernetes.tar.gz
# tar xzvf kubernetes.tar.gz

# cd /root/kubernetes/cluster/addons/dns
# mv  kubedns-svc.yaml.sed kubedns-svc.yaml

#把文件中$DNS_SERVER_IP替换成10.254.0.2
# sed -i 's/$DNS_SERVER_IP/10.254.0.2/g' ./kubedns-svc.yaml

# mv ./kubedns-controller.yaml.sed ./kubedns-controller.yaml

#$DNS_DOMAIN替换成cluster.local
# sed -i 's/$DNS_DOMAIN/cluster.local/g' ./kubedns-controller.yaml

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

文件二:

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

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

分别执行2个部署文件

kubectl create -f dashboard.yaml

kubectl create -f dashboard-svc.yaml

如何访问?

[root@master1 dashboard]# kubectl get po -n kube-system -o wide
NAME                                    READY     STATUS    RESTARTS   AGE       IP             NODE
heapster-6c6bb6b7f5-9sskf               1/1       Running   3          3h        172.30.61.4    192.168.161.162
kube-dns-777f78c558-fshmq               3/3       Running   15         9h        172.30.61.3    192.168.161.162
kubernetes-dashboard-8665cd4dfb-2ddd9   1/1       Running   0          10m       172.30.101.2   192.168.161.163
monitoring-grafana-8f6f789f9-lp2zk      1/1       Running   0          1h        172.30.61.6    192.168.161.162
monitoring-influxdb-7c77768d9-9nbbv     1/1       Running   0          1h        172.30.61.5    192.168.161.162

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

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

那我们可以去访问下:

http://192.168.161.163:8888

部署 heapster 插件

下载安装文件
# wget https://github.com/kubernetes/heapster/archive/v1.5.0.tar.gz

# tar xzvf ./v1.5.0.tar.gz

# cd ./heapster-1.5.0/

[root@master1 heapster-1.5.0]# kubectl create -f deploy/kube-config/influxdb/
deployment "monitoring-grafana" created
service "monitoring-grafana" created
serviceaccount "heapster" created
deployment "heapster" created
service "heapster" created
deployment "monitoring-influxdb" created
service "monitoring-influxdb" created

[root@master1 heapster-1.5.0]#  kubectl create -f deploy/kube-config/rbac/heapster-rbac.yaml
clusterrolebinding "heapster" created

登录dashboard

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

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

大家对照着自行修改!!

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

链接:https://pan.baidu.com/s/1RPUsippDee5C9tOnBkdlqg 密码:ckez

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

gcr.io/google_containers/kubernetes-dashboard-amd64:v1.8.1
docker pull registry.docker-cn.com/kubernetesdashboarddev/kubernetes-dashboard-amd64:head


gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.5
docker pull registry.cn-hangzhou.aliyuncs.com/wonders/k8s-dns-kube-dns-amd64:1.14.5


gcr.io/google_containers/heapster-grafana-amd64:v4.4.3
docker pull registry.cn-hangzhou.aliyuncs.com/inspur_research/heapster-grafana-amd64:v4.4.3


gcr.io/google_containers/heapster-amd64:v1.4.2
docker pull registry.cn-hangzhou.aliyuncs.com/inspur_research/heapster-amd64:v1.4.2


gcr.io/google_containers/heapster-influxdb-amd64:v1.3.3
docker pull registry.cn-hangzhou.aliyuncs.com/inspur_research/heapster-influxdb-amd64:v1.3.3


gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.5
docker pull registry.cn-hangzhou.aliyuncs.com/inspur_research/k8s-dns-dnsmasq-nanny-amd64:1.14.5

网友贡献:

hub.c.163.com/zhijiansd/k8s-dns-kube-dns-amd64:1.14.5

hub.c.163.com/zhijiansd/k8s-dns-dnsmasq-nanny-amd64:1.14.5

hub.c.163.com/zhijiansd/k8s-dns-sidecar-amd64:1.14.5

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

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

接下来…我会继续更新。。。

赞 (9)

发表评论