Skip to content

Commit 62071e4

Browse files
authored
Merge pull request #1460 from roycaihw/pull-master-into-release-17
Pull master into release-17.0
2 parents 668ab15 + 6cc274f commit 62071e4

13 files changed

+999
-18
lines changed

CHANGELOG.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
# v17.0.0-snapshot
2+
3+
Kubernetes API Version: 1.17.17
4+
5+
Changelog since v17.17.0b1:
6+
7+
### Bug or Regression
8+
- Fix watch stream non-chunked response handling ([kubernetes-client/python-base#231](https://github.com/kubernetes-client/python-base/pull/231), [@dhague](https://github.com/dhague))
9+
- Fixed a decoding error for BOOTMARK watch events ([kubernetes-client/python-base#234](https://github.com/kubernetes-client/python-base/pull/234), [@yliaog](https://github.com/yliaog))
10+
11+
### Feature
12+
- Load_kube_config_from_dict() support define custom temp files path ([kubernetes-client/python-base#233](https://github.com/kubernetes-client/python-base/pull/233), [@onecer](https://github.com/onecer))
13+
- The dynamic client now supports customizing http "Accept" header through the `header_params` parameter, which can be used to customizing API server response, e.g. retrieving object metadata only. ([kubernetes-client/python-base#236](https://github.com/kubernetes-client/python-base/pull/236), [@Yashks1994](https://github.com/Yashks1994))
14+
115
# v17.17.0b1
216

317
Kubernetes API Version: 1.17.17
@@ -16,6 +30,55 @@ Changelog since v17.14.0a1:
1630
- raise exception when an empty config file is passed to load_kube_config [kubernetes-client/python-base#223](https://github.com/kubernetes-client/python-base/pull/223)
1731
- Fix bug with Watch and 410 retries [kubernetes-client/python-base#227](https://github.com/kubernetes-client/python-base/pull/227)
1832

33+
# v18.17.0a1
34+
35+
Kubernetes API Version: 1.18.17
36+
37+
**Important Information:**
38+
39+
- The Kubernetes Python client versioning scheme has changed. The version numbers used till Kubernetes Python Client v12.y.z lagged behind the actual Kubernetes minor version numbers. From this release, the client is moving a version format `vY.Z.P` where `Y` and `Z` are respectively from the Kubernetes version `v1.Y.Z` and `P` would incremented due to changes on the Python client side itself. Ref: https://github.com/kubernetes-client/python/issues/1244
40+
- Python 2 had reached [End of Life](https://www.python.org/doc/sunset-python-2/) on January 1, 2020. The Kubernetes Python Client has dropped support for Python 2 from this release (v18.0.0) and will no longer provide support to older clients as per the [Kubernetes support policy](https://kubernetes.io/docs/setup/release/version-skew-policy/#supported-versions).
41+
42+
**Deprecations:**
43+
- The following deprecated APIs can no longer be served:
44+
- All resources under `apps/v1beta1` and `apps/v1beta2` - use `apps/v1` instead
45+
- `daemonsets`, `deployments`, `replicasets` resources under `extensions/v1beta1` - use `apps/v1` instead
46+
- `networkpolicies` resources under `extensions/v1beta1` - use `networking.k8s.io/v1` instead
47+
- `podsecuritypolicies` resources under `extensions/v1beta1` - use `policy/v1beta1` instead ([#85903](https://github.com/kubernetes/kubernetes/pull/85903), [@liggitt](https://github.com/liggitt)) [SIG API Machinery, Apps, Cluster Lifecycle, Instrumentation and Testing]
48+
49+
**New Feature:**
50+
- Support leader election. [kubernetes-client/python-base#206](https://github.com/kubernetes-client/python-base/pull/206)
51+
52+
**Bug Fix:**
53+
- Raise exception when an empty config file is passed to load_kube_config. [kubernetes-client/python-base#223](https://github.com/kubernetes-client/python-base/pull/223)
54+
- fix: load cache error when CacheDecoder object is not callable. [kubernetes-client/python-base#226](https://github.com/kubernetes-client/python-base/pull/226)
55+
- Fix Watch retries with 410 errors. [kubernetes-client/python-base#227](https://github.com/kubernetes-client/python-base/pull/227)
56+
- Automatically handles chunked or non-chunked responses. Fix ResponseNotChunked error from watch. [kubernetes-client/python-base#231](https://github.com/kubernetes-client/python-base/pull/231)
57+
58+
**API Change:**
59+
- Add allowWatchBookmarks, resoureVersionMatch parameters to custom objects. [kubernetes-client/gen#180](https://github.com/kubernetes-client/gen/pull/180)
60+
- Fix bug in reflector that couldn't recover from "Too large resource version" errors ([#92537](https://github.com/kubernetes/kubernetes/pull/92537), [@wojtek-t](https://github.com/wojtek-t)) [SIG API Machinery]
61+
- Fixed: log timestamps now include trailing zeros to maintain a fixed width ([#91207](https://github.com/kubernetes/kubernetes/pull/91207), [@iamchuckss](https://github.com/iamchuckss)) [SIG Apps and Node]
62+
- Fixed: log timestamps now include trailing zeros to maintain a fixed width ([#91207](https://github.com/kubernetes/kubernetes/pull/91207), [@iamchuckss](https://github.com/iamchuckss)) [SIG Apps and Node]
63+
- Resolve regression in metadata.managedFields handling in update/patch requests submitted by older API clients ([#92007](https://github.com/kubernetes/kubernetes/pull/92007), [@apelisse](https://github.com/apelisse)) [SIG API Machinery and Testing]
64+
- A new IngressClass resource has been added to enable better Ingress configuration. ([#88509](https://github.com/kubernetes/kubernetes/pull/88509), [@robscott](https://github.com/robscott)) [SIG API Machinery, Apps, CLI, Network, Node and Testing]
65+
- The CSIDriver API has graduated to storage.k8s.io/v1, and is now available for use. ([#84814](https://github.com/kubernetes/kubernetes/pull/84814), [@huffmanca](https://github.com/huffmanca)) [SIG Storage]
66+
- autoscaling/v2beta2 HorizontalPodAutoscaler added a `spec.behavior` field that allows scale behavior to be configured. Behaviors are specified separately for scaling up and down. In each direction a stabilization window can be specified as well as a list of policies and how to select amongst them. Policies can limit the absolute number of pods added or removed, or the percentage of pods added or removed. ([#74525](https://github.com/kubernetes/kubernetes/pull/74525), [@gliush](https://github.com/gliush)) [SIG API Machinery, Apps, Autoscaling and CLI]
67+
- Ingress:
68+
- `spec.ingressClassName` replaces the deprecated `kubernetes.io/ingress.class` annotation, and allows associating an Ingress object with a particular controller.
69+
- path definitions added a `pathType` field to allow indicating how the specified path should be matched against incoming requests. Valid values are `Exact`, `Prefix`, and `ImplementationSpecific` ([#88587](https://github.com/kubernetes/kubernetes/pull/88587), [@cmluciano](https://github.com/cmluciano)) [SIG Apps, Cluster Lifecycle and Network]
70+
- The alpha feature `AnyVolumeDataSource` enables PersistentVolumeClaim objects to use the spec.dataSource field to reference a custom type as a data source ([#88636](https://github.com/kubernetes/kubernetes/pull/88636), [@bswartz](https://github.com/bswartz)) [SIG Apps and Storage]
71+
- The alpha feature `ConfigurableFSGroupPolicy` enables v1 Pods to specify a spec.securityContext.fsGroupChangePolicy policy to control how file permissions are applied to volumes mounted into the pod. ([#88488](https://github.com/kubernetes/kubernetes/pull/88488), [@gnufied](https://github.com/gnufied)) [SIG Storage]
72+
- The alpha feature `ServiceAppProtocol` enables setting an `appProtocol` field in ServicePort and EndpointPort definitions. ([#88503](https://github.com/kubernetes/kubernetes/pull/88503), [@robscott](https://github.com/robscott)) [SIG Apps and Network]
73+
- The alpha feature `ImmutableEphemeralVolumes` enables an `immutable` field in both Secret and ConfigMap objects to mark their contents as immutable. ([#86377](https://github.com/kubernetes/kubernetes/pull/86377), [@wojtek-t](https://github.com/wojtek-t)) [SIG Apps, CLI and Testing]
74+
- The beta feature `ServerSideApply` enables tracking and managing changed fields for all new objects, which means there will be `managedFields` in `metadata` with the list of managers and their owned fields.
75+
- The alpha feature `ServiceAccountIssuerDiscovery` enables publishing OIDC discovery information and service account token verification keys at `/.well-known/openid-configuration` and `/openid/v1/jwks` endpoints by API servers configured to issue service account tokens. ([#80724](https://github.com/kubernetes/kubernetes/pull/80724), [@cceckman](https://github.com/cceckman)) [SIG API Machinery, Auth, Cluster Lifecycle and Testing]
76+
- CustomResourceDefinition schemas that use `x-kubernetes-list-map-keys` to specify properties that uniquely identify list items must make those properties required or have a default value, to ensure those properties are present for all list items. See https://kubernetes.io/docs/reference/using-api/api-concepts/#merge-strategy for details. ([#88076](https://github.com/kubernetes/kubernetes/pull/88076), [@eloyekunle](https://github.com/eloyekunle)) [SIG API Machinery and Testing]
77+
- CustomResourceDefinition schemas that use `x-kubernetes-list-type: map` or `x-kubernetes-list-type: set` now enable validation that the list items in the corresponding custom resources are unique. ([#84920](https://github.com/kubernetes/kubernetes/pull/84920), [@sttts](https://github.com/sttts)) [SIG API Machinery]
78+
79+
80+
To read the full CHANGELOG visit [here](https://raw.githubusercontent.com/kubernetes/kubernetes/master/CHANGELOG/CHANGELOG-1.18.md).
81+
1982
# v17.14.0a1
2083

2184
Kubernetes API Version: 1.17.14

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ supported versions of Kubernetes clusters.
8787
- [client 11.y.z](https://pypi.org/project/kubernetes/11.0.0/): Kubernetes 1.14 or below (+-), Kubernetes 1.15 (✓), Kubernetes 1.16 or above (+-)
8888
- [client 12.y.z](https://pypi.org/project/kubernetes/12.0.1/): Kubernetes 1.15 or below (+-), Kubernetes 1.16 (✓), Kubernetes 1.17 or above (+-)
8989
- [client 17.y.z](https://pypi.org/project/kubernetes/17.14.0a1/): Kubernetes 1.16 or below (+-), Kubernetes 1.17 (✓), Kubernetes 1.18 or above (+-)
90+
- [client 18.y.z](https://pypi.org/project/kubernetes/18.17.0a1/): Kubernetes 1.17 or below (+-), Kubernetes 1.18 (✓), Kubernetes 1.19 or above (+-)
9091

9192
> See [here](#homogenizing-the-kubernetes-python-client-versions) for an explaination of why there is no v13-v16 release.
9293
@@ -124,6 +125,7 @@ between client-python versions.
124125
| 12.0 Alpha/Beta | Kubernetes main repo, 1.16 branch ||
125126
| 12.0 | Kubernetes main repo, 1.16 branch ||
126127
| 17.0 Alpha/Beta | Kubernetes main repo, 1.17 branch ||
128+
| 18.0 Alpha/Beta | Kubernetes main repo, 1.18 branch ||
127129

128130
> See [here](#homogenizing-the-kubernetes-python-client-versions) for an explaination of why there is no v13-v16 release.
129131
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
# Copyright 2021 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
This example demonstrates the following:
17+
- Creation of a custom resource definition (CRD) using dynamic-client
18+
- Creation of cluster scoped custom resources (CR) using the above created CRD
19+
- List, patch (update), delete the custom resources
20+
- Delete the custom resource defintion (CRD)
21+
"""
22+
23+
from kubernetes import config, dynamic
24+
from kubernetes.dynamic.exceptions import ResourceNotFoundError
25+
from kubernetes.client import api_client
26+
import time
27+
28+
29+
def main():
30+
# Creating a dynamic client
31+
client = dynamic.DynamicClient(
32+
api_client.ApiClient(configuration=config.load_kube_config())
33+
)
34+
35+
# fetching the custom resource definition (CRD) api
36+
crd_api = client.resources.get(
37+
api_version="apiextensions.k8s.io/v1", kind="CustomResourceDefinition"
38+
)
39+
40+
# Creating a Namespaced CRD named "ingressroutes.apps.example.com"
41+
name = "ingressroutes.apps.example.com"
42+
43+
crd_manifest = {
44+
"apiVersion": "apiextensions.k8s.io/v1",
45+
"kind": "CustomResourceDefinition",
46+
"metadata": {
47+
"name": name,
48+
},
49+
"spec": {
50+
"group": "apps.example.com",
51+
"versions": [
52+
{
53+
"name": "v1",
54+
"schema": {
55+
"openAPIV3Schema": {
56+
"properties": {
57+
"spec": {
58+
"properties": {
59+
"strategy": {"type": "string"},
60+
"virtualhost": {
61+
"properties": {
62+
"fqdn": {"type": "string"},
63+
"tls": {
64+
"properties": {
65+
"secretName": {"type": "string"}
66+
},
67+
"type": "object",
68+
},
69+
},
70+
"type": "object",
71+
},
72+
},
73+
"type": "object",
74+
}
75+
},
76+
"type": "object",
77+
}
78+
},
79+
"served": True,
80+
"storage": True,
81+
}
82+
],
83+
"scope": "Cluster",
84+
"names": {
85+
"plural": "ingressroutes",
86+
"listKind": "IngressRouteList",
87+
"singular": "ingressroute",
88+
"kind": "IngressRoute",
89+
"shortNames": ["ir"],
90+
},
91+
},
92+
}
93+
94+
crd_creation_response = crd_api.create(crd_manifest)
95+
print(
96+
"\n[INFO] custom resource definition `ingressroutes.apps.example.com` created\n"
97+
)
98+
print("%s\t\t%s" % ("SCOPE", "NAME"))
99+
print(
100+
"%s\t\t%s\n"
101+
% (crd_creation_response.spec.scope, crd_creation_response.metadata.name)
102+
)
103+
104+
# Fetching the "ingressroutes" CRD api
105+
106+
try:
107+
ingressroute_api = client.resources.get(
108+
api_version="apps.example.com/v1", kind="IngressRoute"
109+
)
110+
except ResourceNotFoundError:
111+
# Need to wait a sec for the discovery layer to get updated
112+
time.sleep(2)
113+
114+
ingressroute_api = client.resources.get(
115+
api_version="apps.example.com/v1", kind="IngressRoute"
116+
)
117+
118+
# Creating a custom resource (CR) `ingress-route-*`, using the above CRD `ingressroutes.apps.example.com`
119+
120+
ingressroute_manifest_first = {
121+
"apiVersion": "apps.example.com/v1",
122+
"kind": "IngressRoute",
123+
"metadata": {
124+
"name": "ingress-route-first",
125+
},
126+
"spec": {
127+
"virtualhost": {
128+
"fqdn": "www.google.com",
129+
"tls": {"secretName": "google-tls"},
130+
},
131+
"strategy": "RoundRobin",
132+
},
133+
}
134+
135+
ingressroute_manifest_second = {
136+
"apiVersion": "apps.example.com/v1",
137+
"kind": "IngressRoute",
138+
"metadata": {
139+
"name": "ingress-route-second",
140+
},
141+
"spec": {
142+
"virtualhost": {
143+
"fqdn": "www.yahoo.com",
144+
"tls": {"secretName": "yahoo-tls"},
145+
},
146+
"strategy": "RoundRobin",
147+
},
148+
}
149+
150+
ingressroute_api.create(body=ingressroute_manifest_first)
151+
ingressroute_api.create(body=ingressroute_manifest_second)
152+
print("\n[INFO] custom resources `ingress-route-*` created\n")
153+
154+
# Listing the `ingress-route-*` custom resources
155+
156+
ingress_routes_list = ingressroute_api.get()
157+
print("%s\t\t\t%s\t\t%s\t\t\t\t%s" % ("NAME", "FQDN", "TLS", "STRATEGY"))
158+
for item in ingress_routes_list.items:
159+
print(
160+
"%s\t%s\t%s\t%s"
161+
% (
162+
item.metadata.name,
163+
item.spec.virtualhost.fqdn,
164+
item.spec.virtualhost.tls,
165+
item.spec.strategy,
166+
)
167+
)
168+
169+
# Patching the ingressroutes custom resources
170+
171+
ingressroute_manifest_first["spec"]["strategy"] = "Random"
172+
ingressroute_manifest_second["spec"]["strategy"] = "WeightedLeastRequest"
173+
174+
patch_ingressroute_first = ingressroute_api.patch(
175+
body=ingressroute_manifest_first, content_type="application/merge-patch+json"
176+
)
177+
patch_ingressroute_second = ingressroute_api.patch(
178+
body=ingressroute_manifest_second, content_type="application/merge-patch+json"
179+
)
180+
181+
print(
182+
"\n[INFO] custom resources `ingress-route-*` patched to update the strategy\n"
183+
)
184+
patched_ingress_routes_list = ingressroute_api.get()
185+
print("%s\t\t\t%s\t\t%s\t\t\t\t%s" % ("NAME", "FQDN", "TLS", "STRATEGY"))
186+
for item in patched_ingress_routes_list.items:
187+
print(
188+
"%s\t%s\t%s\t%s"
189+
% (
190+
item.metadata.name,
191+
item.spec.virtualhost.fqdn,
192+
item.spec.virtualhost.tls,
193+
item.spec.strategy,
194+
)
195+
)
196+
197+
# Deleting the ingressroutes custom resources
198+
199+
delete_ingressroute_first = ingressroute_api.delete(name="ingress-route-first")
200+
delete_ingressroute_second = ingressroute_api.delete(name="ingress-route-second")
201+
202+
print("\n[INFO] custom resources `ingress-route-*` deleted")
203+
204+
# Deleting the ingressroutes.apps.example.com custom resource definition
205+
206+
crd_api.delete(name=name)
207+
print(
208+
"\n[INFO] custom resource definition `ingressroutes.apps.example.com` deleted"
209+
)
210+
211+
212+
if __name__ == "__main__":
213+
main()

0 commit comments

Comments
 (0)