Issue with deploying/loading a Nginx VirtaulServer Custom Resource and applying to the AWS EKS

69 Views Asked by At

All my resources including the Custom Resource Definition (CRD) are YAML.

I am having an issue deploying a Kubernetes resource called a “Nginx VirtualServer” (basically a Nginx custom ingress resource) that makes use of a Custom Resource Definition (CRD). I have no issue with deploying the VirtualServer CRD itself to the EKS, but when I try and deploy the resource that makes use of the CRD I get this error:

java.io.IOException: Unknown apiVersionKind k8s.nginx.org/v1/VirtualServer is it registered?
                at io.kubernetes.client.util.Yaml.modelMapper(Yaml.java:555)
                at io.kubernetes.client.util.Yaml.loadAll(Yaml.java:179)
                at io.kubernetes.client.util.Yaml.loadAll(Yaml.java:145)

This looks to be coming from snakeYaml not being able to find the correct Custom Resource model to map to. I am using the Java Kubernetes Client (https://github.com/kubernetes-client/java) to do the deployment to the EKS.

When I apply the yaml file using the kubernetes-cli it works with no problem when deploying, so the problem is only when using the java kubernetes client.

Does anyone have any idea what I am missing here? I am loading the CRD using snakeYaml before loading the VirtualServer resource, but this does not solve the issue.

Here is an example of my YAML that makes use of the CRD:

# Ingress resources are bound to specific ingress controllers using an identifier
# Ingress Controller Identifier: nginx-firstone
kind: VirtualServer
apiVersion: k8s.nginx.org/v1
metadata: 
  name: nginx-firstone-dmz-vs
  namespace: dmz
spec: 
  host: some-host-name
  ingressClassName: nginx-firstone
  tls: 
    secret: firstone-secret
    redirect: 
      enable: true
      code: 301
  upstreams: 
  - name: psp-dmz-webinterfaceclient-service-80-us
    service: psp-dmz-webinterfaceclient-service
    port: 80
    connect-timeout: "60"
    send-timeout: "60"
    read-timeout: "60"
    keepalive: 75
  - name: psp-dmz-webinterfaceclient-service-85-us
    service: psp-dmz-webinterfaceclient-service
    port: 85
    connect-timeout: "60"
    send-timeout: "60"
    read-timeout: "60"
    keepalive: 75
  routes: 
  - path: /merchantportal
    action: 
      proxy: 
        upstream: psp-dmz-webinterfaceclient-service-80-us
        requestHeaders: 
            pass: true
        rewritePath: /merchantportal
    errorPages: 
      - codes: [404]
        return: 
          code: 200
          body: This was returned as a 200
  - path: /merchantenrolment
    action: 
      proxy: 
        upstream: psp-dmz-webinterfaceclient-service-85-us
        requestHeaders: 
            pass: true
        rewritePath: /merchantenrolment
    errorPages: 
      - codes: [404]
        return: 
          code: 200
          body: This was returned as a 200
---
0

There are 0 best solutions below