Ex. 6.5 Testing the policy

Hello
I can not get the selective ingress from #6 on to work.
~ $ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 230: eth0@if231: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1460 qdisc noqueue qlen 1000 link/ether 72:1b:d7:c8:cb:ac brd ff:ff:ff:ff:ff:ff inet 10.0.1.209/32 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::701b:d7ff:fec8:cbac/64 scope link valid_lft forever preferred_lft forever
The ip is 10.0.1.209/32
so I'm using 10.0.1.0/32
in allclosed.yaml
(I also tested other variants like 10.0.0.0/32
and 10.0.0.0/16
which did not work).
apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: deny-default spec: podSelector: {} policyTypes: - Ingress ingress: - from: - ipBlock: cidr: 10.0.1.0/32 # - Egress
Curl and ping are both not working for this ip address. Anyone have any idea why that could be?
Thanks.
Comments
-
Hi @ghilknov,
The cilium network plugin manages the 10.0.0.0/8 network by default. You can extract this from the cilium-config ConfigMap:
kubectl -n kube-system get cm cilium-config -oyaml | grep cluster-pool-ipv4-cidr:
The network policy can either whitelist the entire pod network cidr:
ingress: - from: - ipBlock: cidr: 10.0.0.0/8
or it can whitelist only the source IP of your
curl
command, which should be the cilium_host interface IP of your node where curl is being run, most likely the CP node if closely following the lab guide (runip a
on your CP node to locate the cilium_host interface IP, most likely a 10.0.0.x/32 IP):ingress: - from: - ipBlock: cidr: <cilium_host IP>/32
Regards,
-Chris0 -
Hi Chris
Thanks for your quick answer.
Unfortunately, using either
10.0.0.0/8
or10.0.0.0/32
both do not work. The curl still does not get through to10.0.1.88
. If I delete the NetworkPolicy then it works. So it is not a general problem.Not sure what to do.
I just tried to allow the only the clusterIP but that does not work either.
0 -
Hi @ghilknov,
I was able to reproduce this issue. I observed the same behavior, where the policy does not allow ingress traffic based on the defined rules. It allows all ingress traffic from cidr: 0.0.0.0/0, however, this is not the solution we are trying to implement. Removing the policy also enables all ingress traffic.
This was tried on custom and default installation methods of the cilium CNI plugin.
Will research further for a solution.Regards,
-Chris0 -
Hi Chris
Good to know it is not only me
Also thanks for looking into it.
Regards, ghilknov
0 -
Hi it seems I have the same issue with the 192.168.0.0/16 network, my output for the command provided is:
kube@cp ~/app2 $ kubectl -n kube-system get cm cilium-config -o yaml | grep cidr cluster-pool-ipv4-cidr: 192.168.0.0/16 vtep-cidr: ""
My allclosed.yaml:
apiVersion: networking.k8s.io/v1 kind: NetworkPolicy metadata: name: deny-default spec: podSelector: {} policyTypes: - Ingress ingress: - from: - ipBlock: cidr: 192.168.0.0/16
The output from ip a in my container:
~ $ ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 139: eth0@if140: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue qlen 1000 link/ether be:f9:02:c6:34:f9 brd ff:ff:ff:ff:ff:ff inet 192.168.1.251/32 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::bcf9:2ff:fec6:34f9/64 scope link valid_lft forever preferred_lft forever ~ $
This is the actual output of trying to connect with curl:
kube@cp ~/app2 $ curl 192.168.1.251:80 curl: (28) Failed to connect to 192.168.1.251 port 80 after 130104 ms: Couldn't connect to server
It won't even work with 0.0.0.0/0 in allclosed.yaml
0 -
Hi @sergiotarxz,
With the introduction of the Cilium CNI plugin this exercise no longer works as it used to with Calico, from earlier releases of the lab guide. Calico would enforce network policy rules on the Pod network ipBlock but Cilium does not.
A workaround would be to use the
podSelector
ornamespaceSelector
instead ofipBlock
to test the policy. This also implies a client pod be created to match the policy rule.Regards,
-Chris1
Categories
- All Categories
- 50 LFX Mentorship
- 103 LFX Mentorship: Linux Kernel
- 575 Linux Foundation IT Professional Programs
- 304 Cloud Engineer IT Professional Program
- 125 Advanced Cloud Engineer IT Professional Program
- 53 DevOps Engineer IT Professional Program
- 60 Cloud Native Developer IT Professional Program
- 5 Express Training Courses
- 5 Express Courses - Discussion Forum
- 2K Training Courses
- 19 LFC110 Class Forum
- 7 LFC131 Class Forum
- 27 LFD102 Class Forum
- 156 LFD103 Class Forum
- 20 LFD121 Class Forum
- 1 LFD137 Class Forum
- 61 LFD201 Class Forum
- 1 LFD210 Class Forum
- LFD210-CN Class Forum
- 1 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum
- LFD237 Class Forum
- 23 LFD254 Class Forum
- 611 LFD259 Class Forum
- 105 LFD272 Class Forum
- 1 LFD272-JP クラス フォーラム
- 1 LFD273 Class Forum
- 2 LFS145 Class Forum
- 24 LFS200 Class Forum
- 739 LFS201 Class Forum
- 1 LFS201-JP クラス フォーラム
- 10 LFS203 Class Forum
- 75 LFS207 Class Forum
- 300 LFS211 Class Forum
- 54 LFS216 Class Forum
- 47 LFS241 Class Forum
- 41 LFS242 Class Forum
- 37 LFS243 Class Forum
- 11 LFS244 Class Forum
- 34 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- LFS251 Class Forum
- 140 LFS253 Class Forum
- LFS254 Class Forum
- 1.1K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 93 LFS260 Class Forum
- 132 LFS261 Class Forum
- 33 LFS262 Class Forum
- 80 LFS263 Class Forum
- 15 LFS264 Class Forum
- 11 LFS266 Class Forum
- 18 LFS267 Class Forum
- 17 LFS268 Class Forum
- 23 LFS269 Class Forum
- 203 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- LFS274 Class Forum
- LFS281 Class Forum
- 233 LFW211 Class Forum
- 172 LFW212 Class Forum
- 7 SKF100 Class Forum
- SKF200 Class Forum
- 902 Hardware
- 219 Drivers
- 74 I/O Devices
- 44 Monitors
- 115 Multimedia
- 209 Networking
- 101 Printers & Scanners
- 85 Storage
- 763 Linux Distributions
- 88 Debian
- 66 Fedora
- 15 Linux Mint
- 13 Mageia
- 24 openSUSE
- 142 Red Hat Enterprise
- 33 Slackware
- 13 SUSE Enterprise
- 357 Ubuntu
- 479 Linux System Administration
- 41 Cloud Computing
- 70 Command Line/Scripting
- Github systems admin projects
- 95 Linux Security
- 78 Network Management
- 108 System Management
- 49 Web Management
- 68 Mobile Computing
- 23 Android
- 30 Development
- 1.2K New to Linux
- 1.1K Getting Started with Linux
- 537 Off Topic
- 131 Introductions
- 217 Small Talk
- 21 Study Material
- 826 Programming and Development
- 278 Kernel Development
- 514 Software Development
- 928 Software
- 260 Applications
- 184 Command Line
- 3 Compiling/Installing
- 76 Games
- 316 Installation
- 62 All In Program
- 62 All In Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)