Commit Graph

3491 Commits (8736beede14a33fbf216ee5dfdeb183696a3292b)

Author SHA1 Message Date
Yu-Ju Hong 0075e9dbee dockershim: add unit tests for sandbox/container status
Also add a fake clock in the FakeDockerClient to allow testing container
CreatedAt, StartedAt, FinishedAt timestamps.
2016-09-12 12:55:49 -07:00
Yu-Ju Hong 84aab8d4a8 dockershim: utilize the Metadata in container names
This commit changes how the shim constructs and parses docker container names
by using the new "Metadata" types.
2016-09-12 10:58:21 -07:00
Yu-Ju Hong 7227641fc2 dockershim: move naming helpers to a separate file 2016-09-12 10:58:21 -07:00
Yu-Ju Hong a1833d1947 dockershim: bug fixes and more unit tests
Fixing the name triming and other small bugs. Added sandbox listing unit tests.
2016-09-12 10:58:21 -07:00
Kubernetes Submit Queue 3414a374de Merge pull request #32271 from lojies/kubeleterrmodify
Automatic merge from submit-queue

err is nil,remove it

err is nil here, remove it from code.
2016-09-11 19:02:30 -07:00
Kubernetes Submit Queue 622c2bbd5e Merge pull request #32116 from ZTE-PaaS/zhangke-patch-039
Automatic merge from submit-queue

Fixed TODO: move predicate check into a pod admitter

refractoring AdmitPod func to move predicate check into a pod admitter
2016-09-11 18:25:13 -07:00
Kubernetes Submit Queue c49d8360ec Merge pull request #31958 from ZTE-PaaS/zhangke-patch-034
Automatic merge from submit-queue

Redundant code process for container_mananger start

1. need not sum the total numEnsureStateFuncs
2. numEnsureStateFuncs should > 0, otherwise, calculate numEnsureStateFuncs would be not neccessary
2016-09-11 17:48:55 -07:00
Kubernetes Submit Queue a57f128a2a Merge pull request #32209 from errordeveloper/move-node-csr-helper
Automatic merge from submit-queue

Move CSR helper for nodes out of kubelet

**What this PR does / why we need it**:

Including `cmd/kubelet/app` in kubeadm causes flag leakage.

Namelly, the problem is with `pkg/credentialprovider/gcp`, which
leaks `--google-json-key` and changing the behaviour of `init()`
doesn't sound reasonable, given kubelet is the only one who uses
this packages and obviously the flag is part of the functionality.

The helper is already generic enough, it has already been exported
and works well for kubeadm, so moving it should be fine.

**Special notes for your reviewer**: cc @mikedanese @yifan-gu @gtank

**Release note**:

```release-note
NONE
```
2016-09-11 09:43:27 -07:00
Kubernetes Submit Queue beb4789265 Merge pull request #32091 from ZTE-PaaS/zhangke-patch-038
Automatic merge from submit-queue

wrong word of comment in cache.go
2016-09-11 06:59:51 -07:00
Kubernetes Submit Queue 4e509606e0 Merge pull request #32127 from pmorie/node-update-status
Automatic merge from submit-queue

Improve style of kubelet node status test

Report: man fails to idiomatically use `FakeClient`.
2016-09-11 00:34:55 -07:00
Kubernetes Submit Queue 6538912013 Merge pull request #31322 from feiskyer/killpod
Automatic merge from submit-queue

Kubelet: add KillPod for new runtime API

This PR adds implements of KillPod for new runtime API.

CC @yujuhong @Random-Liu @kubernetes/sig-node @kubernetes/sig-rktnetes
2016-09-10 03:10:32 -07:00
Kubernetes Submit Queue bd50f7c9cc Merge pull request #32202 from feiskyer/kuberuntime-runsandbox
Automatic merge from submit-queue

Kubelet: rename CreatePodSandbox to RunPodSandbox in CRI

As @yifan-gu pointed out in #31847, the name `CreatePodSandbox` doesn't reflect that the sandbox is running after the API succeeds. This PR renames it to `RunPodSandbox` to make this clear.

CC @yujuhong @yifan-gu @kubernetes/sig-node
2016-09-10 00:59:56 -07:00
Kubernetes Submit Queue 56242964ca Merge pull request #32148 from yifan-gu/hostnetwork_mount
Automatic merge from submit-queue

rkt: Refactor host file mounts for host network.

Do not mount /etc/hosts/ /etc/resolv.conf if they are already mounted.

