File tree 4 files changed +189
-0
lines changed
4 files changed +189
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Network Policy
2
+
3
+ ## Minikube
4
+
5
+ * Minikube'u calico plug-in'iyle başlat
6
+
7
+ ```
8
+ $ minikube start --cpus 4 --memory 6144 --cni=calico --container-runtime=docker --host-only-cidr=172.17.17.1/24
9
+ ```
10
+
11
+ * Podları ve namespaceleri oluştur
12
+
13
+ ```
14
+ $ kubectl apply -f deploy.yaml
15
+ ```
16
+
17
+ * Network Policy deploy et
18
+ ```
19
+ $ kubectl apply -f policy.yaml
20
+ ```
21
+
22
+ * Poda'ya bağlan ve sadece 1.1.1.1'e 80 portundan gidebildiğini başka yere gidemediğini teyit et
23
+
24
+ ```
25
+ $ kubectl exec -it -n ns-a poda -- bash
26
+ ```
27
+
28
+ * PodB ve Frontend podlarından pod'a 80 portundan gidebildiğini teyit et. PodC'den ise gidemeyeceksin.
Original file line number Diff line number Diff line change
1
+ kind : Namespace
2
+ apiVersion : v1
3
+ metadata :
4
+ name : ns-a
5
+ labels :
6
+ team : a
7
+ ---
8
+ kind : Namespace
9
+ apiVersion : v1
10
+ metadata :
11
+ name : ns-b
12
+ labels :
13
+ team : b
14
+ ---
15
+ kind : Namespace
16
+ apiVersion : v1
17
+ metadata :
18
+ name : ns-c
19
+ labels :
20
+ team : c
21
+ ---
22
+ apiVersion : v1
23
+ kind : Pod
24
+ metadata :
25
+ name : poda
26
+ namespace : ns-a
27
+ labels :
28
+ team : a
29
+ spec :
30
+ containers :
31
+ - name : containera
32
+ image : ozgurozturknet/k8s:v1
33
+ ports :
34
+ - containerPort : 80
35
+ livenessProbe :
36
+ httpGet :
37
+ path : /healthcheck
38
+ port : 80
39
+ initialDelaySeconds : 5
40
+ periodSeconds : 5
41
+ readinessProbe :
42
+ httpGet :
43
+ path : /ready
44
+ port : 80
45
+ initialDelaySeconds : 20
46
+ periodSeconds : 3
47
+ ---
48
+ apiVersion : v1
49
+ kind : Pod
50
+ metadata :
51
+ name : podb
52
+ namespace : ns-b
53
+ labels :
54
+ team : b
55
+ spec :
56
+ containers :
57
+ - name : containerb
58
+ image : ozgurozturknet/k8s:v1
59
+ ports :
60
+ - containerPort : 80
61
+ livenessProbe :
62
+ httpGet :
63
+ path : /healthcheck
64
+ port : 80
65
+ initialDelaySeconds : 5
66
+ periodSeconds : 5
67
+ readinessProbe :
68
+ httpGet :
69
+ path : /ready
70
+ port : 80
71
+ initialDelaySeconds : 20
72
+ periodSeconds : 3
73
+ ---
74
+ apiVersion : v1
75
+ kind : Pod
76
+ metadata :
77
+ name : podc
78
+ namespace : ns-c
79
+ labels :
80
+ team : c
81
+ spec :
82
+ containers :
83
+ - name : containerc
84
+ image : ozgurozturknet/k8s:v1
85
+ ports :
86
+ - containerPort : 80
87
+ livenessProbe :
88
+ httpGet :
89
+ path : /healthcheck
90
+ port : 80
91
+ initialDelaySeconds : 5
92
+ periodSeconds : 5
93
+ readinessProbe :
94
+ httpGet :
95
+ path : /ready
96
+ port : 80
97
+ initialDelaySeconds : 20
98
+ periodSeconds : 3
99
+ ---
100
+ apiVersion : v1
101
+ kind : Pod
102
+ metadata :
103
+ name : frontend
104
+ namespace : ns-a
105
+ labels :
106
+ app : frontend
107
+ spec :
108
+ containers :
109
+ - name : frontend
110
+ image : ozgurozturknet/k8s:v1
111
+ ports :
112
+ - containerPort : 80
113
+ livenessProbe :
114
+ httpGet :
115
+ path : /healthcheck
116
+ port : 80
117
+ initialDelaySeconds : 5
118
+ periodSeconds : 5
119
+ readinessProbe :
120
+ httpGet :
121
+ path : /ready
122
+ port : 80
123
+ initialDelaySeconds : 20
124
+ periodSeconds : 3
Original file line number Diff line number Diff line change
1
+ apiVersion : networking.k8s.io/v1
2
+ kind : NetworkPolicy
3
+ metadata :
4
+ name : networkpolicy-example
5
+ namespace : ns-a
6
+ spec :
7
+ podSelector :
8
+ matchLabels :
9
+ team : a
10
+ policyTypes :
11
+ - Ingress
12
+ - Egress
13
+ ingress :
14
+ - from :
15
+ - ipBlock :
16
+ cidr : 10.11.0.0/16
17
+ except :
18
+ - 10.11.1.0/24
19
+ - namespaceSelector :
20
+ matchLabels :
21
+ team : b
22
+ - podSelector :
23
+ matchLabels :
24
+ app : frontend
25
+ ports :
26
+ - protocol : TCP
27
+ port : 80
28
+ egress :
29
+ - to :
30
+ - ipBlock :
31
+ cidr : 1.1.1.1/32
32
+ ports :
33
+ - protocol : TCP
34
+ port : 80
Original file line number Diff line number Diff line change
1
+ # Service mesh
2
+
3
+ --- https://istio.io/latest/docs/setup/getting-started/
You can’t perform that action at this time.
0 commit comments