Commit Graph

2318 Commits (8cbbbac27d427668a655fd704c6db17904520e42)

Author SHA1 Message Date
Kubernetes Submit Queue 93ddb7be5f Merge pull request #52237 from smarterclayton/watch_metric
Automatic merge from submit-queue (batch tested with PRs 51824, 50476, 52451, 52009, 52237)

Improve apiserver metrics reporting

Normalize "WATCHLIST" to "WATCH", add "scope" to the other metrics (listing 50k pods is != listing pods in a namespace), and add a new scope "resource" to cover individual resource calls.

This roughly aligns metrics with our ACL model (technically resource scope is GET, but POST to a subresource and POST to a namespace are not the same thing).

```release-note
WATCHLIST calls are now reported as WATCH verbs in prometheus for the apiserver_request_* series.  A new "scope" label is added to all apiserver_request_* values that is either 'cluster', 'resource', or 'namespace' depending on which level the query is performed at.
```
2017-09-15 01:08:11 -07:00
Kubernetes Submit Queue 7181dd4946 Merge pull request #50476 from caesarxuchao/plumb-proxy
Automatic merge from submit-queue (batch tested with PRs 51824, 50476, 52451, 52009, 52237)

Plumbing the proxy dialer to the webhook admission plugin

* Fixing https://github.com/kubernetes/kubernetes/issues/49987. Plumb the `Dial` function to the `transport.Config`
* Fixing https://github.com/kubernetes/kubernetes/issues/52366. Let the webhook admission plugin sets the `TLSConfg.ServerName`.

I tested it in my gke setup. I don't have time to implement an e2e test before 1.8 release. I think it's ok to add the test later, because *i)* the change only affects the alpha webhook admission feature, and *ii)* the webhook feature is unusable without the fix. That said, it's up to my reviewer to decide.

Filed https://github.com/kubernetes/kubernetes/issues/52368 for the missing e2e test.

( The second commit is https://github.com/kubernetes/kubernetes/pull/52372, which is just a cleanup of client configuration in e2e tests. It removed a function that marshalled the client config to json and then unmarshalled it. It is a prerequisite of this PR, because this PR added the `Dial` function to the config which is not json marshallable.)

```release-note
Fixed the webhook admission plugin so that it works even if the apiserver and the nodes are in two networks (e.g., in GKE).
Fixed the webhook admission plugin so that webhook author could use the DNS name of the service as the CommonName when generating the server cert for the webhook.

Action required:
Anyone who generated server cert for admission webhooks need to regenerate the cert. Previously, when generating server cert for the admission webhook, the CN value doesn't matter. Now you must set it to the DNS name of the webhook service, i.e., `<service.Name>.<service.Namespace>.svc`.
```
2017-09-15 01:08:01 -07:00
Kubernetes Submit Queue e190f39112 Merge pull request #50012 from deads2k/cli-17-discovery
Automatic merge from submit-queue

use specified discovery information if possible

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

This uses the available discovery information if available, but it seems we never updated "normal" resources to show the singular name, so its often not available.  I've left this code compatible.

@enisoc @ash2k 
@kubernetes/sig-api-machinery-misc 

```release-note
custom resources that use unconventional pluralization now work properly with kubectl and garbage collection
```
2017-09-14 22:14:21 -07:00
Chao Xu 856a1db57a fix the webhook unit test; the server cert needs to have a valid CN;
fix a fuzzer;
2017-09-14 15:36:25 -07:00
Chao Xu 186a0684d5 plumb the proxyTransport to the webhook admission plugin;
set the ServerName in the config for webhook admission plugin.
2017-09-14 15:35:12 -07:00
deads2k 1c8a9e4060 use specified discovery information if possible 2017-09-13 10:49:10 -04:00
Kubernetes Submit Queue 35b38a342b Merge pull request #52078 from sttts/sttts-codegen-owners
Automatic merge from submit-queue

code-generator: add myself to OWNERS
2017-09-13 06:58:39 -07:00
Kubernetes Submit Queue 77e660ed15 Merge pull request #52227 from liggitt/non-preferred-version-priority
Automatic merge from submit-queue (batch tested with PRs 52227, 52120)

Fix discovery restmapper finding resources in non-preferred versions

Fixes: #52219

Also reverts behavioral changes to tests that version-qualified cronjobs to work around this issue.

The discovery rest mapper was only populating the priority rest mapper's search list with preferred groupversions.

That meant that if a resource existed in multiple non-preferred versions, AND did not exist in the preferred version (like cronjob, which only exists in v1beta2.batch and v2alpha1.batch, but not v1.batch), the priority restmapper would not find it in its group/version priority list, and would return an error.

```release-note
Fixed an issue looking up cronjobs when they existed in more than one API version
```
2017-09-12 01:09:14 -07:00
Clayton Coleman c13a3c0320
Report "resource" scope where possible
Also rename the variables to match the concept
2017-09-11 22:13:54 -04:00
Clayton Coleman 545aba778d
Report scope on all apiserver metrics
Counting list of namespaces is != list across all namespaces (same for
latency)
2017-09-11 22:13:54 -04:00
Clayton Coleman 5e46d5b545
Normalize WATCHLIST to WATCH in metrics
This causes confusion and doesn't match what we authorize on
2017-09-11 22:13:51 -04:00
Kubernetes Submit Queue db809c0eb7 Merge pull request #52194 from DirectXMan12/infra/restore-metrics-owners
Automatic merge from submit-queue

Restore OWNERS file for k8s.io/metrics

The owners file for k8s.io/metrics somehow got lost.  This restores it
to its contents on the "legacy" branch of k8s.io/metrics.

```release-note
NONE
```
2017-09-11 01:11:39 -07:00
Kubernetes Submit Queue e821e531db Merge pull request #50877 from dixudx/taint_unimplemented_comment
Automatic merge from submit-queue

newline to separate unimplemented TaintEffectNoScheduleNoAdmit

**What this PR does / why we need it**:
Unimplemented `TaintEffectNoScheduleNoAdmit ` should not be treated as comments of `TaintEffectNoExecute `

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

**Special notes for your reviewer**:
/assign @k82cn 

**Release note**:

```release-note
None
```
2017-09-09 02:30:05 -07:00
Jordan Liggitt a6316fb3a5
Fix discovery restmapper finding resources in non-preferred versions 2017-09-08 22:35:23 -04:00
Kubernetes Submit Queue d6df4a5127 Merge pull request #52063 from mtaufen/dkcfg-e2enode
Automatic merge from submit-queue (batch tested with PRs 52047, 52063, 51528)

Improve dynamic kubelet config e2e node test and fix bugs

Rather than just changing the config once to see if dynamic kubelet
config at-least-sort-of-works, this extends the test to check that the
Kubelet reports the expected Node condition and the expected configuration
values after several possible state transitions.

Additionally, this adds a stress test that changes the configuration 100
times. It is possible for resource leaks across Kubelet restarts to
eventually prevent the Kubelet from restarting. For example, this test
revealed that cAdvisor's leaking journalctl processes (see:
https://github.com/google/cadvisor/issues/1725) could break dynamic
kubelet config. This test will help reveal these problems earlier.

This commit also makes better use of const strings and fixes a few bugs
that the new testing turned up.

Related issue: #50217

I had been sitting on this until the cAdvisor fix merged in #51751, as these tests fail without that fix.

**Release note**:

```release-note
NONE
```
2017-09-08 16:06:56 -07:00
Solly Ross 288c2b152e Restore OWNERS file for k8s.io/metrics
The owners file for k8s.io/metrics somehow got lost.  This restores it
to its contents on the "legacy" branch of k8s.io/metrics.
2017-09-08 15:10:22 -04:00
Clayton Coleman fc2d201e15
Allow watch cache to be disabled per type
Currently setting watch cache size for a given resource does not disable
the watch cache. This commit adds a new `default-watch-cache-size` flag
to map to the existing field, and refactors how watch cache sizes are
calculated to bring all of the code into one place. It also adds debug
logging to startup to allow us to verify watch cache enablement in
production.
2017-09-08 13:42:28 -04:00
Kubernetes Submit Queue 36b3a0d75b Merge pull request #52030 from soltysh/creationtimestamp_audit
Automatic merge from submit-queue (batch tested with PRs 51900, 51782, 52030)

Fill in creationtimestamp in audit events

**What this PR does / why we need it**:
This is fixing null creationtimestamp in audit events.

@sttts @crassirostris like we've talked earlier today

**Release note**:
```release-note
none
```
2017-09-08 09:46:36 -07:00
Kubernetes Submit Queue 4a72b32d36 Merge pull request #51782 from charrywanganthony/audit-1
Automatic merge from submit-queue (batch tested with PRs 51900, 51782, 52030)

A policy with 0 rules should return an error

**Which issue this PR fixes** 
[isuue#51565](https://github.com/kubernetes/kubernetes/issues/51565)

**Release note**: 
``` 
An audit policy file with 0 rule returns an error.
```
2017-09-08 09:46:33 -07:00
Kubernetes Submit Queue 63d6bdb58c Merge pull request #51900 from sttts/sttts-informer-stratification
Automatic merge from submit-queue (batch tested with PRs 51900, 51782, 52030)

apiservers: stratify versioned informer construction

The versioned share informer factory has been part of the GenericApiServer config,
but its construction depended on other fields of that config (e.g. the loopback
client config). Hence, the order of changes to the config mattered.

This PR stratifies this by moving the SharedInformerFactory from the generic Config
to the CompleteConfig struct. Hence, it is only filled during completion when it is
guaranteed that the loopback client config is set.

While doing this, the CompletedConfig construction is made more type-safe again,
i.e. the use of SkipCompletion() is considereably reduced. This is archieved by
splitting the derived apiserver Configs into the GenericConfig and the ExtraConfig
part. Then the completion is structural again because CompleteConfig is again
of the same structure: generic CompletedConfig and local completed ExtraConfig.

Fixes #50661.
2017-09-08 09:46:29 -07:00
Dr. Stefan Schimanski fbd310dbc7 Update bazel 2017-09-08 16:12:54 +02:00
Dr. Stefan Schimanski d99c7df360 kube-aggregator: use shared informers from RecommendedConfig 2017-09-08 16:12:54 +02:00
Kubernetes Submit Queue a416534744 Merge pull request #51505 from atlassian/fix-unstructured-converter
Automatic merge from submit-queue

Fix pointer receivers handling in unstructured converter

**What this PR does / why we need it**:
Fixes unstructured converter to properly handle types that have `MarshalJSON()` implemented with a pointer receiver. In particular the converter now can roundtrip `*Unstructured` type.

**Which issue this PR fixes**:
Fixes #47889. Similar to #43346.

**Special notes for your reviewer**:
Without the fix the tests are failing:
```console
make test WHAT=./vendor/k8s.io/apimachinery/pkg/conversion/unstructured

Running tests for APIVersion: v1,admissionregistration.k8s.io/v1alpha1,admission.k8s.io/v1alpha1,apps/v1beta1,apps/v1beta2,authentication.k8s.io/v1,authentication.k8s.io/v1beta1,authorization.k8s.io/v1,authorization.k8s.io/v1beta1,autoscaling/v1,autoscaling/v2alpha1,batch/v1,batch/v1beta1,batch/v2alpha1,certificates.k8s.io/v1beta1,extensions/v1beta1,imagepolicy.k8s.io/v1alpha1,networking.k8s.io/v1,policy/v1beta1,rbac.authorization.k8s.io/v1,rbac.authorization.k8s.io/v1beta1,rbac.authorization.k8s.io/v1alpha1,scheduling.k8s.io/v1alpha1,settings.k8s.io/v1alpha1,storage.k8s.io/v1beta1,storage.k8s.io/v1,,federation/v1beta1
+++ [0829 16:39:36] Running tests without code coverage
--- FAIL: TestCustomToUnstructured (0.00s)
    --- FAIL: TestCustomToUnstructured/false (0.00s)
        Error Trace:    converter_test.go:500
        Error:          Not equal:
                        expected: bool(false)
                        actual: map[string]interface {}(map[string]interface {}{"data":"ZmFsc2U="})
        Messages:       customPointer1
    --- FAIL: TestCustomToUnstructured/[1] (0.00s)
        Error Trace:    converter_test.go:500
        Error:          Not equal:
                        expected: []interface {}([]interface {}{1})
                        actual: map[string]interface {}(map[string]interface {}{"data":"WzFd"})
        Messages:       customPointer1
    --- FAIL: TestCustomToUnstructured/true (0.00s)
        Error Trace:    converter_test.go:500
        Error:          Not equal:
                        expected: bool(true)
                        actual: map[string]interface {}(map[string]interface {}{"data":"dHJ1ZQ=="})
        Messages:       customPointer1
    --- FAIL: TestCustomToUnstructured/0 (0.00s)
        Error Trace:    converter_test.go:500
        Error:          Not equal:
                        expected: int64(0)
                        actual: map[string]interface {}(map[string]interface {}{"data":"MA=="})
        Messages:       customPointer1
    --- FAIL: TestCustomToUnstructured/null (0.00s)
        Error Trace:    converter_test.go:500
        Error:          Not equal:
                        expected: <nil>(<nil>)
                        actual: map[string]interface {}(map[string]interface {}{"data":"bnVsbA=="})
        Messages:       customPointer1
    --- FAIL: TestCustomToUnstructured/[] (0.00s)
        Error Trace:    converter_test.go:500
        Error:          Not equal:
                        expected: []interface {}([]interface {}{})
                        actual: map[string]interface {}(map[string]interface {}{"data":"W10="})
        Messages:       customPointer1
    --- FAIL: TestCustomToUnstructured/{"a":1} (0.00s)
        Error Trace:    converter_test.go:500
        Error:          Not equal:
                        expected: map[string]interface {}{"a":1}
                        actual: map[string]interface {}{"data":"eyJhIjoxfQ=="}

                        Diff:
                        --- Expected
                        +++ Actual
                        @@ -1,3 +1,3 @@
                         (map[string]interface {}) (len=1) {
                        - (string) (len=1) "a": (int64) 1
                        + (string) (len=4) "data": (string) (len=12) "eyJhIjoxfQ=="
                         }
        Messages:       customPointer1
    --- FAIL: TestCustomToUnstructured/0.0 (0.00s)
        Error Trace:    converter_test.go:500
        Error:          Not equal:
                        expected: float64(0)
                        actual: map[string]interface {}(map[string]interface {}{"data":"MC4w"})
        Messages:       customPointer1
    --- FAIL: TestCustomToUnstructured/{} (0.00s)
        Error Trace:    converter_test.go:500
        Error:          Not equal:
                        expected: map[string]interface {}{}
                        actual: map[string]interface {}{"data":"e30="}

                        Diff:
                        --- Expected
                        +++ Actual
                        @@ -1,2 +1,3 @@
                        -(map[string]interface {}) {
                        +(map[string]interface {}) (len=1) {
                        + (string) (len=4) "data": (string) (len=4) "e30="
                         }
        Messages:       customPointer1
--- FAIL: TestCustomToUnstructuredTopLevel (0.00s)
    --- FAIL: TestCustomToUnstructuredTopLevel/1 (0.00s)
        Error Trace:    converter_test.go:519
        Error:          Not equal:
                        expected: map[string]interface {}{"a":1}
                        actual: map[string]interface {}{"data":"eyJhIjoxfQ=="}

                        Diff:
                        --- Expected
                        +++ Actual
                        @@ -1,3 +1,3 @@
                         (map[string]interface {}) (len=1) {
                        - (string) (len=1) "a": (int64) 1
                        + (string) (len=4) "data": (string) (len=12) "eyJhIjoxfQ=="
                         }
FAIL
FAIL    k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/conversion/unstructured    0.047s
make: *** [test] Error 1
```

```console
make test WHAT=./vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured

Running tests for APIVersion: v1,admissionregistration.k8s.io/v1alpha1,admission.k8s.io/v1alpha1,apps/v1beta1,apps/v1beta2,authentication.k8s.io/v1,authentication.k8s.io/v1beta1,authorization.k8s.io/v1,authorization.k8s.io/v1beta1,autoscaling/v1,autoscaling/v2alpha1,batch/v1,batch/v1beta1,batch/v2alpha1,certificates.k8s.io/v1beta1,extensions/v1beta1,imagepolicy.k8s.io/v1alpha1,networking.k8s.io/v1,policy/v1beta1,rbac.authorization.k8s.io/v1,rbac.authorization.k8s.io/v1beta1,rbac.authorization.k8s.io/v1alpha1,scheduling.k8s.io/v1alpha1,settings.k8s.io/v1alpha1,storage.k8s.io/v1beta1,storage.k8s.io/v1,,federation/v1beta1
+++ [0829 16:40:38] Running tests without code coverage
--- FAIL: TestConversionRoundtrip (0.00s)
    unstructured_test.go:111: FromUnstructured failed: Object 'Kind' is missing in '{"object":{"apiVersion":"v1","kind":"Foo","metadata":{"name":"foo1"}}}'
FAIL
FAIL    k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured  0.046s
make: *** [test] Error 1
```

**Release note**:
```release-note
NONE
```
/kind bug
/sig api-machinery
2017-09-08 07:09:12 -07:00
Maciej Szulik 3dd3e7aa52
Fill in creationtimestamp in audit events 2017-09-08 15:59:10 +02:00
Dr. Stefan Schimanski b153268da7 apiserver: avoid panics on nil sub-option structs 2017-09-08 14:38:17 +02:00
Dr. Stefan Schimanski 2b64d3a0fd apiserver: split core API creation from secure serving 2017-09-08 14:38:11 +02:00
Dr. Stefan Schimanski ca3f745346 apiserver: stratify versioned informer construction 2017-09-08 14:16:09 +02:00
Dr. Stefan Schimanski dffe50f8bd apiserver: allow disabling authz/n via options 2017-09-08 14:16:09 +02:00
Dr. Stefan Schimanski 1bcea54104 apiserver: make config completion structural recursion 2017-09-08 14:16:09 +02:00
Dr. Stefan Schimanski 7d09148ad7 apiserver: separate apiserver specific configs into ExtraConfig 2017-09-08 14:16:09 +02:00
Chao Wang 0ad4282fd0 A policy with 0 rules should return an error 2017-09-08 20:02:03 +08:00
Kubernetes Submit Queue 5006426022 Merge pull request #52071 from CaoShuFeng/warning
Automatic merge from submit-queue (batch tested with PRs 52091, 52071)

Log a warning when --audit-policy-file not passed to apiserver

When audit backend provided, but --audit-policy-file is not passed, leave a info in log.
**Release note**:
```
Log a warning when --audit-policy-file not passed to apiserver
```
2017-09-08 04:57:59 -07:00
Mikhail Mazurskiy a672b98cc6
Fix pointer receivers handling in unstructured converter 2017-09-08 21:28:42 +10:00
Kubernetes Submit Queue 45fe0a9e04 Merge pull request #51932 from dixudx/fix_forbidden_messages
Automatic merge from submit-queue

fix format of forbidden messages

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

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

**Special notes for your reviewer**:
/assign @deads2k @liggitt 

**Release note**:

```release-note
None
```
2017-09-08 03:57:04 -07:00
Kubernetes Submit Queue eda3db550b Merge pull request #51876 from smarterclayton/disable_client_paging
Automatic merge from submit-queue (batch tested with PRs 48552, 51876)

Disable default paging in list watches

For 1.8 this will be off by default. In 1.9 it will be on by default.
Add tests and rename some fields to use the `chunking` terminology.

Note that the pager may be used for other things besides chunking.

Follow on to #48921, we left the field on to get some exercise in the normal code paths, but needs to be disabled for 1.8.

@liggitt let's merge on wednesday.
2017-09-07 23:08:17 -07:00
Cao Shufeng 3b91f1cc0d Log a warning when --audit-policy-file not passed to apiserver 2017-09-08 13:43:03 +08:00
Di Xu 95738d5a0e fix format of forbidden messages 2017-09-08 09:20:13 +08:00
Michael Taufen a846ba191c Improve dynamic kubelet config e2e node test and fix bugs
Rather than just changing the config once to see if dynamic kubelet
config at-least-sort-of-works, this extends the test to check that the
Kubelet reports the expected Node condition and the expected configuration
values after several possible state transitions.

Additionally, this adds a stress test that changes the configuration 100
times. It is possible for resource leaks across Kubelet restarts to
eventually prevent the Kubelet from restarting. For example, this test
revealed that cAdvisor's leaking journalctl processes (see:
https://github.com/google/cadvisor/issues/1725) could break dynamic
kubelet config. This test will help reveal these problems earlier.

This commit also makes better use of const strings and fixes a few bugs
that the new testing turned up.

Related issue: #50217
2017-09-07 15:50:17 -07:00
Kubernetes Submit Queue 310b24bfcd Merge pull request #52097 from smarterclayton/log
Automatic merge from submit-queue (batch tested with PRs 52097, 52054)

Provide field info in storage configuration

Makes debugging how storage was configured difficult

@kubernetes/sig-api-machinery-bugs
2017-09-07 15:28:23 -07:00
Kubernetes Submit Queue 7e5d2df299 Merge pull request #52076 from sttts/sttts-protobuf-gen-cut-off
Automatic merge from submit-queue (batch tested with PRs 51239, 51644, 52076)

code-generator/protobuf: cut-off kubernetes specifics

The package list moved to hack/update-generated-protobuf-dockerized.sh.

This make the protobuf generator usable outside of kube.
2017-09-07 14:31:25 -07:00
Kubernetes Submit Queue 424819888a Merge pull request #52065 from liggitt/proxy-request-uri
Automatic merge from submit-queue

Fix proxied request-uri to be valid HTTP requests

Fixes #52022, introduced in 1.7. Stringifying/re-parsing the URL masked that the path was not constructed with a leading `/` in the first place.

This makes upgrade requests proxied to pods/services via the API server proxy subresources be valid HTTP requests

```release-note
Fixes an issue with upgrade requests made via pod/service/node proxy subresources sending a non-absolute HTTP request-uri to backends
```
2017-09-07 13:03:34 -07:00
Jordan Liggitt 9648f1cb7a
Fix proxied request-uri to be valid HTTP requests 2017-09-07 13:10:49 -04:00
Dr. Stefan Schimanski 0fdcd993bf code-generator/protobuf: cut-off kubernetes specifics 2017-09-07 18:31:48 +02:00
Clayton Coleman 1fde2698ec
Provide field info in storage configuration 2017-09-07 12:29:45 -04:00
Dr. Stefan Schimanski 4039a72234 client-gen: avoid panic for empty groups 2017-09-07 10:43:26 +02:00
Dr. Stefan Schimanski db8903ba35 Add sttts to code-generator OWNERS 2017-09-07 10:34:33 +02:00
Clayton Coleman 8b571bb63b
Disable default paging in list watches
For 1.8 this will be off by default. In 1.9 it will be on by default.
Add tests and rename some fields to use the `chunking` terminology.

Note that the pager may be used for other things besides chunking.
2017-09-06 23:10:59 -04:00
Kubernetes Submit Queue 3168bd4b12 Merge pull request #50708 from DirectXMan12/versions/autoscaling-v2beta1
Automatic merge from submit-queue (batch tested with PRs 51956, 50708)

Move autoscaling/v2 from alpha1 to beta1

This graduates autoscaling/v2alpha1 to autoscaling/v2beta1.  The move is more-or-less just a straightforward rename.

Part of kubernetes/features#117

```release-note
v2 of the autoscaling API group, including improvements to the HorizontalPodAutoscaler, has moved from alpha1 to beta1.
```
2017-09-06 15:46:24 -07:00
Kubernetes Submit Queue d369160c79 Merge pull request #50842 from CaoShuFeng/remove_versioned_test_from_filters
Automatic merge from submit-queue (batch tested with PRs 49133, 51557, 51749, 50842, 52018)

enhance unit tests of advance audit feature

This change addresses comments from @crassirostris 
https://github.com/kubernetes/kubernetes/pull/49115#discussion_r133416080

It does three things:
1. use auditinternal for unit test in filter stage
2. add a seperate unit test for Audit-ID http header
3. add unit test for audit log backend


**Release note**:
```
NONE
```
2017-09-06 13:36:15 -07:00
Chao Xu 4d1d33af46 bazel 2017-09-06 10:21:01 -07:00