docker,k8s安装es
docker安装Es
docker安装elasticsearch
docker原生
docker run --name es -p 9200:9200 -p 9300:9300 \
-e "discovery.type"="single-node" \
-e ES_JAVA_OPTS="-Xms64m -Xmx128m" \
-v /es/esData/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /es/esData/data:/usr/share/elasticsearch/data \
-v /es/esData/plugins:/usr/share/elasticsearch/plugins \
-v /es/esData/es/logs:/usr/share/elasticsearch/logs \
-d elasticsearch:7.7.1
docker-compose.yml
version: '3'
services:
prometheus:
container_name: elasticsearch
image: elasticsearch:7.7.1
ports:
- "9200:9200"
- "9300:9300"
restart: unless-stopped
volumes:
- /es/esData/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
- /es/esData/data:/usr/share/elasticsearch/data \
- /es/esData/plugins:/usr/share/elasticsearch/plugins \
- /es/esData/es/logs:/usr/share/elasticsearch/logs \
environment:
discovery.type: "single-node"
ES_JAVA_OPTS: "-Xms64m -Xmx128m"
docker安装kibana
docker原生
docker run --name kibana -p 5601:5601 \
-v /es/esData/config/kibana.yml:/usr/share/kibana/config/kibana.yml \
-d kibana:7.7.1
docker-compose.yml
version: '3'
services:
prometheus:
container_name: kibana
image: kibana:7.7.1
ports:
- "5601:5601"
restart: unless-stopped
volumes:
- /es/esData/config/kibana.yml:/usr/share/kibana/config/kibana.yml
kibana.yml
#
# ** THIS IS AN AUTO-GENERATED FILE **
#
# Default Kibana configuration for docker target
server.name: kibana
server.host: "0"
elasticsearch.hosts: [ "http://192.168.0.215:9200" ]
monitoring.ui.container.elasticsearch.enabled: true
访问
访问es:192.168.0.215:9200
访问kibana:192.168.0.215:5601
k8s配置清单-ES
elasticsearch
deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: elasticsearch
name: elasticsearch
namespace: sg-bs
spec:
replicas: 1
selector:
matchLabels:
app: elasticsearch
template:
metadata:
labels:
app: elasticsearch
spec:
nodeSelector:
kubernetes.io/hostname: sg-15
containers:
- image: elasticsearch:7.7.1
imagePullPolicy: IfNotPresent
name: elasticsearch
ports:
- containerPort: 9200
name: elasticsearch
protocol: TCP
volumeMounts:
- mountPath: /usr/share/elasticsearch/config/elasticsearch.yml
name: config
- mountPath: /usr/share/elasticsearch/data
name: data
- mountPath: /usr/share/elasticsearch/plugins
name: plugins
- mountPath: /usr/share/elasticsearch/logs
name: logs
volumes:
- hostPath:
path: /es/esData/config/elasticsearch.yml
type: DirectoryOrCreate
name: config
- hostPath:
path: /es/esData/data
type: DirectoryOrCreate
name: data
- hostPath:
path: /es/esData/plugins
type: DirectoryOrCreate
name: plugins
- hostPath:
path: /es/esData/es/logs
type: DirectoryOrCreate
name: logs
service.yml
apiVersion: v1
kind: Service
metadata:
labels:
app: elasticsearch
name: elasticsearch
namespace: sg-bs
spec:
type: NodePort
ports:
- name: elasticsearch
port: 9200
nodePort: 31920
protocol: TCP
targetPort: elasticsearch
selector:
app: elasticsearch
kibana
deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: kibana
name: kibana
namespace: sg-bs
spec:
replicas: 1
selector:
matchLabels:
app: kibana
template:
metadata:
labels:
app: kibana
spec:
nodeSelector:
kubernetes.io/hostname: sg-15
containers:
- image: kibana:7.7.1
imagePullPolicy: IfNotPresent
name: kibana
ports:
- containerPort: 5601
name: kibana
protocol: TCP
volumeMounts:
- mountPath: /usr/share/kibana/config/kibana.yml
name: config
volumes:
- hostPath:
path: /es/esData/config/kibana.yml
type: DirectoryOrCreate
name: config
service.yml
apiVersion: v1
kind: Service
metadata:
labels:
app: kibana
name: kibana
namespace: sg-bs
spec:
type: NodePort
ports:
- name: kibana
port: 5601
nodePort: 31921
protocol: TCP
targetPort: kibana
selector:
app: kibana
访问
访问es:192.168.0.215:31920
访问kibana:192.168.0.215:31921
选择了IT,必定终身学习