K8S集群搭建高可用prometheus+grafana

使用k3s来搭建测试环境。

为什么使用k3s

K3s 是一个轻量级的、完全兼容的 Kubernetes 发行版本。非常适合测试。

K3s将所有 Kubernetes 控制平面组件都封装在单个二进制文件和进程中,文件大小<100M,占用资源更小,且包含了kubernetes运行所需要的部分外部依赖和本地存储提供程序。

K3s提供了离线安装包,安装起来非常方便,可以避免安装过程中遇到各种网络资源访问问题。

安装k3s

1.准备工作

systemctl disable firewalld --now

2.使用官方脚本在线安装集群

#master
curl -sfL https://get.k3s.io | sh -
#在master节点上获取集群token
cat /var/lib/rancher/k3s/server/node-token

#在agent节点使用token部署工作节点
curl -sfL https://get.k3s.io | K3S_URL=https://master:6443 K3S_TOKEN=XXX sh -

3.在master节点查看集群状态

root@master:~# kubectl get nodes
NAME     STATUS   ROLES                  AGE   VERSION
master   Ready    control-plane,master   14d   v1.25.3+k3s1
agent    Ready    <none>                 14d   v1.25.3+k3s1

部署prometheus+grafana

使用github的kube-prometheus项目快速部署

git clone https://github.com/prometheus-operator/kube-prometheus.git -p release-0.11

cd kube-promethues

kubectl apply --server-side -f manifests/setup

kubectl wait \
	--for condition=Established \
	--all CustomResourceDefinition \
	--namespace=monitoring
kubectl apply -f manifests/

此时,k3s集群开始拉去镜像,并自动部署高可用prometheus集群。

#查看prometheus集群的构建状态
kubectl get all -n monitoring
kubectl get pod -n monitoring

#如果发现有不能拉取的镜像,或者构建失败的pod,通过describe查看具体信息。
kubectl describe pod kube-state-metrics-XXX -n monitoring
#找到对应的镜像名,到dockerhub上找相同的拉取。

最后,通过修改service.yml的方式,使集群的端口以NodePort的方式暴露出来。

K8S集群搭建高可用prometheus+grafana
K8S集群搭建高可用prometheus+grafana

修改完成后,一定要重新部署service,使修改生效

kubectl apply -f grafana-service.yaml -n monitoring

查看NodePort并访问

kubectl get svc -n monitoring
K8S集群搭建高可用prometheus+grafana

通过集群里任意IP:PORT进行web页面的访问

K8S集群搭建高可用prometheus+grafana

文章来源:https://www.cnaaa.net,转载请注明出处:https://www.cnaaa.net/archives/6185

(0)
李逍遥的头像李逍遥
上一篇 2022年11月21日 下午4:43
下一篇 2022年11月22日 下午5:30

相关推荐

  • 使用openssl创建自签发SSL证书

    使用openssl创建自签发SSL证书 生成根证书 生成ca秘钥,得到ca.key openssl genrsa -out ca.key 4096 生成ca证书签发请求,得到ca.csr openssl req -new -key ca.key -out ca.csr -subj “/C=CN/ST=JS/L=NanJing/O=other/OU=other…

    2023年1月31日
    96500
  • CentOS 使用speedtest命令行测试网速

    安装speedtest-cli speedtest-cli是一个用Python编写的轻量级Linux命令行工具,在Python2.4至3.4版本下均可运行。它基于Speedtest.net的基础架构来测量网络的上/下行速率。安装speedtest-cli很简单——只需要下载其Python脚本文件。 使用speedtest-cli测试网速 输入这个命令后,它会…

    2022年6月28日
    1.2K00
  • Win10共享文件夹无法访问怎么办

    无论是学习还是工作我们都会去设置共享文件来使用,不过难免也会遇到无法打开或者使用共性文件夹的情况,而这一般是系统设置出现问题,而以下是小编所带来几种解决win10不能共享文件夹的解决方法,一起来看看吧。   Win10无法打开共享文件的解决方法   方法一   1. 首先在Windows10电脑上按下Win+R组合键,打开运行窗口,输入命令services.…

    2024年6月11日
    1.3K00
  • Windows无法使用Internet Explorer浏览器访问外部网站如何处理?

    问题描述 在Windows实例内无法使用操作系统自带的Internet Explorer浏览器访问外部网站,提示如下: 问题原因 在Windows实例内无法使用Internet Explorer浏览器访问外部网站,可能是如下原因导致: 解决方案 您可以通过以下步骤逐步排查,解决上述问题。 说明 以下操作步骤以Windows Server 2019 数据中心版…

    2023年11月16日
    1.1K00
  • 如何清理windows server 2008 R2 中winsxs文件夹

    最近发现公司的一台服务器C盘只剩5G左右的空间,经过仔细查看发现C:\windows\winsxs 目录占了20多G的容量。此文件夹是更新系统补丁产生的不能直接删除,所以只能通过cleanmgr.exe工具进行清理C盘。 以下方法亲自验证清理成功: 一、在Windows Server 2008 R2,右击C盘,查看属性,发现界面中没有清理C盘的工具按钮,那如…

    2023年4月3日
    1.2K00

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

在线咨询: QQ交谈

邮件:712342017@qq.com

工作时间:周一至周五,8:30-17:30,节假日休息

关注微信