python icon indicating copy to clipboard operation
python copied to clipboard

create_namespaced_deployment not finding deployment API version

Open fernandoarf opened this issue 3 years ago • 0 comments

What happened (please include outputs or screenshots): I am trying to generate a deployment for Seldon Core through the CLI using the AppsV1Api.create_namespaced_deployment and I get the following error:

{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"SeldonDeployment in version "v1" cannot be handled as a Deployment: no kind "SeldonDeployment" is registered for version "machinelearning.seldon.io/v1" in scheme "k8s.io/kubernetes/pkg/api/legacyscheme/scheme.go:30"","reason":"BadRequest","code":400}

When applying the exact same yaml through "kubectl apply -f" I can successfully create the deployment.

Checking the API Versions on the server I can see that the "machinelearning.seldon.io/v1" is present. image image

What you expected to happen:

Expected to have the same result as applying the yaml through kubectl

How to reproduce it (as minimally and precisely as possible):

  • Configure a Kubernetes cluster
  • Install Seldon Core (docs link)
  • Run the "create_namespaced_deployment" function with any SeldonDeployment yaml. Example bellow:
import yaml
from kubernetes import client, config

DEPLOY_SELDON=f"""
apiVersion: machinelearning.seldon.io/v1
kind: SeldonDeployment
metadata:
  name: test-mlflow
  namespace: seldon
spec:
  name: model
  predictors:
  - componentSpecs:
    - spec:
        # We are setting high failureThreshold as installing conda dependencies
        # can take long time and we want to avoid k8s killing the container prematurely
        containers:
        - name: model
          livenessProbe:
            initialDelaySeconds: 80
            failureThreshold: 200
            periodSeconds: 5
            successThreshold: 1
            httpGet:
              path: /health/ping
              port: http
              scheme: HTTP
          readinessProbe:
            initialDelaySeconds: 80
            failureThreshold: 200
            periodSeconds: 5
            successThreshold: 1
            httpGet:
              path: /health/ping
              port: http
              scheme: HTTP
    graph:
      children: []
      implementation: MLFLOW_SERVER
      modelUri: gs://seldon-models/v1.10.0-dev/mlflow/elasticnet_wine
      name: model
    name: default
    replicas: 1
    """
config.load_kube_config()
api_client = client.ApiClient(configuration)
api_instance = client.AppsV1Api(api_client)
api_instance.create_namespaced_deployment(
body=yaml.safe_load(DEPLOY_SELDON), namespace="seldon")

Anything else we need to know?: The Python CLI does not recognize the API version but the "kubectl apply" can apply the deployment without any issues

Environment:

  • Kubernetes version (kubectl version): 1.22
  • OS (e.g., MacOS 10.13.6): Ubuntu 20.04
  • Python version (python --version): 3.9.12
  • Python client version (pip list | grep kubernetes): 24.2.0

fernandoarf avatar Sep 22 '22 18:09 fernandoarf