|
| 1 | +# Meta |
| 2 | + |
| 3 | +- Name: Hostname Compatible Process Types |
| 4 | +- Start Date: 2025-03-30 |
| 5 | +- Author(s): @joshwlewis |
| 6 | +- Status: Draft <!-- Acceptable values: Draft, Approved, On Hold, Superseded --> |
| 7 | +- RFC Pull Request: |
| 8 | +- CNB Pull Request: |
| 9 | +- CNB Issue: |
| 10 | +- Supersedes: |
| 11 | + |
| 12 | +# Summary |
| 13 | + |
| 14 | +Process types in the Cloud Native Buildpacks Buildpack specification are less restrictive than the RFC1123 2.1 host name definition. Therefore, CNB process types may not be compatible with internet routing or kubernetes resource naming. This RFC proposes to restrict CNB process names to meet RFC1123 2.1 and increase usage compatibility with other CNCF / OSS usage. |
| 15 | + |
| 16 | +# Definitions |
| 17 | + |
| 18 | +RFC1123 Requirements for Internet Hosts Section 2.1: The IETF ["Requirements for Internet Hosts" RFC](https://datatracker.ietf.org/doc/html/rfc1123#section-2.1) describes the syntax for host names on the internet. |
| 19 | +Kubernetes Resource Names: Many resource names are restricted to RFC1123, as outlined [here](https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#dns-subdomain-names). |
| 20 | +Process Types: The name of a process in a Cloud Native Buildpacks result as [described in `launch.toml`](https://github.com/buildpacks/spec/blob/main/buildpack.md#launchtoml-toml). |
| 21 | + |
| 22 | +# Motivation |
| 23 | + |
| 24 | +The images resulting from CNB builds are often deployed to internet connected environments, where it's useful to connect or manage the image lifecycle with a domain name. |
| 25 | + |
| 26 | +For example, after building a web service image with Cloud Native Buildpacks, developers might want to expose various processes to the internet like static-assets.myapp.com and api.myapp.com. However, process types may currently include `_`, `.`, and/or `[A-Z]`, making process types like `Static_Assets` allowed, but not internet routable -- `Static_Assets.myapp.com` is not a valid domain name. |
| 27 | + |
| 28 | +Or, developers might want to manage Kubernetes resources dynamically using process types defined in the resulting image: |
| 29 | + |
| 30 | +``` |
| 31 | +kubectl autoscale replicaset static-assets --max=6 --min=2 --cpu-percent=50 |
| 32 | +``` |
| 33 | + |
| 34 | +However, while CNB allows a `Static_Assets` process type, Kubernetes rejects it as a resource name: |
| 35 | + |
| 36 | +``` |
| 37 | +object name does not conform to Kubernetes naming requirements: "Static_Assets" |
| 38 | +``` |
| 39 | + |
| 40 | +These incompatibilities make using process types in dynamic scenarios challenging and/or impossible. |
| 41 | + |
| 42 | +# What it is |
| 43 | + |
| 44 | +The current Buildpack specification defines these process type restrictions: |
| 45 | + |
| 46 | +> MUST only contain numbers, letters, and the characters ., \_, and -. |
| 47 | +
|
| 48 | +While RFC1123 uses a stricter syntax with these notable differences: |
| 49 | + |
| 50 | +- Underscores (`_`) are not allowed |
| 51 | +- Periods (`.`) are not allowed |
| 52 | +- Dashes ('-') are not allowed as the first or last character |
| 53 | +- Uppercase and lowercase letters are not differentiated |
| 54 | +- Must be 63 characters or less |
| 55 | + |
| 56 | +The buildpack specification will be modified to match RFC1123 2.1. |
| 57 | + |
| 58 | +# How it Works |
| 59 | + |
| 60 | +The platform specification will be changed to reject process types that do not comply with RFC1123 2.1. For maximum compatibility with Kubernetes resource names, the Kubernetes regular expression will be used: |
| 61 | + |
| 62 | +``` |
| 63 | +/[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/ |
| 64 | +``` |
| 65 | + |
| 66 | +When a process name fails to meet this expression, appropriate error messaging may be given by the platform, for example: |
| 67 | + |
| 68 | +``` |
| 69 | +The "Static_Assets" process type must comply with RFC 1123 host name syntax. Underscores are not allowed. Uppercase letters are not allowed." |
| 70 | +``` |
| 71 | + |
| 72 | +# Migration |
| 73 | + |
| 74 | +This is a breaking API change, and will require a new Buildpack API version. |
| 75 | + |
| 76 | +This may require buildpacks to change the way process types are defined. For buildpacks using statically chosen process types that do not comply with RFC1123, they'll need to change the chosen process types. For buildpacks using dynamically assigned process types, they'll need to coerce process types (by substitution and/or truncation) to meet the specification or risk builds failing when the dynamically chosen name does not comply. |
| 77 | + |
| 78 | +# Drawbacks |
| 79 | + |
| 80 | +- It's a breaking API change and will cause ecosystem churn. |
| 81 | + |
| 82 | +# Alternatives |
| 83 | + |
| 84 | +## Do Nothing |
| 85 | + |
| 86 | +If we do nothing, developers in our ecosystem will not be able to use process types for internet routing or kubernetes resource names. |
| 87 | + |
| 88 | +# Prior Art |
| 89 | + |
| 90 | +N/A |
| 91 | + |
| 92 | +# Unresolved Questions |
| 93 | + |
| 94 | +- Are there additional resources in the spec that should also have this restriction? |
| 95 | + - Image names? (probably not, given it's common to use url-based image names with periods and slashes) |
| 96 | + |
| 97 | +# Spec. Changes (OPTIONAL) |
| 98 | + |
| 99 | +This change will require changes to the Buildpack API spec. |
| 100 | + |
| 101 | +# History |
| 102 | + |
| 103 | +<!-- |
| 104 | +## Amended |
| 105 | +### Meta |
| 106 | +[meta-1]: #meta-1 |
| 107 | +- Name: (fill in the amendment name: Variable Rename) |
| 108 | +- Start Date: (fill in today's date: YYYY-MM-DD) |
| 109 | +- Author(s): (Github usernames) |
| 110 | +- Amendment Pull Request: (leave blank) |
| 111 | +
|
| 112 | +### Summary |
| 113 | +
|
| 114 | +A brief description of the changes. |
| 115 | +
|
| 116 | +### Motivation |
| 117 | +
|
| 118 | +Why was this amendment necessary? |
| 119 | +---> |
| 120 | + |
| 121 | +``` |
| 122 | +
|
| 123 | +``` |
0 commit comments