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

How to represent other Resource types, eg. Istio VirtualService #187

Open
samuela opened this issue Feb 4, 2023 · 2 comments
Open

How to represent other Resource types, eg. Istio VirtualService #187

samuela opened this issue Feb 4, 2023 · 2 comments

Comments

@samuela
Copy link

samuela commented Feb 4, 2023

Kubernetes tools like Istio require the creation of yaml like

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: ska-deleteme-2023-vs
  namespace: ska-deleteme-2023
  annotations:
    external-dns.alpha.kubernetes.io/controller: dns-controller
    external-dns.getcruise.com/zone.class: dns-internal-dev
spec:
  gateways:
    - istio-system/paasapps
  hosts:
    - ska-deleteme-2023.dev.paasapps.robot.car
  http:
    - route:
...

Notably, kind: VirtualService is not part of kubernetes and apiVersion refers to a non-kubernetes api. (See https://istio.io/latest/docs/reference/config/networking/virtual-service/ for more info.)

How can one create this sort of config via dhall-kubernetes? I'm not seeing any sort of VirtualService in the dhall-kubernetes Resource definitions, which is to be expected since this is Istio-specific nonsense. However, I'm also not able to find any way of extending k8s.Resource with extra definitions.

I'd like to be able to write something along the lines of

let istio =
      { apiVersion = "networking.istio.io/v1beta1"
      , kind = "VirtualService"
      , metadata = { name = "foo", namespace = "bar" }
      ...
      }

in  [ k8s.Resource.Service service, k8s.Resource.Deployment deployment, istio ]

but ofc this doesn't work since the type of istio is not in the large type union that is all dhall-kubernetes resource types.

How does one accomplish this sort of pattern with dhall-kubernetes?

@Gabriella439
Copy link
Contributor

yeah, as you noted in the linked issue, if you could extend the union type then you could handle this

@muff1nman
Copy link
Contributor

One way to handle this pattern right now is to export all the openapi definitions from your cluster (native k8s and CRDs) and then generate your own types using the openapi converter: https://github.com/dhall-lang/dhall-haskell/tree/master/dhall-openapi

It works pretty good for the most part, however one issue with this approach is if you have multiple types with different resource group/version combos. I was working on making a more comprehensive generator style here: dhall-lang/dhall-haskell#2135 but haven't had a chance to finish this work yet.

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

3 participants