Skip to main content

Configuring Application Services

Flyte manages application services by deploying them as Knative Services (KServices) within the Kubernetes cluster. Configuration for these services is divided into the control plane (AppService), which handles high-level orchestration and status caching, and the data plane (InternalAppService), which manages the lifecycle of the underlying Kubernetes resources.

Control Plane Configuration

The control plane configuration is defined in the apps section of the Flyte configuration. It primarily manages how the control plane interacts with the data plane and how it caches application status.

apps:
# The URL of the InternalAppService (data plane).
# In unified mode, this is typically the local address of the internal listener.
internalAppServiceUrl: "http://localhost:8091"

# TTL for the in-memory app status cache.
# Defaults to 30s. Set to 0 to disable caching.
cacheTtl: 30s

These settings are mapped to the AppConfig struct in app/config/config.go. The CacheTTL ensures that frequent status requests from the UI or CLI do not overwhelm the data plane or the Kubernetes API.

Data Plane Configuration

The data plane configuration is defined in the internalApps section. This section controls the deployment behavior, networking, and environment of the KService pods.

internalApps:
# Must be set to true to enable the app deployment controller.
enabled: true

# Base domain for public URLs.
# Apps are exposed at "{name}-{project}-{domain}.{base_domain}".
baseDomain: "apps.flyte.example.com"

# URL scheme for public app URLs (http or https). Defaults to https.
scheme: https

# Port for app subdomain URLs. Set to 0 to omit (standard 80/443).
ingressAppsPort: 0

# Default and maximum request timeouts for Knative services.
defaultRequestTimeout: 300s
maxRequestTimeout: 3600s

# Template for internal app endpoint pattern.
# Supported variables: {{ project }}, {{ domain }}.
namespacedNameSuffixTemplate: "{{ project }}-{{ domain }}"

These settings are managed by the InternalAppConfig struct in app/config/config.go.

Public Ingress Generation

Flyte generates a deterministic public URL for each application based on the BaseDomain, Scheme, and IngressAppsPort. The AppK8sClient.PublicIngress method in app/internal/k8s/app_client.go implements this logic:

func (c *AppK8sClient) PublicIngress(id *flyteapp.Identifier) *flyteapp.Ingress {
if c.cfg.BaseDomain == "" {
return nil
}
scheme := c.cfg.Scheme
if scheme == "" {
scheme = "https"
}
host := strings.ToLower(fmt.Sprintf("%s.%s",
KServiceName(id), c.cfg.BaseDomain))
url := scheme + "://" + host
if c.cfg.IngressAppsPort != 0 {
url += fmt.Sprintf(":%d", c.cfg.IngressAppsPort)
}
return &flyteapp.Ingress{PublicUrl: url}
}

Environment Variable Injection

Flyte automatically injects environment variables into every application pod to facilitate service discovery and provide cluster-level configuration.

Default Environment Variables

You can specify a map of environment variables in internalApps.defaultEnvVars to be injected into all pods. This is useful for providing cluster-internal endpoints, such as _U_EP_OVERRIDE, which application processes might need to connect back to Flyte.

Internal Endpoint Pattern

Flyte injects the INTERNAL_APP_ENDPOINT_PATTERN environment variable into every container. This allows applications to discover and communicate with other applications within the same cluster using a predictable URL format.

The pattern is constructed in AppK8sClient.buildKService using the NamespacedNameSuffixTemplate:

suffix := renderNamespacedSuffix(c.cfg.NamespacedNameSuffixTemplate, appID.GetProject(), appID.GetDomain())
podSpec.Containers[0].Env = append(podSpec.Containers[0].Env, corev1.EnvVar{
Name: "INTERNAL_APP_ENDPOINT_PATTERN",
Value: fmt.Sprintf("http://{app_fqdn}-%s.%s.svc.cluster.local", suffix, ns),
})

Applications can replace {app_fqdn} with the target application name to form a valid internal URL.

KService Lifecycle and Naming

Flyte manages the lifecycle of Knative Services, including deployment, scaling, and termination.

Naming Convention

All applications are deployed into a fixed Kubernetes namespace defined by AppNamespace (defaulting to flyte). To ensure uniqueness, Flyte generates KService names using the format {name}-{project}-{domain}.

If the generated name exceeds the Kubernetes DNS label limit of 63 characters, Flyte appends a deterministic 8-character SHA256 suffix to guarantee uniqueness while staying within the limit. This logic is implemented in KServiceName within app/internal/k8s/app_client.go.

Stopping Applications

When an application is stopped, Flyte does not delete the KService object. Instead, it:

  1. Patches the KService to set networking.knative.dev/visibility to cluster-local.
  2. Sets the Knative autoscaling annotations min-scale and initial-scale to 0.
  3. Deletes the LatestReadyRevision to ensure immediate termination of running pods.

This allows the application to be restarted quickly by simply redeploying it, which restores the visibility and scaling parameters.

Configuration Reference

KeyDefaultDescription
apps.internalAppServiceUrlhttp://localhost:8091URL of the data plane service.
apps.cacheTtl30sTTL for the control plane status cache.
internalApps.enabledfalseEnables the app deployment controller.
internalApps.baseDomain""Base domain for public application URLs.
internalApps.schemehttpsURL scheme (http/https) for public URLs.
internalApps.ingressAppsPort0Port for public URLs (0 to omit).
internalApps.defaultRequestTimeout300sDefault timeout for app requests.
internalApps.maxRequestTimeout3600sMaximum allowed timeout (Knative cap).
internalApps.defaultEnvVars{}Map of env vars injected into all pods.
internalApps.namespacedNameSuffixTemplate{{ project }}-{{ domain }}Template for internal service discovery URLs.