Ref https://github.com/coreos/rkt/issues/2430#issuecomment-244343576
2016-09-09 21:50:39 -07:00
Minhan Xia 118ebd57aa fix a bug in hostport where it flushes KUBE-MARK-MASQ chain 2016-09-09 14:39:47 -07:00
Euan Kemp b1ee543463 Revert "Merge pull request #30513 from tmrts/kubelet-rkt-cri/use-image-service"
This reverts commit aff7dfcaab, reversing
changes made to 7a4d81ea43.
2016-09-09 13:35:22 -07:00
Bryan Boreham a2e583a86c Move default directory for exec plugin into exec plugin 2016-09-09 11:43:16 +01:00
Bryan Boreham 4e961e2bf5 Add options to set CNI config and binary directories
Also make clearer the function of --network-plugin-dir when using CNI
2016-09-09 11:43:16 +01:00
Kubernetes Submit Queue bed9f4d36c Merge pull request #31320 from feiskyer/kuberuntime-sandboxid
Automatic merge from submit-queue

Kubelet: implement GetPodContainerID for new runtime API

Add implements of `GetPodContainerID` interface for new runtime API.

CC @yujuhong @kubernetes/sig-node @kubernetes/sig-rktnetes
2016-09-08 21:41:03 -07:00
Ke Zhang 0ce6d8dafb TODO: move predicate check into a pod admitter 2016-09-09 09:58:42 +08:00
Kubernetes Submit Queue 99493570c3 Merge pull request #32268 from mdshuai/imagefs-inodes
Automatic merge from submit-queue

correct imagefs inodes value in kubelet summary stats

Fix https://github.com/kubernetes/kubernetes/issues/31501
Correct get imagefs inodes value from imageFsInfo.Inodes in kubelet summary stats api. 

@derekwaynecarr
2016-09-08 17:19:21 -07:00
Kubernetes Submit Queue 36bc5b11c3 Merge pull request #32232 from Random-Liu/avoid-syncpod-when-no-mirrorpod
Automatic merge from submit-queue

Avoid unnecessary status update when there is no corresponding mirror pod

Fixes https://github.com/kubernetes/kubernetes/issues/32191.

This PR changes status manager to skip update when there is no mirror pod for a static pod.
We need this because:
1) When static pod terminates and mirror pod is deleted, this will avoid extra `syncPod`.
2) During mirror pod creation and recreation, this will avoid unnecessary `syncPod`.

Mark P1 to match the original issue.

@wojtek-t @yujuhong 
/cc @kubernetes/sig-node
2016-09-08 11:53:31 -07:00
Pengfei Ni 277070e267 Kubelet: add KillPod for new runtime API 2016-09-08 20:56:50 +08:00
Pengfei Ni 0cc4686d85 Kubelet: implement GetPodContainerID for new runtime API 2016-09-08 20:53:52 +08:00
Kubernetes Submit Queue b2d02bd1ab Merge pull request #31395 from yujuhong/getpods
Automatic merge from submit-queue

Instruct PLEG to detect pod sandbox state changes

This PR adds a Sandboxes list in `kubecontainer.Pod`, so that PLEG can check
sandbox changes using `GetPods()` . The sandboxes are treated as regular
containers (type `kubecontainer.Container`) for now to avoid additional
changes in PLEG.

/cc @feiskyer @yifan-gu @euank
2016-09-08 05:41:16 -07:00
lojies e4697fc7e3 err is nil,remove it 2016-09-08 18:30:09 +08:00
Kubernetes Submit Queue aff7dfcaab Merge pull request #30513 from tmrts/kubelet-rkt-cri/use-image-service
Automatic merge from submit-queue

Kubelet rkt CRI use ImageService

Implements `container.ImageService` and refactors the `pkg/kubelet/rkt` to use it
2016-09-08 02:49:58 -07:00
mdshuai c3ddd882df correct imagefs inodes value in summary stats 2016-09-08 17:19:48 +08:00
Ilya Dmitrichenko d14df7afa7 Move CSR helper for nodes out of kubelet
Including `cmd/kubelet/app` in kubeadm causes flag leakage.

Namelly, the problem is with `pkg/credentialprovider/gcp`, which
leaks `--google-json-key` and changing the behaviour of `init()`
doesn't sound reasonable, given kubelet is the only one who uses
this packages and obviously the flag is part of the functionality.

The helper is already generic enough, it has already been exported
and works well for kubeadm, so moving it should be fine.
2016-09-08 07:27:38 +01:00
Random-Liu 1b1f2766ed Avoid StatusManager.syncPod when there is no corresponding mirror pod for static pod. 2016-09-07 17:03:15 -07:00
Kubernetes Submit Queue 0bd0d5571a Merge pull request #31540 from mtaufen/DockerOrDieRename
Automatic merge from submit-queue

Rename ConnectToDockerOrDie to CreateDockerClientOrDie

This function does not actually attempt to connect to the docker daemon, it just creates a client object that can be used to do so later. The old name was confusing, as it implied that a failure to touch the docker daemon could cause program termination (rather than just a failure to create the client).
2016-09-07 15:27:41 -07:00
Kubernetes Submit Queue 4c9ab4e856 Merge pull request #32213 from derekwaynecarr/log-an-event-when-eviction-cannot-kill-fast-enough
Automatic merge from submit-queue

