安装helm环境

[root@hello ~/yaml]#
[root@hello ~/yaml]# curl https://baltocdn.com/helm/signing.asc | sudo apt-key add -
[root@hello ~/yaml]# sudo apt-get install apt-transport-https --yes
[root@hello ~/yaml]# echo "deb https://baltocdn.com/helm/stable/debian/ all main" | sudo tee /etc/apt/sources.list.d/helm-stable-debian.list
deb https://baltocdn.com/helm/stable/debian/ all main
[root@hello ~/yaml]# sudo apt-get update
[root@hello ~/yaml]# sudo apt-get install helm
[root@hello ~/yaml]#

添加安装下载源

[root@hello ~/yaml]# helm repo add loki https://grafana.github.io/loki/charts && helm repo update
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config
"loki" has been added to your repositories
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "loki" chart repository
Update Complete. ⎈Happy Helming!⎈
[root@hello ~/yaml]#
[root@hello ~/yaml]# [root@hello ~/yaml]# helm pull loki/loki-stack
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config
[root@hello ~/yaml]# ls
loki-stack-2.1.2.tgz nfs-storage.yaml nginx-ingress.yaml
[root@hello ~/yaml]# tar xf loki-stack-2.1.2.tgz
[root@hello ~/yaml]# ls
loki-stack loki-stack-2.1.2.tgz nfs-storage.yaml nginx-ingress.yaml

安装loki日志系统

[root@hello ~/yaml]# helm install loki loki-stack/
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config
WARNING: This chart is deprecated
W1203 07:31:04.751065 212245 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+
W1203 07:31:04.754254 212245 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+
W1203 07:31:04.833003 212245 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+
W1203 07:31:04.833003 212245 warnings.go:70] policy/v1beta1 PodSecurityPolicy is deprecated in v1.21+, unavailable in v1.25+
NAME: loki
LAST DEPLOYED: Fri Dec 3 07:31:04 2021
NAMESPACE: default
STATUS: deployed
REVISION: 1
NOTES:
The Loki stack has been deployed to your cluster. Loki can now be added as a datasource in Grafana. See http://docs.grafana.org/features/datasources/loki/ for more detail.
[root@hello ~/yaml]#

查看安装后是否完成

[root@hello ~/yaml]# helm list -A
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
loki default 1 2021-12-03 07:31:04.3324429 +0000 UTC deployed loki-stack-2.1.2 v2.0.0
[root@hello ~/yaml]# [root@hello ~/yaml]# kubectl get pod
NAME READY STATUS RESTARTS AGE
loki-0 0/1 Running 0 68s
loki-promtail-79tn8 1/1 Running 0 68s
loki-promtail-qzjjs 1/1 Running 0 68s
loki-promtail-zlt7p 1/1 Running 0 68s
nfs-client-provisioner-dc5789f74-jsrh7 1/1 Running 0 44m
[root@hello ~/yaml]#

查看svc并修改类型

[root@hello ~/yaml]# kubectl  get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.68.0.1 <none> 443/TCP 4h44m
loki ClusterIP 10.68.140.107 <none> 3100/TCP 2m58s
loki-headless ClusterIP None <none> 3100/TCP 2m58s
[root@hello ~/yaml]#

将svc设置为 type: NodePort

[root@hello ~/yaml]# kubectl  edit  svc loki
service/loki edited
[root@hello ~/yaml]#
[root@hello ~/yaml]# kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.68.0.1 <none> 443/TCP 4h46m
loki NodePort 10.68.140.107 <none> 3100:31089/TCP 4m34s
loki-headless ClusterIP None <none> 3100/TCP 4m34s
[root@hello ~/yaml]#

添加nginx应用

[root@hello ~/yaml]# vim nginx-app.yaml
[root@hello ~/yaml]# cat nginx-app.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
selector:
matchLabels:
app: nginx
replicas: 1
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx
labels:
app: nginx
jobLabel: nginx
spec:
ports:
- name: nginx
port: 80
protocol: TCP
selector:
app: nginx
type: NodePort
[root@hello ~/yaml]#

查看nginx的pod

[root@hello ~/yaml]# kubectl apply -f nginx-app.yaml
deployment.apps/nginx created
service/nginx created [root@hello ~/yaml]# kubectl get pod | grep nginx
nginx-5d59d67564-7fj4b 1/1 Running 0 29s
[root@hello ~/yaml]#

测试访问

[root@hello ~/yaml]# kubectl  get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.68.0.1 <none> 443/TCP 4h57m
loki NodePort 10.68.140.107 <none> 3100:31089/TCP 15m
loki-headless ClusterIP None <none> 3100/TCP 15m
nginx NodePort 10.68.150.95 <none> 80:31317/TCP 105s
[root@hello ~/yaml]#
[root@hello ~/yaml]# while true; do curl --silent --output /dev/null --write-out '%{http_code}' http://192.168.1.12:31317; sleep 1; echo; done

在grafana中添加源

查看日志

添加面板

https://blog.csdn.net/qq_33921750

https://my.oschina.net/u/3981543

https://www.zhihu.com/people/chen-bu-yun-2

https://segmentfault.com/u/hppyvyv6/articles

https://juejin.cn/user/3315782802482007

https://space.bilibili.com/352476552/article

https://cloud.tencent.com/developer/column/93230

知乎、CSDN、开源中国、思否、掘金、哔哩哔哩、腾讯云

