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: pre core exemption handling #311

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
2f30126
testing pre-core exemptions with CRD package
TristanHoladay Mar 26, 2024
a6fe91a
updates to crd package; move podinfo exemption into separate chart fo…
TristanHoladay Mar 27, 2024
7247e50
create slim dev package in crd-test
TristanHoladay Mar 28, 2024
f514d7f
merge main and resolve
TristanHoladay Mar 28, 2024
55307d2
yamllint fixes
TristanHoladay Apr 2, 2024
1d86857
Merge branch 'main' into feat-pre-exemption
TristanHoladay Apr 2, 2024
f5be901
Merge branch 'main' into feat-pre-exemption
TristanHoladay Apr 29, 2024
a6df2db
adding uds misc chart for exemption passthrough; refactoring exemptio…
TristanHoladay Apr 30, 2024
8b0db03
removing crd.yaml from exemption-crd package (generate in CI instead)…
TristanHoladay Apr 30, 2024
0e92999
changed uds-misc to pre-core-exemptions; removed podinfo and other lo…
TristanHoladay Apr 30, 2024
bc27422
Merge branch 'main' into feat-pre-exemption
TristanHoladay Apr 30, 2024
fc8d81e
adding tasks for CI workflows
TristanHoladay Apr 30, 2024
c79e20e
adding test task and bundle for pre core exemptions helm overrides te…
TristanHoladay Apr 30, 2024
34810e5
Merge branch 'main' into feat-pre-exemption
TristanHoladay Apr 30, 2024
249b914
add pre-core-exemptions validation task
TristanHoladay Apr 30, 2024
3ab699c
yamllint fix
TristanHoladay Apr 30, 2024
1553ec8
adding docs
TristanHoladay Apr 30, 2024
f41f964
Merge branch 'main' into feat-pre-exemption
TristanHoladay Apr 30, 2024
c7a8c86
Merge branch 'main' into feat-pre-exemption
TristanHoladay May 1, 2024
6b43305
refactor pre core exemption helm values
TristanHoladay May 1, 2024
b011dac
skip pre-core-exemption validation for CI all tests
TristanHoladay May 1, 2024
dfd1329
exemption crd package to uds-crds and added package CRD generation; r…
TristanHoladay May 2, 2024
221f232
yamllint
TristanHoladay May 2, 2024
4c4cd44
refactor pre-core-exemptions validation tasks
TristanHoladay May 2, 2024
36d0542
fix pre-core-exemptions chart path
TristanHoladay May 2, 2024
d19988c
yamllint
TristanHoladay May 2, 2024
1821349
Merge branch 'main' into feat-pre-exemption
TristanHoladay May 2, 2024
303411f
remove --no-tea from deploy tasks
TristanHoladay May 2, 2024
73aed5d
fixed CI config package name
TristanHoladay May 2, 2024
0d140af
Merge branch 'main' into feat-pre-exemption
TristanHoladay May 3, 2024
973caa2
Merge branch 'main' into feat-pre-exemption
TristanHoladay May 7, 2024
4e3a01a
set values overrides in zarf package to handle override during zarf p…
TristanHoladay May 8, 2024
5e03bfa
yamllint
TristanHoladay May 8, 2024
41528b9
fixed zarf.yaml variables paths; updated README
TristanHoladay May 8, 2024
33c0a22
testing upgrade to uds version v0.10.4
TristanHoladay May 9, 2024
4f8dc33
adding --no-progress and --no-tea flags
TristanHoladay May 9, 2024
e932c12
Revert "testing upgrade to uds version v0.10.4"
TristanHoladay May 9, 2024
4fb9610
Revert "Revert "testing upgrade to uds version v0.10.4""
TristanHoladay May 9, 2024
a832c8e
Revert "adding --no-progress and --no-tea flags"
TristanHoladay May 9, 2024
488a655
reverting back to uds 0.9.2
TristanHoladay May 9, 2024
0343f5b
merge and resolve
TristanHoladay May 14, 2024
73e07d5
Merge branch 'main' into feat-pre-exemption
TristanHoladay May 14, 2024
1a92324
Merge branch 'main' into feat-pre-exemption
TristanHoladay May 14, 2024
f45a352
get podinfo_name for validation check
TristanHoladay May 16, 2024
a8321b2
Merge branch 'main' into feat-pre-exemption
TristanHoladay May 16, 2024
10babf8
wrap variable since uds var.
TristanHoladay May 17, 2024
addff09
Merge branch 'main' into feat-pre-exemption
TristanHoladay May 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions .github/bundles/exemption/uds-bundle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
kind: UDSBundle
TristanHoladay marked this conversation as resolved.
Show resolved Hide resolved
metadata:
name: k3d-core-slim-dev
description: A UDS bundle for deploying Istio from UDS Core on a development cluster
TristanHoladay marked this conversation as resolved.
Show resolved Hide resolved
# x-release-please-start-version
version: "0.21.0"
# x-release-please-end

