How to create the knative serving

10/5/2020

I have written a custom resource as part of the deployment. As part of this in the reconcileKind function, I have written the logic to create pod as shown below using the Kubernetes APIs in Go itself.

Image

I would like to convert this to knative serving (instead of creating the POD which will be always running) so that I can make of KPA feature. I am aware of creating knative serving using the .yaml way. But I would like to create it by using the Kubernetes API itself. I did search in the official documentation, but everything explained was using the .yaml way.

So I'm curious whether can we achieve knative serving by directly using Kubernetes APIs?

-- coders
go
knative
knative-serving
kubernetes

1 Answer

10/5/2020

How to create the knative serving using golang?

You need to use the Go-client for Knative Serving, e.g. the client type - corresponding to the corev1.Pod that you used in your code.

The Go client for Knative v1.Serving is in the Knative repository.

Instead of CoreV1() in your code, you can use ServingV1() from the Knative Go client.

But I would recommend to use Yaml manifests unless you have custom needs.

-- Jonas
Source: StackOverflow