装置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.listdeb 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 updateWARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/configWARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config"loki" has been added to your repositoriesWARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/configWARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/configHang tight while we grab the latest from your chart repositories......Successfully got an update from the "loki" chart repositoryUpdate Complete. ⎈Happy Helming!⎈[root@hello ~/yaml]#[root@hello ~/yaml]#[root@hello ~/yaml]# helm pull loki/loki-stackWARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/configWARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/config[root@hello ~/yaml]# lsloki-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]# lsloki-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/configWARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/configWARNING: This chart is deprecatedW1203 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: lokiLAST DEPLOYED: Fri Dec 3 07:31:04 2021NAMESPACE: defaultSTATUS: deployedREVISION: 1NOTES: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 -AWARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /root/.kube/configWARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /root/.kube/configNAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSIONloki 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 podNAME READY STATUS RESTARTS AGEloki-0 0/1 Running 0 68sloki-promtail-79tn8 1/1 Running 0 68sloki-promtail-qzjjs 1/1 Running 0 68sloki-promtail-zlt7p 1/1 Running 0 68snfs-client-provisioner-dc5789f74-jsrh7 1/1 Running 0 44m[root@hello ~/yaml]#
查看svc并批改类型
[root@hello ~/yaml]# kubectl get svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEkubernetes ClusterIP 10.68.0.1 <none> 443/TCP 4h44mloki ClusterIP 10.68.140.107 <none> 3100/TCP 2m58sloki-headless ClusterIP None <none> 3100/TCP 2m58s[root@hello ~/yaml]#
将svc设置为 type: NodePort
[root@hello ~/yaml]# kubectl edit svc lokiservice/loki edited[root@hello ~/yaml]#[root@hello ~/yaml]# kubectl get svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEkubernetes ClusterIP 10.68.0.1 <none> 443/TCP 4h46mloki NodePort 10.68.140.107 <none> 3100:31089/TCP 4m34sloki-headless ClusterIP None <none> 3100/TCP 4m34s[root@hello ~/yaml]#
增加nginx利用
[root@hello ~/yaml]# vim nginx-app.yaml[root@hello ~/yaml]# cat nginx-app.yamlapiVersion: apps/v1 kind: Deploymentmetadata: name: nginxspec: selector: matchLabels: app: nginx replicas: 1 template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.7.9 ports: - containerPort: 80---apiVersion: v1kind: Servicemetadata: name: nginx labels: app: nginx jobLabel: nginxspec: 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 createdservice/nginx created[root@hello ~/yaml]# kubectl get pod | grep nginxnginx-5d59d67564-7fj4b 1/1 Running 0 29s[root@hello ~/yaml]#
测试拜访
[root@hello ~/yaml]# kubectl get svcNAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGEkubernetes ClusterIP 10.68.0.1 <none> 443/TCP 4h57mloki NodePort 10.68.140.107 <none> 3100:31089/TCP 15mloki-headless ClusterIP None <none> 3100/TCP 15mnginx 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中增加源
查看日志
增加面板
Linux运维交换社区
Linux运维交换社区,互联网新闻以及技术交换。
68篇原创内容
公众号
https://blog.csdn.net/qq_3392...
https://my.oschina.net/u/3981543
https://www.zhihu.com/people/...
https://segmentfault.com/u/hp...
https://juejin.cn/user/331578...
https://space.bilibili.com/35...
https://cloud.tencent.com/dev...
知乎、CSDN、开源中国、思否、掘金、哔哩哔哩、腾讯云
本文应用 文章同步助手 同步