Commit Graph

127 Commits (8621326a7a542605cb958a61c37b27fa80f6d12c)

Author SHA1 Message Date
k8s-merge-robot 8ed6c8eeb8 Merge pull request #27914 from yifan-gu/fix_kubenet_hostport
Automatic merge from submit-queue

kubenet: Fix host port for rktnetes.

Because rkt pod runs after plugin.SetUpPod() is called, so
getRunningPods() does not return the newly created pod, which
causes the hostport iptable rules to be missing for this new pod.

cc @dcbw @freehan 

A follow up fix for https://github.com/kubernetes/kubernetes/pull/27878#issuecomment-227898936
2016-06-23 18:48:45 -07:00
Yifan Gu 9140ce07bc kubenet: Fix host port for rktnetes.
Because rkt pod runs after plugin.SetUpPod() is called, so
getRunningPods() does not return the newly created pod, which
causes the hostport iptable rules to be missing for this new pod.
2016-06-23 13:17:01 -07:00
Minhan Xia 48169ce736 avoid deleting cbr0 address due to subnet string mismatch 2016-06-22 16:45:04 -07:00
Dan Williams e47d020cb6 kubelet/kubenet: simplify getting nsenter path 2016-06-22 14:26:11 -05:00
Dan Williams a657d0587b kubelet/kubenet: Fix getRunningPods() to support rkt pods
Don't assume there's an infra container.
2016-06-22 13:45:13 -05:00
Dan Williams db078dbea4 kubelet/cni/kubenet: use common container IP address functions 2016-06-22 11:36:10 -05:00
Dan Williams 9865ac325c kubelet/cni: make cni plugin runtime agnostic
Use the generic runtime method to get the netns path.  Also
move reading the container IP address into cni (based off kubenet)
instead of having it in the Docker manager code.  Both old and new
methods use nsenter and /sbin/ip and should be functionally
equivalent.
2016-06-22 11:36:10 -05:00
Dan Williams a519e8a403 kubenet: clean up networking when setup errors occur
Relying on the runtime to later call cleanup is fragile, so make sure
that everything gets nicely cleaned up when setup errors occur.
2016-06-16 13:53:28 -05:00
Dan Williams 965492fdd0 kubelet/kubenet: split hostport handling into separate module 2016-06-16 13:44:32 -05:00
k8s-merge-robot 64da66bab4 Merge pull request #24983 from Arvinderpal/cni_args_ignoreunknown
Automatic merge from submit-queue

Sets IgnoreUnknown=1 in CNI_ARGS

```release-note
release-note-none
```

K8 uses CNI_ARGS to pass pod namespace, name and infra container
id to the CNI network plugin. CNI logic will throw an error
if these args are not known to it, unless the user specifies
IgnoreUnknown as part of CNI_ARGS. This PR sets IgnoreUnknown=1
to prevent the CNI logic from erroring and blocking pod setup.
https://github.com/appc/cni/pull/158
https://github.com/appc/cni/issues/126
2016-06-11 05:38:30 -07:00
k8s-merge-robot 805a0aae71 Merge pull request #27141 from freehan/hpfix
Automatic merge from submit-queue

only handled non host network pods for hostports in kubenet

attempt to fix: #27118
2016-06-09 22:08:10 -07:00
Minhan Xia 1276a91638 kubenet masqurade for outbound traffic 2016-06-09 18:43:34 -07:00
Minhan Xia 1b2386f1ce only handled non host network pods for hostports in kubenet 2016-06-09 11:32:16 -07:00
Minhan Xia e9f8c70eaf pass NetworkPluginDir to kubenet 2016-06-03 10:22:49 -07:00
k8s-merge-robot 98af443209 Merge pull request #26398 from euank/various-kubenet-fixes
Automatic merge from submit-queue

Various kubenet fixes (panics and bugs and cidrs, oh my)

This PR fixes the following issues:

1. Corrects an inverse error-check that prevented `shaper.Reset` from ever being called with a correct ip address
2. Fix an issue where `parseCIDR` would fail after a kubelet restart due to an IP being stored instead of a CIDR being stored in the cache.
3. Fix an issue where kubenet could panic in TearDownPod if it was called before SetUpPod (e.g. after a kubelet restart).. because of bug number 1, this didn't happen except in rare situations (see 2 for why such a rare situation might happen)

This adds a test, but more would definitely be useful.
The commits are also granular enough I could split this up more if desired.

I'm also not super-familiar with this code, so review and feedback would be welcome.

Testing done:
```
$ cat examples/egress/egress.yml
 apiVersion: v1
kind: Pod
metadata:
  labels:
    name: egress
  name: egress-output
  annotations: {"kubernetes.io/ingress-bandwidth": "300k"}
spec:
  restartPolicy: Never
  containers:
    - name: egress
      image: busybox
      command: ["sh", "-c", "sleep 60"]
$ cat kubelet.log
...
Running: tc filter add dev cbr0 protocol ip parent 1:0 prio 1 u32 match ip dst 10.0.0.5/32 flowid 1:1
# setup
...
Running: tc filter del dev cbr0 parent 1:proto ip prio 1 handle 800::800 u32
# teardown
```

