forked from jayakody/ons-2019
-
Notifications
You must be signed in to change notification settings - Fork 0
/
K8S_Networking_Intro.txt
117 lines (88 loc) · 4.75 KB
/
K8S_Networking_Intro.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
===========================================================================
Kubernetes Networking: Basics: (How to inspect a pod namespace: 'nsenter')
==========================================================================
[root@Master1 ~]# kubectl get pods --namespace web -o wide
NAME READY STATUS AGE IP NODE
nginx-deployment-76bf4969df-5xzv7 1/1 Running 7m53s 172.31.155.17 Worker-1
[root@Worker-1 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED NAMES
93490bfce728 docker.io/nginx@sha256 "nginx -g 'daemon off" 47 seconds ago k8s_nginx_nginx-deployment
2ef012ea5db0 k8s.gcr.io/pause:3.1 "/pause" 57 seconds ago k8s_POD_nginx-deployment
[root@worker-1 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED NAMES
5b54f2a44c3b d8233ab899d4 "sleep 3600" 35 minutes ago k8s_busybox_busybox0-6hc7c
43e42c45522b k8s.gcr.io/pause:3.1 "/pause" 10 hours ago k8s_POD_busybox0-6hc7c
[root@worker-1 ~]# docker inspect -f '{{.State.Pid}}' 5b54f2a44c3b
21388
[root@worker-1 ~]# nsenter -t 21388 -n ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 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
17: eth0@if18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether fa:4d:26:0b:4a:c7 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 192.168.1.196/32 brd 192.168.1.196 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::f84d:26ff:fe0b:4ac7/64 scope link
valid_lft forever preferred_lft forever
[root@worker-1 ~]#
[root@worker-1 ~]# docker inspect -f '{{.State.Pid}}' 43e42c45522b
8112
[root@worker-1 ~]# nsenter -t 8112 -n ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 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
17: eth0@if18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether fa:4d:26:0b:4a:c7 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 192.168.1.196/32 brd 192.168.1.196 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::f84d:26ff:fe0b:4ac7/64 scope link
valid_lft forever preferred_lft forever
[root@worker-1 ~]#
[root@worker-1 ~]# nsenter -t 8112 -n ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 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
17: eth0@if18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether fa:4d:26:0b:4a:c7 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 192.168.1.196/32 brd 192.168.1.196 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::f84d:26ff:fe0b:4ac7/64 scope link
valid_lft forever preferred_lft forever
[root@worker-1 ~]#
======================================================
Service Exposture: Ingress
======================================================
$ kubectl get services -n demo -o wide
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR
hostnames ClusterIP 10.96.13.117 <none> 80/TCP 23h app=hostnames
$ kubectl describe service -n demo
Name: hostnames
Namespace: demo
Labels: <none>
Annotations: <none>
Selector: app=hostnames
Type: ClusterIP
IP: 10.96.13.117
Port: default 80/TCP
TargetPort: 9376/TCP
Endpoints: 192.168.1.63:9376,192.168.2.171:9376,192.168.3.155:9376
Session Affinity: None
Events: <none>
$ kubectl get pods --all-namespaces -o wide
kube-system nginx-ingress-controller-5b95b96fb7-r6ltd 1/1 Running 10.2.18.62 kube-1862
kube-system nginx-ingress-controller-5b95b96fb7-vj88x 1/1 Running 10.2.18.63 kube-1863
$ kubectl get ingress -n demo
NAME HOSTS ADDRESS PORTS AGE
ingress-hostnames hostnames.bigswitch.com 80 6d6h
$ kubectl get svc -n demo
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
hostnames ClusterIP 192.168.114.9 <none> 80/TCP 17d