Log an event when container runtime exceeds grace-period during eviction

While debugging flakes in eviction, I encountered scenarios where the container run-time did not evict a pod within the allowed grace period.  This could result in situations where a BE pod would not get killed fast enough and therefore a Bu pod was killed next (assuming there were no other BE pods)

/cc @mtaufen @vishh
2016-09-07 14:11:06 -07:00
derekwaynecarr ff017839c7 Log an event when container runtime exceeds grace-period during eviction 2016-09-07 13:28:08 -04:00
Kubernetes Submit Queue 4300055405 Merge pull request #30267 from feiskyer/kuberuntime-podstatus
Automatic merge from submit-queue

Kubelet: implement GetPodStatus for new runtime API

Implement `GetPodStatus()` for new runtime API.  Part of #28789 .

CC @yujuhong @Random-Liu @dchen1107
2016-09-07 10:14:26 -07:00
Pengfei Ni 58a9da3310 Kubelet: rename CreatePodSandbox to RunPodSandbox in CRI 2016-09-07 21:38:56 +08:00
Kubernetes Submit Queue 243959ce5a Merge pull request #32020 from euank/version-twiddling
Automatic merge from submit-queue

rkt: Update kube-up rkt version to v1.14.0

cc @kubernetes/sig-rktnetes 

This should have been included in #31286 (whoops).

This is a bugfix that I propose for v1.4 inclusion.
2016-09-07 01:18:57 -07:00
Kubernetes Submit Queue a16de4a787 Merge pull request #32072 from sttts/sttts-sysctl-remove-tcp_max_syn_backlog
Automatic merge from submit-queue

Remove net.ipv4.tcp_max_syn_backlog from sysctl whitelist

Remove `net.ipv4.tcp_max_syn_backlog` from sysctl whitelist. This is not namespaced in today's kernels, but must be set on node-level.

Having this on the whitelist, wouldn't harm because the kernel only offers namespaced `net.*` sysctls in the `/proc/sys` tree. But having a sysctl on the whitelist, which cannot be used, doesn't make sense either.

#### 1.4 justification:

- Risk: the whitelist is a published API. We shouldn't have sysctls on there which do not work.
- Rollback: nothing should depend on this behavior.
- Cost: the cost of this is relatively low, as no pod with this sysctl will launch.
2016-09-06 23:59:49 -07:00
Yifan Gu 25786aca98 rkt: Refactor host file mounts for host network.
Do not mount /etc/hosts/ /etc/resolv.conf if they are already mounted.
2016-09-06 15:07:52 -07:00
Euan Kemp a2a324bf8b cluster/rkt: Update default rkt version 2016-09-06 12:09:11 -07:00
Kubernetes Submit Queue 2a7d0df30d Merge pull request #30727 from asalkeld/iptables-caps
Automatic merge from submit-queue

Clean up IPTables caps i.e.: sed -i "s/Iptables/IPTables/g"

Fixes #30651
2016-09-06 09:01:27 -07:00
Paul Morie c0e3efb4db Improve style of kubelet node status test 2016-09-06 09:59:44 -04:00
Kubernetes Submit Queue c4e2ade371 Merge pull request #31761 from ZTE-PaaS/zhangke-patch-032
Automatic merge from submit-queue

change sourcesSeenLock to sync.RWMutex

seenSources can be accessed concurrently
2016-09-05 23:58:27 -07:00
Ke Zhang eca14886ac Redundant code process for container_mananger start 2016-09-06 12:56:54 +08:00
Ke Zhang fb5ec438c4 wrong word of comment in cache.go 2016-09-06 09:57:21 +08:00
Kubernetes Submit Queue 06b6fb5729 Merge pull request #31489 from ZTE-PaaS/zhangke-patch-030
Automatic merge from submit-queue

optimize if-else of setupNode of container_manager_linix

make the code more readable
2016-09-05 17:35:09 -07:00
Kubernetes Submit Queue b9481c18b4 Merge pull request #31227 from pigmej/typos_englishify_pkg_kubelet
Automatic merge from submit-queue

Fix various typos in pkg/kubelet

Just fixed some typos + "englishify" pkg/kubelet.
2016-09-05 16:11:35 -07:00
Dr. Stefan Schimanski 9a34eeed0f Remove net.ipv4.tcp_max_syn_backlog from sysctl whitelist
This is not namespaced in today's kernels.
2016-09-05 13:04:19 +02:00
Kubernetes Submit Queue 768e83657d Merge pull request #31922 from yujuhong/test_asserts
Automatic merge from submit-queue

kubelet_test.go: use assertions

Switch most of the tests in this file to using  the assert library
(`github.com/stretchr/testify/assert`) in the tests for better readability and
less code in general.
2016-09-03 09:51:36 -07:00
Kubernetes Submit Queue d22f04186c Merge pull request #32002 from mikedanese/spammy
Automatic merge from submit-queue

lower loglevel of spammy warning

this get's hit all the time on non containervm systems (e.g. anything with new udev where default ethernet device got renamed to enp0s01247uo83249 because that's more user friendly.)

I'm seeing my logs filed with this.
```
Sep 02 20:31:40 instance-1 kubelet-wrapper[7152]: W0902 20:31:40.234051    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:31:50 instance-1 kubelet-wrapper[7152]: W0902 20:31:50.269382    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:32:00 instance-1 kubelet-wrapper[7152]: W0902 20:32:00.304785    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:32:10 instance-1 kubelet-wrapper[7152]: W0902 20:32:10.329420    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:32:20 instance-1 kubelet-wrapper[7152]: W0902 20:32:20.363680    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:32:30 instance-1 kubelet-wrapper[7152]: W0902 20:32:30.402619    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:32:40 instance-1 kubelet-wrapper[7152]: W0902 20:32:40.429717    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:32:50 instance-1 kubelet-wrapper[7152]: W0902 20:32:50.459636    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:33:00 instance-1 kubelet-wrapper[7152]: W0902 20:33:00.484305    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:33:10 instance-1 kubelet-wrapper[7152]: W0902 20:33:10.528655    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:33:20 instance-1 kubelet-wrapper[7152]: W0902 20:33:20.564380    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:33:30 instance-1 kubelet-wrapper[7152]: W0902 20:33:30.589506    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:33:40 instance-1 kubelet-wrapper[7152]: W0902 20:33:40.618750    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:33:50 instance-1 kubelet-wrapper[7152]: W0902 20:33:50.643367    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:34:00 instance-1 kubelet-wrapper[7152]: W0902 20:34:00.678746    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:34:10 instance-1 kubelet-wrapper[7152]: W0902 20:34:10.712398    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:34:20 instance-1 kubelet-wrapper[7152]: W0902 20:34:20.738242    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:34:30 instance-1 kubelet-wrapper[7152]: W0902 20:34:30.764254    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:34:40 instance-1 kubelet-wrapper[7152]: W0902 20:34:40.789706    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:34:50 instance-1 kubelet-wrapper[7152]: W0902 20:34:50.822828    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:35:00 instance-1 kubelet-wrapper[7152]: W0902 20:35:00.857558    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:35:10 instance-1 kubelet-wrapper[7152]: W0902 20:35:10.893635    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:35:20 instance-1 kubelet-wrapper[7152]: W0902 20:35:20.920920    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:35:30 instance-1 kubelet-wrapper[7152]: W0902 20:35:30.955334    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:35:40 instance-1 kubelet-wrapper[7152]: W0902 20:35:40.988821    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:35:51 instance-1 kubelet-wrapper[7152]: W0902 20:35:51.027433    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:36:01 instance-1 kubelet-wrapper[7152]: W0902 20:36:01.065433    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:36:11 instance-1 kubelet-wrapper[7152]: W0902 20:36:11.104807    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:36:21 instance-1 kubelet-wrapper[7152]: W0902 20:36:21.137300    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:36:31 instance-1 kubelet-wrapper[7152]: W0902 20:36:31.170241    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:36:41 instance-1 kubelet-wrapper[7152]: W0902 20:36:41.205549    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:36:51 instance-1 kubelet-wrapper[7152]: W0902 20:36:51.246228    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:37:01 instance-1 kubelet-wrapper[7152]: W0902 20:37:01.283743    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:37:11 instance-1 kubelet-wrapper[7152]: W0902 20:37:11.322205    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
Sep 02 20:37:21 instance-1 kubelet-wrapper[7152]: W0902 20:37:21.358846    7155 summary.go:352] Missing default interface "eth0" for node:instance-1
```
2016-09-02 18:51:10 -07:00
Kubernetes Submit Queue 1e21eda604 Merge pull request #31197 from freehan/kubenethairpin
Automatic merge from submit-queue

Deprecate the old cbr0 and flannel networking modes

fixes: #19766
2016-09-02 18:51:05 -07:00
Kubernetes Submit Queue ffc12b349f Merge pull request #32000 from pmorie/node-update-status
Automatic merge from submit-queue

Update node status instead of node in kubelet

#31730 added code for the Kubelet to reconcile the existing and new nodes in order to annotate existing nodes with the annotation for controller-managed attach-detach.  However, it used `Update` instead of `UpdateStatus`, which changes the operations the node's token needs to be permitted to use.  Using `UpdateStatus` is functionally equivalent and maintains the same set of permissions nodes need to have today.

