I am trying to setup my OPA as below.
My config map in kubernetes
kubectl create configmap policyconfig --from-file=./config/config.yaml
My Sidecar OPA
- name: opa
image: openpolicyagent/opa:latest
args:
- "run"
- "--server"
- "--addr=0.0.0.0:443"
- "--addr=0.0.0.0:8181"
- "--config-file=policyconfig"
volumes:
- name: policyconfig
configMap:
name: policyconfig
Let me know if it is possible to implement in this way
Alternatively, you can use Gatekeeper. Which in addition to what kube-mgmt (Gatekeeper 1.0) has it also provides (per this):
Another recent tool is MagTape.
You can use kube-mgmt as sidecar for managing OPA on top of Kubernetes.
kube-mgmt automatically discovers policies stored in ConfigMaps in Kubernetes and loads them into OPA. kube-mgmt assumes a ConfigMap contains policies if the ConfigMap is:
https://medium.com/capital-one-tech/policy-enabled-kubernetes-with-open-policy-agent-3b612b3f0203
Update:
With your current setup and requirement you need to add a volumeMounts
to make it work
- name: opa
image: openpolicyagent/opa:latest
args:
- "run"
- "--server"
- "--addr=0.0.0.0:443"
- "--addr=0.0.0.0:8181"
- "--config-file=policyconfig"
volumeMounts:
- name: policyconfig
mountPath: /config
volumes:
- name: policyconfig
configMap:
name: policyconfig