Commit Graph

784 Commits (3215e8535ae8afcf850fbaac9df7ff9abe42f9e0)

Author SHA1 Message Date
Pengfei Ni dd14f6368a Fake docker portfoward for in-process docker CRI integration 2016-09-30 11:30:45 +08:00
Kubernetes Submit Queue 80123cb680 Merge pull request #31684 from nebril/refactor-docker-manager-test
Automatic merge from submit-queue

Pod creation moved outside of docker manager tests

**What this PR does / why we need it**:
It cleans up docker manager tests a little.
**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, #<issue_number>, ...)` format, will close that issue when PR gets merged)*: related to #31550

**Special notes for your reviewer**:
I don't claim that working on this issue is finished, I cleaned up the tests just a bit
**Release note**:
```release-note
NONE
```
2016-09-28 18:10:26 -07:00
Ke Zhang d03a73f3f2 Variables should be initialized near where it would be used 2016-09-26 14:31:31 +08:00
Kubernetes Submit Queue 1f7e79afbf Merge pull request #33066 from Random-Liu/set-docker-client-version
Automatic merge from submit-queue

Add docker client version.

Addressed https://github.com/kubernetes/kubernetes/issues/29478#issuecomment-248197665.

This partially reverted #31540, because currently we are really trying to connect to docker daemon when creating the client.

This PR updated docker client with real docker apiversion with `UpdateClientVersion`, so that the version related logic of engine-api can work properly, such as https://github.com/docker/engine-api/pull/174/files.

@yujuhong @feiskyer
2016-09-22 19:09:14 -07:00
Yu-Ju Hong c43a106b26 Move ConvertPodStatusToRunningPod back to the kubelet/container package
This avoids unnecessary imports between of kuberuntime from dockertools/rkt,
which implements the same kubecontainer.Runtime interface.
2016-09-22 12:13:44 -07:00
Yu-Ju Hong ee5b6a2550 Move image pull throttling logic to kubelet/images
This allows runtimes in different packages (dockertools, rkt, kuberuntime) to
share the same logic. Before this change, only dockertools support this
feature. Now all three packages support image pull throttling.
2016-09-21 18:31:04 -07:00
Random-Liu 08d74f33f6 Add client version. 2016-09-19 21:27:00 -07:00
Yifan Gu 27d4866c4e CRI: Add missing sandbox in runningPod.
Append containers that represent pod sandboxes when converting the
pod status to runningPod.
2016-09-19 11:52:00 -07:00
Clayton Coleman 4a48bf8375
Docker digest validation is too strict
Docker 1.10 does not guarantee that the pulled digest matches the digest
on disk when dealing with v1 schemas stored in a Docker registry. This
is the case for images like
centos/ruby-23-centos7@sha256:940584acbbfb0347272112d2eb95574625c0c60b4e2fdadb139de5859cf754bf
which as a result of #30366 cannot be pulled by Kube from a Docker 1.10
system.

Instead, use RepoDigests field as the primary match, validating the
digest, and then fall back to ID (also validating the match). Adds more
restrictive matching.
2016-09-14 14:13:21 -04:00
Kubernetes Submit Queue 5ffb523cf8 Merge pull request #32259 from ZTE-PaaS/zhangke-patch-040
Automatic merge from submit-queue

Improving StopContainer failed log level

Using at least Warning level will be more property
2016-09-14 02:53:55 -07:00
Yu-Ju Hong d3e1f2c75e 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-13 10:32:28 -07:00
Wojciech Tyczynski 3a0112f6ee Revert "dockershim: add unit tests for sandbox/container status" 2016-09-13 09:01:19 +02:00
Ke Zhang 347293617f Improving StopContainer failed log level 2016-09-13 14:23:15 +08:00
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
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
bprashanth a0c0dcd8bd Log pod ip at V(2) 2016-09-01 17:33:24 -07:00
Maciej Kwiek a2472c2a4e Pod creation moved outside of docker manager tests
Also one deprecated TODO deleted
2016-08-30 13:30:26 +03: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
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
Davanum Srinivas 87a370f67c 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-23 13:44:11 -04:00
Justin Santa Barbara 902ba4e249 Add network-plugin-mtu option for MTU selection
MTU selection is difficult, and if there is a transport such as IPSEC in
use may be impossible.  So we allow specification of the MTU with the
network-plugin-mtu flag, and we pass this down into the network
provider.

Currently implemented by kubenet.
2016-08-23 01:50:58 -04:00
bindata-mockuser e792d4117d Add return code support to kubectl-exec and -run 2016-08-20 15:58:47 +02:00
Kubernetes Submit Queue 7b3c08d7d3 Merge pull request #30789 from yujuhong/image_match
Automatic merge from submit-queue

Fix image inspection and matching

An image string could contain a hostname (e.g., "docker.io") or not. The same
applies to the RepoTags returned from an image inspection. To determine whether
the image docker pulled matches what the user ask for, we check if the either
string is the suffix of the other.

/cc @dims @dchen1107 @Random-Liu

This fixes #30710
2016-08-20 06:18:41 -07:00
Kubernetes Submit Queue 982640f73e Merge pull request #30668 from euank/dockertools-host-network
Automatic merge from submit-queue

dockertools: Don't use network plugin if net=host

I'm pretty sure this was just an oversight the first time around.

Before: `E0815 18:06:17.627468     976 docker_manager.go:350] NetworkPlugin kubenet failed on the status hook for pod 'sleep' - Unexpected command output Device "eth0" does not exist.`

After: No such logline is printed

The pod IP reported in `describe` is the same either way

cc @kubernetes/sig-node
2016-08-19 14:35:17 -07:00
Yu-Ju Hong a47e2ff91a Fix image inspection and matching
An image string could contain a hostname (e.g., "docker.io") or not. The same
applies to the RepoTags returned from an image inspection. To determine whether
the image docker pulled matches what the user ask for, we check if the either
string is the suffix of the other.
2016-08-17 14:48:11 -07:00
Kubernetes Submit Queue 622db63282 Merge pull request #30435 from hodovska/1328441-non-k8scontainers
Automatic merge from submit-queue

Add note: kubelet manages only k8s containers.

Kubelet wrote log when accesing container which was not created in k8s, what could confuse users. That's why we added note about it in documentation and lowered log level of the message to 5.

Here is example of the message: 
```
> Apr 19 11:50:32 openshift-114.lab.sjc.redhat.com atomic-openshift-node[9551]: 
I0419 11:50:32.194020    9600 docker.go:363] 
Docker Container: /tiny_babbage is not managed by kubelet.
```

bug 1328441
Bugzilla link https://bugzilla.redhat.com/show_bug.cgi?id=1328441
2016-08-17 00:54:33 -07:00
Kubernetes Submit Queue 5962874414 Merge pull request #30118 from timstclair/aa-hookup
Automatic merge from submit-queue

Implement AppArmor Kubelet support

Includes PR https://github.com/kubernetes/kubernetes/pull/29812

