Using declarative files in Knative
A good practice when creating environments is to create declarative definitions for your applications. Knative supports this with the --target
flag. For example, if you want to change the previous example into a YAML file, you could use this flag. To do this, run the following command:
$ kn service create api --cluster-local \ --image sergioarmgpl/app2demo \ --port 5000 \ --env MESSAGE="Knative demo v1" \ --revision-name=v1 --target=api.yaml
This command outputs a YAML file with the definition of an API function, without a public endpoint. The output in the api.yaml
file will look like this:
apiVersion: serving.knative.dev/v1 kind: Service metadata: labels: networking.knative.dev/visibility: cluster-local name: api namespace: default spec: template: metadata: annotations: ...