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

feat: add sane defaults to the pod and containers in pepr deployments #445

Merged
merged 11 commits into from
Jan 8, 2024

Conversation

cmwylie19
Copy link
Collaborator

Description

Adds sane defaults to securityContext in Pepr's Admission and Watcher Deployment in the podSpec and containerSpec.

Related Issue

Fixes #444

Relates to #

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Other (security config, docs update, etc)

Checklist before merging

Signed-off-by: Case Wylie <cmwylie19@defenseunicorns.com>
Signed-off-by: Case Wylie <cmwylie19@defenseunicorns.com>
Signed-off-by: Case Wylie <cmwylie19@defenseunicorns.com>
Copy link

netlify bot commented Dec 18, 2023

Deploy Preview for pepr-docs canceled.

Name Link
🔨 Latest commit 3e54803
🔍 Latest deploy log https://app.netlify.com/sites/pepr-docs/deploys/6580d3db79533200087da7e9

@cmwylie19 cmwylie19 changed the title 444 chore: add sane defaults to the pod and containers in pepr deployments Dec 18, 2023
Signed-off-by: Case Wylie <cmwylie19@defenseunicorns.com>
@rjferguson21
Copy link

rjferguson21 commented Dec 18, 2023

Testing this against DUBBD 0.15.0 looks good. All policies that are currently set to enforce are no longer showing failures.

There is one remaining policy that is currently failing but it is currently only in audit mode:

(⎈|k3d-uds-test-cluster:default) ~ kubectl get policyreports -o json -n pepr-system | jq '.items[] | .results[] | select(.result == "fail") | {policy: .policy, rule: .rule, message: .message, resources: .resources }'
{
  "policy": "disallow-auto-mount-service-account-token",
  "rule": "automount-service-accounts",
  "message": "validation error: Automount Kubernetes API Credentials isn't turned off. The field automountServiceAccountToken  must be set to false. rule automount-service-accounts failed at path /automountServiceAccountToken/",
  "resources": [
    {
      "apiVersion": "v1",
      "kind": "ServiceAccount",
      "name": "pepr-static-test",
      "namespace": "pepr-system",
      "uid": "9b5bf683-8955-49a9-b34a-8972a4546675"
    }
  ]
}

The policy is roughly based on this - https://kyverno.io/policies/other/disable-automountserviceaccounttoken/disable-automountserviceaccounttoken/

Looking into what is a reasonable way to address that I found this example: https://cert-manager.io/docs/installation/best-practice/#restrict-auto-mount-of-service-account-tokens

I would be fine to move this along and create a follow on issue to address that particular policy because it seems a bit more involved.

Signed-off-by: Case Wylie <cmwylie19@defenseunicorns.com>
@cmwylie19
Copy link
Collaborator Author

totally got tripped up testing locally b/c I was not able to create the configMap with SSA... turns out the code was right, but I had assigned the role create for the SSA, which of course didn't work

Signed-off-by: Case Wylie <cmwylie19@defenseunicorns.com>
Signed-off-by: Case Wylie <cmwylie19@defenseunicorns.com>
@rjferguson21
Copy link

Retested this against a baseline DUBBD 0.15.0 after @cmwylie19 added fixes specifically for disallow-auto-mount-service-account-token and there are no longer any Kyverno policy violations.

LGTM

rjferguson21
rjferguson21 previously approved these changes Dec 18, 2023
Copy link
Member

@jeff-mccoy jeff-mccoy left a comment

Choose a reason for hiding this comment

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

let's discuss this after the break please

@cmwylie19 cmwylie19 changed the title chore: add sane defaults to the pod and containers in pepr deployments ON HOLD: add sane defaults to the pod and containers in pepr deployments Dec 19, 2023
@RothAndrew
Copy link
Member

Status update? Looking forward to this fix so I can stop excluding the pepr-system namespace from my deployment's kyverno policies

@jeff-mccoy
Copy link
Member

If we break this up, I don't have a problem with security context at all. I have an issue with the automount portion. Is that possible @cmwylie19?

@cmwylie19
Copy link
Collaborator Author

If we break this up, I don't have a problem with security context at all. I have an issue with the automount portion. Is that possible @cmwylie19?

Yes, definitely possible. I think that the automount is taken care of by intentionally and purposefully assigning serviceAccounts to your resources and not using the defaults.

