My k8s use Calico. In my Container, I can only ping the node,and other pod.When I try to access my gitserver,it failed.
sh-4.1$ ping stash
PING hoffman.domain.local (192.168.33.106) 56(84) bytes of data.
<-- not return ,until ctrl+c
Here are some information: in container
sh-4.1$ ip route
default via 169.254.1.1 dev eth0
169.254.1.1 dev eth0 scope link
in node
[clara: ] > ip route
default via 192.168.33.1 dev enp0s31f6 onlink
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1
192.168.33.0/24 dev enp0s31f6 proto kernel scope link src 192.168.33.224
blackhole 192.168.100.192/26 proto bird
192.168.100.212 dev calicc370d883ea scope link
192.168.126.0/26 via 192.168.33.223 dev tunl0 proto bird onlink
sudo kubectl exec -ti -n kube-system calicoctl -- /calicoctl get ippool -o wide
NAME CIDR NAT IPIPMODE VXLANMODE DISABLED SELECTOR
default-ipv4-ippool 192.168.0.0/16 true Always Never false all()
sudo kubectl exec -ti -n kube-system calicoctl -- /calicoctl get ippool -o yaml
apiVersion: projectcalico.org/v3
items:
- apiVersion: projectcalico.org/v3
kind: IPPool
metadata:
creationTimestamp: 2019-11-13T07:01:54Z
name: default-ipv4-ippool
resourceVersion: "2025"
uid: ebbcd7b8-761a-49e9-a7c6-4e2a4d1ceeac
spec:
blockSize: 26
cidr: 192.168.0.0/16
ipipMode: Always
natOutgoing: true
nodeSelector: all()
vxlanMode: Never
kind: IPPoolList
metadata:
resourceVersion: "2484183"
refer to https://docs.projectcalico.org/v3.10/networking/external-connectivity I try to execute
cat << EOF | calicoctl apply -f -
- apiVersion: projectcalico.org/v3
kind: IPPool
metadata:
name: ippool-ext-1
spec:
cidr: 192.168.0.0/16
natOutgoing: true
EOF
it returns
Partial success: applied the first 1 out of 1 'IPPool' resources:
Hit error: error with field IPPool.Spec.CIDR = '192.168.0.0/16' (IPPool(ippool-ext-1) CIDR overlaps with IPPool(default-ipv4-ippool) CIDR 192.168.0.0/16)
command terminated with exit code 1
According to the output of calicoctl get ippool -o yaml,it seams the config is right natOutgoing: true,needn't to modify. the ip of k8s container ↓
sh-4.1$ ifconfig
eth0 Link encap:Ethernet HWaddr 9E:AE:6D:96:A4:67
inet addr:192.168.100.212 Bcast:0.0.0.0 Mask:255.255.255.255
But in k8s pod container, I can't ping my gitserver. I also just run a docker container on the node use the same image, it works ok, git clone successfully.