-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Release 17.0 #1458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Release 17.0 #1458
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
7bc9f78
examples: comment improvement in remote_cluster.py and deployment_cre…
jonasdlindner 553f6ae
add-dynamic-client-examples
Priyankasaggu11929 83f92cc
add example to demonstrate a rolling restart of the deployment
Priyankasaggu11929 251a1b3
Merge pull request #1450 from Priyankasaggu11929/psaggu-deployment-ro…
k8s-ci-robot abb2a6e
update CHANGELOG and README in master branch
roycaihw b13b350
Merge pull request #1451 from roycaihw/update-readme
k8s-ci-robot 1ff6ece
correct CRD's apiVersion, manifest & naming typos
Priyankasaggu11929 def8b28
Merge pull request #1448 from Priyankasaggu11929/psaggu-add-dynamic-c…
k8s-ci-robot eb952e7
add 'list_ingressroute_for_all_namespaces' method
Priyankasaggu11929 7b3e019
Merge pull request #1454 from Priyankasaggu11929/psaggu-list-ingressr…
k8s-ci-robot 682dfa2
generated python-base update
roycaihw 1f50a6b
update changelog in preparation of the v17.17.0 release
roycaihw bb7bb64
add OS X sed check to update-submodule.sh
roycaihw 88841db
Merge pull request #1455 from roycaihw/update-submodule
k8s-ci-robot 02c4f7a
Merge pull request #1456 from roycaihw/sed-check
k8s-ci-robot 468115e
refactor OS X sed check into a util
roycaihw 04e62c6
Merge pull request #1457 from roycaihw/refactor-sed-check
k8s-ci-robot f73c609
Update constants to reflect Client release 17.14.0a1
palnabarun 856b8fc
Generate client 17.14.0a1
palnabarun e74d3ba
Fix custom objects API to preserve backward compatibility
palnabarun c203601
Add kubernetes.client.apis as an alias to kubernetes.client.api
palnabarun 7574d77
Add test to ensure kubernetes client threadpool is cleaned up
fabianvf 871110c
add a test for default configuration behavior
roycaihw c293c64
Update CHANGELOG with v17.14.0a1
palnabarun b590924
Refactor the format of compatibitility matrix
palnabarun 27e3b67
Add v17.14.0a1 to the compatibility matrix
palnabarun 2afe18d
Add a note about the change in client versioning schema
palnabarun 291ee0d
changelog for pulling master and corresponding submodule changes
roycaihw bdab88a
Beta release of 1.17
scottilee 7d11149
GA release of 1.17
scottilee db33e2a
Update CHANGE and README
scottilee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
213 changes: 213 additions & 0 deletions
213
examples/dynamic-client/cluster_scoped_custom_resource.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
# Copyright 2021 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
""" | ||
This example demonstrates the following: | ||
- Creation of a custom resource definition (CRD) using dynamic-client | ||
- Creation of cluster scoped custom resources (CR) using the above created CRD | ||
- List, patch (update), delete the custom resources | ||
- Delete the custom resource defintion (CRD) | ||
""" | ||
|
||
from kubernetes import config, dynamic | ||
from kubernetes.dynamic.exceptions import ResourceNotFoundError | ||
from kubernetes.client import api_client | ||
import time | ||
|
||
|
||
def main(): | ||
# Creating a dynamic client | ||
client = dynamic.DynamicClient( | ||
api_client.ApiClient(configuration=config.load_kube_config()) | ||
) | ||
|
||
# fetching the custom resource definition (CRD) api | ||
crd_api = client.resources.get( | ||
api_version="apiextensions.k8s.io/v1", kind="CustomResourceDefinition" | ||
) | ||
|
||
# Creating a Namespaced CRD named "ingressroutes.apps.example.com" | ||
name = "ingressroutes.apps.example.com" | ||
|
||
crd_manifest = { | ||
"apiVersion": "apiextensions.k8s.io/v1", | ||
"kind": "CustomResourceDefinition", | ||
"metadata": { | ||
"name": name, | ||
}, | ||
"spec": { | ||
"group": "apps.example.com", | ||
"versions": [ | ||
{ | ||
"name": "v1", | ||
"schema": { | ||
"openAPIV3Schema": { | ||
"properties": { | ||
"spec": { | ||
"properties": { | ||
"strategy": {"type": "string"}, | ||
"virtualhost": { | ||
"properties": { | ||
"fqdn": {"type": "string"}, | ||
"tls": { | ||
"properties": { | ||
"secretName": {"type": "string"} | ||
}, | ||
"type": "object", | ||
}, | ||
}, | ||
"type": "object", | ||
}, | ||
}, | ||
"type": "object", | ||
} | ||
}, | ||
"type": "object", | ||
} | ||
}, | ||
"served": True, | ||
"storage": True, | ||
} | ||
], | ||
"scope": "Cluster", | ||
"names": { | ||
"plural": "ingressroutes", | ||
"listKind": "IngressRouteList", | ||
"singular": "ingressroute", | ||
"kind": "IngressRoute", | ||
"shortNames": ["ir"], | ||
}, | ||
}, | ||
} | ||
|
||
crd_creation_response = crd_api.create(crd_manifest) | ||
print( | ||
"\n[INFO] custom resource definition `ingressroutes.apps.example.com` created\n" | ||
) | ||
print("%s\t\t%s" % ("SCOPE", "NAME")) | ||
print( | ||
"%s\t\t%s\n" | ||
% (crd_creation_response.spec.scope, crd_creation_response.metadata.name) | ||
) | ||
|
||
# Fetching the "ingressroutes" CRD api | ||
|
||
try: | ||
ingressroute_api = client.resources.get( | ||
api_version="apps.example.com/v1", kind="IngressRoute" | ||
) | ||
except ResourceNotFoundError: | ||
# Need to wait a sec for the discovery layer to get updated | ||
time.sleep(2) | ||
|
||
ingressroute_api = client.resources.get( | ||
api_version="apps.example.com/v1", kind="IngressRoute" | ||
) | ||
|
||
# Creating a custom resource (CR) `ingress-route-*`, using the above CRD `ingressroutes.apps.example.com` | ||
|
||
ingressroute_manifest_first = { | ||
"apiVersion": "apps.example.com/v1", | ||
"kind": "IngressRoute", | ||
"metadata": { | ||
"name": "ingress-route-first", | ||
}, | ||
"spec": { | ||
"virtualhost": { | ||
"fqdn": "www.google.com", | ||
"tls": {"secretName": "google-tls"}, | ||
}, | ||
"strategy": "RoundRobin", | ||
}, | ||
} | ||
|
||
ingressroute_manifest_second = { | ||
"apiVersion": "apps.example.com/v1", | ||
"kind": "IngressRoute", | ||
"metadata": { | ||
"name": "ingress-route-second", | ||
}, | ||
"spec": { | ||
"virtualhost": { | ||
"fqdn": "www.yahoo.com", | ||
"tls": {"secretName": "yahoo-tls"}, | ||
}, | ||
"strategy": "RoundRobin", | ||
}, | ||
} | ||
|
||
ingressroute_api.create(body=ingressroute_manifest_first) | ||
ingressroute_api.create(body=ingressroute_manifest_second) | ||
print("\n[INFO] custom resources `ingress-route-*` created\n") | ||
|
||
# Listing the `ingress-route-*` custom resources | ||
|
||
ingress_routes_list = ingressroute_api.get() | ||
print("%s\t\t\t%s\t\t%s\t\t\t\t%s" % ("NAME", "FQDN", "TLS", "STRATEGY")) | ||
for item in ingress_routes_list.items: | ||
print( | ||
"%s\t%s\t%s\t%s" | ||
% ( | ||
item.metadata.name, | ||
item.spec.virtualhost.fqdn, | ||
item.spec.virtualhost.tls, | ||
item.spec.strategy, | ||
) | ||
) | ||
|
||
# Patching the ingressroutes custom resources | ||
|
||
ingressroute_manifest_first["spec"]["strategy"] = "Random" | ||
ingressroute_manifest_second["spec"]["strategy"] = "WeightedLeastRequest" | ||
|
||
patch_ingressroute_first = ingressroute_api.patch( | ||
body=ingressroute_manifest_first, content_type="application/merge-patch+json" | ||
) | ||
patch_ingressroute_second = ingressroute_api.patch( | ||
body=ingressroute_manifest_second, content_type="application/merge-patch+json" | ||
) | ||
|
||
print( | ||
"\n[INFO] custom resources `ingress-route-*` patched to update the strategy\n" | ||
) | ||
patched_ingress_routes_list = ingressroute_api.get() | ||
print("%s\t\t\t%s\t\t%s\t\t\t\t%s" % ("NAME", "FQDN", "TLS", "STRATEGY")) | ||
for item in patched_ingress_routes_list.items: | ||
print( | ||
"%s\t%s\t%s\t%s" | ||
% ( | ||
item.metadata.name, | ||
item.spec.virtualhost.fqdn, | ||
item.spec.virtualhost.tls, | ||
item.spec.strategy, | ||
) | ||
) | ||
|
||
# Deleting the ingressroutes custom resources | ||
|
||
delete_ingressroute_first = ingressroute_api.delete(name="ingress-route-first") | ||
delete_ingressroute_second = ingressroute_api.delete(name="ingress-route-second") | ||
|
||
print("\n[INFO] custom resources `ingress-route-*` deleted") | ||
|
||
# Deleting the ingressroutes.apps.example.com custom resource definition | ||
|
||
crd_api.delete(name=name) | ||
print( | ||
"\n[INFO] custom resource definition `ingressroutes.apps.example.com` deleted" | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# Copyright 2021 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
""" | ||
This example demonstrates the following: | ||
- Creation of a k8s configmap using dynamic-client | ||
- List, patch(update), delete the configmap | ||
""" | ||
|
||
from kubernetes import config, dynamic | ||
from kubernetes.client import api_client | ||
|
||
|
||
def main(): | ||
# Creating a dynamic client | ||
client = dynamic.DynamicClient( | ||
api_client.ApiClient(configuration=config.load_kube_config()) | ||
) | ||
|
||
# fetching the configmap api | ||
api = client.resources.get(api_version="v1", kind="ConfigMap") | ||
|
||
configmap_name = "test-configmap" | ||
|
||
configmap_manifest = { | ||
"kind": "ConfigMap", | ||
"apiVersion": "v1", | ||
"metadata": { | ||
"name": configmap_name, | ||
"labels": { | ||
"foo": "bar", | ||
}, | ||
}, | ||
"data": { | ||
"config.json": '{"command":"/usr/bin/mysqld_safe"}', | ||
"frontend.cnf": "[mysqld]\nbind-address = 10.0.0.3\n", | ||
}, | ||
} | ||
|
||
# Creating configmap `test-configmap` in the `default` namespace | ||
|
||
configmap = api.create(body=configmap_manifest, namespace="default") | ||
|
||
print("\n[INFO] configmap `test-configmap` created\n") | ||
|
||
# Listing the configmaps in the `default` namespace | ||
|
||
configmap_list = api.get( | ||
name=configmap_name, namespace="default", label_selector="foo=bar" | ||
) | ||
|
||
print("NAME:\n%s\n" % (configmap_list.metadata.name)) | ||
print("DATA:\n%s\n" % (configmap_list.data)) | ||
|
||
# Updating the configmap's data, `config.json` | ||
|
||
configmap_manifest["data"]["config.json"] = "{}" | ||
|
||
configmap_patched = api.patch( | ||
name=configmap_name, namespace="default", body=configmap_manifest | ||
) | ||
|
||
print("\n[INFO] configmap `test-configmap` patched\n") | ||
print("NAME:\n%s\n" % (configmap_patched.metadata.name)) | ||
print("DATA:\n%s\n" % (configmap_patched.data)) | ||
|
||
# Deleting configmap `test-configmap` from the `default` namespace | ||
|
||
configmap_deleted = api.delete(name=configmap_name, body={}, namespace="default") | ||
print("\n[INFO] configmap `test-configmap` deleted\n") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.