which kubernetes client do we need to use to deploy a YAML of "kind: NetworkPlugins"?

Viewed 65

I have installed kubernetes-19.15.0b1 pyyaml-6.0 and trying to replicate:

kubectl create -f plumber-networkplugins.yaml

using python Kubernetes client, I want to apply this YAML, I have tried both methods create_namespaced_network_plugins() and create_from_yaml(), nothing seems to work in the case of network plugins kind.

plumber-networkplugins.yaml

---
apiVersion: plumber.k8s.pf9.io/v1
kind: NetworkPlugins
metadata:
  name: networkplugins-sample11
spec:
  privateRegistryBase: "localhost:5100"
  plugins:
    hostPlumber:
      namespace: "kube-system"
    multus:
      namespace: "kube-system"
    whereabouts:
      namespace: "kube-system"
      ipReconcilerSchedule: "*/2 * * * *"
    sriov:
      namespace: "kube-system"

what I tried:

from kubernetes import client as k8_client, utils as k8_utils, config as k8_config

self.config = k8_config.load_kube_config(clusterKubeConfigFile)
self.core_v1_api = k8_client.CoreV1Api()

# k8s 1.16.0+
self.apps_v1_api = k8_client.AppsV1Api()

self.api_client = k8_client.ApiClient()

# self.networking_v1_api = k8_client.NetworkingApi()
self.networking_v1_api = k8_client.NetworkingV1Api()
# self.networking_v1_api = k8_client.NetworkingV1beta1Api()

# TRY 1 using create_from_yaml()
# k8_utils.create_from_yaml(self.apps_v1_api, self.host_plumber_yaml_file)
# k8_utils.create_from_yaml(self.api_client, self.host_plumber_yaml_file)
# k8_utils.create_from_yaml(self.networking_v1_api, self.host_plumber_yaml_file)

# TRY 2 using create_namespaced_network_plugins()
with open(self.host_plumber_yaml_file) as f:
    dep = yaml.safe_load(f)
    resp = self.networking_v1_api.create_namespaced_network_plugins(
        body=dep)
    # resp = self.api_client.create_namespaced_network_policy(
        # body=dep, namespace="kube-system")
    print("Deployment created. status='%s'" % str(resp.status))

what mistake I am doing here and which client should I use for "kind: NetworkPlugins"?

0 Answers
Related