In this example we are using Elastic Cloud managed elasticsearch and will deploy the metricbeat to a k8s cluster.
Create Secret
apiVersion: v1 data: ELASTICSEARCH_AUTH: [base64_encoded_auth] ELASTICSEARCH_CLOUD_ID: [base64_encoded_cloudid] ELASTICSEARCH_RABBITMQ_PASSWORD: [base64_encoded_password] ELASTICSEARCH_RABBITMQ_USER: [base64_encoded_user] kind: Secret metadata: name: metricbeat type: Opaque
Create DNS pointing to RabbitMQ
apiVersion: v1 kind: Service metadata: name: rabbitmq spec: externalName: your-rabbitmq-host-name.com type: ExternalName
Config Map
apiVersion: v1
data:
metricbeat.yml: |
cloud.id: '${ELASTICSEARCH_CLOUD_ID}'
cloud.auth: '${ELASTICSEARCH_AUTH}'
metricbeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: false
metricbeat.modules:
- module: rabbitmq
period: 10s
hosts: ['rabbitmq:15672']
username: ${ELASTICSEARCH_RABBITMQ_USER}
password: ${ELASTICSEARCH_RABBITMQ_PASSWORD}
processors:
- add_cloud_metadata: ~
- add_docker_metadata: ~
kind: ConfigMap
metadata:
name: metricbeat
Deploy
apiVersion: apps/v1beta2
kind: Deployment
metadata:
labels:
app: metricbeat
name: metricbeat
spec:
selector:
matchLabels:
app: metricbeat
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
labels:
app: metricbeat
spec:
containers:
- envFrom:
- secretRef:
name: metricbeat
optional: false
image: docker.elastic.co/beats/metricbeat:7.6.0
imagePullPolicy: Always
name: metricbeat
resources: {}
securityContext:
allowPrivilegeEscalation: false
capabilities: {}
privileged: false
readOnlyRootFilesystem: false
runAsNonRoot: false
stdin: true
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
tty: true
volumeMounts:
- mountPath: /usr/share/metricbeat/metricbeat.yml
name: metricbeat
subPath: metricbeat.yml
volumes:
- configMap:
defaultMode: 292
name: metricbeat
optional: false
name: metricbeat