Guest User

Untitled

a guest
Oct 28th, 2019
853
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 9.28 KB | None | 0 0
  1. ---
  2. apiVersion: v1
  3. kind: ConfigMap
  4. metadata:
  5.   name: metricbeat-daemonset-config
  6.   namespace: kube-system
  7.   labels:
  8.     k8s-app: metricbeat
  9. data:
  10.   metricbeat.yml: |-
  11.     metricbeat.config.modules:
  12.      # Mounted `metricbeat-daemonset-modules` configmap:
  13.       path: ${path.config}/modules.d/*.yml
  14.       # Reload module configs as they change:
  15.       reload.enabled: false
  16.  
  17.     # To enable hints based autodiscover uncomment this:
  18.     #metricbeat.autodiscover:
  19.     #  providers:
  20.     #    - type: kubernetes
  21.     #      host: ${NODE_NAME}
  22.     #      hints.enabled: true
  23.  
  24.     processors:
  25.       - add_tags:  
  26.           tags: ["staging"]
  27.       - add_cloud_metadata:
  28.     cloud.id: ${ELASTIC_CLOUD_ID}
  29.     cloud.auth: ${ELASTIC_CLOUD_AUTH}
  30.  
  31.     output.elasticsearch:
  32.       hosts: ['${ELASTICSEARCH_HOST:elasticsearch}:${ELASTICSEARCH_PORT:9200}']
  33.       username: ${ELASTICSEARCH_USERNAME}
  34.       password: ${ELASTICSEARCH_PASSWORD}
  35. ---
  36. apiVersion: v1
  37. kind: ConfigMap
  38. metadata:
  39.   name: metricbeat-daemonset-modules
  40.   namespace: kube-system
  41.   labels:
  42.     k8s-app: metricbeat
  43. data:
  44.   system.yml: |-
  45.     - module: system
  46.       period: 10s
  47.       metricsets:
  48.        - cpu
  49.         - load
  50.         - memory
  51.         - network
  52.         - process
  53.         - process_summary
  54.         #- core
  55.         #- diskio
  56.         #- socket
  57.       processes: ['.*']
  58.       process.include_top_n:
  59.         by_cpu: 5      # include top 5 processes by CPU
  60.         by_memory: 5   # include top 5 processes by memory
  61.  
  62.     - module: system
  63.       period: 1m
  64.       metricsets:
  65.        - filesystem
  66.         - fsstat
  67.       processors:
  68.       - drop_event.when.regexp:
  69.           system.filesystem.mount_point: '^/(sys|cgroup|proc|dev|etc|host|lib)($|/)'
  70.   kubernetes.yml: |-
  71.     - module: kubernetes
  72.       metricsets:
  73.        - node
  74.         - system
  75.         - pod
  76.         - container
  77.         - volume
  78.       period: 10s
  79.       host: ${NODE_NAME}
  80.       hosts: ["localhost:10255"]
  81.       # If using Red Hat OpenShift remove the previous hosts entry and
  82.       # uncomment these settings:
  83.       #hosts: ["https://${HOSTNAME}:10250"]
  84.       #bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
  85.       #ssl.certificate_authorities:
  86.         #- /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt
  87.     - module: kubernetes
  88.       metricsets:
  89.        - proxy
  90.       period: 10s
  91.       host: ${NODE_NAME}
  92.       hosts: ["localhost:10249"]
  93. ---
  94. # Deploy a Metricbeat instance per node for node metrics retrieval
  95. apiVersion: extensions/v1beta1
  96. kind: DaemonSet
  97. metadata:
  98.   name: metricbeat
  99.   namespace: kube-system
  100.   labels:
  101.     k8s-app: metricbeat
  102. spec:
  103.   template:
  104.     metadata:
  105.       labels:
  106.         k8s-app: metricbeat
  107.     spec:
  108.       serviceAccountName: metricbeat
  109.       terminationGracePeriodSeconds: 30
  110.       hostNetwork: true
  111.       dnsPolicy: ClusterFirstWithHostNet
  112.       containers:
  113.       - name: metricbeat
  114.         image: docker.elastic.co/beats/metricbeat:7.4.1
  115.         args: [
  116.           "-c", "/etc/metricbeat.yml",
  117.           "-e",
  118.           "-system.hostfs=/hostfs",
  119.         ]
  120.         env:
  121.         - name: ELASTICSEARCH_HOST
  122.           value: elasticsearch
  123.         - name: ELASTICSEARCH_PORT
  124.           value: "9200"
  125.         - name: ELASTICSEARCH_USERNAME
  126.           value: elastic
  127.         - name: ELASTICSEARCH_PASSWORD
  128.           value: changeme
  129.         - name: ELASTIC_CLOUD_ID
  130.           valueFrom:   
  131.             secretKeyRef:  
  132.               name: elastic-cloud-id   
  133.               key: elastic-cloud-id
  134.         - name: ELASTIC_CLOUD_AUTH
  135.           valueFrom:   
  136.             secretKeyRef:  
  137.               name: elastic-cloud-auth 
  138.               key: elastic-cloud-auth  
  139.         - name: NODE_NAME
  140.           valueFrom:
  141.             fieldRef:
  142.               fieldPath: spec.nodeName
  143.         securityContext:
  144.           runAsUser: 0
  145.         resources:
  146.           limits:
  147.             memory: 200Mi
  148.           requests:
  149.             cpu: 100m
  150.             memory: 100Mi
  151.         volumeMounts:
  152.         - name: config
  153.           mountPath: /etc/metricbeat.yml
  154.           readOnly: true
  155.           subPath: metricbeat.yml
  156.         - name: modules
  157.           mountPath: /usr/share/metricbeat/modules.d
  158.           readOnly: true
  159.         - name: dockersock
  160.           mountPath: /var/run/docker.sock
  161.         - name: proc
  162.           mountPath: /hostfs/proc
  163.           readOnly: true
  164.         - name: cgroup
  165.           mountPath: /hostfs/sys/fs/cgroup
  166.           readOnly: true
  167.       volumes:
  168.       - name: proc
  169.         hostPath:
  170.           path: /proc
  171.       - name: cgroup
  172.         hostPath:
  173.           path: /sys/fs/cgroup
  174.       - name: dockersock
  175.         hostPath:
  176.           path: /var/run/docker.sock
  177.       - name: config
  178.         configMap:
  179.           defaultMode: 0600
  180.           name: metricbeat-daemonset-config
  181.       - name: modules
  182.         configMap:
  183.           defaultMode: 0600
  184.           name: metricbeat-daemonset-modules
  185.       - name: data
  186.         hostPath:
  187.           path: /var/lib/metricbeat-data
  188.           type: DirectoryOrCreate
  189. ---
  190. apiVersion: v1
  191. kind: ConfigMap
  192. metadata:
  193.   name: metricbeat-deployment-config
  194.   namespace: kube-system
  195.   labels:
  196.     k8s-app: metricbeat
  197. data:
  198.   metricbeat.yml: |-
  199.     metricbeat.config.modules:
  200.      # Mounted `metricbeat-daemonset-modules` configmap:
  201.       path: ${path.config}/modules.d/*.yml
  202.       # Reload module configs as they change:
  203.       reload.enabled: false
  204.  
  205.     processors:
  206.       - add_tags:  
  207.           tags: ["staging"]
  208.       - add_cloud_metadata:
  209.     cloud.id: ${ELASTIC_CLOUD_ID}
  210.     cloud.auth: ${ELASTIC_CLOUD_AUTH}
  211.  
  212.     output.elasticsearch:
  213.       hosts: ['${ELASTICSEARCH_HOST:elasticsearch}:${ELASTICSEARCH_PORT:9200}']
  214.       username: ${ELASTICSEARCH_USERNAME}
  215.       password: ${ELASTICSEARCH_PASSWORD}
  216. ---
  217. apiVersion: v1
  218. kind: ConfigMap
  219. metadata:
  220.   name: metricbeat-deployment-modules
  221.   namespace: kube-system
  222.   labels:
  223.     k8s-app: metricbeat
  224. data:
  225.  # This module requires `kube-state-metrics` up and running under `kube-system` namespace
  226.   kubernetes.yml: |-
  227.     - module: kubernetes
  228.       metricsets:
  229.        - state_node
  230.         - state_deployment
  231.         - state_replicaset
  232.         - state_pod
  233.         - state_container
  234.         # Uncomment this to get k8s events:
  235.         #- event
  236.       period: 10s
  237.       host: ${NODE_NAME}
  238.       hosts: ["kube-state-metrics:8080"]
  239. ---
  240. # Deploy singleton instance in the whole cluster for some unique data sources, like kube-state-metrics
  241. apiVersion: apps/v1beta1
  242. kind: Deployment
  243. metadata:
  244.   name: metricbeat
  245.   namespace: kube-system
  246.   labels:
  247.     k8s-app: metricbeat
  248. spec:
  249.   template:
  250.     metadata:
  251.       labels:
  252.         k8s-app: metricbeat
  253.     spec:
  254.       serviceAccountName: metricbeat
  255.       hostNetwork: true
  256.       dnsPolicy: ClusterFirstWithHostNet
  257.       containers:
  258.       - name: metricbeat
  259.         image: docker.elastic.co/beats/metricbeat:7.4.1
  260.         args: [
  261.           "-c", "/etc/metricbeat.yml",
  262.           "-e",
  263.         ]
  264.         env:
  265.         - name: ELASTICSEARCH_HOST
  266.           value: elasticsearch
  267.         - name: ELASTICSEARCH_PORT
  268.           value: "9200"
  269.         - name: ELASTICSEARCH_USERNAME
  270.           value: elastic
  271.         - name: ELASTICSEARCH_PASSWORD
  272.           value: changeme
  273.         - name: ELASTIC_CLOUD_ID
  274.           valueFrom:   
  275.             secretKeyRef:  
  276.               name: elastic-cloud-id   
  277.               key: elastic-cloud-id
  278.         - name: ELASTIC_CLOUD_AUTH
  279.           valueFrom:   
  280.             secretKeyRef:  
  281.               name: elastic-cloud-auth 
  282.               key: elastic-cloud-auth  
  283.         - name: NODE_NAME
  284.           valueFrom:
  285.             fieldRef:
  286.               fieldPath: spec.nodeName
  287.         securityContext:
  288.           runAsUser: 0
  289.         resources:
  290.           limits:
  291.             memory: 200Mi
  292.           requests:
  293.             cpu: 100m
  294.             memory: 100Mi
  295.         volumeMounts:
  296.         - name: config
  297.           mountPath: /etc/metricbeat.yml
  298.           readOnly: true
  299.           subPath: metricbeat.yml
  300.         - name: modules
  301.           mountPath: /usr/share/metricbeat/modules.d
  302.           readOnly: true
  303.       volumes:
  304.       - name: config
  305.         configMap:
  306.           defaultMode: 0600
  307.           name: metricbeat-deployment-config
  308.       - name: modules
  309.         configMap:
  310.           defaultMode: 0600
  311.           name: metricbeat-deployment-modules
  312. ---
  313. apiVersion: rbac.authorization.k8s.io/v1beta1
  314. kind: ClusterRoleBinding
  315. metadata:
  316.   name: metricbeat
  317. subjects:
  318. - kind: ServiceAccount
  319.   name: metricbeat
  320.   namespace: kube-system
  321. roleRef:
  322.   kind: ClusterRole
  323.   name: metricbeat
  324.   apiGroup: rbac.authorization.k8s.io
  325. ---
  326. apiVersion: rbac.authorization.k8s.io/v1beta1
  327. kind: ClusterRole
  328. metadata:
  329.   name: metricbeat
  330.   labels:
  331.     k8s-app: metricbeat
  332. rules:
  333. - apiGroups: [""]
  334.   resources:
  335.  - nodes
  336.   - namespaces
  337.   - events
  338.   - pods
  339.   verbs: ["get", "list", "watch"]
  340. - apiGroups: ["extensions"]
  341.   resources:
  342.  - replicasets
  343.   verbs: ["get", "list", "watch"]
  344. - apiGroups: ["apps"]
  345.   resources:
  346.  - statefulsets
  347.   - deployments
  348.   verbs: ["get", "list", "watch"]
  349. - apiGroups:
  350.  - ""
  351.   resources:
  352.  - nodes/stats
  353.   verbs:
  354.  - get
  355. ---
  356. apiVersion: v1
  357. kind: ServiceAccount
  358. metadata:
  359.   name: metricbeat
  360.   namespace: kube-system
  361.   labels:
  362.     k8s-app: metricbeat
  363. ---
Advertisement
Add Comment
Please, Sign In to add comment