I also did various other bits of manual testing and logging to hunt down the panic and other issues, but don't have anything to paste for that 

cc @dcbw @kubernetes/sig-network
2016-05-29 04:04:22 -07:00
k8s-merge-robot 350efaf13d Merge pull request #26096 from euank/set-pod-ip
Automatic merge from submit-queue

rkt: Pass through podIP

This is needed for the /etc/hosts mount and the downward API to work.
Furthermore, this is required for the reported `PodStatus` to be
correct.

The `Status` bit mostly worked prior to #25062, and this restores that
functionality in addition to the new functionality.

In retrospect, the regression in status is large enough the prior PR should have included at least some of this; my bad for not realizing the full implications there.

#25902 is needed for downwards api stuff, but either merge order is fine as neither will break badly by itself.

cc @yifan-gu @dcbw
2016-05-28 12:40:39 -07:00
Euan Kemp c83ad19ae9 kubenet: Fix ipv4 validity check
The length of an IP can be 4 or 16, and even if 16 it can be a valid
ipv4 address. This check is the more-correct way to handle this, and it
also provides more granular error messages.
2016-05-27 16:25:14 -07:00
Euan Kemp 93487867ac kubenet: Update empty ip check
The previous check was incorrect because the `IP.String` method returns
`<nil>` and other non-empty-strings on error conditions.
2016-05-27 10:47:13 -07:00
Euan Kemp c4b8959a75 kubenet: Reduce loglevel of spammy message
When no shaping is enabled, that warning would always be printed.
2016-05-27 10:47:12 -07:00
Euan Kemp 7e0b9bfa66 kubenet: Fix panic when teardown run before setup
Teardown can run before Setup when the kubelet is restarted... in that
case, the shaper was nil and thus calling the shaper resulted in a panic

This fixes that by ensuring the shaper is always set... +1 level of
indirection and all that.
2016-05-27 10:47:12 -07:00
Euan Kemp 2f5e738dc1 kubenet: Fix inconsistent cidr usage/parsing
Before this change, the podCIDRs map contained both cidrs and ips
depending on which code path entered a container into it.

Specifically, SetUpPod would enter a CIDR while GetPodNetworkStatus
would enter an IP.

This normalizes both of them to always enter just IP addresses.

This also removes the now-redundant cidr parsing that was used to get
the ip before
2016-05-27 10:47:12 -07:00
Euan Kemp 766eb6f0f7 kubenet: Fix bug where shaper.Reset wasn't called
The error check was inverse what it should have been, causing
shaper.Reset to only get called with invalid cidrs.
2016-05-27 10:20:43 -07:00
Alex Robinson 07d9dff83c Merge pull request #26208 from freehan/kubenetteardownfix
do not return error if TearDownPod is called twice
2016-05-27 09:59:03 -07:00
Minhan Xia 0834dc489a do not return error if TearDownPod is called twice 2016-05-26 11:57:22 -07:00
Euan Kemp be0ccab5c5 networkplugins: Add mock network plugin 2016-05-25 10:07:54 -07:00
Minhan Xia 6a3ad1d66d add hostport support for kubenet 2016-05-22 22:18:58 -07:00
Dan Williams 552b648caf kubenet: implement fake execer for testcases
When the IP isn't in the internal map, GetPodNetworkStatus() needs
to call the execer for the 'nsenter' program.  That  means the execer
needs to be !nil, which it wasn't before.
2016-05-18 11:28:05 -05:00
Dan Williams 3dbbe26316 kubenet: fix log message text 2016-05-18 11:28:05 -05:00
Dan Williams 5de7b561e3 kubenet: ensure loopback interface is up and consolidate CNI setup 2016-05-18 11:28:05 -05:00
Dan Williams 9b85d20c73 kubelet/runtime: add method to return pod network namespace path
Some runtimes (eg, Hypernetes) don't create network namespaces for pods,
so network plugins must correctly handle any error returned from the
runtime.
2016-05-18 09:26:01 -05:00
Dan Williams 55e6eb2ce3 Allow using netns path instead of container PID to change hairpin mode 2016-05-18 09:25:42 -05:00
Tim Hockin 66d0d87829 Make IsValidLabelValue return error strings 2016-05-17 21:36:10 -07:00
k8s-merge-robot 4ac32179bf Merge pull request #24798 from thockin/validation_pt8-1
Automatic merge from submit-queue

Make IsQualifiedName return error strings

Part of the larger validation PR, broken out for easier review and merge.

