k8s部署es5.6.16
时间: 2023-10-14 11:59:42 浏览: 98
Kubernetes持久化部署elasticsearch7.15.0分布式集群
5星 · 资源好评率100%
您好!要在Kubernetes上部署Elasticsearch 5.6.16,您可以按照以下步骤进行操作:
1. 创建一个Elasticsearch的配置文件(例如es-config.yaml),内容如下:
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: es-config
data:
elasticsearch.yml: |
cluster.name: my-es-cluster
node.name: ${HOSTNAME}
network.host: 0.0.0.0
discovery.zen.ping.unicast.hosts: elasticsearch-service
discovery.zen.minimum_master_nodes: 1
bootstrap.memory_lock: false
xpack.security.enabled: false
```
2. 创建一个Elasticsearch的服务文件(例如es-service.yaml),内容如下:
```yaml
apiVersion: v1
kind: Service
metadata:
name: elasticsearch-service
spec:
selector:
app: elasticsearch
ports:
- name: http
port: 9200
targetPort: 9200
- name: transport
port: 9300
targetPort: 9300
```
3. 创建一个Elasticsearch的部署文件(例如es-deployment.yaml),内容如下:
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: elasticsearch-deployment
spec:
replicas: 1
selector:
matchLabels:
app: elasticsearch
template:
metadata:
labels:
app: elasticsearch
spec:
containers:
- name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.16
ports:
- containerPort: 9200
name: http
- containerPort: 9300
name: transport
volumeMounts:
- name: data
mountPath: /usr/share/elasticsearch/data
env:
- name: ES_JAVA_OPTS
value: "-Xms512m -Xmx512m"
volumes:
- name: data
emptyDir: {}
```
4. 使用kubectl命令依次创建ConfigMap、Service和Deployment:
```shell
kubectl create -f es-config.yaml
kubectl create -f es-service.yaml
kubectl create -f es-deployment.yaml
```
5. 部署完成后,您可以使用以下命令检查Elasticsearch的部署状态:
```shell
kubectl get pods
```
确保Elasticsearch的Pod处于运行状态。
6. 您可以使用以下命令测试Elasticsearch是否正常工作:
```shell
curl http://<Elasticsearch服务的Cluster IP>:9200
```
如果返回类似于以下内容的JSON响应,则表示Elasticsearch已成功部署:
```json
{
"name" : "node-name",
"cluster_name" : "my-es-cluster",
"cluster_uuid" : "uuid",
"version" : {
"number" : "5.6.16",
"build_hash" : "hash"
},
"tagline" : "You Know, for Search"
}
```
请注意,以上步骤仅提供了一个基本的Elasticsearch部署示例,您可能还需要根据您的需求进行其他配置和调整。希望对您有所帮助!如有任何疑问,请随时提问。
阅读全文