Bre*_*ett 8 kubernetes google-kubernetes-engine
对于noob问题很抱歉,但是来自https://github.com/kubernetes/kubernetes/blob/release-1.1/docs/getting-started-guides/logging-elasticsearch.md 它说:
要使用Elasticsearch和Kibana进行集群日志记录,您应该设置以下环境变量,如下所示:
KUBE_LOGGING_DESTINATION=elasticsearch
Run Code Online (Sandbox Code Playgroud)
我在哪里以及如何设置此Env Var?我在想我应该用
gcloud container clusters create
Run Code Online (Sandbox Code Playgroud)
并传递选项,但没有选择......
小智 13
正如Robert的回答中已经提到的,如果群集应该在Google Container Engine(GKE)上运行,则需要手动添加Elasticsearch/Kibana堆栈.使用本所提供的资料后,我能得到它的工作执行以下步骤:
在没有云记录的情况下启动GKE群集
gcloud container --project <PROJECT_ID> clusters create <CLUSTER_ID> --no-enable-cloud-logging
Run Code Online (Sandbox Code Playgroud)使用kubernetes DaemonSet将已配置的流畅容器添加到每个正在运行的节点.
kubectl create -f fluentd-es.yaml
Run Code Online (Sandbox Code Playgroud)
fluentd-es.yaml
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: fluentd-elasticsearch
namespace: kube-system
labels:
app: fluentd-logging
spec:
template:
metadata:
labels:
app: fluentd-es
spec:
containers:
- name: fluentd-elasticsearch
image: gcr.io/google_containers/fluentd-elasticsearch:1.15
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 200Mi
volumeMounts:
- name: varlog
mountPath: /var/log
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
volumes:
- name: varlog
hostPath:
path: /var/log
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
Run Code Online (Sandbox Code Playgroud)添加elasticsearch和kibana pods和服务.
kubectl create -f es-controller.yaml
kubectl create -f es-service.yaml
kubectl create -f kibana-controller.yaml
kubectl create -f kibana-service.yaml
Run Code Online (Sandbox Code Playgroud)
请注意,kubernetes.io/cluster-service: "true"标签(存在于原始文件中)已被删除.在定义中使用此标签会导致运行的pod终止.
ES-controller.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: elasticsearch-logging-v1
namespace: kube-system
labels:
k8s-app: elasticsearch-logging
version: v1
spec:
replicas: 2
selector:
k8s-app: elasticsearch-logging
version: v1
template:
metadata:
labels:
k8s-app: elasticsearch-logging
version: v1
kubernetes.io/cluster-service: "true"
spec:
containers:
- image: gcr.io/google_containers/elasticsearch:1.8
name: elasticsearch-logging
resources:
limits:
cpu: 100m
requests:
cpu: 100m
ports:
- containerPort: 9200
name: db
protocol: TCP
- containerPort: 9300
name: transport
protocol: TCP
volumeMounts:
- name: es-persistent-storage
mountPath: /data
volumes:
- name: es-persistent-storage
emptyDir: {}
Run Code Online (Sandbox Code Playgroud)
ES-service.yaml
apiVersion: v1
kind: Service
metadata:
name: elasticsearch-logging
namespace: kube-system
labels:
k8s-app: elasticsearch-logging
kubernetes.io/name: "Elasticsearch"
spec:
ports:
- port: 9200
protocol: TCP
targetPort: db
selector:
k8s-app: elasticsearch-logging
Run Code Online (Sandbox Code Playgroud)
kibana-controller.yaml
apiVersion: v1
kind: ReplicationController
metadata:
name: kibana-logging-v1
namespace: kube-system
labels:
k8s-app: kibana-logging
version: v1
spec:
replicas: 1
selector:
k8s-app: kibana-logging
version: v1
template:
metadata:
labels:
k8s-app: kibana-logging
version: v1
kubernetes.io/cluster-service: "true"
spec:
containers:
- name: kibana-logging
image: gcr.io/google_containers/kibana:1.3
resources:
limits:
cpu: 100m
requests:
cpu: 100m
env:
- name: "ELASTICSEARCH_URL"
value: "http://elasticsearch-logging:9200"
ports:
- containerPort: 5601
name: ui
protocol: TCP
Run Code Online (Sandbox Code Playgroud)
kibana-service.yaml
apiVersion: v1
kind: Service
metadata:
name: kibana-logging
namespace: kube-system
labels:
k8s-app: kibana-logging
kubernetes.io/name: "Kibana"
spec:
ports:
- port: 5601
protocol: TCP
targetPort: ui
selector:
k8s-app: kibana-logging
Run Code Online (Sandbox Code Playgroud)创建kubectl代理
kubectl proxy
Run Code Online (Sandbox Code Playgroud)用kibana观看你的日志
该文档适用于通过 GCE 的开源 shell 脚本打开集群的用户。目前不支持将 Elasticsearch 作为 Google Container Engine 集群创建命令的一部分。创建集群后,您可以手动将其添加到集群中。
| 归档时间: |
|
| 查看次数: |
2237 次 |
| 最近记录: |