在 k8s(kubernetes)中使用 Loki 进行日志监控的更多相关文章

  1. 使用 Skywalking 对 Kubernetes(K8s)中的微服务进行监控

    1. 概述 老话说的好:任何成功都不是轻易得来的,是不断地坚持与面对的结果. 言归正传,之前我们聊了 SpringCloud 开发的微服务是如何部署在  Kubernetes(K8s)集群中的,今天我 ...

  2. 安装 loki 轻量级日志监控系统

    文章转载自:https://www.cnblogs.com/flypig666/archive/2004/01/13/14151801.html 从本文中学习到的是docker-compose相关命令 ...

  3. 使用kubernetes-event-exporter将k8s的事件导出到elasticsearch日志系统中

    使用kubernetes-event-exporter将k8s的事件导出到elasticsearch日志系统中 前提 版本 kubernetes v1.17.9 kubernetes-event-ex ...

  4. k8s中节点级别的日志

    容器化应用程序写入到 stdout 和 stderr 中的任何信息,都将被容器引擎重定向到某个地方.例如,Docker 容器引擎将 stdout 和 stderr 这两个输出流重定向到 logging ...

  5. k8s中pod的容器日志查看命令

    如果容器已经崩溃停止,您可以仍然使用 kubectl logs --previous 获取该容器的日志,只不过需要添加参数 --previous. 如果 Pod 中包含多个容器,而您想要看其中某一个容 ...

  6. 关于 Kubernetes 中的 Volume 与 GlusterFS 分布式存储

    容器中持久化的文件生命周期是短暂的,如果容器中程序崩溃宕机,kubelet 就会重新启动,容器中的文件将会丢失,所以对于有状态的应用容器中持久化存储是至关重要的一个环节:另外很多时候一个 Pod 中可 ...

  7. Kubernetes 中的核心组件与基本对象概述

    Kubernetes 是 Google 基于 Borg 开源的容器编排调度,用于管理容器集群自动化部署.扩容以及运维的开源平台.作为云原生计算基金会 CNCF(Cloud Native Computi ...

  8. k8s kubernetes 核心笔记 镜像仓库 项目k8s改造(含最新k8s v1.16.2版本)

    k8s kubernetes 核心笔记 镜像仓库 项目k8s改造 2019/10/24 Chenxin 一 基本资料 一 参考: https://kubernetes.io/ 官网 https://k ...

  9. 利用Kubernetes中的leaderelection实现组件高可用

    在Kubernetes中,通常kube-schduler和kube-controller-manager都是多副本进行部署的来保证高可用,而真正在工作的实例其实只有一个.这里就利用到 leaderel ...

  10. 概念验证:在Kubernetes中部署ABAP

    对于将SAP ABAP应用服务器组件容器化和在Kubernetes中部署它们,我们在SPA LinuxLab中做了概念验证(PoC),本文将介绍一些我们的发现和经验.本文会也会指出这项工作的一些潜在的 ...

随机推荐

  1. 通达OA实施的小总结

    1.表格中带有复选框的单独一行单元格(一行两列 表头在第一列 复选框在第二列),在手机上进行显示时,这一行会把行表头屏蔽掉.2.日历控件不要用自定义格式,要不部分手机上无法使用.但是有些手机只能进行填 ...

  2. 01背包&完全背包二维写法的对比,进而理解一维优化后的正逆序

    01背包题解 完全背包题解 二维写法时两种背包问题核心代码的区别: 可以看出,01背包用的是上一层的数据,完全背包用的是当前层的数据 所以优化为一维时, 01背包需逆序 for (int i = 1; ...

  3. What is the Best Python IDE for Data Science?

    Created by Guido van Rossum, Python was first released back in 1991. The interpreted high-level prog ...

  4. Git本地仓库的文件夹不显示红色感叹号、绿色对号等图标

    参考 https://blog.csdn.net/Elon15/article/details/125898375 主要是  在文件名前加8个空格(最少8个)!!!!

  5. supper网盘快速下载器

    本人搬砖党喜欢和大家分享一些快速文档 废话少说 很好用,亲测.对有需求的人 速度很快 软件永久有效下载链接:链接: https://pan.baidu.com/s/1g6LIk4mw18Bov0U7D ...

  6. jmeter的三种参数化方式

    一.通过添加前置处理器(用户参数) 1. 在http层级下添加--前置处理器--用户参数 2.可以修改名称,每次迭代更新一次(一定要勾选上),这样才会每次迭代变量值也更新 ,点击下面添加用户(多次测试 ...

  7. dbeaver,执行SQL时,空行导致SQL执行报错" ERROR: syntax error at or near "case"Position: 1"

    dbeaver,执行SQL时,空行导致SQL执行报错" ERROR: syntax error at or near "case"Position: 1" 解决 ...

  8. KMP算法学习记录

    Foreword: 初学KMP匹配算法,不得其门,总感觉自己想,想不出来,看书上文字解释晦涩难懂.不能准确的捕捉算法设计时候的灵光和思路 .于是自己试着完成了一遍,现将过程记录下来,以供复习. Con ...

  9. ABP vNext微服务架构详细教程(补充篇)——单层模板

    1. 简介 在之前的<ABP vNext微服务架构详细教程>系列中,我们已经构建了完整的微服务架构实例,但是在开发过程中,我们会发现每个基础服务都包含10个类库,这是给予DDD四层架构下A ...

  10. yapi的一些基本操作

    一.yapi能干什么 强大的接口管理平台 提供mock功能 提供测试功能 项目管理功能 插件齐全 二.yapi的权限 项目权限 操作 游客 项目开发者 项目组长 超级管理员 浏览公开项目与接口 √ √ ...