diff --git a/examples/basic/README.md b/examples/basic/README.md index aac532a7dc9c..7278f7e83551 100644 --- a/examples/basic/README.md +++ b/examples/basic/README.md @@ -17,6 +17,8 @@ Basis example contains setup and tear down logic with default NSM infrastructure - [Kernel to VXLAN to Memif Connection](../use-cases/Kernel2Vxlan2Memif) - [Memif to VXLAN to Kernel Connection](../use-cases/Memif2Vxlan2Kernel) +**Featues** +- [Open Policy Agent](../features/opa) ## Run diff --git a/examples/features/namespace.yaml b/examples/features/namespace.yaml new file mode 100644 index 000000000000..7919ccab9bec --- /dev/null +++ b/examples/features/namespace.yaml @@ -0,0 +1,5 @@ +--- +apiVersion: v1 +kind: Namespace +metadata: + generateName: ns- diff --git a/examples/features/opa/README.md b/examples/features/opa/README.md new file mode 100644 index 000000000000..e4cd5bde9bf4 --- /dev/null +++ b/examples/features/opa/README.md @@ -0,0 +1,137 @@ +# Feature OPA + + +Let's consider a current simplified version of NSM authorization. + +![NSM Authorize Scheme](./scheme.png "NSM Authorize Scheme") + +*Note: This scheme simplified many of the complex things that happen in every client and endpoint for simplicity. To understand it in deep consider looking at the source code of applications.* + +Each application in the path of NSM request doesn't trust anybody. Each endpoint doesn't trust the client and on each incoming request the endpoint validates tokens in the path and if they invalid then the endpoint returns an error. +Each client also doesn't trust the endpoint and checks tokens on the response. + +Authorization checks enabled by default in NSM. +For example, all [use-cases](../../use-cases) are using valid token chains by default. + +The example below will do token from step1 from the scheme as invalid. +Expected that Endpoint(in this case NSMgr) will fail the Request from the client on step 4. + +## Run + +1. Create test namespace: +```bash +NAMESPACE=($(kubectl create -f ../namespace.yaml)[0]) +NAMESPACE=${NAMESPACE:10} +``` + +2. Register namespace in `spire` server: +```bash +kubectl exec -n spire spire-server-0 -- \ +/opt/spire/bin/spire-server entry create \ +-spiffeID spiffe://example.org/ns/${NAMESPACE}/sa/default \ +-parentID spiffe://example.org/ns/spire/sa/spire-agent \ +-selector k8s:ns:${NAMESPACE} \ +-selector k8s:sa:default +``` + +3. Select node to deploy NSC and NSE: +```bash +NODE=($(kubectl get nodes -o go-template='{{range .items}}{{ if not .spec.taints }}{{index .metadata.labels "kubernetes.io/hostname"}} {{end}}{{end}}')[0]) +``` + +4. Create customization file: +```bash +cat > kustomization.yaml < patch-nsc.yaml < patch-nse.yaml <