DatadogのKubernetes manifestの設定

Deployment

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: app
  name: server-a
  labels:
    app: server-a
    tags.datadoghq.com/env: environment
    tags.datadoghq.com/service: server-a
    tags.datadoghq.com/version: v1
spec:
  template:
    metadata:
      labels:
        app: server-a
        tags.datadoghq.com/env: environment
        tags.datadoghq.com/service: server-a
        tags.datadoghq.com/version: v1
      annotations:
        ad.datadoghq.com/server-a.logs: '[{"source":"mysource","service":"server-a"}]'
    spec:
      containers:
        - name: server-a
          image: ...
          ...

Cronjob

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
apiVersion: batch/v1  
kind: CronJob  
metadata:  
  namespace: app  
  name: cronjob-a  
  labels:  
    app: cronjob-a  
    tags.datadoghq.com/env: environment  
    tags.datadoghq.com/service: cronjob-a  
    tags.datadoghq.com/version: v1  
spec:  
  jobTemplate:  
    spec:  
      template:  
        metadata:  
          labels:  
            app: cronjob-a  
            tags.datadoghq.com/service: cronjob-a  
            tags.datadoghq.com/version: v1  
          annotations:  
            ad.datadoghq.com/cronjob-a.logs: '[{"source":"mysource","service":"cronjob-a"}]'  
          containers:  
            - name: cronjob-a  
              image: image:tag  
              env:  
                - name: DD_AGENT_HOST  
                  valueFrom:  
                    fieldRef:  
                      fieldPath: status.hostIP  
                - name: DD_ENV  
                  valueFrom:  
                    fieldRef:  
                      fieldPath: metadata.labels['tags.datadoghq.com/env']  
                - name: DD_SERVICE  
                  valueFrom:  
                    fieldRef:  
                      fieldPath: metadata.labels['tags.datadoghq.com/service']  
                - name: DD_VERSION  
                  valueFrom:  
                    fieldRef:  
                      fieldPath: metadata.labels['tags.datadoghq.com/version']

StatefulSet

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: statefulset-a
  namespace: app
spec:
  serviceName: 'statefulset-a'
  replicas: 1
  selector:
    matchLabels:
      app: statefulset-a
  template:
    metadata:
      labels:
        app: statefulset-a
        tags.datadoghq.com/env: environment
        tags.datadoghq.com/service: statefulset-a
        tags.datadoghq.com/version: v1
      annotations:
        ad.datadoghq.com/statefulset-a.logs: '[{"source":"mysource","service":"statefulset-a"}]'
    spec:
      ...
> back to posts