The napptive-ingress trait creates an Ingress to make the component publicly available to the Internet. The resulting ingress will automatically be given a valid DNS name and associated TLS certificate so that it can be consumed by all major browsers without modification.
The public URL where the component will be exposed will be injected in the target container as an environment variable named
NAPPTIVE_CUSTOM_URL in the case of defining an extraDNSName.
The following snippet shows an example application with a napptive-ingress trait to expose an HTTP route on port 80 of the target component. Notice that a https route will be automatically created as major browsers automatically switch to the secure route.
apiVersion: core.oam.dev/v1beta1 kind: Application metadata: name: my-app annotations: version: "v0.0.1" description: "My apply-application application" spec: components: - name: component type: webservice properties: image: my-app-image:v1.0.0 ports: - port: 80 expose: true traits: - type: napptive-ingress # Set to napptive-ingress properties: name: nginx-ingress # (Optional) endpoint name port: 80 # (Required) port where the service is listening for incoming connections. path: / # (Required) path to be exposed rewritePath: / # (Optional) rewrite rule if one is needed. targetServiceName: service # (Optional) name of the service associated with the endpoint extraDNSName: my.domain.com # (Optional) additional DNS name in which this ingress must accept traffic requestBodySize: 10m # (Optional) Modify the maximum request size. This could be useful for scenarios requiring uploading files. writeURLToConfigMap: my-cm # (Optional) Name of the configmap that will be generated with the associated URLs
Some containers may require this information to be available through other environment variables. For that case, you should add the required environment variables using the env trait. Notice that it is important that this type of variables are added after the ingress one, or Kubernetes will fail to detect them.
... traits: - type: env properties: env: name: MY_CUSTOM_CFG value: $(NAPPTIVE_URL) ...
Some applications may require several components to have access to the final exposed endpoint for configuration purposes. To accomplish this, use the
writeURLToConfigMap property of the ingress trait to generate a configmap map with the following keys, that can be mounted by other components as environment variables for their configuration.
|URL||URL associated with the endpoint without the protocol.|
|CUSTOM_URL||URL associated with the extraDNSName property.|
The ingress will automatically redirect requests to the component even if the component has just started. Please wait some time depending on the image being executed so that the component is fully up and running.
Major browsers implement HTTP Strict Transport Security (STS) which translates in automatic promotion of plain requests to
https://. We recommended adapting the client consuming the service to support TLS. Alternatively, check your browser documentation to see whether it is possible to switch off this protection layer.
The napptive-ingress trait supports custom domains to expose an application with the extraDNSName property. For more information, follow our guide of setting up a custom domain for an application.