@RothAndrew should be done today and I will look to get it reviewed tomorrow

Signed-off-by: Case Wylie <cmwylie19@defenseunicorns.com>
@cmwylie19 cmwylie19 changed the title ON HOLD: add sane defaults to the pod and containers in pepr deployments task: add sane defaults to the pod and containers in pepr deployments Jan 8, 2024
@cmwylie19 cmwylie19 changed the title task: add sane defaults to the pod and containers in pepr deployments chore: add sane defaults to the pod and containers in pepr deployments Jan 8, 2024
@cmwylie19 cmwylie19 changed the title chore: add sane defaults to the pod and containers in pepr deployments feat: add sane defaults to the pod and containers in pepr deployments Jan 8, 2024
@cmwylie19
Copy link
Collaborator Author

Tested upgrade process manually details here -- #464

Copy link
Member

@jeff-mccoy jeff-mccoy left a comment

Choose a reason for hiding this comment

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

sgtm

@cmwylie19 cmwylie19 merged commit 3ef4c52 into main Jan 8, 2024
12 of 14 checks passed
@cmwylie19 cmwylie19 deleted the 444 branch January 8, 2024 21:36
jeff-mccoy pushed a commit to defenseunicorns/uds-core that referenced this pull request Jan 13, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [pepr](https://togithub.com/defenseunicorns/pepr) | [`0.21.1` ->
`0.22.0`](https://renovatebot.com/diffs/npm/pepr/0.21.1/0.22.0) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/pepr/0.22.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/pepr/0.22.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/pepr/0.21.1/0.22.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/pepr/0.21.1/0.22.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>defenseunicorns/pepr (pepr)</summary>

###
[`v0.22.0`](https://togithub.com/defenseunicorns/pepr/releases/tag/v0.22.0)

[Compare
Source](https://togithub.com/defenseunicorns/pepr/compare/v0.21.1...v0.22.0)

#### Features

Make `npx pepr deploy` wait recursively for deployments to be in a
ready-state - feat: npx pepr dev does not wait for resources to be fully
up by [@&#8203;schaeferka](https://togithub.com/schaeferka) in
[defenseunicorns/pepr#435

Work on multi-versioned docs automation for the [Docs
Site](https://pepr-docs.netlify.app/v0.21.1/) - feat: delete website by
[@&#8203;btlghrants](https://togithub.com/btlghrants) in
[defenseunicorns/pepr#459

Locking down the Pepr generated Kubernetes manifests with
securityContexts - feat: add sane defaults to the pod and containers in
pepr deployments by [@&#8203;cmwylie19](https://togithub.com/cmwylie19)
in
[defenseunicorns/pepr#445

`npx pepr deploy --force` to override manager field in the underlying
KFC implementation of [Server Side
Apply](https://kubernetes.io/docs/reference/using-api/server-side-apply/#conflicts)
eat: force option on npx pepr deploy by
[@&#8203;cmwylie19](https://togithub.com/cmwylie19) in
[defenseunicorns/pepr#480

(e2e style) Upgrade test of Kubernetes manifests - feat: pepr upgrade
test by [@&#8203;cmwylie19](https://togithub.com/cmwylie19) in
[defenseunicorns/pepr#478

Force rollouts to Pepr's Admission and Watcher deployments by adding an
annotation to podSpecs - feat: add timestamp to podSpec annotations
force rollout on deployments by
[@&#8203;cmwylie19](https://togithub.com/cmwylie19) in
[defenseunicorns/pepr#483

#### What's Changed

- chore: update waitForDeployments by
[@&#8203;cmwylie19](https://togithub.com/cmwylie19) in
[defenseunicorns/pepr#482
- chore: add error message for easier debugging by
[@&#8203;cmwylie19](https://togithub.com/cmwylie19) in
[defenseunicorns/pepr#479
- chore: kubernetes slack channel for pepr and readme updates by
[@&#8203;cmwylie19](https://togithub.com/cmwylie19) in
[defenseunicorns/pepr#467
- chore: test code coverage by
[@&#8203;cmwylie19](https://togithub.com/cmwylie19) in
[defenseunicorns/pepr#468
- chore: bump the development-dependencies group with 2 updates by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#456
- chore: bump actions/dependency-review-action from 3.1.4 to 3.1.5 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#458
- chore: bump the development-dependencies group with 2 updates by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#457
- chore: bump the development-dependencies group with 1 update by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#466
- chore: bump the development-dependencies group with 1 update by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#469
- chore: bump actions/checkout from 2 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#472
- chore: bump actions/setup-node from 2 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#470
- chore: bump codecov/codecov-action from 2 to 3 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#471
- chore: bump the development-dependencies group with 1 update by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#475

**Full Changelog**:
defenseunicorns/pepr@v0.21.1...v0.22.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/defenseunicorns/uds-core).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMjcuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEyNy4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
robmcelvenny pushed a commit to owen-grady/uds-core-slim-dev that referenced this pull request Jun 3, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [pepr](https://togithub.com/defenseunicorns/pepr) | [`0.21.1` ->
`0.22.0`](https://renovatebot.com/diffs/npm/pepr/0.21.1/0.22.0) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/pepr/0.22.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/pepr/0.22.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/pepr/0.21.1/0.22.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/pepr/0.21.1/0.22.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>defenseunicorns/pepr (pepr)</summary>

###
[`v0.22.0`](https://togithub.com/defenseunicorns/pepr/releases/tag/v0.22.0)

[Compare
Source](https://togithub.com/defenseunicorns/pepr/compare/v0.21.1...v0.22.0)

#### Features

Make `npx pepr deploy` wait recursively for deployments to be in a
ready-state - feat: npx pepr dev does not wait for resources to be fully
up by [@&#8203;schaeferka](https://togithub.com/schaeferka) in
[defenseunicorns/pepr#435

Work on multi-versioned docs automation for the [Docs
Site](https://pepr-docs.netlify.app/v0.21.1/) - feat: delete website by
[@&#8203;btlghrants](https://togithub.com/btlghrants) in
[defenseunicorns/pepr#459

Locking down the Pepr generated Kubernetes manifests with
securityContexts - feat: add sane defaults to the pod and containers in
pepr deployments by [@&#8203;cmwylie19](https://togithub.com/cmwylie19)
in
[defenseunicorns/pepr#445

`npx pepr deploy --force` to override manager field in the underlying
KFC implementation of [Server Side
Apply](https://kubernetes.io/docs/reference/using-api/server-side-apply/#conflicts)
eat: force option on npx pepr deploy by
[@&#8203;cmwylie19](https://togithub.com/cmwylie19) in
[defenseunicorns/pepr#480

(e2e style) Upgrade test of Kubernetes manifests - feat: pepr upgrade
test by [@&#8203;cmwylie19](https://togithub.com/cmwylie19) in
[defenseunicorns/pepr#478

Force rollouts to Pepr's Admission and Watcher deployments by adding an
annotation to podSpecs - feat: add timestamp to podSpec annotations
force rollout on deployments by
[@&#8203;cmwylie19](https://togithub.com/cmwylie19) in
[defenseunicorns/pepr#483

#### What's Changed

- chore: update waitForDeployments by
[@&#8203;cmwylie19](https://togithub.com/cmwylie19) in
[defenseunicorns/pepr#482
- chore: add error message for easier debugging by
[@&#8203;cmwylie19](https://togithub.com/cmwylie19) in
[defenseunicorns/pepr#479
- chore: kubernetes slack channel for pepr and readme updates by
[@&#8203;cmwylie19](https://togithub.com/cmwylie19) in
[defenseunicorns/pepr#467
- chore: test code coverage by
[@&#8203;cmwylie19](https://togithub.com/cmwylie19) in
[defenseunicorns/pepr#468
- chore: bump the development-dependencies group with 2 updates by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#456
- chore: bump actions/dependency-review-action from 3.1.4 to 3.1.5 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#458
- chore: bump the development-dependencies group with 2 updates by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#457
- chore: bump the development-dependencies group with 1 update by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#466
- chore: bump the development-dependencies group with 1 update by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#469
- chore: bump actions/checkout from 2 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#472
- chore: bump actions/setup-node from 2 to 4 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#470
- chore: bump codecov/codecov-action from 2 to 3 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#471
- chore: bump the development-dependencies group with 1 update by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[defenseunicorns/pepr#475

**Full Changelog**:
defenseunicorns/pepr@v0.21.1...v0.22.0

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/defenseunicorns/uds-core).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMjcuMCIsInVwZGF0ZWRJblZlciI6IjM3LjEyNy4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Include securityContext for generated resources
4 participants