I'm adding this with the 1.4 milestone because it is a follow-on to a 1.4 PR and fixes a downstream bug (which won't surface to Kube).
2016-09-02 16:56:14 -07:00
Euan Kemp 807d7ba8ec rkt: Remove recommended rkt version
This has been unhelpful logspam forever basically. We always want newer
versions of rkt to be viable options, and often they have bugfixes as
well.
2016-09-02 15:52:37 -07:00
Minhan Xia fd4c947de9 correct typo in kubenet config 2016-09-02 14:33:34 -07:00
Kubernetes Submit Queue be290b5904 Merge pull request #31931 from freehan/kubenetcheck
Automatic merge from submit-queue

kubenet checks required cni plugins are present

related to #31215
2016-09-02 14:32:08 -07:00
Mike Danese 39d190e983 lower loglevel of spammy warning 2016-09-02 13:34:29 -07:00
Paul Morie 67387632dc Update node status instead of node in kubelet 2016-09-02 16:24:39 -04:00
Kubernetes Submit Queue 88c7e25f72 Merge pull request #31923 from bprashanth/logging
Automatic merge from submit-queue

Adding logging and fix test race

Fixes https://github.com/kubernetes/kubernetes/issues/31552, adds clarity for https://github.com/kubernetes/kubernetes/issues/29449

Janet for the job e2e and girish for services. P1 for flake.
2016-09-01 19:50:58 -07:00
bprashanth a0c0dcd8bd Log pod ip at V(2) 2016-09-01 17:33:24 -07:00
Yu-Ju Hong 013f7e3c46 kubelet_test.go: use assertions
Switch most of the tests in this file to using  the assert/require library
(in `github.com/stretchr/testify`) in the tests for better readability and
less code in general.
2016-09-01 17:21:48 -07:00
Minhan Xia 20ed879faa kubenet checks required cni plugins are present 2016-09-01 17:16:05 -07:00
Kubernetes Submit Queue 4e1ff53bb2 Merge pull request #31730 from pmorie/kubelet-attach-detach-update
Automatic merge from submit-queue

Make it possible to enable controller-managed attach-detach on existing nodes

Fixes #31673.  Now, if a node already exists with the given name on Kubelet startup, the Kubelet will reconcile the value of the controller-managed-attach-detach annotation so that existing nodes can have this feature turned on and off by changing the Kubelet configuration.

cc @kubernetes/sig-storage @kubernetes/rh-cluster-infra
2016-09-01 07:31:18 -07:00
Paul Morie 1805d30b67 Reconcile value of controller-managed attach-detach annotation on existing nodes in Kubelet startup 2016-08-31 17:04:54 -04:00
Tim St. Clair 3808243b9e
Append "AppArmor enabled" to the Node ready condition message 2016-08-31 09:27:47 -07:00
Ke Zhang 29edf62778 change sourcesSeenLock to sync.RWMutex 2016-08-31 09:10:14 +08:00
Jedrzej Nowak 9e51eea6a3 Fix various typos in pkg/kubelet 2016-08-30 22:57:47 +02:00
Kubernetes Submit Queue ec061b81d0 Merge pull request #31660 from mtaufen/un-ref-KubeletConfiguration-on-kubelet
Automatic merge from submit-queue

Make kubeletConfiguration field on Kubelet struct a value type
2016-08-30 10:46:48 -07:00
Yu-Ju Hong a49d28710a Extend PLEG to handle pod sandboxes
PLEG will treat them as if they are regular containers and detect changes the
same manner. Note that this makes an assumption that container IDs will not
collide with the podsandbox IDs.
2016-08-30 09:54:24 -07:00
Kubernetes Submit Queue 17787eb6f2 Merge pull request #31557 from timstclair/aa-event
Automatic merge from submit-queue

Include security options in the container created event

New container creation events look like:
```
Created container with docker id /k8s_bar2.a4; Security:[seccomp=sub/subtest(md5:07c9bcb4db631f7ca191d6e0bca49f76)]

Created container with docker id /k8s_bar2.a4; Security:[seccomp=unconfined apparmor=foo-profile]
```

The goal is to provide enough information to confirm that the requseted security constraints were honored.

For https://github.com/kubernetes/kubernetes/issues/31284

/cc @dchen1107 @thockin @jfrazelle @pweil- @pmorie

---

Justification for v1.4:

- Risk: low. This appends some additional information to a human readable message. A bug here would probably not break any functionality
- Roll-back: I don't anticipate any more changes to this area of the code. No functionality depends on this change.
- Cost of not including: Users don't get any (positive) confirmation that the AppArmor or Seccomp profile they requested were actually enabled.
2016-08-30 01:35:33 -07:00
Kubernetes Submit Queue 64f25e1f46 Merge pull request #31531 from pmorie/kubelet-attach-detach-log
Automatic merge from submit-queue

Add log message in Kubelet when controller attach/detach is enabled

Adds a message to the Kubelet log indicating whether controller attach/detach is enabled for a node.

