Step 1: 准备yaml
创建 kibana.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: kb
namespace: elk
spec:
replicas: 1
selector:
matchLabels:
app: kb
template:
metadata:
name: kb
labels:
app: kb
spec:
containers:
- name: kb
image: 'docker.elastic.co/kibana/kibana:7.17.5'
env:
- name: ELASTICSEARCH_HOSTS
value: '["http://es-cluster:9200"]'
ports:
- name: http
containerPort: 5601
创建外网访问 kibana-nodeport.yaml :
apiVersion: v1
kind: Service
metadata:
name: kb-svc
namespace: elk
spec:
type: NodePort
selector:
app: kb
ports:
- port: 5601
targetPort: 5601
nodePort: 31065
Step 2: 创建
创建这些yaml:
kubectl apply -f kibana.yaml
kubectl apply -f kibana-nodeport.yaml
或者用官方kubebiz提供的yaml源:
kubectl apply -f https://www.kubebiz.com/raw/KubeBiz/kibana/7.17.5/all?namespace=elk
Step 3: 验证
查看pod状态
kubectl get pods -n elk
NAME READY STATUS RESTARTS AGE
kb-67b9569f5d-c7m9b 1/1 Running 0 3m
...
等待所有pod的状态为Running
。
查看服务:
kubectl get service -n elk
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kb-svc NodePort xx.x6.241.187 <none> 5601:31065/TCP 3s
...
通过创建的nodePort访问,通过 <nodepot-ip>
:31065
在游览器访问: