Cannot deploy virtual-server on Minikube

11/4/2021

I am just exploring and want to helm my k8dash, but got the weird error since I have been able to deploy on AWS EKS.

I am running them on my Minikube V1.23.2

My helm version is v3.6.2

Kubernetes kubectl version is v1.22.3

Basically if I do helm template, the VirtualServer would be like this:

apiVersion: k8s.nginx.org/v1
kind: VirtualServer
metadata:
  name: k8dash
  namespace: k8dash
spec:
  host: namahost.com
  routes:
  - action:
      pass: RELEASE-NAME
    path: /
  upstreams:
  - name: RELEASE-NAME
    port: 80
    service: RELEASE-NAME

and I got this error:

Error: unable to build Kubernetes objects from release manifest: unable to recognize "": no matches for kind "VirtualServer" in version "k8s.nginx.org/v1"

It's weird, deploying this one on AWS EKS just fine but locally got this error and I could not find any clue while Googling. Does it has something to do with my tools version?

-- arsaphone
kubernetes
kubernetes-helm
nginx-ingress

1 Answer

11/18/2021

You have to install additional CRDs as both VirtualServer and VirtualServerRoute are not oob, but nginx resources.

CustomResourceDefinitions:

The CustomResourceDefinition API resource allows you to define custom resources. Defining a CRD object creates a new custom resource with a name and schema that you specify. The Kubernetes API serves and handles the storage of your custom resource. The name of a CRD object must be a valid DNS subdomain name.

This frees you from writing your own API server to handle the custom resource, but the generic nature of the implementation means you have less flexibility than with API server aggregation.


Nginx Create Custom Resources

Note: By default, it is required to create custom resource definitions for VirtualServer, VirtualServerRoute, TransportServer and Policy. Otherwise, the Ingress Controller pods will not become Ready. If you’d like to disable that requirement, configure -enable-custom-resources command-line argument to false and skip this section.

Create custom resource definitions for VirtualServer and VirtualServerRoute, TransportServer and Policy resources.

You can find crds under https://github.com/nginxinc/kubernetes-ingress/tree/master/deployments/common/crds:

$ git clone https://github.com/nginxinc/kubernetes-ingress/
$ cd kubernetes-ingress/deployments
$ git checkout v2.0.3 (or latest, as you wish)

$ kubectl apply -f common/crds/k8s.nginx.org_virtualservers.yaml
$ kubectl apply -f common/crds/k8s.nginx.org_virtualserverroutes.yaml
$ kubectl apply -f common/crds/k8s.nginx.org_transportservers.yaml
$ kubectl apply -f common/crds/k8s.nginx.org_policies.yaml

After successful applying you will be able to create both VirtualServer and VirtualServerRoute

-- Vit
Source: StackOverflow