@lavalamp FYI, but I know you're swamped, too.
2016-05-14 22:14:17 -07:00
Yifan Gu 9d5bcf4251 rkt: Add tests for GarbageCollect(). 2016-05-13 15:13:52 -07:00
k8s-merge-robot fd3ef234de Merge pull request #23711 from dcbw/kubenet-promiscuous
Automatic merge from submit-queue

kubenet: set bridge promiscuous mode based on hairpinMode

Closes: https://github.com/kubernetes/kubernetes/issues/23657
Closes: https://github.com/kubernetes/kubernetes/issues/20475

<!-- Reviewable:start -->
---
This change is [<img src="http://reviewable.k8s.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](http://reviewable.k8s.io/reviews/kubernetes/kubernetes/23711)
<!-- Reviewable:end -->
2016-05-12 10:33:18 -07:00
Dan Williams b749902b42 kubenet: set bridge promiscuous mode based on hairpinMode
Closes: https://github.com/kubernetes/kubernetes/issues/23657
Closes: https://github.com/kubernetes/kubernetes/issues/20475
2016-05-12 10:02:33 -05:00
Ed Robinson afdbad078a
Corrects some misspellings in comments
This should help to make
https://goreportcard.com/report/k8s.io/kubernetes#misspell
look a little nicer.
2016-05-11 08:16:13 +01:00
k8s-merge-robot 9f00ed6075 Merge pull request #25377 from freehan/kubenetmutex
Automatic merge from submit-queue

modify kubenet mutex and add timer
2016-05-10 17:22:15 -07:00
k8s-merge-robot 3894c7972c Merge pull request #25185 from freehan/kubenetgetpodstatus
Automatic merge from submit-queue

kubenet try to retrieve ip inside pod net namespace

Kubenet currently stores the ips of pods inside a map. Kubelet gets pod ip from kubenet during syncpod. If Kubelet restarts, all pods on the node lost their ips in podStatus. This PR adds logic to retrieve pod IP from pod netns. 

cc: @yujuhong
2016-05-10 16:08:45 -07:00
Tim Hockin 72955770f3 Make IsQualifiedName return error strings 2016-05-10 11:23:23 -07:00
Minhan Xia 3573903a8d modify kubenet mutex and add timer 2016-05-09 14:54:15 -07:00
Minhan Xia 1252f5695b add unit tests for kubenet 2016-05-06 12:10:45 -07:00
k8s-merge-robot 32256d53aa Merge pull request #25136 from dcbw/kubenet-fixup-txqueuelen
Automatic merge from submit-queue

kubenet: fix up CNI bridge TX queue length if needed

CNI's bridge plugin mis-handles the TxQLen when creating the bridge,
leading to a zero-length TX queue.  This doesn't typically cause
problems (since virtual interfaces don't have hard queue limits)
but when adding traffic shaping, some qdiscs pull their packet
limits from the TX queue length, leading to a packet limit of 0
in some cases.  Until we can depend on a new enough version of
CNI, fix up the TX queue length internally.

Closes: https://github.com/kubernetes/kubernetes/issues/25092
2016-05-06 06:29:31 -07:00
Minhan Xia ae6f9ab970 kubenet try to retrieve ip inside pod net namespace 2016-05-05 17:57:32 -07:00
Minhan Xia 04b80f7fb8 rename Status interface to GetPodNetworkStatus 2016-05-04 13:46:31 -07:00
Minhan Xia 265fdd9344 add NetworkStatus in NetworkPlugin interface for kubelet to consume 2016-05-04 13:46:31 -07:00
Dan Williams aad6535a00 kubenet: fix up CNI bridge TX queue length if needed
CNI's bridge plugin mis-handles the TxQLen when creating the bridge,
leading to a zero-length TX queue.  This doesn't typically cause
problems (since virtual interfaces don't have hard queue limits)
but when adding traffic shaping, some qdiscs pull their packet
limits from the TX queue length, leading to a packet limit of 0
in some cases.  Until we can depend on a new enough version of
CNI, fix up the TX queue length internally.
2016-05-04 10:14:40 -05:00
Arvinderpal dede4d507c Sets IgnoreUnknown=1 in CNI_ARGS
K8 uses CNI_ARGS to pass pod namespace, name and infra container
id to the CNI network plugin. CNI logic will throw an error
if these args are not known to it, unless the user specifies
IgnoreUnknown as part of CNI_ARGS. This PR sets IgnoreUnknown=1
to prevent the CNI logic from erroring and blocking pod setup.
https://github.com/appc/cni/pull/158
https://github.com/appc/cni/issues/126
2016-04-29 07:40:15 -07:00
Minhan Xia c8470c49ac add mutex for kubenet 2016-04-26 13:58:10 -07:00
k8s-merge-robot a586177360 Merge pull request #23740 from dcbw/kubenet-shaper
Automatic merge from submit-queue

kubenet: hook pod bandwidth resources up to shaper

@bprashanth @thockin Last bit for shaping.
2016-04-25 22:15:42 -07:00