From e1a4f5fc3759dc659e6c6df97d49a686ab9b2564 Mon Sep 17 00:00:00 2001 From: bruce-au <51087152+bruce-au@users.noreply.github.com> Date: Wed, 14 Aug 2019 13:28:25 -0400 Subject: [PATCH] Adding ability to define additional bootstrap policies loaded upon OPA startup, in addition to the authz policy. (#16332) Signed-off-by: Bruce Yu --- stable/opa/Chart.yaml | 2 +- stable/opa/README.md | 3 +- stable/opa/templates/deployment.yaml | 44 +++++++++++++++++----------- stable/opa/values.yaml | 11 +++++++ 4 files changed, 41 insertions(+), 19 deletions(-) diff --git a/stable/opa/Chart.yaml b/stable/opa/Chart.yaml index edb7c7ef70..dac1b2cae2 100644 --- a/stable/opa/Chart.yaml +++ b/stable/opa/Chart.yaml @@ -6,7 +6,7 @@ keywords: - opa - admission control - policy -version: 1.7.0 +version: 1.8.0 home: https://www.openpolicyagent.org icon: https://raw.githubusercontent.com/open-policy-agent/opa/master/logo/logo.png sources: diff --git a/stable/opa/README.md b/stable/opa/README.md index 1d1c5b4112..b3039e1f2e 100644 --- a/stable/opa/README.md +++ b/stable/opa/README.md @@ -85,4 +85,5 @@ Reference](https://www.openpolicyagent.org/docs/configuration.html). | `sar.resources` | CPU and memory limits for the sar container. | `{}` | | `priorityClassName` | The name of the priorityClass for the pods. | Unset | | `prometheus.enabled` | Flag to expose the `/metrics` endpoint to be scraped. | `false` | -| `annotations` | Annotations to be added to the deployment template. | `{}` | \ No newline at end of file +| `annotations` | Annotations to be added to the deployment template. | `{}` | +| `bootstrapPolicies` | Bootstrap policies to be loaded during OPA startup. | `{}` | \ No newline at end of file diff --git a/stable/opa/templates/deployment.yaml b/stable/opa/templates/deployment.yaml index 2e8986d6f5..0d9d2528ff 100644 --- a/stable/opa/templates/deployment.yaml +++ b/stable/opa/templates/deployment.yaml @@ -30,7 +30,7 @@ spec: {{- if .Values.priorityClassName }} priorityClassName: {{ .Values.priorityClassName }} {{- end }} -{{- if .Values.authz.enabled }} +{{- if or .Values.authz.enabled .Values.bootstrapPolicies}} initContainers: - name: initpolicy image: {{ .Values.mgmt.image }}:{{ .Values.mgmt.imageTag }} @@ -41,9 +41,10 @@ spec: - /bin/sh - -c - | - tr -dc 'A-F0-9' < /dev/urandom | dd bs=1 count=32 2>/dev/null > /authz/mgmt-token - TOKEN=`cat /authz/mgmt-token` - cat > /authz/authz.rego </dev/null > /bootstrap/mgmt-token + TOKEN=`cat /bootstrap/mgmt-token` + cat > /bootstrap/authz.rego < /bootstrap/{{ $policyName }}.rego < : |- +# +# For example, to mask the entire input body in the decision logs: +# bootstrapPolicies: +# log: |- +# package system.log +# mask["/input"] +bootstrapPolicies: {} + # To enforce mutating policies, change to MutatingWebhookConfiguration. admissionControllerKind: ValidatingWebhookConfiguration