-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed as not planned
Labels
kind/featureCategorizes issue or PR as related to a new feature.Categorizes issue or PR as related to a new feature.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Description
What is the feature and why do you need it:
Can 'DynamicClient' support 'apply'?
Describe the solution you'd like to see:
While I try https://github.com/kubernetes-client/python/blob/master/examples/dynamic-client/service.py example,I replace .create to .apply and except this can create if not exist or patch(like kubectl apply), but I got
AttributeError: 'DynamicClient' object has no attribute 'applyhow could I use apply?
my code
from kubernetes import config, dynamic
from kubernetes.client import api_client
def main():
client = dynamic.DynamicClient(
api_client.ApiClient(configuration=config.load_kube_config())
)
api = client.resources.get(api_version="v1", kind="Service")
name = "frontend-service"
service_manifest = {
"apiVersion": "v1",
"kind": "Service",
"metadata": {"labels": {"name": name}, "name": name, "resourceversion": "v1"},
"spec": {
"ports": [
{"name": "port", "port": 80, "protocol": "TCP", "targetPort": 80}
],
"selector": {"name": name},
},
}
service = api.apply(body=service_manifest, namespace="default")
if __name__ == "__main__":
main()Metadata
Metadata
Assignees
Labels
kind/featureCategorizes issue or PR as related to a new feature.Categorizes issue or PR as related to a new feature.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.Denotes an issue or PR that has aged beyond stale and will be auto-closed.