Commit Graph

175 Commits (7450d1b4277998eea436e5daa552a8bf94adef06)

Author SHA1 Message Date
Jan Safranek 97b5299cd7 Add GetMode to mounter interface.
Kubelet must not call os.Lstat on raw volume paths when it runs in a container.
Mounter knows where the file really is.
2018-05-23 10:17:59 +02:00
Kubernetes Submit Queue e6b6e5c4b4
Merge pull request #63045 from msau42/fix-subpath-readonly
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

passthrough readOnly to subpath

**What this PR does / why we need it**:
If a volume is mounted as readonly, or subpath volumeMount is configured as readonly, then the subpath bind mount should be readonly.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #62752

**Special notes for your reviewer**:

**Release note**:

```release-note
Fixes issue where subpath readOnly mounts failed
```
2018-05-07 23:36:49 -07:00
Seth Jennings 1fb3b24b63 kubelet: fix warning message to not print pointer addrs 2018-04-30 16:38:43 -05:00
Michelle Au 6b1947c9ba passthrough readOnly to subpath 2018-04-26 11:18:36 -07:00
Jan Safranek 01a44d22cf Add private mount propagation to API.
And make it default
2018-04-12 13:57:54 +02:00
Kubernetes Submit Queue 865d3cf409
Merge pull request #62018 from andyzhangx/local-windows-path-fix
Automatic merge from submit-queue (batch tested with PRs 61147, 62236, 62018). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

fix local volume absolute path issue on Windows

