Skip to content

Commit

Permalink
docs: Add example for kube-apiserver entity policy
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Stringer <joe@cilium.io>
  • Loading branch information
joestringer committed May 7, 2024
1 parent 87ed04b commit 3d1efae
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Documentation/security/policy/language.rst
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,25 @@ all
The all entity represents the combination of all known clusters as well
world and whitelists all communication.

Access to/from kube-apiserver
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Allow all endpoints with the label ``env=dev`` to access the kube-apiserver.

.. only:: html

.. tabs::
.. group-tab:: k8s YAML

.. literalinclude:: ../../../examples/policies/l3/entities/apiserver.yaml
.. group-tab:: JSON

.. literalinclude:: ../../../examples/policies/l3/entities/apiserver.json

.. only:: epub or latex

.. literalinclude:: ../../../examples/policies/l3/entities/apiserver.json

Access to/from local host
~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
7 changes: 7 additions & 0 deletions examples/policies/l3/entities/apiserver.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[{
"labels": [{"key": "name", "value": "dev-to-kube-apiserver"}],
"endpointSelector": {"matchLabels": {"env":"dev"}},
"egress": [{
"toEntities": ["kube-apiserver"]
}]
}]
11 changes: 11 additions & 0 deletions examples/policies/l3/entities/apiserver.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
name: "dev-to-kube-apiserver"
spec:
endpointSelector:
matchLabels:
env: dev
egress:
- toEntities:
- kube-apiserver

0 comments on commit 3d1efae

Please sign in to comment.