Commit Graph

2585 Commits (06776c2ab3254b3547f26f4ecae57cbc46d3e79f)

Author SHA1 Message Date
Kubernetes Submit Queue 1ba331ef59 Merge pull request #53474 from jekohk/clientgo-examples/crud-rollback
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>.

client-go/examples: Update CRUD Deployment sample

**What this PR does / why we need it**: 
PR motivated by [#128](https://github.com/kubernetes/client-go/issues/128), namely updating the CRUD example with the following:
- Add new step which demonstrates rolling back deployments 
- Cleanup retry loop for `Update()` steps
- Make `-kubeconfig` flag optional when running example (same as out-of-cluster example)
- Update `README.md` to reflect changes 

**Special notes for your reviewer**:
My first Kubernetes contribution- feedback very welcome!

**Release note**:

```release-note
NONE
```

/cc @ahmetb @caesarxuchao
2017-10-24 19:01:34 -07:00
Kubernetes Submit Queue 598d7e111e Merge pull request #54366 from tamalsaha/patch-1
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>.

Bug: Fix NPE in time.Equal method
2017-10-24 16:48:14 -07:00
John Kelly e71c9f1b4b client-go: fix err scope in CRUD example
This fixes some scope isses that were introduced by shadowing vars inside anonymous functions as well as using a naked return.
Fixed by using unique err names and explicitly returning errors.
Additional improvement is using the HomeDir() util function provided by client-go instead of including a helper function at the bottom of this example.

Signed-off-by: John Kelly <jekohk@gmail.com>
2017-10-24 19:44:18 -04:00
John Kelly 94f5bcf6f7 client-go: use retry util in CRUD example
This updates the create-update-delete-deployment example with the following:
Make use of client-go retry util in Update() steps instead of simple for loops.
Using RetryOnConflict is generally better practice as it won't become stuck in a retry loop and uses exponential backoff to prevent exhausting the apiserver.
Instead of changing annotations to demonstrate Updates/Rollbacks, change the container image as it is less confusing for readers and a better real-world example.
Improve comments and README to reflect above changes.

Signed-off-by: John Kelly <jekohk@gmail.com>
2017-10-24 19:44:18 -04:00
John Kelly ce73088a71 client-go: Update CRUD example
This updates the create-update-delete-deployment example with the following:
Add rollback step to demonstrate rolling back deployments with client-go.
Modify the for-loops used in both Update steps to Get() the latest version
of the Deployment from the server before attempting Update().
This is necessary because the object returned by Create() does
not have the new resourceVersion, causing the initial Update() to always fail
due to conflicting resource versions. Putting the Get() at the top of the
loop seems to fix this bug.
Make -kubeconfig flag optional if config is in default location, using the
same method found in the out-of-cluster example.

Patch is motivated by effort to improve client-go examples.

Signed-off-by: John Kelly <jekohk@gmail.com>
2017-10-24 19:44:18 -04:00
Tamal Saha 7b69af3bd0 Fix NPE in time.Equal method 2017-10-24 09:47:25 -07:00
Kubernetes Submit Queue 16cdda003c Merge pull request #54302 from sbezverk/refactor_rbd_volume
Automatic merge from submit-queue (batch tested with PRs 54229, 54380, 54302, 54454). 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>.

Refactor RBD volume

Refactor RBD Volume Persistent Volume Spec so RBD PV's SecretRef
allows referencing a secret from a persistent volume in any namespace.
This allows locating credentials for persistent volumes in namespaces
other than the one containing the PVC.
Closes #54432
```release-note
RBD Persistent Volume Sources can now reference User's Secret in namespaces other than the namespace of the bound Persistent Volume Claim
```
2017-10-24 08:35:11 -07:00
Kubernetes Submit Queue de75c09db4 Merge pull request #47347 from deads2k/agg-34-check
Automatic merge from submit-queue (batch tested with PRs 53579, 47347). 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>.

actually check for a live discovery endpoint before aggregating

Aggregation doesn't work without being able to hit a discovery endpoint.  This adds a simple status check for whether the discovery endpoint is reachable.  The actual status code doesn't matter, we just need to be able to make the connection.
2017-10-24 06:02:20 -07:00
Kubernetes Submit Queue f7c8a7aa17 Merge pull request #53579 from sttts/sttts-client-gen-groupname-comment-everywhere
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>.

generators: allow +groupName everywhere in doc.go

... not only directly above the package directive.

Avoiding confusion as in https://github.com/kubernetes/kubernetes/issues/53498.
2017-10-24 05:29:10 -07:00
Kubernetes Submit Queue e02d4a9855 Merge pull request #52897 from huzhengchuan/fix/incorrect_links_api
Automatic merge from submit-queue (batch tested with PRs 52556, 52897, 54342). 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 broken links in api after moving proposals to subdirs

**What this PR does / why we need it**:
fix incorrect links in api after kubernetes/community#1010

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

**Special notes for your reviewer**:
CC @bgrant0607
**Release note**:

```
NONE
```
2017-10-23 19:34:02 -07:00
Kubernetes Submit Queue 2e998d82c4 Merge pull request #52556 from roycaihw/51790
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>.

Apiserver proxy rewrites URL when service returns absolute path with request's host

**What this PR does / why we need it**:
When a service responses with an URL using an absolute path and the request's host (e.g. in redirection location), current transport recognizes the URL as a different host and doesn't rewrite the absolute path.

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

**Special notes for your reviewer**:

**Release note**:

```release-note
Apiserver proxy rewrites URL when service returns absolute path with request's host.
```
2017-10-23 19:24:24 -07:00
Haowei Cai 4a5b9dd70e Add comments to explain difference between req.URL.Host and req.Host. 2017-10-23 15:48:11 -07:00
Serguei Bezverkhi ab32196ffd Refactor RBD volume (Generated files) 2017-10-23 16:59:34 -04:00
Serguei Bezverkhi 1411c2698e Refactor RBD volume 2017-10-23 16:59:34 -04:00
Kubernetes Submit Queue ca8d97d673 Merge pull request #53743 from DirectXMan12/feature/polymorphic-scale-client
Automatic merge from submit-queue (batch tested with PRs 53743, 53564). 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>.

Polymorphic Scale Client

This PR introduces a polymorphic scale client based on discovery information that's able to scale scalable resources in arbitrary group-versions, as long as they present the scale subresource in their discovery information.

Currently, it supports `extensions/v1beta1.Scale` and `autoscaling/v1.Scale`, but supporting other versions of scale if/when we produce them should be fairly trivial.

It also updates the HPA to use this client, meaning the HPA will now work on any scalable resource, not just things in the `extensions/v1beta1` API group.

**Release note**:
```release-note
Introduces a polymorphic scale client, allowing HorizontalPodAutoscalers to properly function on scalable resources in any API group.
```

Unblocks #29698
Unblocks #38756
Unblocks #49504 
Fixes #38810
2017-10-23 13:39:07 -07:00
Kubernetes Submit Queue b1e2d7a9dc Merge pull request #54413 from kad/spdy-no-proxy-cidr
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>.

Use CIDR-aware proxy resolver for SPDY RoundTripper

**What this PR does / why we need it**: `kubectl attach` for example doesn't work if NO_PROXY specifies API endpoint IP via CIDR notation.

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

**Special notes for your reviewer**: Potentially it will be good to get that change to 1.8.x

**Release note**:
```release-note
- API machinery's httpstream/spdy calls now support CIDR notation for NO_PROXY
```
2017-10-23 10:07:08 -07:00
Alexander Kanevskiy cbc2688be4 Use CIDR-aware proxy resolver for SPDY RoundTripper
Fixes: #54407
2017-10-23 16:23:55 +03:00
Shyam JVS d515f0e3d2 Revert "update gRPC to pick up data race fix" 2017-10-23 13:23:48 +02:00
Nikhita Raghunath cdcc6ac375 sample-controller: add usage instructions to README
- add usage instructions
- add Use Cases, Defining Types and Clean Up section. Copied
from apiextensions-apiserver/examples/client-go. This is done
to be consistent with all other examples.
- fix formatting
2017-10-22 15:26:38 +05:30
Kubernetes Submit Queue 507790c9c6 Merge pull request #54181 from apelisse/update-kube-openapi
Automatic merge from submit-queue (batch tested with PRs 54199, 54181, 54196). 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>.

Update openapi to use kube-openapi code

**What this PR does / why we need it**: OpenAPI code has moved to `github.com/kubernetes/kube-openapi`. Let's use that code as a dependency, since now it's duplicated.

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

**Special notes for your reviewer**:

**Release note**:
```release-note
NONE
```

No user visible changes. Just code moving around.
2017-10-20 18:57:03 -07:00
Kubernetes Submit Queue 0736c55776 Merge pull request #53442 from deads2k/server-02-nesteddecoding
Automatic merge from submit-queue (batch tested with PRs 53916, 53442). 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 nested encoder and decoder to admission config

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

Adds the required nested object encoder/decoder pairs for admission config extensions.

@sttts
2017-10-20 10:43:58 -07:00
Antoine Pelisse 3ed58475c4 Update openapi to use kube-openapi code 2017-10-20 09:21:06 -07:00
Kubernetes Submit Queue 4282ab39fc Merge pull request #54257 from tiran/lister-getbykey
Automatic merge from submit-queue (batch tested with PRs 53194, 54257, 53014). 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 GetByKey() in typeLister_NonNamespacedGet

The Get() function of non-namespace lister passes a temporary object to
indexer.Get() in order to fetch the actual object from the indexer. This
may cause Go to allocate the temporary object on the heap instead of the
stack, as it is passed into interfaces. For non-namespaced objects,
Get(&Type{ObjectMeta: v1.ObjectMeta{Name: name}}) should be equivalent
to GetByKey(name).

This could be the root cause of excessive allocations, e.g. in tests
clusterRoleLister.Get() has trigger 4 billion allocations. See
openshift/origin#16954
2017-10-20 03:19:12 -07:00
Kubernetes Submit Queue 70960a5ed7 Merge pull request #53128 from dixudx/godeps_fix_grpc_data_race
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>.

update gRPC to pick up data race fix

**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 #53124

**Special notes for your reviewer**:

**Release note**:

```release-note
update gRPC to v1.6.0 to pick up data race fix grpc/grpc-go#1316 
```
2017-10-20 01:32:18 -07:00
Christian Heimes 5f9d8ba5a1 Run hack/update-bazel.sh
Signed-off-by: Christian Heimes <cheimes@redhat.com>
2017-10-19 23:44:34 +02:00
Christian Heimes 477aadaa2f Regenerate code with hack/update-codegen.sh
Signed-off-by: Christian Heimes <cheimes@redhat.com>
2017-10-19 22:26:13 +02:00
Christian Heimes d57280efb2 Use GetByKey() in typeLister_NonNamespacedGet
The Get() function of non-namespace lister passes a temporary object to
indexer.Get() in order to fetch the actual object from the indexer. This
may cause Go to allocate the temporary object on the heap instead of the
stack, as it is passed into interfaces. For non-namespaced objects,
Get(&Type{ObjectMeta: v1.ObjectMeta{Name: name}}) should be equivalent
to GetByKey(name).

This could be the root cause of excessive allocations, e.g. in tests
clusterRoleLister.Get() has trigger 4 billion allocations. See
https://github.com/openshift/origin/issues/16954

Signed-off-by: Christian Heimes <cheimes@redhat.com>
2017-10-19 22:23:58 +02:00
Kubernetes Submit Queue f07b359e5b Merge pull request #54156 from deads2k/admission-06-restclient
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>.

update admission webhook to accept client config

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

This plumbs a complete client through the plugin initializer for admission webhooks.  It achieves parity with our existing webhooks and provides flexibility if people want to do something special or different.  Easy things are easy, hard things are possible.  This does not change behavior for kube-apiserver.

@kubernetes/sig-auth-api-reviews @kubernetes/sig-api-machinery-bugs
2017-10-19 10:55:23 -07:00
Solly Ross f22bfcd65a [client-go] Add fake scale client
This adds a new fake scale client (for use in testing) to match the
new polymorphic scale client.
2017-10-19 13:21:03 -04:00
Solly Ross ef583aeed2 Fuzz label selectors
Previously, we did not have custom code for fuzzing label selectors.
Anything that used a label selector (like Scale) had to manually bypass
fuzzing the selector, or write its own fuzzer.  This introduces a fuzzer
for label selectors which generates random correct selectors with random
keys and values.
2017-10-19 11:01:45 -04:00
Solly Ross d61a2d9037 [client-go] Polymorphic Scale Client
This introduces a polymorphic scale client capable of operating against
scale subresources which return different group-versions of Scale.  The
scale subresources may be in group-versions different than the scale
itself, so that we no longer need a copy of every scalable resource in
the extensions API group.

To discovery which Scale group-versions go to which subresources,
discovery is used.

The scale client maintains its own internal versions and conversions to
several external versions, with a "hub" version that's a copy of the
autoscaling internal version.

It currently supports the following group-versions for Scale subresources:

- extensions/v1beta1.Scale
- autoscaling/v1.Scale
2017-10-19 11:01:45 -04:00
Solly Ross f83a19676c [client-go] fake discovery returns server groups
The fake discovery client currently returns `nil, nil` for several
methods.  Among them is the `ServerGroups` method, which is used by the
discovery REST mapper implementations.  This updates the fake discovery
client to actually return server groups so that the discovery REST
mapper can be used in tests.
2017-10-19 11:01:45 -04:00
Solly Ross eac2049fc9 [client-go] avoid Registry in fake REST client
Previously, the fake RESTClient in client-go required a Registry.  It
used the Registry to fetch the GroupVersion for the fake client.
However, the way it did so was dubious in some cases (it hard-coded the
default API group in places), and not strictly necssary.

This updates the fake client to just recieve the GroupVersion and
internal group name directly, instead of requiring a Registry, so that
it can be consumed in unit tests where a Registry isn't necessarily
readily available (e.g. elsewhere in client-go).
2017-10-19 11:01:44 -04:00
James Munnelly 49f8037dd6 Add link to k8s.io/sample-controller 2017-10-19 15:46:36 +01:00
deads2k f6fde0ba54 actually check for a live discovery endpoint before aggregating 2017-10-19 10:07:07 -04:00
David Eads 0859798e8e update admission webhook to accept client config 2017-10-19 09:52:58 -04:00
Kubernetes Submit Queue 78ada62c30 Merge pull request #53821 from rrati/apiserver-clean-shutdown
Automatic merge from submit-queue (batch tested with PRs 54145, 53821). 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>.

Added PreStopHooks to apiserver to allow clean shutdown.  

BootStrapController now registers a PreStopHook to clean up the kubernetes service endpoints.  The PreStopHooks allow the apiserver to shutdown cleanly under a controlled shutdown case.  The BootStrapController's PreStopHook will clean up after itself by removing the apiserver from the list of IPs in the kubernetes service.

fixes #53438
2017-10-19 06:50:13 -07:00
Kubernetes Submit Queue 7d190fcfcb Merge pull request #54145 from deads2k/admission-05-url
Automatic merge from submit-queue (batch tested with PRs 54145, 53821). 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 url path for admission webhooks

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

Adds an optional field to admission webhook registration that allows a user to specify a path to post to.  This achieves parity with other webhooks.

Each segment is required to be a dns subdomain, which mirrors url rules for groups.

@kubernetes/api-reviewers 

```release-note
admission webhook registration now allows URL paths
```
2017-10-19 06:50:10 -07:00
David Eads 730d42011a generated 2017-10-19 08:06:38 -04:00
David Eads 33deaedaf6 add url path for admission webhooks 2017-10-19 08:06:38 -04:00
Kubernetes Submit Queue 194f3983f0 Merge pull request #54218 from CaoShuFeng/stra
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 error message of custrom resource validation

/assign @deads2k 
/assign @sttts 

**Release note**:
```
NONE
```
2017-10-19 05:02:12 -07:00
Cao Shufeng 9aed856664 fix error message of custrom resource validation 2017-10-19 17:32:25 +08:00
Kubernetes Submit Queue 9a7800f7d2 Merge pull request #52753 from munnerz/sample-controller
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>.

sample-controller: add example CRD controller

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

Adds a sample-controller example repository

fixes #52752

**Special notes for your reviewer**:

This is currently based on the sttts:sttts-codegen-scripts branch and should not be merged until that is (ref https://github.com/kubernetes/kubernetes/pull/52186)

**Release note**:

```
Add sample-controller repository
```

/cc @sttts @nikhita @colemickens
2017-10-19 02:32:12 -07:00
Kubernetes Submit Queue 6997d6c062 Merge pull request #54167 from deads2k/server-03-splitfiles
Automatic merge from submit-queue (batch tested with PRs 54167, 54182). 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>.

split up large rest handling file

These are nothing but exact block moves because the giant rest.go made it really hard to find anything.

@kubernetes/sig-api-machinery-pr-reviews 

/assign sttts
/assign caesarxuchao
2017-10-18 18:21:20 -07:00
Kubernetes Submit Queue 7f26f03b68 Merge pull request #54158 from nikhita/crd-lastTransitionTime
Automatic merge from submit-queue (batch tested with PRs 49305, 54158). 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>.

apiextensions: fix LastTransitionTime for NamesAccepted condition

Fixes #54148. 

Without this change, `LastTransitionTime` for the NamesAccepted condition for CRDs always showed up as `null`.

**Release note**:

```release-note
NONE
```
2017-10-18 16:35:19 -07:00
James Munnelly 740afa0e65 Add sample CustomResourceDefinition controller
sample-controller: add API types

sample-controller: regenerate files

sample-controller: add implementation

sample-controller: update bazel

sample-controller: update make-rules and cache_go_dirs

sample-controller: Set noStatus tag. Remove openapi-gen tag.

sample-controller: add deletion tombstone handling logic

sample-controller: update README, remove use of reflect in UpdateFuncs

sample-controller: add OWNERS file

sample-controller: add LICENSE
2017-10-19 00:21:57 +01:00
Kubernetes Submit Queue aaec4e20e8 Merge pull request #53164 from enisoc/rc-rs-conversion
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 RC/RS conversion

This fixes some round-trip information loss when representing an RC as an RS. I want to use these conversions in #49429 to eliminate the maintenance burden of duplicated RC code.

@kubernetes/sig-apps-pr-reviews
2017-10-18 15:42:10 -07:00
Kubernetes Submit Queue 900c0761e3 Merge pull request #53722 from deads2k/rbac-01-allow-star
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>.

allow */subresource in rbac policy rules

xref #29698
xref #38756
xref #49504
xref #38810

Allow `*/subresource` format in RBAC policy rules to support polymorphic subresources like `*/scale` for HPA.

@DirectXMan12 fyi

```release-note
RBAC PolicyRules now allow resource=`*/<subresource>` to cover `any-resource/<subresource>`.   For example, `*/scale` covers `replicationcontroller/scale`.
```
2017-10-18 14:02:05 -07:00
David Eads cd663d7ad0 split up large rest handling file 2017-10-18 16:12:14 -04:00
Anthony Yeh c1377383bb
Add fuzz test for RC/RS conversion. 2017-10-18 12:37:30 -07:00