cc @kubernetes/sig-storage
2016-08-29 23:22:11 -07:00
Michael Taufen ceb00add97 Make kubeletConfiguration field on Kubelet struct a value type 2016-08-29 18:03:34 -07:00
Angus Salkeld f785f3d3ef Clean up IPTables caps i.e.: sed -i "s/Iptables/IPTables/g" 2016-08-29 10:34:42 +10:00
Kubernetes Submit Queue cdbc3b56eb Merge pull request #31523 from derekwaynecarr/imagefs-observations
Automatic merge from submit-queue

Set imagefs rank and reclaim functions when nodefs+imagefs share comm…

Fixes #31192 

I decided that the behavior should match the current output of the kubelet summary API.  With no dedicated imagefs, the ranking and reclaim functions will match the nodefs ranking and reclaim functions.

/cc @ronnielai @vishh
2016-08-27 02:58:42 -07:00
Kubernetes Submit Queue 087d431409 Merge pull request #31401 from yujuhong/resource_name
Automatic merge from submit-queue

Print out resource name when evicting pods

This fixes #31397


/cc @derekwaynecarr
2016-08-26 18:55:21 -07:00
Tim St. Clair 785c83cc2d
Include security options in the container created event 2016-08-26 15:32:48 -07:00
Michael Taufen b9ad337bbd Rename ConnectToDockerOrDie to CreateDockerClientOrDie
This function does not actually attempt to connect to the docker daemon,
it just creates a client object that can be used to do so later. The old
name was confusing, as it implied that a failure to touch the docker daemon
could cause program termination (rather than just a failure to create the
client).
2016-08-26 11:21:07 -07:00
Paul Morie 3b23b9ba9f Add log message in Kubelet when controller attach/detach is enabled 2016-08-26 12:28:37 -04:00
derekwaynecarr 6a7eb7b420 Set imagefs rank and reclaim functions when nodefs+imagefs share common device 2016-08-26 11:08:43 -04:00
Kubernetes Submit Queue eeac23282d Merge pull request #31446 from liggitt/log-streaming
Automatic merge from submit-queue

Fix hang/websocket timeout when streaming container log with no content

When streaming and following a container log, no response headers are sent from the kubelet `containerLogs` endpoint until the first byte of content is written to the log. This propagates back to the API server, which also will not send response headers until it gets response headers from the kubelet. That includes upgrade headers, which means a websocket connection upgrade is not performed and can time out.

To recreate, create a busybox pod that runs `/bin/sh -c 'sleep 30 && echo foo && sleep 10'`

As soon as the pod starts, query the kubelet API:
```
curl -N -k -v 'https://<node>:10250/containerLogs/<ns>/<pod>/<container>?follow=true&limitBytes=100'
```

or the master API:
```
curl -N -k -v 'http://<master>:8080/api/v1/<ns>/pods/<pod>/log?follow=true&limitBytes=100'
```

In both cases, notice that the response headers are not sent until the first byte of log content is available.

This PR:
* does a 0-byte write prior to handing off to the container runtime stream copy. That commits the response header, even if the subsequent copy blocks waiting for the first byte of content from the log.
* fixes a bug with the "ping" frame sent to websocket streams, which was not respecting the requested protocol (it was sending a binary frame to a websocket that requested a base64 text protocol)
* fixes a bug in the limitwriter, which was not propagating 0-length writes, even before the writer's limit was reached
2016-08-26 06:09:43 -07:00
Kubernetes Submit Queue 9deb18b989 Merge pull request #31378 from yifan-gu/rkt_fetch_no_store
Automatic merge from submit-queue

rkt: Force `rkt fetch` to fetch from remote to conform the image pull policy.

Fix https://github.com/kubernetes/kubernetes/issues/27646

Use `--no-store` option for `rkt fetch` to force it to fetch from remote.
However, `--no-store` will fetch the remote image regardless of whether the content of the image has changed or not. 
This causes performance downgrade when the image tag is ':latest' and the image pull policy is 'always'. 
The issue is tracked in https://github.com/coreos/rkt/issues/2937.
2016-08-26 01:53:20 -07:00
Kubernetes Submit Queue feb4d2004a Merge pull request #31064 from soundcloud/grobie/filter-internal-labels
Automatic merge from submit-queue

Filter internal Kubernetes labels from Prometheus metrics

**What this PR does / why we need it**:

Kubernetes uses Docker labels as storage for some internal labels. The
majority of these labels are not meaningful metric labels and a few of
them are even harmful as they're not static and cause wrong aggregation
results.

This change provides a custom labels func to only attach meaningful
labels to cAdvisor exported metrics.

**Which issue this PR fixes**

google/cadvisor#1312

**Special notes for your reviewer**:

Depends on google/cadvisor#1429. Once that is merged, I'll update the vendor update commit.

**Release note**:

