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

Add nameref for openshift routes? #97

Closed
schweikert opened this issue Jun 12, 2018 · 9 comments
Closed

Add nameref for openshift routes? #97

schweikert opened this issue Jun 12, 2018 · 9 comments

Comments

@schweikert
Copy link
Contributor

schweikert commented Jun 12, 2018

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

@schweikert
Copy link
Contributor Author

This would be solved also by #91 probably

@Liujingfang1
Copy link
Contributor

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

@schweikert
Copy link
Contributor Author

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

@Liujingfang1
Copy link
Contributor

Liujingfang1 commented Jun 13, 2018

#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.

@Liujingfang1
Copy link
Contributor

#42

@schweikert
Copy link
Contributor Author

Awesome, thanks! Looking forward to trying it out.

@Liujingfang1
Copy link
Contributor

#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.

@schweikert
Copy link
Contributor Author

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.

@trick77
Copy link

trick77 commented Jan 18, 2019

@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?

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