**What this PR does / why we need it**:
remove IsAbs validation on local volume since it does not work on windows cluster, Windows absolute path `D:` is not allowed in local volume, the [validation](https://github.com/kubernetes/kubernetes/blob/master/pkg/apis/core/validation/validation.go#L1386) happens on both master and agent node, while for windows cluster, the master is Linux and agent is Windows, so `path.IsAbs()` func will not work all in both nodes. 
**Instead**, this PR use `MakeAbsolutePath` func to convert `local.path` value in kubelet, it supports both linux and windows styple. 

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #62016

**Special notes for your reviewer**:

**Release note**:

```
fix local volume absolute path issue on Windows
```
/sig storage
/sig windows
2018-04-10 05:31:20 -07:00
andyzhangx 520b8d49fc remove IsAbs validation on local volume
use MakeAbsolutePath to convert path in Windows

fix test error: allow relative path for local volume

fix comments

fix comments and add windows unit tests
2018-04-06 13:26:14 +00:00
Kubernetes Submit Queue 368233b9b8
Merge pull request #61613 from dims/ensure-etc-hosts-always-has-a-header
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Ensure /etc/hosts has a header always - Fix conformance test

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

We need to be able to tell if an /etc/hosts in a container has been touched by kubernetes or not (whether we use the host network or not).

We have 2 scenarios where we copy /etc/hosts
- with host network (we just copy the /etc/hosts from node)
- without host network (create a fresh /etc/hosts from pod info)

We are having trouble figuring out whether a /etc/hosts in a
pod/container has been "fixed-up" or not. And whether we used
host network or a fresh /etc/hosts in the various ways we start
up the tests which are:

- VM/box against a remote cluster
- As a container inside the k8s cluster
- DIND scenario in CI where test runs inside a managed container

Please see previous mis-guided attempt to fix this problem at
ba20e63446 In this commit we revert
the code from there as well.

So we should make sure:
- we always add a header if we touched the file
- we add slightly different headers so we can figure out if we used the
  host network or not.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #60938

**Special notes for your reviewer**:
Also see
- https://github.com/kubernetes/kubernetes/pull/61405
- https://github.com/kubernetes/kubernetes/pull/60939
- https://github.com/kubernetes/kubernetes/issues/60938

**Release note**:

```release-note
NONE
```
2018-04-04 18:01:55 -07:00
Davanum Srinivas fd72938dd5 Ensure /etc/hosts has a header always - Fix conformance test
We have 2 scenarios where we copy /etc/hosts
- with host network (we just copy the /etc/hosts from node)
- without host network (create a fresh /etc/hosts from pod info)

We are having trouble figuring out whether a /etc/hosts in a
pod/container has been "fixed-up" or not. And whether we used
host network or a fresh /etc/hosts in the various ways we start
up the tests which are:

- VM/box against a remote cluster
- As a container inside the k8s cluster
- DIND scenario in CI where test runs inside a managed container

Please see previous mis-guided attempt to fix this problem at
ba20e63446 In this commit we revert
the code from there as well.

So we should make sure:
- we always add a header if we touched the file
- we add slightly different headers so we can figure out if we used the
  host network or not.

Update the test case to inject /etc/hosts from node to another path
(/etc/hosts-original) as well and use that to compare.
2018-04-03 08:25:29 -04:00
Rohit Agarwal 87dda3375b Delete in-tree support for NVIDIA GPUs.
This removes the alpha Accelerators feature gate which was deprecated in 1.10.
The alternative feature DevicePlugins went beta in 1.10.
2018-04-02 20:17:01 -07:00
Kubernetes Submit Queue 7ce753aa73
Merge pull request #61894 from atlassian/misc-cleanups
Automatic merge from submit-queue (batch tested with PRs 61894, 61369). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Use range in loops; misc fixes

**What this PR does / why we need it**:
It is cleaner to use `range` in for loops to iterate over channel until it is closed.

**Release note**:
```release-note
NONE
```
/kind cleanup
2018-03-30 21:16:01 -07:00
Kubernetes Submit Queue d7f6154136
Merge pull request #57658 from andyxning/code_refactor
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Remove CgroupParent from RunContainerOptions

**What this PR does / why we need it**:
`CgroupParent` argument for a container is derived from sandbox config instead of container config in [dockershim](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/dockershim/helpers_linux.go#L125-L132). The logic to get `cgroupParent` for container is useless.
**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:
I may be wrong for only considering docker runtime. But according to cri runtime api, only [`LinuxPodSandboxConfig` has a field `CgroupParent`](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/apis/cri/v1alpha1/runtime/api.pb.go#L590). So i think it is only valid in sandbox config.

BTW, maybe we also need to delete [`CgroupParent` field in `RunContainerOptions` struct](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/container/runtime.go#L432).
**Release note**:

```release-note
None
```
2018-03-29 14:51:04 -07:00
Mikhail Mazurskiy c23a8a85cc
Use range in loops; misc fixes 2018-03-29 22:55:25 +11:00
Kubernetes Submit Queue 1ce0148047
Merge pull request #61504 from Random-Liu/fix-pod-scheduled-bug
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Fix `PodScheduled` bug for static pod.

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

This is an implementation of option 2 in https://github.com/kubernetes/kubernetes/issues/60589#issuecomment-375103979.
I've validated this in my own cluster, and there won't be continuously status update for static pod any more.

Signed-off-by: Lantao Liu <lantaol@google.com>



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

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
none
```
2018-03-24 12:34:28 -07:00
Lantao Liu 19a1bd8b99 Fix `PodScheduled` bug for static pod.
Signed-off-by: Lantao Liu <lantaol@google.com>
2018-03-22 01:04:08 +00:00
Michelle Au 91c557f504 Use inner volume name instead of outer volume name for subpath directory 2018-03-21 17:13:38 -07:00
Michelle Au f6d97b5d2b Add feature gate for subpath 2018-03-05 09:14:44 +01:00
Jan Safranek 5110db5087 Lock subPath volumes
Users must not be allowed to step outside the volume with subPath.
Therefore the final subPath directory must be "locked" somehow
and checked if it's inside volume.

On Windows, we lock the directories. On Linux, we bind-mount the final
subPath into /var/lib/kubelet/pods/<uid>/volume-subpaths/<container name>/<subPathName>,
it can't be changed to symlink user once it's bind-mounted.
2018-03-05 09:14:44 +01:00
wackxu f737ad62ed update import 2018-02-27 20:23:35 +08:00
Pengfei Ni 2d942dab68 Disable mount propagation for windows containers 2018-02-23 13:14:26 +08:00
Lantao Liu f69b4e9262 Fix pod scheduled.
Signed-off-by: Lantao Liu <lantaol@google.com>
2018-02-16 00:51:20 +00:00
JulienBalestra 2130f5bc55 kubelet: revert the status HostIP behavior 2018-02-14 23:38:09 +01:00
Kubernetes Submit Queue 7b678dc403
Merge pull request #57106 from JulienBalestra/kubelet-update-local-pods
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Kubelet status manager sync the status of local Pods

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

In the kubelet, when using `--pod-manifest-path` the kubelet creates static pods but doesn't update the status accordingly in the `PodList`.

This PR fixes the incorrect status of each Pod in the kubelet's `PodList`.

This is the setup used to reproduce the issue:

**manifest**:

```bash
cat ~/kube/staticpod.yaml
```

```yaml
apiVersion: v1
kind: Pod
metadata:
  labels:
    app: nginx
  name: nginx
  namespace: default
spec:
  hostNetwork: true
  containers:
  - name: nginx
    image: nginx:latest
    imagePullPolicy: IfNotPresent
    volumeMounts:
    - name: os-release
      mountPath: /usr/share/nginx/html/index.html
      readOnly: true

  volumes:
  - name: os-release
    hostPath:
      path: /etc/os-release
```


**kubelet**:

```bash
~/go/src/k8s.io/kubernetes/_output/bin/kubelet --pod-manifest-path ~/kube/ --cloud-provider="" --register-node --kubeconfig kubeconfig.yaml
```


You can observe this by querying the kubelet API `/pods`:

```bash
curl -s 127.0.0.1:10255/pods | jq .
```

```json
{
  "kind": "PodList",
  "apiVersion": "v1",
  "metadata": {},
  "items": [
    {
      "metadata": {
        "name": "nginx-nodeName",
        "namespace": "default",
        "selfLink": "/api/v1/namespaces/default/pods/nginx-nodeName",
        "uid": "0fdfa64c73d9de39a9e5c05ef7967e72",
        "creationTimestamp": null,
        "labels": {
          "app": "nginx"
        },
        "annotations": {
          "kubernetes.io/config.hash": "0fdfa64c73d9de39a9e5c05ef7967e72",
          "kubernetes.io/config.seen": "2017-12-12T18:42:46.088157195+01:00",
          "kubernetes.io/config.source": "file"
        }
      },
      "spec": {
        "volumes": [
          {
            "name": "os-release",
            "hostPath": {
              "path": "/etc/os-release",
              "type": ""
            }
          }
        ],
        "containers": [
          {
            "name": "nginx",
            "image": "nginx:latest",
            "resources": {},
            "volumeMounts": [
              {
                "name": "os-release",
                "readOnly": true,
                "mountPath": "/usr/share/nginx/html/index.html"
              }
            ],
            "terminationMessagePath": "/dev/termination-log",
            "terminationMessagePolicy": "File",
            "imagePullPolicy": "IfNotPresent"
          }
        ],
        "restartPolicy": "Always",
        "terminationGracePeriodSeconds": 30,
        "dnsPolicy": "ClusterFirst",
        "nodeName": "nodeName",
        "hostNetwork": true,
        "securityContext": {},
        "schedulerName": "default-scheduler",
        "tolerations": [
          {
            "operator": "Exists",
            "effect": "NoExecute"
          }
        ]
      },
      "status": {
        "phase": "Pending",
        "conditions": [
          {
            "type": "PodScheduled",
            "status": "True",
            "lastProbeTime": null,
            "lastTransitionTime": "2017-12-12T17:42:51Z"
          }
        ]
      }
    }
  ]
}
```

The status of the nginx `Pod` will remain in **Pending** state phase.

```bash
curl -I 127.0.0.1
HTTP/1.1 200 OK
```

It's reported as expected on the apiserver side:

```bash
kubectl get po --all-namespaces -w

NAMESPACE   NAME                    READY     STATUS    RESTARTS   AGE
default     nginx-nodeName   0/1       Pending   0          0s
default     nginx-nodeName   1/1       Running   0          2s
```


It doesn't work either with a standalone kubelet:

```bash
~/go/src/k8s.io/kubernetes/_output/bin/kubelet --pod-manifest-path ~/kube/ --cloud-provider="" --register-node false
```

**Special notes for your reviewer**:

**Release note**:
```release-note
NONE
```
2018-02-13 16:46:33 -08:00
Seth Jennings 9ab9ddeb19 kubelet: check for illegal phase transition 2018-02-12 15:28:10 -06:00
Kubernetes Submit Queue eff9f75f70
Merge pull request #59297 from joelsmith/master
Automatic merge from submit-queue (batch tested with PRs 59010, 59212, 59281, 59014, 59297). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Improve error returned when fetching container logs during pod termination

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

This change better handles fetching of logs when a container is in a crash loop backoff state. In cases where it is unable to fetch the logs, it gives a helpful error message back to a user who has requested logs of a container from a terminated pod. Rather than attempting to get logs for a container using an empty container ID, it returns a useful error message.

In cases where the container runtime gets an error, log the error but don't leak it back through the API to the user.


**Which issue(s) this PR fixes**:
Fixes #59296

**Release note**:

```release-note
NONE

```
2018-02-07 15:27:49 -08:00
Joel Smith 749980b726 Handle fetch of container logs of error containers during pod termination
* improve error returned when failing to fetch container logs
* handle cases where logs are requested for containers without the container ID
2018-02-07 12:23:56 -07:00
Lee Verberne e10042d22f Increment CRI version from v1alpha1 to v1alpha2
This also incorporates the version string into the package name so
that incompatibile versions will fail to connect.

Arbitrary choices:
- The proto3 package name is runtime.v1alpha2. The proto compiler
  normally translates this to a go package of "runtime_v1alpha2", but
  I renamed it to "v1alpha2" for consistency with existing packages.
- kubelet/apis/cri is used as "internalapi". I left it alone and put the
  public "runtimeapi" in kubelet/apis/cri/runtime.
2018-02-07 09:06:26 +01:00
Joel Smith 66b061dad2 Ensure that the runtime mounts RO volumes read-only
Add a feature gate ReadOnlyAPIDataVolumes to a provide a way to
disable the new behavior in 1.10, but for 1.11, the new
behavior will become non-optional.

Also, update E2E tests for downwardAPI and projected volumes
to mount the volumes somewhere other than /etc.
2018-02-01 10:02:29 -07:00
JulienBalestra 4c289014a0 Kubelet provides an updated and complete status of local-static Pods 2018-01-20 12:02:31 +01:00
Andy Xie aa7c5896cb code refactor 2017-12-28 13:35:28 +08:00
Cao Shufeng 0c9bb5a964 remove useless function hasHostPortConflicts
`hasHostPortConflicts` is not used anywhere. Delete it.
2017-12-18 16:14:26 +08:00
Davanum Srinivas 7568462ec3 Remove hacks added for mesos
Since Mesos is no longer in your main repository and since we have
things like dynamic kubelet configuration in progress, we should
drop these undocumented, untested, private hooks.

cmd/kubelet/app/server.go::CreateAPIServerClientConfig
CreateAPIServerClientConfig::getRuntime
pkg/kubelet/kubelet_pods.go::getPhase

Also remove stuff from Dependencies struct that were specific to
the Mesos integration (ContainerRuntimeOptions and Options)

Also remove stale references in test/e2e and and test owners file
2017-12-03 13:52:30 -05:00
Kubernetes Submit Queue 83e46f0a9e
Merge pull request #55902 from yguo0905/annotations
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Expose single annotation/label via downward API

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

https://github.com/kubernetes/community/blob/master/contributors/design-proposals/node/annotations-downward-api.md

Support exposing single annotation via both env and volume downward API using the following syntax:

```
metadata.annotations['key']
metadata.labels['key']
```

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

#31218

**Special notes for your reviewer**:

This PR takes over the work in https://github.com/kubernetes/kubernetes/pull/41648.

**Release note**:

```
A single value in metadata.annotations/metadata.labels can be passed into the containers via Downward API
```

/assign @thockin @vishh
2017-11-22 18:54:29 -08:00
Yang Guo 34a7b3dea8 Create a separate conversion function for the field labels used by downward API 2017-11-22 11:02:20 -08:00
mtanino 8903e8cd85 BlockVolumesSupport: CRI, VolumeManager and OperationExecutor changes
This patch contains following changes.
- container runtime changes for adding block devices
- volumemanager changes
- operationexecutor changes
2017-11-20 14:10:26 -05:00
Kubernetes Submit Queue 01c74145c7
Merge pull request #55665 from brendandburns/path
Automatic merge from submit-queue (batch tested with PRs 55908, 55829, 55293, 55653, 55665). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

If mountPath is missing, prefix with root dir.

If `mountPath` is not absolute, add the os-specific root directory as a prefix.

Ref: https://github.com/kubernetes/kubernetes/pull/51240
https://groups.google.com/forum/#!topic/kubernetes-sig-storage/k_0Wr2kYkpU

@thockin @saad-ali @andyzhangx 

Note to @thockin I left the validation in place, in seems like it is a net win, since it will give a decent
error message to most people, but the fall-back defaulting is there if it doesn't catch 'c:'

I'm happy to rip out the validation if that is preferable to everyone.  Let me know.

```release-note
If a non-absolute mountPath is passed to the kubelet, prefix it with the appropriate root path.
```
2017-11-17 17:11:16 -08:00
Brendan Burns 1b7f028ecb If mountPath is missing, prefix with root dir. 2017-11-16 05:30:53 +00:00
Zihong Zheng 0bc2e1f62f Move DNS related kubelet codes into its own package 2017-11-15 10:56:44 -08:00
Dr. Stefan Schimanski 012b085ac8 pkg/apis/core: mechanical import fixes in dependencies 2017-11-09 12:14:08 +01:00
Zihong Zheng c1a959c660 Clean up redundant DNS related kubelet codes
Signed-off-by: Zihong Zheng <zihongz@google.com>
2017-11-04 12:33:32 -07:00
Kubernetes Submit Queue 2084f7f4f3
Merge pull request #54488 from lichuqiang/plugin_base
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Add admission handler for device resources allocation

**What this PR does / why we need it**:
Add admission handler for device resources allocation to fail fast during pod creation

**Which issue this PR fixes** 
fixes #51592

**Special notes for your reviewer**:
@jiayingz Sorry, there is something wrong with my branch in #51895. And I think the existing comments in the PR might be too long for others to view. So I closed it and opened the new one, as we have basically reach an agreement on the implement :)
I have covered the functionality and unit test part here, and would set about the e2e part ASAP

/cc @jiayingz @vishh @RenaudWasTaken 

**Release note**:

```release-note
NONE
```
2017-11-02 17:24:06 -07:00
lichuqiang ebd445eb8c add admission handler for device resources allocation 2017-11-02 09:17:48 +08:00
Kevin 4c8539cece use core client with explicit version globally 2017-10-27 15:48:32 +08:00
David Ashpole 42a2a2fafe fix #54499. Removed containers are not waiting 2017-10-25 16:33:00 -07:00
Dr. Stefan Schimanski 7773a30f67 pkg/api/legacyscheme: fixup imports 2017-10-18 17:23:55 +02:00
Michael Taufen 8180536bed Mulligan: Remove deprecated and experimental fields from KubeletConfiguration
Revert "Merge pull request #51857 from kubernetes/revert-51307-kc-type-refactor"

This reverts commit 9d27d92420, reversing
changes made to 2e69d4e625.

See original: #51307

We punted this from 1.8 so it could go through an API review. The point
of this PR is that we are trying to stabilize the kubeletconfig API so
that we can move it out of alpha, and unblock features like Dynamic
Kubelet Config, Kubelet loading its initial config from a file instead
of flags, kubeadm and other install tools having a versioned API to rely
on, etc.

We shouldn't rev the version without both removing all the deprecated
junk from the KubeletConfiguration struct, and without (at least
temporarily) removing all of the fields that have "Experimental" in
their names. It wouldn't make sense to lock in to deprecated fields.
"Experimental" fields can be audited on a 1-by-1 basis after this PR,
and if found to be stable (or sufficiently alpha-gated), can be restored
to the KubeletConfiguration without the "Experimental" prefix.
2017-10-11 09:52:39 -07:00
Michelle Au 266120c189 Don't skip mounts if we can't find the volume 2017-10-09 14:00:23 -07:00
David Ashpole 4300c75d48 fix #52462. Do not GC exited containers in running pods 2017-09-28 09:37:21 -07:00
Kubernetes Submit Queue ae6b329368 Merge pull request #51644 from sjenning/init-container-status-fix
Automatic merge from submit-queue (batch tested with PRs 51239, 51644, 52076)

do not update init containers status if terminated

fixes #29972 #41580

This fixes an issue where, if a completed init container is removed while the pod or subsequent init containers are still running, the status for that init container will be reset to `Waiting` with `PodInitializing`.  

This can manifest in a number of ways.

If the init container is removed why the main pod containers are running, the status will be reset with no functional problem but the status will be reported incorrectly in `kubectl get pod` for example

If the init container is removed why a subsequent init container is running, the init container will be **re-executed** leading to all manner of badness.

@derekwaynecarr @bparees
2017-09-07 14:31:23 -07:00
David Ashpole 9ac30e2c28 wait for container cleanup before deletion 2017-09-04 17:38:09 -07:00