Skip to content

Commit 579f925

Browse files
committed
access-policies
1 parent 98cf988 commit 579f925

File tree

2 files changed

+189
-0
lines changed

2 files changed

+189
-0
lines changed

docs/explanation/zero-trust.md

+2
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ spec:
3838
![access-policy-3](../assets/access-policy-3.png)
3939
4040
Now that both applications has explicitly declared their policies, the communication is allowed.
41+
42+
See more about [how to define access policies](../how-to-guides/access-policies.md)

docs/how-to-guides/access-policies.md

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# Access policies
2+
3+
This guide will show you how to define [access policies](../explanation/zero-trust.md) for your [workload](../explanation/workloads/README.md).
4+
5+
## Receive requests from workloads in the same namespace
6+
7+
For app `<MY-APP>` to be able to receive incoming requests from `<MY-OTHER-APP>` in the same namespace, this specification is needed for `<MY-APP>`:
8+
9+
=== "app.yaml"
10+
11+
```yaml
12+
apiVersion: "nais.io/v1alpha1"
13+
kind: "Application"
14+
metadata:
15+
name: <MY-APP>
16+
...
17+
spec:
18+
...
19+
accessPolicy:
20+
inbound:
21+
rules:
22+
- application: <MY-OTHER-APP>
23+
```
24+
25+
=== "visualization"
26+
27+
```mermaid
28+
graph LR
29+
accTitle: Receive requests from other workload in the same namespace
30+
accDescr: The diagram shows two applications in the same namespace, MY-APP and MY-OTHER-APP. Application MY-APP is allowed to receive requests from MY-OTHER-APP.
31+
32+
MY-OTHER-APP--"✅"-->MY-APP
33+
34+
subgraph namespace
35+
MY-OTHER-APP
36+
MY-APP
37+
end
38+
```
39+
40+
## Receive requests from workloads in other namespaces
41+
42+
For app `<MY-APP>` to be able to receive incoming requests from `<ANOTHER-APP>` in `<ANOTHER-NAMESPACE>`, this specification is needed for `<MY-APP>`:
43+
44+
=== "app.yaml"
45+
46+
```yaml
47+
apiVersion: "nais.io/v1alpha1"
48+
kind: "Application"
49+
metadata:
50+
name: <MY-APP>
51+
...
52+
spec:
53+
...
54+
accessPolicy:
55+
inbound:
56+
rules:
57+
- application: <ANOTHER-APP>
58+
namespace: <ANOTHER-NAMESPACE>
59+
```
60+
61+
=== "visualization"
62+
63+
```mermaid
64+
graph LR
65+
accTitle: Receive requests from other app in the another namespace
66+
accDescr: The diagram shows two applications in different namespaces, <MY-APP and ANOTHER-APP. Application MY-APP is allowing requests from ANOTHER-APP.
67+
68+
ANOTHER-APP--"✅"-->MY-APP
69+
70+
subgraph namespace
71+
MY-APP
72+
end
73+
74+
subgraph another-namespace
75+
ANOTHER-APP
76+
end
77+
```
78+
79+
## Send requests to another app in the same namespace
80+
81+
For app `MY-APP` to be able to send requests to `<MY-OTHER-APP>` in the same namespace, this specification is needed for `<MY-APP`:
82+
83+
=== "nais.yaml"
84+
85+
```yaml
86+
apiVersion: "nais.io/v1alpha1"
87+
kind: "Application"
88+
metadata:
89+
name: <MY-APP>
90+
...
91+
spec:
92+
...
93+
accessPolicy:
94+
outbound:
95+
rules:
96+
- application: <MY-OTHER-APP>
97+
```
98+
99+
=== "visualization"
100+
101+
```mermaid
102+
graph LR
103+
accTitle: Send requests to other app in the same namespace
104+
accDescr: The diagram shows two applications in the same namespace, MY-APP and MY-OTHER-APP. Application MY-APP is allowed to send requests to MY-OTHER-APP.
105+
106+
MY-APP--"✅"-->MY-OTHER-APP
107+
108+
subgraph mynamespace
109+
MY-APP
110+
MY-OTHER-APP
111+
end
112+
```
113+
114+
## Send requests to other app in the another namespace
115+
116+
For app `<MY-APP>` to be able to send requests to `<ANOTHER-APP>` in `<ANOTHER-NAMESPACE>`, this specification is needed for `<MY-APP>`:
117+
118+
=== "nais.yaml"
119+
120+
```yaml
121+
apiVersion: "nais.io/v1alpha1"
122+
kind: "Application"
123+
metadata:
124+
name: <MY-APP>
125+
...
126+
spec:
127+
...
128+
accessPolicy:
129+
outbound:
130+
rules:
131+
- application: <ANOTHER-APP>
132+
namespace: <ANOTHER-NAMESPACE>
133+
```
134+
135+
=== "visualization"
136+
137+
```mermaid
138+
graph LR
139+
accTitle: Send requests to other app in another-namespace
140+
accDescr: The diagram shows two applications in different namespaces, MY-APP and ANOTHER. Application MY-APP is allowed to send requests to ANOTHER-APP.
141+
142+
MY-APP--"✅"-->ANOTHER-APP
143+
144+
subgraph mynamespace
145+
MY-APP
146+
end
147+
148+
subgraph another-namespace
149+
ANOTHER-APP
150+
end
151+
```
152+
153+
## Send requests to external endpoints
154+
155+
For app `<MY-APP>` to be able to send requests outside of the environment, this specification is needed for `<MY-APP>`:
156+
157+
=== "app.yaml"
158+
159+
```yaml
160+
apiVersion: "nais.io/v1alpha1"
161+
kind: "Application"
162+
metadata:
163+
name: <MY-APP>
164+
...
165+
spec:
166+
...
167+
accessPolicy:
168+
outbound:
169+
external:
170+
- host: external-application.com
171+
```
172+
173+
=== "visualization"
174+
175+
```mermaid
176+
graph LR
177+
accTitle: External services
178+
accDescr: The diagram shows an application, <MY-APP>, that is allowed to send requests to an external service.
179+
180+
MY-APP--"✅"-->external-application.com
181+
182+
subgraph environment
183+
subgraph mynamespace
184+
MY-APP
185+
end
186+
end
187+
```

0 commit comments

Comments
 (0)