Skip to content

Cherry-pick #24789 to 7.x: Implement k8s secrets provider for Agent#24898

Merged
ChrsMark merged 1 commit intoelastic:7.xfrom
ChrsMark:backport_24789_7.x
Apr 2, 2021
Merged

Cherry-pick #24789 to 7.x: Implement k8s secrets provider for Agent#24898
ChrsMark merged 1 commit intoelastic:7.xfrom
ChrsMark:backport_24789_7.x

Conversation

@ChrsMark
Copy link
Copy Markdown
Member

@ChrsMark ChrsMark commented Apr 1, 2021

Cherry-pick of PR #24789 to 7.x branch. Original message:

This PR aims to add support for consuming k8s secrets through Agent's variables.

Note: This is still a draft but comments are needed so as to verify it's going to the right direction, so plz @blakerouse @exekias feel free to comment here.

How to test this:

  1. Create the k8s secret:
cat << EOF | kubectl apply -f -apiVersion: v1
kind: Secret
metadata:
  name: somesecret
type: Opaque
data:
  value: $(echo -n "passpass" | base64)
EOF
  1. Use the following config:
providers.kubernetes_secrets:
  kube_config: /Users/chrismark/.kube/config

inputs:
  - type: logfile
    streams:
      - paths: ${env.logpath}/${kubernetes_secrets.default.somesecret.value}/another.log
  1. Run inspect command to check what is the compiled configuration (use proper path for the elastic-agent.yml config file :
    logpath=/var/log ./elastic-agent -c /Users/ubuntu/Desktop/elastic-agent.yml inspect output -o default

Verify that the following is produced:

[default] filebeat:
filebeat:
  inputs:
  - index: logs-generic-default
    paths: /var/log/passpass/another.log

Unit testing:

  1. go test -v ./pkg/agent/transpiler/... -run TestVars_ReplaceWithFetchContextProvider
  2. go test -v ./pkg/composable/providers/kubernetessecrets...

Closes #24143

@ChrsMark ChrsMark added [zube]: In Review backport Team:Integrations Label for the Integrations team labels Apr 1, 2021
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Apr 1, 2021
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/integrations (Team:Integrations)

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Apr 1, 2021
@ChrsMark
Copy link
Copy Markdown
Member Author

ChrsMark commented Apr 1, 2021

/test

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 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

Expand to view the summary

Build stats

  • Build Cause: ChrsMark commented: /test

  • Start Time: 2021-04-01T19:50:26.243+0000

  • Duration: 53 min 58 sec

  • Commit: ed0f4d6

Test stats 🧪

Test Results
Failed 0
Passed 6556
Skipped 24
Total 6580

Trends 🧪

Image of Build Times

Image of Tests

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 6556
Skipped 24
Total 6580

@ChrsMark ChrsMark merged commit 2b60aa7 into elastic:7.x Apr 2, 2021
@zube zube bot removed the [zube]: Done label Jul 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Team:Integrations Label for the Integrations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants