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

fix: oathkeeper - allow self managed rules when maester is disabled #685

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
37 changes: 37 additions & 0 deletions hacks/manifests/oathkeeper-external-accessrules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: v1
kind: ConfigMap
metadata:
# The name comes from oathkeeper's subchart.
name: '{{ include "oathkeeper.fullname" . }}-rules'
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a static file, not a template, functions are not supported 😉

Copy link
Author

Choose a reason for hiding this comment

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

Yes! I know, haha. I just wanted to give you the feel for it since you were thinking about a larger refactor.

In principle, you would need, at least, the name of the release ahead of time, use that helper, or use fullnameOverride with oathkeeper.

I should have written a comment after pushing this, I'm sorry about that. I'm going to put the PR in draft now.

Maybe I should just try doing the changes in the CI that would lead to this tests working? Maybe you can give me some guidance on how you would like to do this:

This is moderately bigger refactor that needs to be done in a separate issue/pr. In this case I think we can emulate the use-case by adding a oathkeeper-rules manifest here, so it will act as a pre-existing cm which has to be consumed by the chart

Thanks again for your help.

Copy link
Collaborator

Choose a reason for hiding this comment

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

No worries :) My idea for the CI refactor would be rather straightforward.
Current structure

hacks/
  values/
    oathkeeper.yaml
    keto.yaml
    ...

New structure

hacks/
  values/
    oathkeeper/
      case1.yaml
      case2.yaml
    keto/
      foo.yaml

This would allow us to hold multiple config options in the CI and tests all of them automatically :)

In the quote you send i meant to deploy the cm as a static object, with a predefined foo name, and then feed that name as a variable in the values


data:
access-rules.json: |-
[
{
"id": "rule-foobar",
"upstream": {
"url": "https://httpbin.org/anything"
},
"match": {
"url": "http://<[^/]+>/authenticator/noop/authorizer/allow/mutator/noop",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH"
]
},
"authenticators": [
{
"handler": "noop"
}
],
"authorizer": {
"handler": "allow"
},
"mutators": [{
"handler": "noop"
}]
}
]
165 changes: 165 additions & 0 deletions hacks/values/oathkeeper-external-accessrules.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
---
demo: false
maester:
enabled: false
#
#service:
# proxy:
# type: NodePort
# api:
# type: NodePort
#

image:
initContainer:
repository: docker.io/library/busybox
tag: 1.36

ingress:
proxy:
enabled: true
defaultBackend:
service:
name: myservice
port:
number: 80
annotations:
kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: "true"
api:
enabled: true
priorityClassName: "system-cluster-critical"

pdb:
enabled: true
spec:
maxUnavailable: 25%

deployment:
extraInitContainers: |
- name: "hello-world"
image: "alpine:latest"
command: ["/bin/sh"]
args: ["-c", "echo hello, world!"]
extraContainers: |
- name: "sidecar"
image: "alpine:latest"
command: ["/bin/sh"]
args: ["-c", "sleep infinity"]
podMetadata:
labels:
ory.sh/pod_label: oathkeeper
annotations:
ory.sh/pod_annotation: oathkeeper
autoscaling:
enabled: true
targetCPU:
type: Utilization
averageUtilization: 80
targetMemory:
type: Utilization
averageUtilization: 80
behavior:
scaleDown:
stabilizationWindowSeconds: 60
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
oathkeeper:
managedAccessRules: false
accessRules: |
[
{
"id": "rule-foobar",
"upstream": {
"url": "https://httpbin.org/anything"
},
"match": {
"url": "http://<[^/]+>/authenticator/noop/authorizer/allow/mutator/noop",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH"
]
},
"authenticators": [
{
"handler": "noop"
}
],
"authorizer": {
"handler": "allow"
},
"mutators": [{
"handler": "noop"
}]
}
]
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}
config:
mutators:
noop:
enabled: true
authorizers:
allow:
enabled: true
deny:
enabled: true
authenticators:
noop:
enabled: true

secret:
enabled: true

service:
metrics:
labels:
app.kubernetes.io/element: "metrics"
release: "metrics"
app: oathkeeper

serviceMonitor:
labels:
release: "prometheus"
tlsConfig:
insecureSkipVerify: true
relabelings:
- action: labeldrop
regex: request
metricRelabelings:
- action: labeldrop
regex: request
targetLabels:
- app

test:
labels:
test-org: ory
test-product: oathkeeper
test-service: authorizer
busybox:
repository: docker.io/library/busybox
tag: 1.36
4 changes: 2 additions & 2 deletions helm/charts/oathkeeper/templates/deployment-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ spec:
name: {{ include "oathkeeper.fullname" . }}-config
{{- end }}
- name: {{ include "oathkeeper.name" . }}-rules-volume
{{- if .Values.oathkeeper.managedAccessRules }}
{{- if or .Values.oathkeeper.managedAccessRules ( not .Values.maester.enabled ) }}
configMap:
name: {{ include "oathkeeper.fullname" . }}-rules
{{- else }}
Expand All @@ -76,7 +76,7 @@ spec:
serviceAccountName: {{ include "oathkeeper.serviceAccountName" . }}
automountServiceAccountToken: {{ .Values.deployment.automountServiceAccountToken }}
initContainers:
{{- if (not .Values.oathkeeper.managedAccessRules) }}
{{- if ( not ( or .Values.oathkeeper.managedAccessRules ( not .Values.maester.enabled ) ) ) }}
- name: init
image: "{{ .Values.image.initContainer.repository }}:{{ .Values.image.initContainer.tag }}"
volumeMounts:
Expand Down
Loading