Skip to content
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

Change examples/dynamic-client creation of DynamicClient to include configuration object that is not None #2283

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions examples/dynamic-client/accept_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@

def main():
# Creating a dynamic client
client = dynamic.DynamicClient(
api_client.ApiClient(configuration=config.load_kube_config())
)
configuration = api_client.Configuration()
config.load_kube_config()
client = api_client.ApiClient(configuration=configuration)
dynamic_client = dynamic.DynamicClient(client)


# fetching the node api
api = client.resources.get(api_version="v1", kind="Node")
api = dynamic_client.resources.get(api_version="v1", kind="Node")

# Creating a custom header
params = {'header_params': {'Accept': 'application/json;as=PartialObjectMetadataList;v=v1;g=meta.k8s.io'}}
Expand Down
13 changes: 7 additions & 6 deletions examples/dynamic-client/cluster_scoped_custom_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@

def main():
# Creating a dynamic client
client = dynamic.DynamicClient(
api_client.ApiClient(configuration=config.load_kube_config())
)
configuration = api_client.Configuration()
config.load_kube_config()
client = api_client.ApiClient(configuration=configuration)
dynamic_client = dynamic.DynamicClient(client)

# fetching the custom resource definition (CRD) api
crd_api = client.resources.get(
crd_api = dynamic_client.resources.get(
api_version="apiextensions.k8s.io/v1", kind="CustomResourceDefinition"
)

Expand Down Expand Up @@ -104,14 +105,14 @@ def main():
# Fetching the "ingressroutes" CRD api

try:
ingressroute_api = client.resources.get(
ingressroute_api = dynamic_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(
ingressroute_api = dynamic_client.resources.get(
api_version="apps.example.com/v1", kind="IngressRoute"
)

Expand Down
9 changes: 5 additions & 4 deletions examples/dynamic-client/configmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@

def main():
# Creating a dynamic client
client = dynamic.DynamicClient(
api_client.ApiClient(configuration=config.load_kube_config())
)
configuration = api_client.Configuration()
config.load_kube_config()
client = api_client.ApiClient(configuration=configuration)
dynamic_client = dynamic.DynamicClient(client)

# fetching the configmap api
api = client.resources.get(api_version="v1", kind="ConfigMap")
api = dynamic_client.resources.get(api_version="v1", kind="ConfigMap")

configmap_name = "test-configmap"

Expand Down
9 changes: 5 additions & 4 deletions examples/dynamic-client/deployment_rolling_restart.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@

def main():
# Creating a dynamic client
client = dynamic.DynamicClient(
api_client.ApiClient(configuration=config.load_kube_config())
)
configuration = api_client.Configuration()
config.load_kube_config()
client = api_client.ApiClient(configuration=configuration)
dynamic_client = dynamic.DynamicClient(client)

# fetching the deployment api
api = client.resources.get(api_version="apps/v1", kind="Deployment")
api = dynamic_client.resources.get(api_version="apps/v1", kind="Deployment")

name = "nginx-deployment"

Expand Down
9 changes: 5 additions & 4 deletions examples/dynamic-client/namespaced_custom_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,13 @@ def delete_namespace(namespace_api, name):

def main():
# Creating a dynamic client
client = dynamic.DynamicClient(
api_client.ApiClient(configuration=config.load_kube_config())
)
configuration = api_client.Configuration()
config.load_kube_config()
client = api_client.ApiClient(configuration=configuration)
dynamic_client = dynamic.DynamicClient(client)

# fetching the custom resource definition (CRD) api
crd_api = client.resources.get(
crd_api = dynamic_client.resources.get(
api_version="apiextensions.k8s.io/v1", kind="CustomResourceDefinition"
)

Expand Down
10 changes: 6 additions & 4 deletions examples/dynamic-client/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@

def main():
# Creating a dynamic client
client = dynamic.DynamicClient(
api_client.ApiClient(configuration=config.load_kube_config())
)

configuration = api_client.Configuration()
config.load_kube_config()
client = api_client.ApiClient(configuration=configuration)
dynamic_client = dynamic.DynamicClient(client)

# fetching the node api
api = client.resources.get(api_version="v1", kind="Node")
api = dynamic_client.resources.get(api_version="v1", kind="Node")

# Listing cluster nodes

Expand Down
9 changes: 5 additions & 4 deletions examples/dynamic-client/replication_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@

def main():
# Creating a dynamic client
client = dynamic.DynamicClient(
api_client.ApiClient(configuration=config.load_kube_config())
)
configuration = api_client.Configuration()
config.load_kube_config()
client = api_client.ApiClient(configuration=configuration)
dynamic_client = dynamic.DynamicClient(client)

# fetching the replication controller api
api = client.resources.get(api_version="v1", kind="ReplicationController")
api = dynamic_client.resources.get(api_version="v1", kind="ReplicationController")

name = "frontend-replication-controller"

Expand Down
9 changes: 5 additions & 4 deletions examples/dynamic-client/request_timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@

def main():
# Creating a dynamic client
client = dynamic.DynamicClient(
api_client.ApiClient(configuration=config.load_kube_config())
)
configuration = api_client.Configuration()
config.load_kube_config()
client = api_client.ApiClient(configuration=configuration)
dynamic_client = dynamic.DynamicClient(client)

# fetching the configmap api
api = client.resources.get(api_version="v1", kind="ConfigMap")
api = dynamic_client.resources.get(api_version="v1", kind="ConfigMap")

configmap_name = "request-timeout-test-configmap"

Expand Down
9 changes: 5 additions & 4 deletions examples/dynamic-client/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@

def main():
# Creating a dynamic client
client = dynamic.DynamicClient(
api_client.ApiClient(configuration=config.load_kube_config())
)
configuration = api_client.Configuration()
config.load_kube_config()
client = api_client.ApiClient(configuration=configuration)
dynamic_client = dynamic.DynamicClient(client)

# fetching the service api
api = client.resources.get(api_version="v1", kind="Service")
api = dynamic_client.resources.get(api_version="v1", kind="Service")

name = "frontend-service"

Expand Down