部署前预习
使用Es官方Operator方式
Quickstart | Elastic Cloud on Kubernetes [2.4] | Elastic
kubectl apply -f https://download.elastic.co/downloads/eck/1.6.0/all-in-one.yaml
#查看状态
kubectl -n elastic-system logs -f statefulset.apps/elastic-operator
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: es-cluster
# 可以指定名称空间
spec:
version: 7.13.1
nodeSets:
- name: masters
count: 3
config:
node.roles: ["master"]
xpack.ml.enabled: true
volumeClaimTemplates:
- metadata:
name: es-master
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: "rook-ceph-block"
- name: data
count: 4
config:
node.roles: ["data", "ingest", "ml", "transform"]
volumeClaimTemplates:
- metadata:
name: es-node
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: "rook-ceph-block"
测试访问 Deploy an Elasticsearch cluster | Elastic Cloud on Kubernetes [2.4] | Elastic
## elastic的访问
kubectl get secret es-cluster-es-elastic-user -o=jsonpath='{.data.elastic}' | base64 --decode; echo
## 1、集群内组件访问
###账号 elastic
###密码 t5upEg4l5J37629558659y8Ww
curl -u "elastic:2WC5On8Xio6E767K4x4ph1T7Q54" -k "https://es-cluster-es-http:9200"
curl -u "elastic:2WC5On8Xio6E767K4x4ph1T7Q54" -k "https://10.96.9.9:9200"
## 2、集群本地访问
kubectl port-forward service/es-cluster-es-http 9200
curl -u "elastic:$PASSWORD" -k "https://localhost:9200"
## 3、做成下面的Ingress访问
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: elastic-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
nginx.ingress.kubernetes.io/server-snippet: |
proxy_ssl_verify off;
spec:
tls:
- hosts:
- elastic.it.com
secretName: it.com
rules:
- host: elastic.it.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: es-cluster-es-http
port:
number: 9200
apiVersion: kibana.k8s.elastic.co/v1
kind: Kibana
metadata:
name: kibana
spec:
version: 7.13.1
count: 1
elasticsearchRef:
name: es-cluster
kubectl get secret es-cluster-es-elastic-user -o=jsonpath='{.data.elastic}' | base64 --decode; echo
### 账号 elastic
### 密码 618FAZBH5a26990707098798798
###登录即可
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: kibana-ingress
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
nginx.ingress.kubernetes.io/server-snippet: |
proxy_ssl_verify off;
spec:
tls:
- hosts:
- kibana.it.com
secretName: it.com
rules:
- host: kibana.it.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: kibana-kb-http
port:
number: 5601
apiVersion: beat.k8s.elastic.co/v1beta1
kind: Beat
metadata:
name: beats
spec:
type: filebeat
version: 7.13.1
elasticsearchRef:
name: es-cluster
config:
filebeat.inputs:
- type: container
paths:
- /var/log/containers/*.log
daemonSet:
podTemplate:
spec:
dnsPolicy: ClusterFirstWithHostNet
hostNetwork: true
securityContext:
runAsUser: 0
containers:
- name: filebeat
volumeMounts:
- name: varlogcontainers
mountPath: /var/log/containers
- name: varlogpods
mountPath: /var/log/pods
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
volumes:
- name: varlogcontainers
hostPath:
path: /var/log/containers
- name: varlogpods
hostPath:
path: /var/log/pods
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。