Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port IncludeAnnotations setting to Agent and small manifest fix #28247

Merged
merged 6 commits into from
Oct 5, 2021

Conversation

ChrsMark
Copy link
Member

@ChrsMark ChrsMark commented Oct 5, 2021

What does this PR do?

Small followup fix related to #27691:

  • Fix proposed manifest's condition from kubernetes.pod.labels.app == redis to ``kubernetes.labels.app == redis`
  • Port IncludeAnnotations
  • Handle start/stop of watchers properly

How to test this PR manually

Using the following redis Pod:

apiVersion: v1
kind: Pod
metadata:
  name: redis
  labels:
    role: main
    app: redis
  annotations:
    level: production
spec:
  hostNetwork: true
  dnsPolicy: ClusterFirstWithHostNet
  containers:
    - name: redis
      image: redis:latest
      ports:
        - name: web
          containerPort: 6379
          protocol: TCP

Test the following scenarios:

  1. Check Pod's annotation is added as metadata
providers.kubernetes:
  scope: node
  kube_config: /Users/chrismark/.kube/config
  node: "kind-control-plane"
  cleanup_timeout: 360s
  include_annotations: ["level"]
  resources:
    pod:
      enabled: true

inputs:
- name: redis
  type: redis/metrics
  use_output: default
  meta:
    package:
      name: redis
      version: 0.3.6
  data_stream:
    namespace: default
  streams:
    - data_stream:
        dataset: redis.info
        type: metrics
      metricsets:
        - info
      hosts:
        - '${kubernetes.pod.ip}:${kubernetes.container.port}'
      idle_timeout: 20s
      maxconn: 10
      network: tcp
      period: 10s
      condition: ${kubernetes.labels.app} == 'redis' AND ${kubernetes.container.port_name} == 'web'
  1. Check condition based on kubernetes.namespace_annotations.foo == bar

kubectl annotate ns default foo=bar

providers.kubernetes:
  scope: node
  kube_config: /Users/chrismark/.kube/config
  node: "kind-control-plane"
  cleanup_timeout: 360s
  include_annotations: ["level"]
  resources:
    pod:
      enabled: true

inputs:
- name: redis
  type: redis/metrics
  use_output: default
  meta:
    package:
      name: redis
      version: 0.3.6
  data_stream:
    namespace: default
  streams:
    - data_stream:
        dataset: redis.info
        type: metrics
      metricsets:
        - info
      hosts:
        - '${kubernetes.pod.ip}:${kubernetes.container.port}'
      idle_timeout: 20s
      maxconn: 10
      network: tcp
      period: 10s
      condition: ${kubernetes.namespace_annotations.foo} == 'bar' AND ${kubernetes.container.port_name} == 'web'
  1. Check that ns annotations are being added to Pod's metadata.
providers.kubernetes:
 scope: node
 kube_config: /Users/chrismark/.kube/config
 node: "kind-control-plane"
 cleanup_timeout: 360s
 include_annotations: ["level"]
 add_resource_metadata:
    namespace:
      include_annotations: ["foo"]
 resources:
   pod:
     enabled: true

inputs:
- name: redis
 type: redis/metrics
 use_output: default
 meta:
   package:
     name: redis
     version: 0.3.6
 data_stream:
   namespace: default
 streams:
   - data_stream:
       dataset: redis.info
       type: metrics
     metricsets:
       - info
     hosts:
       - '${kubernetes.pod.ip}:${kubernetes.container.port}'
     idle_timeout: 20s
     maxconn: 10
     network: tcp
     period: 10s
     condition: ${kubernetes.labels.app} == 'redis' AND ${kubernetes.container.port_name} == 'web'

@ChrsMark ChrsMark added Team:Integrations Label for the Integrations team backport-v7.16.0 Automated backport with mergify labels Oct 5, 2021
@ChrsMark ChrsMark self-assigned this Oct 5, 2021
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Oct 5, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations (Team:Integrations)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Oct 5, 2021
@ChrsMark ChrsMark changed the title Port IncludeAnnotations setting to Agent and small mainfest fix Port IncludeAnnotations setting to Agent and small manifest fix Oct 5, 2021
Signed-off-by: chrismark <[email protected]>
@elasticmachine
Copy link
Collaborator

elasticmachine commented Oct 5, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Duration: 129 min 3 sec

❕ Flaky test report

No test was executed to be analysed.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

Copy link
Contributor

@MichaelKatsoulis MichaelKatsoulis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with some minor cosmetic updates.

@ChrsMark ChrsMark merged commit a690364 into elastic:master Oct 5, 2021
mergify bot pushed a commit that referenced this pull request Oct 5, 2021
ChrsMark added a commit that referenced this pull request Oct 5, 2021
Icedroid pushed a commit to Icedroid/beats that referenced this pull request Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v7.16.0 Automated backport with mergify Team:Integrations Label for the Integrations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants