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

[Fleet] Add support_agentless property in agent policy schema and preconfiguration #182709

Merged
merged 10 commits into from
May 8, 2024

Conversation

criamico
Copy link
Contributor

@criamico criamico commented May 6, 2024

Closes #180377

Summary

Add a new support_agentless property in agent policy and in preconfiguration; this property is only allowed when the environment has both isServerless set to true and agentless feature flag enabled, otherwise policy creation/update will throw error supports_agentless is only allowed in serverless environments that support agentless feature.

No UI change is required for now as this property will be needed as part of a wider support to agentless policies.

Testing

Serverless

  • Run serverless env configured for agentless following this guide
  • Make sure to have agentless feature flag enabled
  • Create an agent policy with support_agentless property:
POST kbn:/api/fleet/agent_policies
{
  "name": "New agent policy",
  "namespace": "default",
  "supports_agentless": true
}
  • Update an existing agent policy with the new property:
PUT kbn:/api/fleet/agent_policies/<opolicy_id>
{
  "name": "New agent policy",
  "supports_agentless": true
}
  • Create a preconfigured agent policy in kibana.dev.yml, and verify it that it's correct via GET kbn:/api/fleet/agent_policies:
xpack.fleet.agentPolicies: [
  {
    "name": "Agentless Policy",
    "id": "agentless",
    "is_managed": true,
    "namespace": "default",
    "supports_agentless": true,
  },
]
  • Note that if agentless feature flag is disabled, any of the above will throw an error.

Stateful

Spin up a stateful env and verify that all of the previous commands fail with 400 and above error message.

Checklist

@criamico criamico self-assigned this May 6, 2024
@criamico criamico added the Team:Fleet Team label for Observability Data Collection Fleet team label May 6, 2024
@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@criamico
Copy link
Contributor Author

criamico commented May 6, 2024

/ci

@criamico criamico added the release_note:skip Skip the PR/issue when compiling release notes label May 6, 2024
@criamico
Copy link
Contributor Author

criamico commented May 6, 2024

/ci

@criamico
Copy link
Contributor Author

criamico commented May 7, 2024

@elasticmachine merge upstream

@criamico
Copy link
Contributor Author

criamico commented May 7, 2024

/ci

@criamico criamico marked this pull request as ready for review May 7, 2024 13:53
@criamico criamico requested review from a team as code owners May 7, 2024 13:53
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@criamico
Copy link
Contributor Author

criamico commented May 7, 2024

PR needed in preparation for #180375. I originally thought to group the changes in a single PR but the changeset would become too big.

@kc13greiner kc13greiner self-requested a review May 7, 2024 15:27
Copy link
Contributor

@kilfoyle kilfoyle left a comment

Choose a reason for hiding this comment

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

LGTM for the docs part. 👍

Copy link
Member

@kpollich kpollich left a comment

Choose a reason for hiding this comment

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

Code + tests LGTM. Thanks for splitting this up into separate PR's 🚀

x-pack/plugins/fleet/server/services/agent_policy.ts Outdated Show resolved Hide resolved
x-pack/plugins/fleet/server/services/preconfiguration.ts Outdated Show resolved Hide resolved
Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

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

SO mapping changes LGTM

Copy link
Contributor

@kc13greiner kc13greiner left a comment

Choose a reason for hiding this comment

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

LGTM!

@criamico
Copy link
Contributor Author

criamico commented May 8, 2024

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
fleet 1179 1180 +1
Unknown metric groups

API count

id before after diff
fleet 1300 1301 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @criamico

@criamico criamico merged commit eb5e329 into elastic:main May 8, 2024
20 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label May 8, 2024
@criamico criamico deleted the 180377_Add_support_agentless_property branch May 8, 2024 08:58
criamico added a commit that referenced this pull request May 24, 2024
Closes #180375

## Summary
Expand support for Agentless in Fleet UI. Implemented on this PR:
- Agent policies created with `supports_agentless` (added in
#182709) are now marked as
`is_managed`
- Added support for `deployment_modes.agentless.enabled` and
`hide_in_deployment_modes` introduced with
elastic/package-spec#684:
- `hide_in_deployment_modes` shows/hides variables in agentless/default
UI
- `deployment_modes.agentless.enabled: true` determines an integration
as enabled for agentless

## Notes
- In this PR, an integration enabled for serverless is still added to
the default `agentless` policy.
- Integrations enabled for agentless don't display any specific
"agentless" form yet. That part is TBD

### Testing
- Run local env for
[agentless](https://docs.elastic.dev/security-solution/cloud-security/agentless)

### Verify that new settings are honoured in integration policy
- Use the compiled package with new properties defined in
elastic/package-spec#738
`agentless_test_package-1.0.1-rc1.zip` (Packages in this
[comment](#183045 (comment)))
- Upload it to Kibana:
  ```sh
curl -k -XPOST -H 'content-type: application/zip' -H 'kbn-xsrf: true'
https://localhost:5601/api/fleet/epm/packages -u
elastic_serverless:changeme --data-binary
@agentless_test_package-0.0.1.zip
  ```
- Check that the variable marked with `hide_in_deployment_modes:
"agentless"` are not visible
- Check that the agent policies selector is not visible

![Screenshot 2024-05-22 at 10 37
42](https://github.com/elastic/kibana/assets/16084106/02f12ebf-f448-4cfa-b9e7-8cb1a1226e5e)


### Verify that agent policies with `supports_agentless` are marked as
managed
- Create a new policy with `supports_agentless`
  ```
  POST kbn:/api/fleet/agent_policies
  {
    "name": "Test - Agentless policy",
    "namespace": "default",
    "supports_agentless": true
  }
  ```
- Check that the created policy has `is_managed = true`
- Try to change the value to false - an error is thrown
  ```
  PUT kbn:/api/fleet/agent_policies/<policy_id>
  {
    "name": "Test - Agentless policy",
    "namespace": "default",
    "supports_agentless": false
  }
  ```


### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet] Add supports_agentless property to agent policy schema/API
9 participants