CentOS7搭建Kubernetes-dashboard管理服务

一、先决条件


1、首先你必有现成的Kubernetes集群,如果现在你一无所有,请参考:

http://zlyang.blog.51cto.com/1196234/1951010

2、建议采用etcd集群,搭建过程请参考:

http://zlyang.blog.51cto.com/1196234/1951164

二、部署Kubernetes-dashboard

[所有机器:Master、Node1、Node2]

1、安装flannel(flannel为管理Containers网络)

[[email protected] ~]# yum -y install epel-release flannel

2、配置flanel

[Master]

[[email protected] ~]# vim /etc/sysconfig/flanneld

# Flanneld configuration options

# etcd url location.  Point this to the server where etcd runs

FLANNEL_ETCD_ENDPOINTS="http://k8s-master:2379"

# etcd config key.  This is the configuration key that flannel queries

# For address range assignment

FLANNEL_ETCD_PREFIX="/atomic.io/network"

# Any additional options that you want to pass

#FLANNEL_OPTIONS=""

  [Node]

[[email protected] ~]# vim /etc/sysconfig/flanneld

# Flanneld configuration options

# etcd url location.  Point this to the server where etcd runs

FLANNEL_ETCD_ENDPOINTS="http://k8s-master:2379"

# etcd config key.  This is the configuration key that flannel queries

# For address range assignment

FLANNEL_ETCD_PREFIX="/atomic.io/network"

# Any additional options that you want to pass

#FLANNEL_OPTIONS=""

  3、添加Etcd网络配置

  [Master]

[[email protected] ~]# mkdir -p /atomic.io/network/

[[email protected] ~]# chmod -R 777 /atomic.io

[[email protected] ~]# etcdctl mk /atomic.io/network/config ‘{"Network":"10.254.0.0/16"}‘

****** 注:此IP为/etc/kubernetes/apiserver中{KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16" }填写的地址

4、启动flannel服务

  [所有机器]

[[email protected] ~]# systemctl start flanneld.service

[[email protected] ~]# systemctl enable flanneld.service

5、修改Kubernetes所有Node节点kubelet设置中添加dns信息,否则会报错

[Node1/Node2]

[[email protected] ~]# vim /etc/kubernetes/kubelet

###

# kubernetes kubelet (minion) config

# The address for the info server to serve on (set to 0.0.0.0 or "" for all interfaces)

KUBELET_ADDRESS="--address=0.0.0.0"

# The port for the info server to serve on

KUBELET_PORT="--port=10250"

# You may leave this blank to use the actual hostname

KUBELET_HOSTNAME="--hostname-override=k8s-node1"

# location of the api-server

KUBELET_API_SERVER="--api-servers=http://k8s-master:8080"

# pod infrastructure container

KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"

# Add your own!

#KUBELET_ARGS=""

KUBELET_ARGS="--cluster-dns=223.5.5.5 --cluster-domain=k8s-master"

6、重启Node上的服务

  [Master]

for SERVICES in flanneld etcd kube-apiserver kube-controller-manager kube-scheduler; do     systemctl restart $SERVICES;     systemctl enable $SERVICES;     systemctl status $SERVICES ;   done

  [Node]

for SERVICES in flanneld kube-proxy kubelet docker; do     systemctl restart $SERVICES;     systemctl enable $SERVICES;     systemctl status $SERVICES ; done

7、安装dashboard

[Node1/Node2]

    a、导入images

***由于墙的原因,需要先导入images,如果你可以翻墙,忽略此步骤

下载地址:

    b、导入:

[[email protected] ~]# docker load < kubernetes-dashboard.tar.gz

    c、查看

[[email protected] ~]# docker images

REPOSITORY                                            TAG                 IMAGE ID            CREATED             SIZE

gcr.io/google_containers/kubernetes-dashboard-amd64   v1.6.2              bd4d50b8499e        8 days ago          139 MB

8、创建dashboard容器

    [Master]

a、下载kubernetes-dashboar.yaml文件

[[email protected] ~]# git clone https://github.com/jdedu/kubernetes.git

b、修改其中标红项

[[email protected] ~]# vim kubernetes/kubernetes-dashboard.yaml

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.2

imagePullPolicy: Always

ports:

- containerPort: 9090

protocol: TCP

args:

- --apiserver-host=http://192.168.80.130: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

targetPort: 9090

selector:

app: kubernetes-dashboard

  9、创建dashboard容器

  [Master]

[[email protected] ~]# kubectl create -f kubernetes-dashboard.yaml

deployment "kubernetes-dashboard" created

service "kubernetes-dashboard" created

  10、查看状态

  a、查看pods

[[email protected] ~]# kubectl get pods --namespace=kube-system

NAME                                    READY     STATUS              RESTARTS   AGE

kubernetes-dashboard-1607234690-3bnk2   0/1       ContainerCreating   0          34s

b、查看构建详细信息

[[email protected] ~]# kubectl describe pods kubernetes-dashboard-1607234690-3bnk2 --namespace=kube-system

Name:   kubernetes-dashboard-1607234690-3bnk2

Namespace:  kube-system

Node:   k8s-node2/192.168.80.132

Start Time: Thu, 03 Aug 2017 17:15:50 +0800

Labels:   app=kubernetes-dashboard

pod-template-hash=1607234690

Status:   Pending

IP:

Controllers:  ReplicaSet/kubernetes-dashboard-1607234690

Containers:

kubernetes-dashboard:

Container ID:

Image:    gcr.io/google_containers/kubernetes-dashboard-amd64:v1.6.2

Image ID:

Port:   9090/TCP

Args:

--apiserver-host=http://192.168.80.130:8080

State:      Waiting

Reason:     ContainerCreating

Ready:      False

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   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 kubernetes-dashboard-1607234690-3bnk2 to k8s-node2

三、测试

  a、在测试机上添加host信息

192.168.80.130  k8s-master

b、使用浏览器输入:http://k8s-master:8080/ui

四、错误

  [错误1]

[[email protected] ~]# kubectl describe pods kubernetes-dashboard-1607234690-3bnk2 --namespace=kube-system

1s    1s    1 {kubelet k8s-node2}           Warning   FailedSync  Error syncing pod, skipping: failed to "StartContainer" for "kubernetes-dashboard" with CrashLoopBackOff: "Back-off 10s restarting failed container=kubernetes-dashboard pod=kubernetes-dashboard-980055440-l9zl5_kube-system(870d02e1-7810-11e7-9517-000c296a54e8)"

再次使用kubectl logs查看具体错误信息

[[email protected] ~]# kubectl logs kubernetes-dashboard-1607234690-l6gfk --namespace=kube-system

No request provided. Skipping authorization header

Error while initializing connection to Kubernetes apiserver. This most likely means that the cluster is misconfigured (e.g., it has invalid apiserver certificates or service accounts configuration) or the --apiserver-host param points to a server that does not exist. Reason: Get http://k8s-master:8080/version: dial tcp: lookup k8s-master on 223.5.5.5:53: no such host

Refer to the troubleshooting guide for more information: https://github.com/kubernetes/dashboard/blob/master/docs/user-guide/troubleshooting.md

  [解决方案]

[[email protected] ~]# vim kubenetes-dashboard.yaml

- --apiserver改成ip,不要使用域名

此过程中可能会遇到很多问题,如果需要帮助,请发邮件至:[email protected]

时间: 2024-12-18 07:45:45

CentOS7搭建Kubernetes-dashboard管理服务的相关文章

CentOS7搭建Kubernetes dashboard

CentOS7搭建Kubernetes dashboard一 环境声明Centos7三台,master节点一台,node节点两台Dashboard需要一个镜像,需要执行命令下载:docker pull mritd/kubernetes-dashboard-amd64:v1.5.1ps:还有很多其他的镜像也能搭建dashboard,不过这个版本是汉化版 注意:两个node节点都需要下载此镜像,master节点不用,因为dashboard的pod会被master调度到两台node之一去创建,不会在m

CentOS7 搭建kubernetes、etcd

一.前言 Kubernetes 是Google开源的容器集群管理系统,基于Docker构建一个容器的调度服务,提供资源调度.均衡容灾.服务注册.动态扩缩容等功能套件,目前最新版本为0.6.2.本文介绍如何基于Centos7.0构建Kubernetes平台,在正式介绍之前,大家有必要先理解Kubernetes几个核心概念及其承担的功能.以下为Kubernetes的架构设计图 1. Pods        在Kubernetes系统中,调度的最小颗粒不是单纯的容器,而是抽象成一个Pod,Pod是一个

centos7 中 systemd systemctl管理服务的命令

背景: centos7 和 6的重大改变 对于系统管理员而言,系统的服务管理是一件很日常和很重要的工作,而7在6的基础上有了很大的改变,就连命令都完全不一样了.所以要拥抱变化,学习7是如何进行服务的管理和控制的. system和systemctl的初探 Systemctl是一个systemd工具,主要负责控制systemd系统和服务管理器. Systemd是一个系统管理守护进程.工具和库的集合,用于取代System V初始进程.Systemd的功能是用于集中管理和配置类UNIX系统. 在Linu

centos7搭建虚拟用户ftp服务

1.创建虚拟账户文件,奇数行为用户名,偶数行为密码2.将存储虚拟账户用户名密码文件转换为数据库,数据库文件为vuser.db3.配置pam验证加载账户名密码数据库4.创建系统账户指定ftp根目录位置,用户名为virtualftp5.修改ftp主配置文件支持虚拟账户6.创建存储虚拟账户访问ftp目录7.设置Alice允许下载和上传权限8.设置marry下载上传创建目录删除数据覆盖重命名文件或者目录9.创建测试数据启动服务设置服务开机自动启动1)创建测试数据2)设置ftp根目录为755权限,允许其他

搭建IPA用户管理服务器&安装ssh远程访问服务

1.搭建IPA用户管理服务器 搭建准备前工作 workstation: #先停掉dhcp服务 systemctl stop dhcpd;systemctl disable dhcpd #分别在workstation,server1,server2,database上安装ntp服务 yum -y install ntp #打开ntp配置文件,做如下修改 workstation: vim /etc/ntp.conf 17 restrict 192.168.40.0 mask 255.255.255.

使用ElasticSearch+LogStash+Kibana+Redis搭建日志管理服务

1.使用ElasticSearch+LogStash+Kibana+Redis搭建日志管理服务 http://www.tuicool.com/articles/BFzye2 2.ElasticSearch+LogStash+Kibana+Redis日志服务的高可用方案 http://www.tuicool.com/articles/EVzEZzn 3.示例 开源实时日志分析ELK平台部署 http://baidu.blog.51cto.com/71938/1676798?utm_source=t

CentOS7中搭建Cobbler自动装机服务

cobbler是一个使用python开发的开源项目,通过部署系统所设计的所有服务集中在一起,来提供一个全自动批量安装快速建立Linux系统的网络安装环境.Cobbler提供了DHCP管理.YUM源管理.电源管理等功能,除此之外还支持命令行管理.WEB界面管理,并且提供了API接口,方便进行二次开发.下面将利用一台CentOS系统虚拟机搭建Cobbler服务平台,为其他新机器安装Linux操作系统. 部署Cobbler环境 1.导入epel源 服务端共享安装: epel-release-lates

Kubernetes+Federation打造跨多云管理服务

Kubernetes日渐普及,在公有云.私有云等多个环境中部署kubernetes集群已是常规做法,而随着环境的复杂多样和集群数量增长,如何高效地管理这些集群成为新的问题.于是跨多云管理服务应运而生. 华为云高级工程师Fisher在Cloud Native Days China 2019杭州站发表了名为<Kubernetes+Federation打造跨多云管理服务>的议题,介绍了基于Federation的多云管理现状及未来计划.本文整理自Fisher现场分享实录. 大家好,我是华为云的Fish

linux常用命令---centOS7的管理服务(针对yum安装的)

centOS7的管理服务(针对yum安装的) 原文地址:https://www.cnblogs.com/open-yang/p/11253289.html