packages:
- name: uds-k3d-dev
repository: ghcr.io/defenseunicorns/packages/uds-k3d
# renovate: datasource=github-tags depName=defenseunicorns/uds-k3d versioning=semver
ref: 0.6.0
overrides:
uds-dev-stack:
minio:
variables:
- name: buckets
description: "Set Minio Buckets"
path: buckets
- name: svcaccts
description: "Minio Service Accounts"
path: svcaccts
- name: users
description: "Minio Users"
path: users
- name: policies
description: "Minio policies"
path: policies

- name: init
repository: ghcr.io/defenseunicorns/packages/init
# renovate: datasource=github-tags depName=defenseunicorns/zarf versioning=semver
ref: v0.33.1

- name: podinfo
repository: ghcr.io/defenseunicorns/uds-cli/podinfo
ref: 0.0.1
overrides:
podinfo:
podinfo:
values:
- path: securityContext
value:
runAsUser: 0
runAsGroup: 0

- name: core-slim-dev
path: ../../../build/
# x-release-please-start-version
ref: 0.21.0
# x-release-please-end
overrides:
pre-core-exemptions:
pre-core-exemptions:
values:
- path: enabled
value: true
- path: exemptions
value: |
- policies:
- DisallowPrivileged
- RequireNonRootUser
- DropAllCapabilities
title: "podinfo1"
matcher:
namespace: podinfo
name: "^podinfo.*"
- policies:
- DisallowNodePortServices
title: "podinfo2"
matcher:
namespace: podinfo
name: "^.*-local.*"
kind: service
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ packages:
ref: v0.33.1

