Kustomize: Add nameref for openshift routes?

Created on 12 Jun 2018  路  9Comments  路  Source: kubernetes-sigs/kustomize

Hi,

I understand that this is likely going to be rejected, but I'll try anyway :) Something that is really needed to make the nameprefix mechanism work in a OpenShift context, is replacing the name of the target service in Route objects (apiVersion: route.openshift.io/v1). Would you maybe consider doing the nameref subtitution for that too?

A typical route definition looks as follows:

apiVersion: route.openshift.io/v1
kind: Route
metadata:
  name: frontend
spec:
  tls:
    termination: edge
  to:
    kind: Service
    name: frontend

See: https://docs.openshift.org/latest/dev_guide/routes.html

Most helpful comment

For the records: it works for this use case :) Thanks @Liujingfang1 !

I have written here detailed instructions on how to use it for OpenShift routes:
https://github.com/adnovum/kustomize-openshift

Maybe we can extend that repo in the future to contain more tuning tips for using kustomize with openshift.

All 9 comments

This would be solved also by #91 probably

@schweikert Adding name prefix should work for Route kind since kustomize doesn't really check the kind name for prefixing part.

The problem is spec.to.name, which is the name of a service that gets renamed by kustomize

105 can solve the problem.

The intended workflow is like this:
You add an annotation to the type.go of Route in the filed spec.to

    // +k8s:openapi-gen=x-kubernetes-object-ref-api-version:v1
    // +k8s:openapi-gen=x-kubernetes-object-ref-kind:Service

Get the open API definition of it and save it to a file route.json.

Then in kustomization.yaml, add a filed as

crds:
- route.json

Then kustomize build will update the filed spec.to.name as the service referred is renamed.

42

Awesome, thanks! Looking forward to trying it out.

42 merged. Here is an example showing how it works https://github.com/kubernetes-sigs/kustomize/tree/master/pkg/commands/testdata/testcase-crds/crd

Let me know if you need any help on this.

For the records: it works for this use case :) Thanks @Liujingfang1 !

I have written here detailed instructions on how to use it for OpenShift routes:
https://github.com/adnovum/kustomize-openshift

Maybe we can extend that repo in the future to contain more tuning tips for using kustomize with openshift.

@Liujingfang1 I realise this request has been addressed/closed but I was wondering if there is an easier way to create JSON CRD files for OpenShift extensions rather than to add the properties by hand? Like, would it be possible to simply generate a Kustomize JSON CRD for the entire DeploymentConfig struct for example?

Was this page helpful?
0 / 5 - 0 ratings