```release-note
Remove environment variables and internal Kubernetes Docker labels from cAdvisor Prometheus metric labels.

Old behavior:

- environment variables explicitly whitelisted via --docker-env-metadata-whitelist were exported as `container_env_*=*`. Default is zero so by default non were exported
- all docker labels were exported as `container_label_*=*`

New behavior:

- Only `container_name`, `pod_name`, `namespace`, `id`, `image`, and `name` labels are exposed
- no environment variables will be exposed ever via /metrics, even if whitelisted
```

---

Given that we have full control over the exported label set, I shortened the pod_name, pod_namespace and container_name label names. Below an example of the change (reformatted for readability).

```
# BEFORE
container_cpu_cfs_periods_total{
  container_label_io_kubernetes_container_hash="5af8c3b4",
  container_label_io_kubernetes_container_name="sync",
  container_label_io_kubernetes_container_restartCount="1",
  container_label_io_kubernetes_container_terminationMessagePath="/dev/termination-log",
  container_label_io_kubernetes_pod_name="popularsearches-web-3165456836-2bfey",
  container_label_io_kubernetes_pod_namespace="popularsearches",
  container_label_io_kubernetes_pod_terminationGracePeriod="30",
  container_label_io_kubernetes_pod_uid="6a291e48-47c4-11e6-84a4-c81f66bdf8bd",
  id="/docker/68e1f15353921f4d6d4d998fa7293306c4ac828d04d1284e410ddaa75cf8cf25",
  image="redacted.com/popularsearches:42-16-ba6bd88",
  name="k8s_sync.5af8c3b4_popularsearches-web-3165456836-2bfey_popularsearches_6a291e48-47c4-11e6-84a4-c81f66bdf8bd_c02d3775"
} 72819

# AFTER
container_cpu_cfs_periods_total{
  container_name="sync",
  pod_name="popularsearches-web-3165456836-2bfey",
  namespace="popularsearches",
  id="/docker/68e1f15353921f4d6d4d998fa7293306c4ac828d04d1284e410ddaa75cf8cf25",
  image="redacted.com/popularsearches:42-16-ba6bd88",
  name="k8s_sync.5af8c3b4_popularsearches-web-3165456836-2bfey_popularsearches_6a291e48-47c4-11e6-84a4-c81f66bdf8bd_c02d3775"
} 72819
```

Feedback requested on:
* Label names. Other suggestions? Should we keep these very long ones?
* Do we need to export io.kubernetes.pod.uid? It makes working with the metrics a bit more complicated and the pod name is already unique at any time (but not over time). The UID is aslo part of `name`.

As discussed with @timstclair, this should be added to v1.4 as the current labels are harmful.

PTAL @jimmidyson @fabxc @vishh
2016-08-25 21:11:10 -07:00
Ke Zhang 86163979f4 optimize if-else of setupNode of container_manager_linix 2016-08-26 10:30:39 +08:00
Kubernetes Submit Queue d3ecad111e Merge pull request #28717 from freehan/ebtable
Automatic merge from submit-queue

Filter duplicate network packets in promiscuous bridge mode (with ebtables)

also fixes: #30783
2016-08-25 19:12:09 -07:00
Yifan Gu de402ac2c5 rkt: Force `rkt fetch` to fetch from remote to conform the fetch policy. 2016-08-25 14:44:44 -07:00
Yu-Ju Hong a072bda6fd Print out resource name when evicting pods 2016-08-25 14:11:21 -07:00
Jordan Liggitt 0deddb1a62
Do initial 0-byte write to stdout when streaming container logs 2016-08-25 14:29:22 -04:00
Michael Taufen f277205f4f Kubelet Refactoring
This refactor removes the legacy KubeletConfig object and adds a new
KubeletDeps object, which contains injected runtime objects and
separates them from static config. It also reduces NewMainKubelet to two
arguments: a KubeletConfiguration and a KubeletDeps.

Some mesos and kubemark code was affected by this change, and has been
modified accordingly.

And a few final notes:

KubeletDeps:
KubeletDeps will be a temporary bin for things we might consider
"injected dependencies", until we have a better dependency injection
story for the Kubelet. We will have to discuss this eventually.

RunOnce:
We will likely not pull new KubeletConfiguration from the API server
when in runonce mode, so it doesn't make sense to make this something
that can be configured centrally. We will leave it as a flag-only option
for now. Additionally, it is increasingly looking like nobody actually uses the
Kubelet's runonce mode anymore, so it may be a candidate for deprecation
and removal.
2016-08-25 10:57:31 -07:00
Kubernetes Submit Queue 6901a00078 Merge pull request #31286 from yifan-gu/rkt_privileged
Automatic merge from submit-queue

rkt: Improve support for privileged pod (pod whose all containers are privileged) 

Fix https://github.com/kubernetes/kubernetes/issues/31100

This takes advantage of https://github.com/coreos/rkt/pull/2983 . By appending the new `--all-run` insecure-options to `rkt run-prepared` command when all the containers are privileged. The pod now gets more privileged power.
2016-08-25 06:58:43 -07:00
Kubernetes Submit Queue 4ddfc4849a Merge pull request #27180 from sttts/sysctl-implementation
Automatic merge from submit-queue

