-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Automated release of 24.0.0 snapshot upstream master 1661179298 #1882
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
asmacdo
wants to merge
41
commits into
kubernetes-client:release-24.0
from
asmacdo:automated-release-of-24.0.0-snapshot-upstream-master-1661179298
Closed
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
7d0cd17
It turns out SSL sockets can buffer data such that the select method …
iciclespider f1dfdbb
used unittest.mock instead of mock
harshitasao 5645c57
add a cronjob crud example
xg0719 63b2250
update changelog
yliaog 7dfd36b
added compatibility for 1.24.1
yliaog c76f0df
Merge pull request #1785 from iciclespider/fix-port-forward-hang
k8s-ci-robot 768f520
Merge pull request #1820 from yliaog/master
k8s-ci-robot 0724d16
Bump actions/setup-python from 3 to 4
dependabot[bot] 1f59210
update changelog with release notes from master branch
yliaog 0227abe
Merge pull request #1825 from kubernetes-client/dependabot/github_act…
k8s-ci-robot 46c0768
Merge pull request #1828 from yliaog/master
k8s-ci-robot 3a3e402
Bump helm/kind-action from 1.2.0 to 1.3.0
dependabot[bot] da50723
Merge pull request #1831 from kubernetes-client/dependabot/github_act…
k8s-ci-robot e0dfc6b
Add interactive configuration to exec provider.
brendandburns 9c79d2b
Revert "Add interactive configuration to exec provider."
brendandburns c9ad883
Add interactive configuration to exec provider.
brendandburns f17a26a
update changelog with release notes from master branch
yliaog d963980
added compatibility matrix for 1.24.2 release.
yliaog 0986337
Merge pull request #1839 from yliaog/master
k8s-ci-robot cc03f4e
example annotate deployment
showjason 3165e80
Merge pull request #1843 from showjason/annotate-deployment
k8s-ci-robot 13c4c76
Check availability of poll method before using
Akasurde 2677e9c
Merge pull request #1848 from Akasurde/i1753
k8s-ci-robot 5529ded
Fix DynamicClient.server_side_apply
kariya-mitsuru f412089
Merge branch 'kubernetes-client:master' into master
xg0719 7d40da7
add a cronjob crud example
xg0719 e8a10b1
Merge pull request #1850 from kariya-mitsuru/fix-server-side-apply
k8s-ci-robot ab58e5c
Merge branch 'kubernetes-client:master' into master
xg0719 51badbc
Add 'usedforsecurity=False' parameter to md5 call
efussi d593fc6
change BatchV1beta1Api to BatchV1Api
xg0719 64a1086
Merge pull request #1833 from brendandburns/master
k8s-ci-robot 2c5f775
Merge pull request #1854 from efussi/master
k8s-ci-robot 5195b65
Merge branch 'kubernetes-client:master' into master
xg0719 74e8516
Merge pull request #1852 from xg0719/master
k8s-ci-robot 9742e7a
Deploy docs as wiki
Rishit-dagli 0553bba
Merge pull request #1860 from Rishit-dagli/Rishit-dagli-wiki
k8s-ci-robot e5ca5ae
fix issue #1782 Resolve load_kube_config TMP file issue
tobewithyou1996 17372b7
Remove duplicate
akfmdl 1ea41ec
Merge pull request #1874 from akfmdl/Feat/remove-duplicate-comments
k8s-ci-robot ada96fa
Merge pull request #1871 from tobewithyou1996/master
k8s-ci-robot e3c0042
Merge pull request #1804 from harshitasao/issue-1790
k8s-ci-robot 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Deploy Wiki | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'kubernetes/docs/**' | ||
branches: | ||
- master | ||
|
||
jobs: | ||
deploy-wiki: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
- name: Install rsync | ||
run: | | ||
sudo apt install rsync grsync | ||
- name: Clone Wiki | ||
run: | | ||
git config --global --add safe.directory "/github/workspace" | ||
git config --global --add safe.directory "/github/workspace/wiki" | ||
git clone https://github.com/kubernetes-client/python.wiki.git wiki | ||
message=$(git log -1 --format=%B) | ||
- name: Copy to wiki repository | ||
run: | | ||
rsync -av --delete kubernetes/docs/ wiki/ --exclude .git | ||
- name: Push wiki | ||
run: | | ||
cd wiki | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add . | ||
git commit -m "$message" | ||
git push | ||
|
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
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
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
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
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,88 @@ | ||
""" | ||
This example covers the following: | ||
- Create deployment | ||
- Annotate deployment | ||
""" | ||
|
||
|
||
from kubernetes import client, config | ||
import time | ||
|
||
|
||
def create_deployment_object(): | ||
container = client.V1Container( | ||
name="nginx-sample", | ||
image="nginx", | ||
image_pull_policy="IfNotPresent", | ||
ports=[client.V1ContainerPort(container_port=80)], | ||
) | ||
# Template | ||
template = client.V1PodTemplateSpec( | ||
metadata=client.V1ObjectMeta(labels={"app": "nginx"}), | ||
spec=client.V1PodSpec(containers=[container])) | ||
# Spec | ||
spec = client.V1DeploymentSpec( | ||
replicas=1, | ||
selector=client.V1LabelSelector( | ||
match_labels={"app": "nginx"} | ||
), | ||
template=template) | ||
# Deployment | ||
deployment = client.V1Deployment( | ||
api_version="apps/v1", | ||
kind="Deployment", | ||
metadata=client.V1ObjectMeta(name="deploy-nginx"), | ||
spec=spec) | ||
|
||
return deployment | ||
|
||
|
||
def create_deployment(apps_v1_api, deployment_object): | ||
# Create the Deployment in default namespace | ||
# You can replace the namespace with you have created | ||
apps_v1_api.create_namespaced_deployment( | ||
namespace="default", body=deployment_object | ||
) | ||
|
||
|
||
def annotate_deployment(apps_v1_api, deployment_name, annotations): | ||
# Annotate the Deployment in default namespace | ||
# You can replace the namespace with you have created | ||
apps_v1_api.patch_namespaced_deployment( | ||
name=deployment_name, namespace='default', body=annotations) | ||
|
||
|
||
def main(): | ||
# Loading the local kubeconfig | ||
config.load_kube_config() | ||
apps_v1_api = client.AppsV1Api() | ||
deployment_obj = create_deployment_object() | ||
|
||
create_deployment(apps_v1_api, deployment_obj) | ||
time.sleep(1) | ||
before_annotating = apps_v1_api.read_namespaced_deployment( | ||
'deploy-nginx', 'default') | ||
print('Before annotating, annotations: %s' % | ||
before_annotating.metadata.annotations) | ||
|
||
annotations = [ | ||
{ | ||
'op': 'add', # You can try different operations like 'replace', 'add' and 'remove' | ||
'path': '/metadata/annotations', | ||
'value': { | ||
'deployment.kubernetes.io/str': 'nginx', | ||
'deployment.kubernetes.io/int': '5' | ||
} | ||
} | ||
] | ||
|
||
annotate_deployment(apps_v1_api, 'deploy-nginx', annotations) | ||
time.sleep(1) | ||
after_annotating = apps_v1_api.read_namespaced_deployment( | ||
name='deploy-nginx', namespace='default') | ||
print('After annotating, annotations: %s' % | ||
after_annotating.metadata.annotations) | ||
|
||
|
||
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,128 @@ | ||
#!/usr/bin/python3 | ||
# -*- coding:utf-8 -*- | ||
|
||
import json | ||
import time | ||
|
||
from kubernetes import client, config | ||
|
||
config.load_kube_config() | ||
|
||
|
||
def create_namespaced_cron_job(namespace='default', body=None): | ||
cronjob_json = body | ||
if body is None: | ||
print('body is required!') | ||
exit(0) | ||
name = body['metadata']['name'] | ||
if judge_crontab_exists(namespace, name): | ||
print(f'{name} exists, please do not repeat!') | ||
else: | ||
v1 = client.BatchV1Api() | ||
ret = v1.create_namespaced_cron_job(namespace=namespace, body=cronjob_json, pretty=True, | ||
_preload_content=False, async_req=False) | ||
ret_dict = json.loads(ret.data) | ||
print(f'create succeed\n{json.dumps(ret_dict)}') | ||
|
||
|
||
def delete_namespaced_cron_job(namespace='default', name=None): | ||
if name is None: | ||
print('name is required!') | ||
exit(0) | ||
if not judge_crontab_exists(namespace, name): | ||
print(f"{name} doesn't exists, please enter a new one!") | ||
else: | ||
v1 = client.BatchV1Api() | ||
ret = v1.delete_namespaced_cron_job(name=name, namespace=namespace, _preload_content=False, async_req=False) | ||
ret_dict = json.loads(ret.data) | ||
print(f'delete succeed\n{json.dumps(ret_dict)}') | ||
|
||
|
||
def patch_namespaced_cron_job(namespace='default', body=None): | ||
cronjob_json = body | ||
if body is None: | ||
print('body is required!') | ||
exit(0) | ||
name = body['metadata']['name'] | ||
if judge_crontab_exists(namespace, name): | ||
v1 = client.BatchV1Api() | ||
ret = v1.patch_namespaced_cron_job(name=name, namespace=namespace, body=cronjob_json, | ||
_preload_content=False, async_req=False) | ||
ret_dict = json.loads(ret.data) | ||
print(f'patch succeed\n{json.dumps(ret_dict)}') | ||
else: | ||
print(f"{name} doesn't exists, please enter a new one!") | ||
|
||
|
||
def get_cronjob_list(namespace='default'): | ||
v1 = client.BatchV1Api() | ||
ret = v1.list_namespaced_cron_job(namespace=namespace, pretty=True, _preload_content=False) | ||
cron_job_list = json.loads(ret.data) | ||
print(f'cronjob number={len(cron_job_list["items"])}') | ||
return cron_job_list["items"] | ||
|
||
|
||
def judge_crontab_exists(namespace, name): | ||
cron_job_list = get_cronjob_list(namespace) | ||
for cron_job in cron_job_list: | ||
if name == cron_job['metadata']['name']: | ||
return True | ||
return False | ||
|
||
|
||
def get_cronjob_body(namespace, name, command): | ||
body = { | ||
"apiVersion": "batch/v1", | ||
"kind": "CronJob", | ||
"metadata": { | ||
"name": name, | ||
"namespace": namespace | ||
}, | ||
"spec": { | ||
"schedule": "*/1 * * * *", | ||
"concurrencyPolicy": "Allow", | ||
"suspend": False, | ||
"jobTemplate": { | ||
"spec": { | ||
"template": { | ||
"spec": { | ||
"containers": [ | ||
{ | ||
"name": name, | ||
"image": "busybox:1.35", | ||
"command": command | ||
} | ||
], | ||
"restartPolicy": "Never" | ||
} | ||
} | ||
} | ||
}, | ||
"successfulJobsHistoryLimit": 3, | ||
"failedJobsHistoryLimit": 1 | ||
} | ||
} | ||
return body | ||
|
||
|
||
if __name__ == '__main__': | ||
# get | ||
cronjob_list = get_cronjob_list() | ||
|
||
# delete | ||
delete_namespaced_cron_job('default', 'hostname') | ||
time.sleep(2) | ||
|
||
# create | ||
container_command = [ | ||
"/bin/sh", | ||
"-c", | ||
"date; echo Hello from the Kubernetes cluster; hostname" | ||
] | ||
hostname_json = get_cronjob_body('default', 'hostname', container_command) | ||
create_namespaced_cron_job('default', hostname_json) | ||
|
||
# update | ||
container_command[2] = "date; echo this is patch; hostname" | ||
hostname_json = get_cronjob_body('default', 'hostname', container_command) | ||
patch_namespaced_cron_job('default', hostname_json) |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will have a v25 client soon as Kubernetes 1.25 gets released. Do you think you can wait for that instead of having a patch release to v24?
cc @yliaog