Implements the Kubelet logic for AppArmor based on the alpha API proposed [here](https://github.com/kubernetes/kubernetes/blob/master/docs/proposals/apparmor.md). Also adds an E2E test, and I ran manual tests.

Remaining work: PodSecurityPolicy support, profile loader daemon, documentation, (maybe) beta API.

/cc @jfrazelle @Amey-D @kubernetes/sig-node 

*Note on release-note-none: I am implementing AppArmor over multiple PRs. I will submit a single release note once the implementation is done to cover all of them.*
2016-08-15 22:32:58 -07:00
Euan Kemp c94e134ae4 dockertools: Don't use network plugin if net=host
This was already handled in most places. I think this is the only
remaining instance of it in the docker package.

This could lead to confusing results. E.g. if `networkPlugin` was cni,
it could lead to error logs about not getting network status for host
pods if eth0 didn't exist on the host.
2016-08-15 18:17:11 -07:00
Kubernetes Submit Queue 967dc4234a Merge pull request #30582 from dims/fix-issue-30580
Automatic merge from submit-queue

Fix image verification when hostname is present in image

Deal better with the situation where a image name contains
a hostname as well.

Fixes #30580
2016-08-15 14:26:05 -07:00
Tim St. Clair 3c7896719b
Implement AppArmor Kubelet support 2016-08-15 13:25:17 -07:00
Kubernetes Submit Queue 69419a145a Merge pull request #29802 from jfrazelle/fix-go-vet-errors
Automatic merge from submit-queue

fix go vet errors

<!--
Checklist for submitting a Pull Request

Please remove this comment block before submitting.

1. Please read our [contributor guidelines](https://github.com/kubernetes/kubernetes/blob/master/CONTRIBUTING.md).
2. See our [developer guide](https://github.com/kubernetes/kubernetes/blob/master/docs/devel/development.md).
3. If you want this PR to automatically close an issue when it is merged,
   add `fixes #<issue number>` or `fixes #<issue number>, fixes #<issue number>`
   to close multiple issues (see: https://github.com/blog/1506-closing-issues-via-pull-requests).
4. Follow the instructions for [labeling and writing a release note for this PR](https://github.com/kubernetes/kubernetes/blob/master/docs/devel/pull-requests.md#release-notes) in the block below.
-->

```release-note
```

This fixes the `go vet` errors brought about by go 1.7 testing re (#28742).

The are all pretty trivial and mostly related to literal composites.

also related to #16086
2016-08-15 13:10:08 -07:00
Dominika Hodovska 08945a9b6a Add note: kubelet manages only k8s containers.
bug 1328441
Bugzilla link https://bugzilla.redhat.com/show_bug.cgi?id=1328441
2016-08-15 12:36:29 +02:00
Davanum Srinivas cc9f41c6d3 Fix image verification when hostname is present in image
Deal better with the situation where a image name contains
a hostname as well.

Fixes #30580
2016-08-13 23:10:07 -04:00
Kubernetes Submit Queue 8a35d4c97c Merge pull request #30366 from dims/fix-issue-30355
Automatic merge from submit-queue

Validate SHA/Tag when checking docker images

Docker API does not validate the tag/sha, for example, all the following
calls work say for a alpine image with short SHA "4e38e38c8ce0"
echo -e "GET /images/alpine:4e38e38c8ce0/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock
echo -e "GET /images/alpine:4e38e38c/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock
echo -e "GET /images/alpine:4/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock

So we should check the response from the Docker API and look for the tags or SHA explicitly.

Fixes #30355
2016-08-12 23:42:40 -07:00
Kubernetes Submit Queue 929b238adc Merge pull request #30137 from nhlfr/cni-plugin-fail
Automatic merge from submit-queue

Set pod state as "unknown" when CNI plugin fails

Before this change, CNI plugin failure didn't change anything in the pod status, so pods having containers without requested network were "running".

Fixes #29148
2016-08-12 19:28:14 -07:00
Davanum Srinivas 875fd16e1e Validate SHA/Tag when checking docker images
Docker API does not validate the tag/sha, for example, all the following
calls work say for a alpine image with short SHA "4e38e38c8ce0"
echo -e "GET /images/alpine:4e38e38c8ce0/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock
echo -e "GET /images/alpine:4e38e38c/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock
echo -e "GET /images/alpine:4/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock

So we should check the response from the Docker API and look for the
tags or SHA explicitly.

Fixes #30355
2016-08-11 08:53:05 -04:00
Jess Frazelle 7e9d82129e
fix go vet errors
Signed-off-by: Jess Frazelle <jessfraz@google.com>

fix composites

Signed-off-by: Jess Frazelle <me@jessfraz.com>
2016-08-10 16:45:41 -07:00
Random-Liu ade092fe77 Add container ports label. 2016-08-08 18:40:18 -07:00
Michal Rostecki 31cdd70808 Set pod state as "unknown" when CNI plugin fails
Before this change, CNI plugin failure didn't change anything in
the pod status, so pods having containers without requested
network were "running".

Fixes #29148
2016-08-08 17:55:19 +02:00
Kubernetes Submit Queue e628f6fa1d Merge pull request #29442 from xiangpengzhao/fix-log-info
Automatic merge from submit-queue

Log more info of container for debugging.
2016-08-05 19:19:19 -07:00
Kubernetes Submit Queue c2614aee9a Merge pull request #29500 from lixiaobing10051267/masterFound
Automatic merge from submit-queue

Check all places to break the loop when object found

Check all places to break the loop when object found.
2016-08-03 20:05:15 -07:00
Kubernetes Submit Queue 804109d349 Merge pull request #29950 from andreykurilin/kubelet_typos
Automatic merge from submit-queue

Fix various typos in kubelet
2016-08-03 10:05:46 -07:00
Yu-Ju Hong 5960d87d21 dockershim: Implement sandbox methods 2016-08-02 15:24:52 -07:00
Andrey Kurilin 9f1c3a4c56 Fix various typos in kubelet 2016-08-03 01:14:44 +03:00
Michal Rostecki 59ca5986dd Print/log pointers of structs with %#v instead of %+v
There are many places in k8s where %+v is used to format a pointer
to struct, which isn't working as expected.

Fixes #26591
2016-08-01 22:27:56 +02:00
Yu-Ju Hong e80ad2be38 dockershim: add support for legacy methods 2016-07-28 18:24:29 -07:00