- name: core
path: ../../build/
path: ../../../build/
# x-release-please-start-version
ref: 0.21.0
# x-release-please-end
Expand Down
2 changes: 2 additions & 0 deletions .github/filters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ tempo:
- "src/tempo/**"
velero:
- "src/velero/**"
pre-core-exemptions:
- "src/pre-core-exemptions/**"
2 changes: 1 addition & 1 deletion .github/workflows/nightly-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
paths:
- tasks/iac.yaml
- .github/workflows/test-eks.yaml
- .github/bundles/*
- .github/bundles/infra-bundle/*
- .github/test-infra/buckets-iac/*

jobs:
Expand Down
9 changes: 9 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ jobs:
uds run deploy-standard-bundle --no-progress
uds run -f tasks/test.yaml validate-packages --no-progress

# Cluster must be up for generating the CRD
- name: Create Exemption CRD Package
if: ${{ matrix.flavor == 'upstream' }}
run: uds run -f tasks/create.yaml exemption-crd-package

- name: Debug Output
if: ${{ always() && !inputs.snapshot }}
uses: ./.github/actions/debug-output
Expand All @@ -80,6 +85,10 @@ jobs:
if: ${{ !inputs.snapshot && matrix.flavor != 'registry1' }}
run: uds run -f tasks/publish.yaml bundles

- name: Publish Exemption CRD Package
if: ${{ matrix.flavor == 'upstream' }}
run: uds run -f tasks/publish.yaml exemption-crd-package

- name: (Snapshot) Publish Standard Package
if: ${{ inputs.snapshot }}
run: uds run -f tasks/publish.yaml standard-package --set FLAVOR=${{ matrix.flavor }} --set TARGET_REPO="ghcr.io/defenseunicorns/packages/uds/snapshots" --set VERSION="${SNAPSHOT_VERSION}"
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test-eks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
run: ZARF_ARCHITECTURE=amd64 uds run -f tasks/create.yaml standard-package

- name: Create Core Bundle
run: uds create .github/bundles --confirm
run: uds create .github/bundles/infra-bundle --confirm

- name: Create Cluster
run: uds run -f tasks/iac.yaml create-cluster
Expand All @@ -64,13 +64,13 @@ jobs:

- name: Deploy Core Bundle
env:
UDS_CONFIG: .github/bundles/uds-config.yaml
run: uds deploy .github/bundles/uds-bundle-uds-core-eks-nightly-*.tar.zst --confirm
UDS_CONFIG: .github/bundles/infra-bundle/uds-config.yaml
run: uds deploy .github/bundles/infra-bundle/uds-bundle-uds-core-eks-nightly-*.tar.zst --confirm
timeout-minutes: 20

- name: Remove UDS Core
if: always()
run: uds remove .github/bundles/uds-bundle-uds-core-eks-*.tar.zst --confirm
run: uds remove .github/bundles/infra-bundle/uds-bundle-uds-core-eks-*.tar.zst --confirm
timeout-minutes: 10
continue-on-error: true

Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,13 @@ jobs:
run: uds run registry-login --set REGISTRY=registry1.dso.mil --set REGISTRY_USERNAME=${{ secrets.IRON_BANK_ROBOT_USERNAME }} --set REGISTRY_PASSWORD=${{ secrets.IRON_BANK_ROBOT_PASSWORD }} --set REGISTRY_RETRY_INTERVAL=90

- name: Test a single source package
if: ${{ inputs.package != 'all' && inputs.test_type == 'install' }}
if: ${{ inputs.package != 'all' && inputs.package != 'pre-core-exemptions' && inputs.test_type == 'install' }}
run: uds run test-single-package --set FLAVOR=${{ inputs.flavor }}

- name: Test pre core exemptions package
if: ${{ inputs.package == 'pre-core-exemptions' && inputs.test_type == 'install'}}
run: uds run test-pre-core-exemptions

- name: Test UDS Core Install
if: ${{ inputs.package == 'all' && inputs.test_type == 'install' }}
run: uds run test-uds-core --set FLAVOR=${{ inputs.flavor }}
Expand Down
37 changes: 35 additions & 2 deletions docs/CONFIGURE_POLICY_EXEMPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,38 @@ shared:

variables:
# package specific variables here

```
```

## Handling Pre Core Exemptions

If you find that you are deploying a resource before uds-core that requires an exemption CR once uds-core is deployed there are two options:

1) Pass exemptions to the core `pre-core-exemptions` package as helm values overrides. See [Pre Core Exemptions Docs](../src/pre-core-exemptions/README.md)

2) Deploy the exemption CRD as a package in your bundle before your pre-core resource.
(e.g.)
```yaml
kind: UDSBundle
metadata:
name: example CRD

packages:
- name: exemption-crd
repository: ghcr.io/defenseunicorns/packages/uds/exemption-crd
ref: <same-ref-as-core>

# Where the exemption CR lives
- name: custom-init
repository: ghcr.io/custom-init
ref: v0.1.0

- name: core
path: ghcr.io/defenseunicorns/packages/uds/core
ref: 0.20.0-upstream
```

> Warning
>
> Though both options have been tested, there is no guarantee
> that upgrades, specifically to the CRD package and your CR,
> will not break your deployment.
16 changes: 16 additions & 0 deletions packages/exemption-crd/zarf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
kind: ZarfPackageConfig
metadata:
name: uds-core-exemption-crd
TristanHoladay marked this conversation as resolved.
Show resolved Hide resolved
yolo: true
# x-release-please-start-version
version: 0.20.0
TristanHoladay marked this conversation as resolved.
Show resolved Hide resolved
# x-release-please-end

components:
- name: exemption-crd
required: true
manifests:
- name: crd
files:
# generated in CI
- ./crd.yaml
5 changes: 5 additions & 0 deletions packages/slim-dev/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ components:
import:
path: ../standard

- name: pre-core-exemptions
required: true
import:
path: ../standard

# Keycloak
- name: keycloak
required: true
Expand Down
5 changes: 5 additions & 0 deletions packages/standard/zarf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ components:
path: ../../dist
name: module

- name: pre-core-exemptions
required: true
import:
path: ../../src/pre-core-exemptions

# Metrics Server
- name: metrics-server
required: true
Expand Down
2 changes: 1 addition & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"versioning": "default",
"extra-files": [
".github/bundles/uds-bundle.yaml",
".github/bundles/infra-bundle/uds-bundle.yaml",
"README.md",
"packages/slim-dev/zarf.yaml",
"packages/standard/zarf.yaml",
Expand Down
2 changes: 2 additions & 0 deletions src/pepr/tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ tasks:
env:
- "PEPR_WATCH_MODE=true"

- cmd: "kubectl get crd exemptions.uds.dev -o yaml > packages/exemption-crd/crd.yaml"

- cmd: "npx kubernetes-fluent-client crd packages.uds.dev src/pepr/operator/crd/generated"

- cmd: "npx kubernetes-fluent-client crd exemptions.uds.dev src/pepr/operator/crd/generated"
Expand Down
53 changes: 53 additions & 0 deletions src/pre-core-exemptions/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Pre Core Exemptions

This package serves as a way for users deploying uds-core to pass exemptions to core for things that are deployed before core.
TristanHoladay marked this conversation as resolved.
Show resolved Hide resolved

For example, if a team is deploying a bundle containing a custom init package that has rook-ceph, the first time it
deploys everything will be fine, but if it cycles for whatever reason once core is deployed then rook-ceph will be denied by Pepr policies. Thus an exemption CR is needed.
The problem, though, is the init package can't deploy an exemption resource when the exemption CRD has not yet been deployed by core.
TristanHoladay marked this conversation as resolved.
Show resolved Hide resolved

This package solves that timing issue by applying whatever exemptions are given to it as soon as the Pepr core module has been successfully deployed.

## How to Use

Add helm values overrides to your `uds-bundle.yaml`:

```yaml
kind: UDSBundle
metadata:
name: example helm overrides

packages:
- name: custom-init
repository: ghcr.io/custom-init
ref: v0.1.0

- name: core
path: ghcr.io/defenseunicorns/packages/uds/core
ref: 0.20.0-upstream
overrides:
pre-core-exemptions:
pre-core-exemptions:
values:
- path: enabled
value: true
- path: exemptions
value: |
- policies:
- DisallowPrivileged
- RequireNonRootUser
- DropAllCapabilities
title: "podinfo1"
matcher:
namespace: podinfo
name: "^podinfo.*"
test: 1
- policies:
- DisallowNodePortServices
title: "podinfo2"
matcher:
namespace: podinfo
name: "^.*-local.*"
kind: service
test: 2
```
23 changes: 23 additions & 0 deletions src/pre-core-exemptions/chart/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
5 changes: 5 additions & 0 deletions src/pre-core-exemptions/chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: v2
name: pre-core-exemptions
description: Helm chart for exemptions that are required before core but couldn't be applied before core
type: application
version: 0.1.0
9 changes: 9 additions & 0 deletions src/pre-core-exemptions/chart/templates/uds-exemption.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{{- if .Values.enabled }}
apiVersion: uds.dev/v1alpha1
kind: Exemption
metadata:
name: pre-core-exemptions
namespace: {{ .Values.namespace }}
spec:
exemptions: {{ .Values.exemptions | nindent 4 }}
{{- end }}
3 changes: 3 additions & 0 deletions src/pre-core-exemptions/chart/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enabled: false
namespace: uds-policy-exemptions
exemptions: {}
29 changes: 29 additions & 0 deletions src/pre-core-exemptions/tasks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# works in conjunction with .github/bundles/exemption/uds-bundle.yaml
variables:
- name: PODINFO_NAME

tasks:
- name: validate
actions:
- description: Validate exemptions are applied
wait:
cluster:
kind: exemption
name: pre-core-exemptions
namespace: uds-policy-exemptions
condition: exists

- description: Get podinfo name
cmd: echo $(uds zarf tools kubectl get pods -n podinfo -o jsonpath='{.items[0].metadata.name}')
setVariables:
- name: PODINFO_NAME

- description: Cycle podinfo
cmd: uds zarf tools kubectl delete pod -n podinfo ${PODINFO_NAME}

- description: Check for podinfo to come back up
wait:
cluster:
kind: Pod
name: $PODINFO_NAME
namespace: podinfo
Loading