You create a public service with the Tanzu CLI by describing its configuration in a YAML file and then applying the configuration file.
You must create the following manifests to describe the configuration of a public service:
A health check manifest. Defines the health check settings for the public service. Based on the health-check settings, Tanzu Service Mesh periodically sends requests to the service to check whether it is reachable and functional.
A public service manifest. Contains the general configuration details about the public service, including its name, the fully qualified domain name (FQDN) of the service, and its external port. For a GSLB-enabled public service, the public service manifest also contains the GSLB parameters.
A public service route manifest. Defines the name of the internal service associated with the public service and the internal port of the internal service. When a user makes a request to the public service, Tanzu Service routes the request to the internal service in the cluster for processing.
You must retrieve the template for each manifest from the Tanzu Service Mesh API, provide values for the fields in the manifest, and then combine the manifests in a single YAML file, called public service configuration file. Arrange the manifests in the public service configuration file in the following order:
Health check manifest
Public service manifest
Public service route manifest
You must then apply the resulting public service configuration file to your Tanzu Service Mesh tenant to create the public service based on the configuration.
Prerequisites
Become familiar with the concepts global namespace and public service in Tanzu Service Mesh. Also become familiar with the concepts of a GSLB-enabled public service and a non-GSLB public service.
Choose a fully qualified domain name (FQDN) at which the public service will be exposed. If this service is accessible from the Internet through a GSLB, it must be a valid FQDN that is resolvable on the Internet. If no GSLB integration exists or if the public service is not accessible from the outside, you can define any FQDN that is configured in your DNS.
(Only for a GSLB-enabled public service) In the configuration for a GSLB-enabled public service, you must include the ID of an external DNS account. For information on how to get an external DNS account ID, see Get an External DNS ID for a Public Service Configuration. For information about creating a DNS account with the CLI, see Create a DNS Account Using the CLI.
(Only for a GSLB-enabled public service) Become familiar with the following GSLB concepts that are used in Tanzu Service Mesh. For more information about these concepts, see Configure Global Load Balancing for Your Application in Tanzu Service Mesh.
Global load balancing scheme (round robin, weighted, and active-passive)
Health checks
(Only for a GSLB-enabled public service) If you want to use the weighted or active-passive (failover) global load balancing scheme for the public service, add the required labels to the service configuration on each cluster where the service is deployed. For instructions on how to add these labels, see Configure Global Load Balancing for Your Application in Tanzu Service Mesh.
If you want to expose the public service at an HTTPS URL, add the Transport Layer Security (TLS) certificate that you want to use for the service to Tanzu Service Mesh. You must provide the name of the certificate in the public service configuration. For information about adding a certificate to Tanzu Service Mesh, see Add a Certificate to Tanzu Service Mesh Using the CLI.
Make sure that the Common Name (CN) on the certificate is the same FQDN that you specify for the public service in the public service configuration YAML file.
Be familiar with the Kubernetes YAML manifest format.
Procedure
Example: Public Service Configuration Files
Configuration for a non-GSLB public service
apiVersion: templates.tsm.vmware.com/v1 kind: HealthCheck metadata: labels: projectId: default name: sample-healthcheck spec: name: sample-healthcheck protocol: HTTP domain: my-subdomain.shopping.com port: 3000 path: "/" healthThreshold: 3 certificate_id: "" external_port: 80 interval: 10 --- apiVersion: gns.tsm.vmware.com/v1 kind: PublicService metadata: labels: gnsId: my-gns projectId: default name: my-subdomain.shopping.com spec: fqdn: my-subdomain.shopping.com name: "" external_port: 80 external_protocol: HTTP ttl: 300 public_domain: primary_domain: shopping.com sub_domain: my-subdomain certificate_id: "" gslb: ha_policy: "" wildcard_certificate_id: "" healthcheck_ids: - sample-healthcheck --- apiVersion: gns.tsm.vmware.com/v1 kind: PublicServiceRoute metadata: labels: fqdn: my-subdomain.shopping.com gnsId: my-gns projectId: default name: my-sample-pub-svc.3000 spec: paths: - "/" target: shopping target_port: 3000
Configuration for a GSLB-enabled public service
apiVersion: templates.tsm.vmware.com/v1 kind: HealthCheck metadata: labels: projectId: default name: sample-healthcheck spec: name: sample-healthcheck protocol: HTTP domain: my-subdomain.shopping.com port: 3000 path: "/" healthThreshold: 3 certificate_id: "" external_port: 80 interval: 10 --- apiVersion: gns.tsm.vmware.com/v1 kind: PublicService metadata: labels: gnsId: my-gns projectId: default name: my-subdomain.shopping.com spec: fqdn: my-subdomain.shopping.com name: "" external_port: 443 external_protocol: HTTPS ttl: 300 public_domain: external_dns_id: 188aacb9-4503-486a-9818-653a9240ef7d primary_domain: shopping.com sub_domain: my-subdomain certificate_id: myHttpsCert gslb: type: ROUND_ROBIN ha_policy: "" wildcard_certificate_id: "" healthcheck_ids: - sample-healthcheck --- apiVersion: gns.tsm.vmware.com/v1 kind: PublicServiceRoute metadata: labels: fqdn: my-subdomain.shopping.com gnsId: my-gns projectId: default name: my-sample-pub-svc.3000 spec: paths: - "/" target: shopping target_port: 3000
What to do next
To verify that the new public service was added to its global namespace in the Tanzu Service Mesh Сonsole, perform these steps:
In the navigation pane on the left, click Home.
On the GNS Overview tab, click the name of the global namespace that contains the public service.
On the global namespace details page, click the Public Services tab.
To view the details of the public service, including its configuration, click the name of the public service.
To edit the configuration of a public service, perform these steps:
Delete the public service from Tanzu Service Mesh, passing the name of the public service configuration YAML file in the
tanzu sm delete
command.Recreate the configuration of the public service with the values you want in a YAML file by following the instructions in the procedure above.
At the top of the public service details page, a health status of Syncing or Error is initially displayed for a new public service for a few minutes while the public service is starting, and Tanzu Service Mesh determines its health by sending health check requests to the endpoint specified in the health check manifest. If the public service responds successfully to the health check requests according to the specified health check settings, the health status Syncing or Error is no longer displayed.