Add sysctl support

Implementation of proposal https://github.com/kubernetes/kubernetes/pull/26057, feature  https://github.com/kubernetes/features/issues/34

TODO:
- [x] change types.go
- [x] implement docker and rkt support
- [x] add e2e tests
- [x] decide whether we want apiserver validation
- ~~[ ] add documentation~~: api docs exist. Existing PodSecurityContext docs is very light and links back to the api docs anyway: 6684555ed9/docs/user-guide/security-context.md
- [x] change PodSecurityPolicy in types.go
- [x] write admission controller support for PodSecurityPolicy
- [x] write e2e test for PodSecurityPolicy
- [x] make sure we are compatible in the sense of https://github.com/kubernetes/kubernetes/blob/master/docs/devel/api_changes.md
- [x] test e2e with rkt: it only works with kubenet, not with no-op network plugin. The later has no sysctl support.
- ~~[ ] add RunC implementation~~ (~~if that is already in kube,~~ it isn't)
- [x] update whitelist
- [x] switch PSC fields to annotations
- [x] switch PSP fields to annotations
- [x] decide about `--experimental-whitelist-sysctl` flag to be additive or absolute
- [x] decide whether to add a sysctl node whitelist annotation

### Release notes:

```release-note
The pod annotation `security.alpha.kubernetes.io/sysctls` now allows customization of namespaced and well isolated kernel parameters (sysctls), starting with `kernel.shm_rmid_forced`, `net.ipv4.ip_local_port_range`, `net.ipv4.tcp_max_syn_backlog` and `net.ipv4.tcp_syncookies` for Kubernetes 1.4.

The pod annotation  `security.alpha.kubernetes.io/unsafeSysctls` allows customization of namespaced sysctls where isolation is unclear. Unsafe sysctls must be enabled at-your-own-risk on the kubelet with the `--experimental-allowed-unsafe-sysctls` flag. Future versions will improve on resource isolation and more sysctls will be considered safe.
```
2016-08-25 06:21:24 -07:00
Dr. Stefan Schimanski e356e52247 Add sysctl whitelist on the node 2016-08-25 13:22:01 +02:00
Dominika Hodovska bea189e9c9 Add sysctl api, validation & Docker support 2016-08-25 13:22:01 +02:00
Kubernetes Submit Queue e4178c82f3 Merge pull request #31275 from dims/fix-issue-31219
Automatic merge from submit-queue

Increase request timeout based on termination grace period

When terminationGracePeriodSeconds is set to > 2 minutes (which is
the default request timeout), ContainerStop() times out at 2 minutes.
We should check the timeout being passed in and bump up the
request timeout if needed.

Fixes #31219
2016-08-25 03:20:32 -07:00
Kubernetes Submit Queue bb9523bd0f Merge pull request #31157 from pmorie/kubelet-move
Automatic merge from submit-queue

Kubelet code move: volume / util

Addresses some odds and ends that I apparently missed earlier.  Preparation for kubelet code-move ENDGAME.

cc @kubernetes/sig-node
2016-08-25 00:20:39 -07:00
Kubernetes Submit Queue de65e4c1e1 Merge pull request #31372 from freehan/mtufix
Automatic merge from submit-queue

fix #30376 that broken cross-build

ref: #30376
2016-08-24 19:25:45 -07:00
Pengfei Ni 1c62d2c368 Kubelet: implement PodStatus for new runtime API 2016-08-25 09:36:00 +08:00
Yu-Ju Hong 0fd2385e0b Add "Sandboxes" to the kubecontainer.Pod
This field will only be used by the kuberuntime package and should be ignored
by other type of runtimes.
2016-08-24 14:45:43 -07:00
Kubernetes Submit Queue f488d118ad Merge pull request #31091 from feiskyer/kuberuntime-getnetns
Automatic merge from submit-queue

Kubelet: implement GetNetNS for new runtime api

Kubelet: implement GetNetNS for new runtime api. 

CC @yujuhong @thockin @kubernetes/sig-node @kubernetes/sig-rktnetes
2016-08-24 13:40:40 -07:00
Minhan Xia c1d3c89cfa fix #30376 that broken cross-build 2016-08-24 13:18:18 -07:00
Minhan Xia 42a554ec0d add ebtables rules to filter duplicate packets 2016-08-24 10:19:29 -07:00
Minhan Xia 950e689637 kubenet set cbr0 mac address 2016-08-24 10:18:48 -07:00
Tamer Tas e2fa97c411 pkg/kubelet/rkt: use rktshim.ImageService 2016-08-24 18:13:09 +03:00
Tamer Tas 5f141299ae pkg/kubelet/rktshim: disable ImageStore tests 2016-08-24 17:59:59 +03:00