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

Unable to determine type when creating Ingress resource (apiVersion==networking.k8s.io/v1) #218

Open
kmadisa opened this issue Oct 11, 2021 · 0 comments

Comments

@kmadisa
Copy link

kmadisa commented Oct 11, 2021

I get an error when I try to create a Ingress resource in my test.

Sample ingress.yaml file:

---
# Source: ska-tango-base/templates/ingress.yaml
# use Nginx
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: rest-api-ska-tango-base
  namespace: default
  labels:
    app: ska-tango-images
    component: tango-rest
    function: tango-http-interface
    domain: tango-configuration
    intent: enabling
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$1
    app.gitlab.com/app: CI_PROJECT_PATH_SLUG
    app.gitlab.com/env: CI_ENVIRONMENT_SLUG
spec:
  rules:
    - http:
        paths:
        - path: /default/(tango/rest/.*)
          pathType: Prefix
          backend:
           service:
            name: ska-tango-base-tango-rest
            port:
              number: 8080

Sample test_ingress.py test:

import pytest


@pytest.mark.namespace(create=True, name='test')
@pytest.mark.applymanifests('.', files=[
    'ingress.yaml'
])
def test_ingress(kube):
    """An example test against an tangodb deployment."""

    # wait for the manifests loaded by the 'applymanifests' marker
    # to be ready on the cluster
    kube.wait_for_registered(timeout=30)

    ingresses = kube.get_ingresses()
    tango_ingress = ingresses.get('rest-api-ska-tango-base-RELEASE-NAME')
    assert tango_ingress is not None
    assert tango_ingress.is_ready()

The error that I get when I run pytest -s test_ingress.py --kube-config=~/.kube/config:

>                       f"Unable to determine object type for manifest: {manifest}",
                    )
E                   ValueError: Unable to determine object type for manifest: {'apiVersion': 'networking.k8s.io/v1', 'kind': 'Ingress', 'metadata': {'name': 'rest-api-ska-tango-base', 'namespace': 'default', 'labels': {'app': 'ska-tango-images', 'component': 'tango-rest', 'function': 'tango-http-interface', 'domain': 'tango-configuration', 'intent': 'enabling'}, 'annotations': {'kubernetes.io/ingress.class': 'nginx', 'nginx.ingress.kubernetes.io/rewrite-target': '/$1', 'app.gitlab.com/app': 'CI_PROJECT_PATH_SLUG', 'app.gitlab.com/env': 'CI_ENVIRONMENT_SLUG'}}, 'spec': {'rules': [{'http': {'paths': [{'path': '/default/(tango/rest/.*)', 'pathType': 'Prefix', 'backend': {'service': {'name': 'ska-tango-base-tango-rest', 'port': {'number': 8080}}}}]}}]}}

../../../../../.local/lib/python3.6/site-packages/kubetest/manifest.py:108: ValueError
================================================================================= short test summary info ==================================================================================
ERROR test_ingress.py::test_ingress - ValueError: Unable to determine object type for manifest: {'apiVersion': 'networking.k8s.io/v1', 'kind': 'Ingress', 'metadata': {'name': 'rest-api-...
===================================================================================== 1 error in 0.19s =====================================================================================

I'm using kubernetes==17.17.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant