diff --git a/deployment/chainloop/Chart.yaml b/deployment/chainloop/Chart.yaml index 8ed8052fe..9d3f8f80a 100644 --- a/deployment/chainloop/Chart.yaml +++ b/deployment/chainloop/Chart.yaml @@ -7,7 +7,7 @@ description: Chainloop is an open source software supply chain control plane, a type: application # Bump the patch (not minor, not major) version on each change in the Chart Source code -version: 1.489.0 +version: 1.489.1 # Do not update appVersion, this is handled automatically by the release process appVersion: v1.135.4 diff --git a/deployment/chainloop/README.md b/deployment/chainloop/README.md index 16b341039..c6441e003 100644 --- a/deployment/chainloop/README.md +++ b/deployment/chainloop/README.md @@ -17,6 +17,30 @@ Compatibility with the following Ingress Controllers has been verified, other co - [Nginx Ingress Controller](https://kubernetes.github.io/ingress-nginx/) - [Traefik](https://doc.traefik.io/traefik/providers/kubernetes-ingress/) +The Ingress Controller, and every load balancer in front of it, must support HTTP/2 for the endpoints in [Exposed endpoints](#exposed-endpoints). + +### Exposed endpoints + +Chainloop needs two public endpoints. You set each hostname in the chart values. The examples use `chainloop.example`. + +| Hostname | Service | Chart values | Requires HTTP/2 | +|---|---|---|---| +| `cp.chainloop.example` | Control plane | `controlplane.ingress`, `controlplane.service` | Yes | +| `cas.chainloop.example` | Artifact CAS | `cas.ingress`, `cas.service` | Yes | + +Each endpoint serves HTTP and native gRPC. The control plane endpoint also serves gRPC-Web. The endpoints also accept HTTP/1.1 for browser and plain HTTP calls. Native gRPC calls on them need HTTP/2. + +HTTP/2 must stay in place on the full path from a gRPC client to the pod. If a load balancer or proxy changes the connection to HTTP/1.1, native gRPC clients such as the `chainloop` CLI fail. The chart sets the HTTP/2 upstream annotations for the NGINX and Traefik controllers. For other controllers and for load balancers in front of the cluster, enable HTTP/2 yourself. + +The chart also creates two deprecated gRPC-only endpoints. By default (`useLegacyGRPCEndpoints: true`), the clients still use them. These endpoints also need HTTP/2: + +| Hostname | Service | Chart values | Status | +|---|---|---|---| +| `api.cp.chainloop.example` | Control plane, gRPC only | `controlplane.ingressAPI`, `controlplane.serviceAPI` | Deprecated | +| `api.cas.chainloop.example` | Artifact CAS, gRPC only | `cas.ingressAPI`, `cas.serviceAPI` | Deprecated | + +The chart always creates the deprecated gRPC-only Services (`serviceAPI`), in both modes. It creates the deprecated Ingresses only when `controlplane.ingressAPI.enabled` and `cas.ingressAPI.enabled` are `true`, also in both modes. Existing CLI installations that use them continue to work. To move the clients to the shared endpoints, see [Migrate to the shared control plane and CAS endpoints](#migrate-to-the-shared-control-plane-and-cas-endpoints). + ## TL;DR Deploy Chainloop in [development mode](#development) by running @@ -195,6 +219,60 @@ helm dt unwrap chainloop-1.77.0.wrap.tgz oci://chainloop.azurecr.io --yes # 🎉 Helm chart unwrapped successfully: You can use it now by running "helm install oci://chainloop.azurecr.io/chart/chainloop --generate-name" ``` +## Upgrading + +### Migrate to the shared control plane and CAS endpoints + +#### What changes + +Earlier versions of Chainloop exposed the control plane API and the CAS API on separate gRPC-only endpoints, for example `api.cp.` and `api.cas.`. These endpoints are deprecated. The `controlplane` and `cas` `ingressAPI` and `serviceAPI` settings are also deprecated. + +Chainloop now uses one shared endpoint for each service, for example `cp.` and `cas.`. Each shared endpoint serves HTTP and native gRPC. See [Exposed endpoints](#exposed-endpoints). + +To keep compatibility with existing deployments, the top-level value `useLegacyGRPCEndpoints` selects the endpoints that the clients use. The clients are the control plane connection to the CAS, and the `chainloop config save` command in the install notes (NOTES.txt): + +- `true` (default for now): the clients use the deprecated gRPC-only endpoints (`ingressAPI`, `serviceAPI`). The behavior of your deployment does not change. +- `false`: the clients use the shared endpoints (`ingress`, `service`). + +A future chart release changes the default to `false`. A later release removes the deprecated gRPC-only endpoints. + +The chart continues to create the deprecated endpoints with both values: the Services always, and the Ingresses when `ingressAPI.enabled` is `true`. CLIs that you did not reconfigure continue to work. + +You have two options when you upgrade an existing deployment. + +#### Option 1: Migrate to the shared endpoints (recommended) + +We recommend that you migrate before the default changes. Do these steps: + +1. Enable the shared endpoints: + - If you use an Ingress, set `controlplane.ingress` and `cas.ingress` with their hostnames, `tls: true` and a certificate source. `cas.ingress` is disabled by default. See [Enable a custom domain with TLS](#enable-a-custom-domain-with-tls). + - If clients connect through a Service of type `NodePort` or `LoadBalancer`, copy these settings (`type`, node ports, load balancer settings) from `controlplane.serviceAPI` and `cas.serviceAPI` to `controlplane.service` and `cas.service`. The shared Services are of type `ClusterIP` by default. +2. Make sure that HTTP/2 works on the full path from the client to the pod for `cp.` and `cas.`. This includes all load balancers. If one hop changes the connection to HTTP/1.1, native gRPC clients such as the CLI fail. +3. If your values file sets custom annotations in `controlplane.ingressAPI.annotations` or `cas.ingressAPI.annotations`, move them to `controlplane.ingress.annotations` and `cas.ingress.annotations`. +4. Set `useLegacyGRPCEndpoints: false` at the top level of your values file. Then upgrade the release: + + ```yaml + useLegacyGRPCEndpoints: false + ``` + +5. Reconfigure each CLI that is already installed. An installed CLI keeps its saved addresses: + + ```bash + chainloop config save --control-plane cp.:443 --artifact-cas cas.:443 + ``` + + If the shared Ingresses do not use TLS, use port 80 and the `--insecure` flag. The install notes (NOTES.txt) show the command for your values. + +#### Option 2: Enable the compatibility mode + +If you cannot migrate now, set `useLegacyGRPCEndpoints: true` explicitly at the top level of your values file: + +```yaml +useLegacyGRPCEndpoints: true +``` + +With this setting, the future change of the default does not change the endpoints of your clients. Migrate to the shared endpoints before a chart release removes the deprecated gRPC-only endpoints. + ## How to guides ### CAS upload speeds are slow, what can I do? @@ -243,8 +321,9 @@ or as shown before, provide them as imperative inputs during Helm Install/Upgrad The control plane ingress serves HTTP, gRPC-Web, and native gRPC on the same hostname. Its HTTP server routes each request, so these protocols can share an upstream HTTP/2 connection. -The existing gRPC ingress stays available. Existing clients can keep their current endpoints. +The existing gRPC ingress stays available, but it is deprecated. Existing clients can keep their current endpoints. To test the shared endpoint, point a gRPC client to the control plane HTTP hostname on port 443. +To move the clients to the shared endpoints, see [Migrate to the shared control plane and CAS endpoints](#migrate-to-the-shared-control-plane-and-cas-endpoints). The CAS shared endpoint mirrors the control plane (spec D-020): one standard HTTP listener dispatches each request, and native gRPC reaches the native transport through an in-process reverse proxy. `cas.ingress` is one catch-all route on the same hostname — one path `/` with an HTTP/2 (gRPC) upstream — so ByteStream uploads and downloads, browser downloads, and status probes share one Service port and one certificate, including mixed requests on one upstream connection. The chart selects gRPC transport annotations from the pod TLS configuration. You can override them under `cas.ingress.annotations`. The upload body-size annotations keep their existing defaults. @@ -542,7 +621,7 @@ Google Cloud has a [managed Prometheus offering](https://cloud.google.com/stackd ### Configure Chainloop CLI to point to your instance -Once you have your instance of Chainloop deployed, you need to configure the [CLI](https://github.com/chainloop-dev/chainloop/releases) to point to both the CAS and the Control plane gRPC APIs like this. +Once you have your instance of Chainloop deployed, you need to configure the [CLI](https://github.com/chainloop-dev/chainloop/releases) to point to both the CAS and the Control plane gRPC APIs like this. The install notes of the chart (NOTES.txt) show this command with the endpoints that `useLegacyGRPCEndpoints` selects. See [Migrate to the shared control plane and CAS endpoints](#migrate-to-the-shared-control-plane-and-cas-endpoints). ```bash chainloop config save \ @@ -575,12 +654,13 @@ Once done, you can access with [two predefined users](https://github.com/chainlo ### Global parameters -| Name | Description | Value | -| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| `global.imageRegistry` | Global Docker image registry | `""` | -| `global.imagePullSecrets` | Global Docker registry secret names as an array | `[]` | -| `global.compatibility.openshift.adaptSecurityContext` | Adapt the securityContext sections of the deployment to make them compatible with Openshift restricted-v2 SCC: remove runAsUser, runAsGroup and fsGroup and let the platform use their allowed default IDs. Possible values: auto (apply if the detected running cluster is Openshift), force (perform the adaptation always), disabled (do not perform adaptation) | `auto` | -| `development` | Deploys Chainloop pre-configured FOR DEVELOPMENT ONLY. It includes a Vault instance in development mode and pre-configured authentication certificates and passphrases | `false` | +| Name | Description | Value | +| ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | +| `global.imageRegistry` | Global Docker image registry | `""` | +| `global.imagePullSecrets` | Global Docker registry secret names as an array | `[]` | +| `global.compatibility.openshift.adaptSecurityContext` | Adapt the securityContext sections of the deployment to make them compatible with Openshift restricted-v2 SCC: remove runAsUser, runAsGroup and fsGroup and let the platform use their allowed default IDs. Possible values: auto (apply if the detected running cluster is Openshift), force (perform the adaptation always), disabled (do not perform adaptation) | `auto` | +| `development` | Deploys Chainloop pre-configured FOR DEVELOPMENT ONLY. It includes a Vault instance in development mode and pre-configured authentication certificates and passphrases | `false` | +| `useLegacyGRPCEndpoints` | Give the clients the deprecated gRPC-only control plane and CAS endpoints (`ingressAPI`, `serviceAPI`) instead of the shared endpoints (`ingress`, `service`). This applies to the control plane connection to the CAS and to the CLI configuration in the install notes (NOTES.txt). Set it to false to use the shared endpoints. A later release changes the default to false. The chart keeps the deprecated Services in both modes | `true` | ### Common parameters @@ -682,60 +762,60 @@ Once done, you can access with [two predefined users](https://github.com/chainlo ### Control Plane Networking -| Name | Description | Value | -| -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ------------------------ | -| `controlplane.service.type` | Service type | `ClusterIP` | -| `controlplane.service.ports.http` | controlplane service HTTP port | `80` | -| `controlplane.service.ports.https` | controlplane service HTTPS port | `443` | -| `controlplane.service.nodePorts.http` | Node port for HTTP | `""` | -| `controlplane.service.nodePorts.https` | Node port for HTTPS | `""` | -| `controlplane.service.clusterIP` | controlplane service Cluster IP | `""` | -| `controlplane.service.loadBalancerIP` | controlplane service Load Balancer IP | `""` | -| `controlplane.service.loadBalancerSourceRanges` | controlplane service Load Balancer sources | `[]` | -| `controlplane.service.externalTrafficPolicy` | controlplane service external traffic policy | `Cluster` | -| `controlplane.service.annotations` | Annotations for the shared HTTP and gRPC service. Traefik uses h2c or HTTPS to match shared listener TLS. | See values.yaml | -| `controlplane.service.extraPorts` | Extra ports to expose in controlplane service (normally used with the `sidecars` value) | `[]` | -| `controlplane.service.sessionAffinity` | Control where client requests go, to the same pod or round-robin | `None` | -| `controlplane.service.sessionAffinityConfig` | Additional settings for the sessionAffinity | `{}` | -| `controlplane.serviceAPI.type` | Service type | `ClusterIP` | -| `controlplane.serviceAPI.ports.http` | controlplane service HTTP port | `80` | -| `controlplane.serviceAPI.ports.https` | controlplane service HTTPS port | `443` | -| `controlplane.serviceAPI.nodePorts.http` | Node port for HTTP | `""` | -| `controlplane.serviceAPI.nodePorts.https` | Node port for HTTPS | `""` | -| `controlplane.serviceAPI.clusterIP` | controlplane service Cluster IP | `""` | -| `controlplane.serviceAPI.loadBalancerIP` | controlplane service Load Balancer IP | `""` | -| `controlplane.serviceAPI.loadBalancerSourceRanges` | controlplane service Load Balancer sources | `[]` | -| `controlplane.serviceAPI.externalTrafficPolicy` | controlplane service external traffic policy | `Cluster` | -| `controlplane.serviceAPI.annotations` | Additional custom annotations for controlplane service | | -| `controlplane.serviceAPI.extraPorts` | Extra ports to expose in controlplane service (normally used with the `sidecars` value) | `[]` | -| `controlplane.serviceAPI.sessionAffinity` | Control where client requests go, to the same pod or round-robin | `None` | -| `controlplane.serviceAPI.sessionAffinityConfig` | Additional settings for the sessionAffinity | `{}` | -| `controlplane.ingress.enabled` | Enable the shared HTTP, gRPC-Web and native gRPC ingress for controlplane | `false` | -| `controlplane.ingress.pathType` | Ingress path type | `ImplementationSpecific` | -| `controlplane.ingress.hostname` | Default host for the ingress record | `cp.dev.local` | -| `controlplane.ingress.ingressClassName` | IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+) | `""` | -| `controlplane.ingress.path` | Default path for the ingress record | `/` | -| `controlplane.ingress.annotations` | Annotations for the shared ingress. NGINX uses HTTP/2 upstream. Add cert-manager annotations here. | See values.yaml | -| `controlplane.ingress.tls` | Enable TLS configuration for the host defined at `controlplane.ingress.hostname` parameter | `false` | -| `controlplane.ingress.selfSigned` | Create a TLS secret for this ingress record using self-signed certificates generated by Helm | `false` | -| `controlplane.ingress.extraHosts` | An array with additional hostname(s) to be covered with the ingress record | `[]` | -| `controlplane.ingress.extraPaths` | An array with additional arbitrary paths that may need to be added to the ingress under the main host | `[]` | -| `controlplane.ingress.extraTls` | TLS configuration for additional hostname(s) to be covered with this ingress record | `[]` | -| `controlplane.ingress.secrets` | Custom TLS certificates as secrets | `[]` | -| `controlplane.ingress.extraRules` | Additional rules to be covered with this ingress record | `[]` | -| `controlplane.ingressAPI.enabled` | Enable ingress record generation for controlplane | `false` | -| `controlplane.ingressAPI.pathType` | Ingress path type | `ImplementationSpecific` | -| `controlplane.ingressAPI.hostname` | Default host for the ingress record | `api.cp.dev.local` | -| `controlplane.ingressAPI.ingressClassName` | IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+) | `""` | -| `controlplane.ingressAPI.path` | Default path for the ingress record | `/` | -| `controlplane.ingressAPI.annotations` | Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations. | | -| `controlplane.ingressAPI.tls` | Enable TLS configuration for the host defined at `controlplane.ingress.hostname` parameter | `false` | -| `controlplane.ingressAPI.selfSigned` | Create a TLS secret for this ingress record using self-signed certificates generated by Helm | `false` | -| `controlplane.ingressAPI.extraHosts` | An array with additional hostname(s) to be covered with the ingress record | `[]` | -| `controlplane.ingressAPI.extraPaths` | An array with additional arbitrary paths that may need to be added to the ingress under the main host | `[]` | -| `controlplane.ingressAPI.extraTls` | TLS configuration for additional hostname(s) to be covered with this ingress record | `[]` | -| `controlplane.ingressAPI.secrets` | Custom TLS certificates as secrets | `[]` | -| `controlplane.ingressAPI.extraRules` | Additional rules to be covered with this ingress record | `[]` | +| Name | Description | Value | +| -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------------------------ | +| `controlplane.service.type` | Service type | `ClusterIP` | +| `controlplane.service.ports.http` | controlplane service HTTP port | `80` | +| `controlplane.service.ports.https` | controlplane service HTTPS port | `443` | +| `controlplane.service.nodePorts.http` | Node port for HTTP | `""` | +| `controlplane.service.nodePorts.https` | Node port for HTTPS | `""` | +| `controlplane.service.clusterIP` | controlplane service Cluster IP | `""` | +| `controlplane.service.loadBalancerIP` | controlplane service Load Balancer IP | `""` | +| `controlplane.service.loadBalancerSourceRanges` | controlplane service Load Balancer sources | `[]` | +| `controlplane.service.externalTrafficPolicy` | controlplane service external traffic policy | `Cluster` | +| `controlplane.service.annotations` | Annotations for the shared HTTP and gRPC service. Traefik uses h2c or HTTPS to match shared listener TLS. | See values.yaml | +| `controlplane.service.extraPorts` | Extra ports to expose in controlplane service (normally used with the `sidecars` value) | `[]` | +| `controlplane.service.sessionAffinity` | Control where client requests go, to the same pod or round-robin | `None` | +| `controlplane.service.sessionAffinityConfig` | Additional settings for the sessionAffinity | `{}` | +| `controlplane.serviceAPI.type` | Deprecated gRPC-only Service type. Use the shared `controlplane.service` and set `useLegacyGRPCEndpoints` to false | `ClusterIP` | +| `controlplane.serviceAPI.ports.http` | controlplane service HTTP port | `80` | +| `controlplane.serviceAPI.ports.https` | controlplane service HTTPS port | `443` | +| `controlplane.serviceAPI.nodePorts.http` | Node port for HTTP | `""` | +| `controlplane.serviceAPI.nodePorts.https` | Node port for HTTPS | `""` | +| `controlplane.serviceAPI.clusterIP` | controlplane service Cluster IP | `""` | +| `controlplane.serviceAPI.loadBalancerIP` | controlplane service Load Balancer IP | `""` | +| `controlplane.serviceAPI.loadBalancerSourceRanges` | controlplane service Load Balancer sources | `[]` | +| `controlplane.serviceAPI.externalTrafficPolicy` | controlplane service external traffic policy | `Cluster` | +| `controlplane.serviceAPI.annotations` | Additional custom annotations for controlplane service | | +| `controlplane.serviceAPI.extraPorts` | Extra ports to expose in controlplane service (normally used with the `sidecars` value) | `[]` | +| `controlplane.serviceAPI.sessionAffinity` | Control where client requests go, to the same pod or round-robin | `None` | +| `controlplane.serviceAPI.sessionAffinityConfig` | Additional settings for the sessionAffinity | `{}` | +| `controlplane.ingress.enabled` | Enable the shared HTTP, gRPC-Web and native gRPC ingress for controlplane | `false` | +| `controlplane.ingress.pathType` | Ingress path type | `ImplementationSpecific` | +| `controlplane.ingress.hostname` | Default host for the ingress record | `cp.dev.local` | +| `controlplane.ingress.ingressClassName` | IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+) | `""` | +| `controlplane.ingress.path` | Default path for the ingress record | `/` | +| `controlplane.ingress.annotations` | Annotations for the shared ingress. NGINX uses HTTP/2 upstream. Add cert-manager annotations here. | See values.yaml | +| `controlplane.ingress.tls` | Enable TLS configuration for the host defined at `controlplane.ingress.hostname` parameter | `false` | +| `controlplane.ingress.selfSigned` | Create a TLS secret for this ingress record using self-signed certificates generated by Helm | `false` | +| `controlplane.ingress.extraHosts` | An array with additional hostname(s) to be covered with the ingress record | `[]` | +| `controlplane.ingress.extraPaths` | An array with additional arbitrary paths that may need to be added to the ingress under the main host | `[]` | +| `controlplane.ingress.extraTls` | TLS configuration for additional hostname(s) to be covered with this ingress record | `[]` | +| `controlplane.ingress.secrets` | Custom TLS certificates as secrets | `[]` | +| `controlplane.ingress.extraRules` | Additional rules to be covered with this ingress record | `[]` | +| `controlplane.ingressAPI.enabled` | Enable the deprecated gRPC-only ingress for controlplane. Use the shared `controlplane.ingress` and set `useLegacyGRPCEndpoints` to false | `false` | +| `controlplane.ingressAPI.pathType` | Ingress path type | `ImplementationSpecific` | +| `controlplane.ingressAPI.hostname` | Default host for the ingress record | `api.cp.dev.local` | +| `controlplane.ingressAPI.ingressClassName` | IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+) | `""` | +| `controlplane.ingressAPI.path` | Default path for the ingress record | `/` | +| `controlplane.ingressAPI.annotations` | Additional annotations for the Ingress resource. To enable certificate autogeneration, place here your cert-manager annotations. | | +| `controlplane.ingressAPI.tls` | Enable TLS configuration for the host defined at `controlplane.ingress.hostname` parameter | `false` | +| `controlplane.ingressAPI.selfSigned` | Create a TLS secret for this ingress record using self-signed certificates generated by Helm | `false` | +| `controlplane.ingressAPI.extraHosts` | An array with additional hostname(s) to be covered with the ingress record | `[]` | +| `controlplane.ingressAPI.extraPaths` | An array with additional arbitrary paths that may need to be added to the ingress under the main host | `[]` | +| `controlplane.ingressAPI.extraTls` | TLS configuration for additional hostname(s) to be covered with this ingress record | `[]` | +| `controlplane.ingressAPI.secrets` | Custom TLS certificates as secrets | `[]` | +| `controlplane.ingressAPI.extraRules` | Additional rules to be covered with this ingress record | `[]` | ### Controlplane Misc @@ -875,11 +955,11 @@ Once done, you can access with [two predefined users](https://github.com/chainlo | `cas.service.loadBalancerIP` | cas service Load Balancer IP | `""` | | `cas.service.loadBalancerSourceRanges` | cas service Load Balancer sources | `[]` | | `cas.service.externalTrafficPolicy` | cas service external traffic policy | `Cluster` | -| `cas.service.annotations` | Annotations for the shared HTTP and gRPC service. Traefik uses h2c or HTTPS to match shared listener TLS. | See values.yaml | +| `cas.service.annotations` | Annotations for the shared HTTP and gRPC service. Traefik uses h2c or HTTPS to match shared listener TLS. | See values.yaml | | `cas.service.extraPorts` | Extra ports to expose in cas service (normally used with the `sidecars` value) | `[]` | | `cas.service.sessionAffinity` | Control where client requests go, to the same pod or round-robin | `None` | | `cas.service.sessionAffinityConfig` | Additional settings for the sessionAffinity | `{}` | -| `cas.serviceAPI.type` | Service type | `ClusterIP` | +| `cas.serviceAPI.type` | Deprecated gRPC-only Service type. Use the shared `cas.service` and set `useLegacyGRPCEndpoints` to false | `ClusterIP` | | `cas.serviceAPI.ports.http` | cas service HTTP port | `80` | | `cas.serviceAPI.ports.https` | cas service HTTPS port | `443` | | `cas.serviceAPI.nodePorts.http` | Node port for HTTP | `""` | @@ -897,7 +977,7 @@ Once done, you can access with [two predefined users](https://github.com/chainlo | `cas.ingress.hostname` | Default host for the ingress record | `cas.dev.local` | | `cas.ingress.ingressClassName` | IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+) | `""` | | `cas.ingress.path` | Default path for the ingress record | `/` | -| `cas.ingress.annotations` | Annotations for the shared CAS ingress: HTTP/2 (gRPC) upstream plus the upload body limits. | See values.yaml | +| `cas.ingress.annotations` | Annotations for the shared CAS ingress: HTTP/2 (gRPC) upstream plus the upload body limits. | See values.yaml | | `cas.ingress.tls` | Enable TLS configuration for the host defined at `controlplane.ingress.hostname` parameter | `false` | | `cas.ingress.selfSigned` | Create a TLS secret for this ingress record using self-signed certificates generated by Helm | `false` | | `cas.ingress.extraHosts` | An array with additional hostname(s) to be covered with the ingress record | `[]` | @@ -905,7 +985,7 @@ Once done, you can access with [two predefined users](https://github.com/chainlo | `cas.ingress.extraTls` | TLS configuration for additional hostname(s) to be covered with this ingress record | `[]` | | `cas.ingress.secrets` | Custom TLS certificates as secrets | `[]` | | `cas.ingress.extraRules` | Additional rules to be covered with this ingress record | `[]` | -| `cas.ingressAPI.enabled` | Enable ingress record generation for controlplane | `false` | +| `cas.ingressAPI.enabled` | Enable the deprecated gRPC-only ingress for CAS. Use the shared `cas.ingress` and set `useLegacyGRPCEndpoints` to false | `false` | | `cas.ingressAPI.pathType` | Ingress path type | `ImplementationSpecific` | | `cas.ingressAPI.hostname` | Default host for the ingress record | `api.cas.dev.local` | | `cas.ingressAPI.ingressClassName` | IngressClass that will be be used to implement the Ingress (Kubernetes 1.18+) | `""` | diff --git a/deployment/chainloop/endpoints_test.go b/deployment/chainloop/endpoints_test.go new file mode 100644 index 000000000..204f68deb --- /dev/null +++ b/deployment/chainloop/endpoints_test.go @@ -0,0 +1,187 @@ +// Copyright 2026 The Chainloop Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package chart_test + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v3" +) + +const ( + notesResource = "ConfigMap/rendered-notes" + sharedEndpointsOptIn = "useLegacyGRPCEndpoints=false" +) + +// renderWithNotes renders the chart and also NOTES.txt, which `helm template` +// skips. It copies the chart and wraps NOTES.txt in a ConfigMap template. +func renderWithNotes(t *testing.T, args []string) (map[string]chartResource, string) { + t.Helper() + dir := t.TempDir() + require.NoError(t, os.CopyFS(dir, os.DirFS("."))) + templates, err := os.OpenRoot(filepath.Join(dir, "templates")) + require.NoError(t, err) + defer templates.Close() + + notes, err := templates.ReadFile("NOTES.txt") + require.NoError(t, err) + require.NoError(t, templates.Remove("NOTES.txt")) + tpl := `{{- define "test.notes" -}}` + string(notes) + `{{- end -}}` + require.NoError(t, templates.WriteFile("_test_notes.tpl", []byte(tpl), 0o600)) + manifest := "apiVersion: v1\nkind: ConfigMap\nmetadata:\n name: rendered-notes\ndata:\n notes: |\n{{ include \"test.notes\" . | indent 4 }}\n" + require.NoError(t, templates.WriteFile("zz-test-notes.yaml", []byte(manifest), 0o600)) + + t.Chdir(dir) + resources := renderChart(t, args) + rendered, ok := resources[notesResource] + require.True(t, ok) + return resources, rendered.Data["notes"] +} + +type controlplaneConfig struct { + CASServer struct { + GRPC struct { + Addr string `yaml:"addr"` + } `yaml:"grpc"` + } `yaml:"cas_server"` +} + +// useLegacyGRPCEndpoints selects the endpoints that the clients use: the +// control plane connection to the CAS and the CLI configuration in NOTES. +// Only an explicit false selects the shared endpoints. +func TestUseLegacyGRPCEndpoints(t *testing.T) { + const ( + legacyCASAddr = "test-chainloop-cas-api:80" + sharedCASAddr = "test-chainloop-cas:80" + ) + sharedIngresses := []string{ + helmSet, "controlplane.ingress.enabled=true", helmSet, "controlplane.ingress.tls=true", + helmSet, casIngressEnabled, helmSet, "cas.ingress.tls=true", + helmSet, "controlplane.ingressAPI.tls=true", helmSet, "cas.ingressAPI.tls=true", + } + for _, tc := range []struct { + name string + args []string + casAddr string + wantNotes []string + }{ + { + name: "default uses the legacy endpoints", + args: sharedIngresses, + casAddr: legacyCASAddr, + wantNotes: []string{ + "chainloop config save \\\n --control-plane api.cp.dev.local:443 \\\n --artifact-cas api.cas.dev.local:443", + }, + }, + { + name: "explicit true uses the legacy endpoints", + args: append([]string{helmSet, "useLegacyGRPCEndpoints=true"}, sharedIngresses...), + casAddr: legacyCASAddr, + wantNotes: []string{ + "--control-plane api.cp.dev.local:443 \\\n --artifact-cas api.cas.dev.local:443", + }, + }, + { + // helm upgrade --reuse-values from an older chart leaves the key unset. + name: "unset key uses the legacy endpoints", + args: append([]string{helmSet, "useLegacyGRPCEndpoints=null"}, sharedIngresses...), + casAddr: legacyCASAddr, + wantNotes: []string{ + "--control-plane api.cp.dev.local:443 \\\n --artifact-cas api.cas.dev.local:443", + }, + }, + { + name: "false uses the shared endpoints", + args: append([]string{helmSet, sharedEndpointsOptIn}, sharedIngresses...), + casAddr: sharedCASAddr, + wantNotes: []string{ + "chainloop config save \\\n --control-plane cp.dev.local:443 \\\n --artifact-cas cas.dev.local:443", + }, + }, + { + name: "false as a string uses the shared endpoints", + args: append([]string{helmSetString, sharedEndpointsOptIn}, sharedIngresses...), + casAddr: sharedCASAddr, + wantNotes: []string{ + "--control-plane cp.dev.local:443 \\\n --artifact-cas cas.dev.local:443", + }, + }, + { + name: "false without shared TLS keeps the CLI insecure", + args: []string{helmSet, sharedEndpointsOptIn, helmSet, "controlplane.ingress.enabled=true", helmSet, casIngressEnabled}, + casAddr: sharedCASAddr, + wantNotes: []string{ + "chainloop --insecure config save \\\n --control-plane cp.dev.local:80 \\\n --artifact-cas cas.dev.local:80", + }, + }, + { + name: "false without shared ingresses port-forwards the shared services", + args: []string{helmSet, sharedEndpointsOptIn}, + casAddr: sharedCASAddr, + wantNotes: []string{ + "svc/test-chainloop-controlplane 9000:80", + "svc/test-chainloop-cas 9001:80", + "--control-plane localhost:9000 \\\n --artifact-cas localhost:9001", + }, + }, + { + name: "false with NodePort uses the shared service node ports", + args: []string{ + helmSet, sharedEndpointsOptIn, + helmSet, "controlplane.ingressAPI.enabled=false", helmSet, "cas.ingressAPI.enabled=false", + helmSet, "controlplane.service.type=NodePort", helmSetString, "controlplane.service.nodePorts.http=30800", + helmSet, "cas.service.type=NodePort", helmSetString, "cas.service.nodePorts.http=30801", + }, + casAddr: sharedCASAddr, + wantNotes: []string{ + "--control-plane localhost:30800 \\\n --artifact-cas localhost:30801", + }, + }, + { + name: "false with LoadBalancer reads the shared services", + args: []string{ + helmSet, sharedEndpointsOptIn, + helmSet, "controlplane.ingressAPI.enabled=false", helmSet, "cas.ingressAPI.enabled=false", + helmSet, "controlplane.service.type=LoadBalancer", helmSet, "cas.service.type=LoadBalancer", + }, + casAddr: sharedCASAddr, + wantNotes: []string{ + "svc test-chainloop-controlplane -w", + "svc test-chainloop-cas -w", + "--control-plane $CP_HOST:$CP_PORT \\\n --artifact-cas $CAS_HOST:$CAS_PORT", + }, + }, + } { + t.Run(tc.name, func(t *testing.T) { + resources, notes := renderWithNotes(t, tc.args) + for _, want := range tc.wantNotes { + require.Contains(t, notes, want) + } + + var cfg controlplaneConfig + require.NoError(t, yaml.Unmarshal([]byte(resources["ConfigMap/test-chainloop-controlplane"].Data["config.yaml"]), &cfg)) + require.Equal(t, tc.casAddr, cfg.CASServer.GRPC.Addr) + + // Both modes keep the legacy gRPC resources. + _, ok := resources["Service/test-chainloop-controlplane-api"] + require.True(t, ok) + _, ok = resources["Service/test-chainloop-cas-api"] + require.True(t, ok) + }) + } +} diff --git a/deployment/chainloop/templates/NOTES.txt b/deployment/chainloop/templates/NOTES.txt index 57185cf73..339559997 100644 --- a/deployment/chainloop/templates/NOTES.txt +++ b/deployment/chainloop/templates/NOTES.txt @@ -11,18 +11,34 @@ APP VERSION: {{ .Chart.AppVersion }} {{- $cpGrpcURL := include "chainloop.controlplane.external_grpc_url" . }} {{- $casGrpcURL := include "chainloop.cas.external_grpc_url" . }} +{{- /* useLegacyGRPCEndpoints selects the deprecated gRPC-only endpoints (*-api) or the shared endpoints */ -}} +{{- $shared := eq (include "chainloop.sharedEndpoints.enabled" .) "true" }} + {{- $cpSvcType := .Values.controlplane.serviceAPI.type }} {{- $cpSvcPort := .Values.controlplane.serviceAPI.ports.http }} {{- $cpSvcName := printf "%s-api" (include "chainloop.controlplane.fullname" .) }} +{{- $cpIngress := .Values.controlplane.ingressAPI }} {{- $casSvcType := .Values.cas.serviceAPI.type }} {{- $casSvcPort := .Values.cas.serviceAPI.ports.http }} {{- $casSvcName := printf "%s-api" (include "chainloop.cas.fullname" .) }} +{{- $casIngress := .Values.cas.ingressAPI }} + +{{- if $shared }} +{{- $cpSvcType = .Values.controlplane.service.type }} +{{- $cpSvcPort = coalesce .Values.controlplane.service.port .Values.controlplane.service.ports.http }} +{{- $cpSvcName = include "chainloop.controlplane.fullname" . }} +{{- $cpIngress = .Values.controlplane.ingress }} +{{- $casSvcType = .Values.cas.service.type }} +{{- $casSvcPort = coalesce .Values.cas.service.port .Values.cas.service.ports.http }} +{{- $casSvcName = include "chainloop.cas.fullname" . }} +{{- $casIngress = .Values.cas.ingress }} +{{- end }} {{- $namespace := include "common.names.namespace" . }} -{{- $cpHasTLS := or (and .Values.controlplane.ingressAPI.enabled .Values.controlplane.ingressAPI.tls) (ne (.Values.controlplane.tls.existingSecret | default "") "") }} -{{- $casHasTLS := or (and .Values.cas.ingressAPI.enabled .Values.cas.ingressAPI.tls) (ne (.Values.cas.tls.existingSecret | default "") "") }} +{{- $cpHasTLS := or (and $cpIngress.enabled $cpIngress.tls) (ne (.Values.controlplane.tls.existingSecret | default "") "") }} +{{- $casHasTLS := or (and $casIngress.enabled $casIngress.tls) (ne (.Values.cas.tls.existingSecret | default "") "") }} {{- $insecure := not (and $cpHasTLS $casHasTLS) }} {{- if and (ne $cpGrpcURL "") (ne $casGrpcURL "") }} diff --git a/deployment/chainloop/templates/_helpers.tpl b/deployment/chainloop/templates/_helpers.tpl index a297125a3..f5c893cb6 100644 --- a/deployment/chainloop/templates/_helpers.tpl +++ b/deployment/chainloop/templates/_helpers.tpl @@ -329,14 +329,27 @@ null {{- end -}} {{- end -}} +{{/* +"true" when the clients use the shared control plane and CAS endpoints. +Only an explicit false opts in: `helm upgrade --reuse-values` from an older chart leaves the key unset. +*/}} +{{- define "chainloop.sharedEndpoints.enabled" -}} +{{- ternary "true" "false" (eq (toString .Values.useLegacyGRPCEndpoints) "false") -}} +{{- end -}} + {{/* External gRPC URL the controlplane API can be reached at This endpoint is used by the CLI to connect via gRPC +It uses the shared endpoint when useLegacyGRPCEndpoints is false, else the deprecated gRPC-only endpoint NOTE: Load balancer service type is not supported */}} {{- define "chainloop.controlplane.external_grpc_url" -}} {{- $service := .Values.controlplane.serviceAPI }} {{- $ingress := .Values.controlplane.ingressAPI }} +{{- if eq (include "chainloop.sharedEndpoints.enabled" .) "true" }} +{{- $service = .Values.controlplane.service }} +{{- $ingress = .Values.controlplane.ingress }} +{{- end }} {{- if (and $ingress $ingress.enabled $ingress.hostname) }} {{- printf "%s:%s" $ingress.hostname (ternary "443" "80" $ingress.tls) }} @@ -437,11 +450,16 @@ NOTE: Load balancer service type is not supported {{/* External gRPC URL the CAS API can be reached at This endpoint is used by the CLI to connect via gRPC +It uses the shared endpoint when useLegacyGRPCEndpoints is false, else the deprecated gRPC-only endpoint NOTE: Load balancer service type is not supported */}} {{- define "chainloop.cas.external_grpc_url" -}} {{- $service := .Values.cas.serviceAPI }} {{- $ingress := .Values.cas.ingressAPI }} +{{- if eq (include "chainloop.sharedEndpoints.enabled" .) "true" }} +{{- $service = .Values.cas.service }} +{{- $ingress = .Values.cas.ingress }} +{{- end }} {{- if (and $ingress $ingress.enabled $ingress.hostname) }} {{- printf "%s:%s" $ingress.hostname (ternary "443" "80" $ingress.tls) }} diff --git a/deployment/chainloop/templates/controlplane/configmap.yaml b/deployment/chainloop/templates/controlplane/configmap.yaml index 159d61cdb..60f70cb4e 100644 --- a/deployment/chainloop/templates/controlplane/configmap.yaml +++ b/deployment/chainloop/templates/controlplane/configmap.yaml @@ -51,7 +51,11 @@ data: {{- end }} cas_server: grpc: + {{- if eq (include "chainloop.sharedEndpoints.enabled" .) "true" }} + addr: {{ printf "%s:%d" (include "chainloop.cas.fullname" .) (coalesce .Values.cas.service.port .Values.cas.service.ports.http | int) }} + {{- else }} addr: {{ printf "%s-api:%.0f" (include "chainloop.cas.fullname" .) .Values.cas.serviceAPI.ports.http }} + {{- end }} insecure: {{ empty (include "controlplane.tls-secret-name" .) }} download_url: {{ include "chainloop.cas.external_url" . }}/download {{- if .Values.cas.defaultMaxEntrySize }} diff --git a/deployment/chainloop/values.yaml b/deployment/chainloop/values.yaml index ad3188815..6f3ede8db 100644 --- a/deployment/chainloop/values.yaml +++ b/deployment/chainloop/values.yaml @@ -33,6 +33,10 @@ global: ## development: false +## @param useLegacyGRPCEndpoints Give the clients the deprecated gRPC-only control plane and CAS endpoints (`ingressAPI`, `serviceAPI`) instead of the shared endpoints (`ingress`, `service`). This applies to the control plane connection to the CAS and to the CLI configuration in the install notes (NOTES.txt). Set it to false to use the shared endpoints. A later release changes the default to false. The chart keeps the deprecated Services in both modes +## +useLegacyGRPCEndpoints: true + ## @section Common parameters ## ## @param kubeVersion Override Kubernetes version @@ -375,7 +379,7 @@ controlplane: annotations: {} serviceAPI: - ## @param controlplane.serviceAPI.type Service type + ## @param controlplane.serviceAPI.type Deprecated gRPC-only Service type. Use the shared `controlplane.service` and set `useLegacyGRPCEndpoints` to false type: ClusterIP ## @param controlplane.serviceAPI.ports.http controlplane service HTTP port @@ -540,7 +544,7 @@ controlplane: ## ref: http://kubernetes.io/docs/user-guide/ingress/ ingressAPI: - ## @param controlplane.ingressAPI.enabled Enable ingress record generation for controlplane + ## @param controlplane.ingressAPI.enabled Enable the deprecated gRPC-only ingress for controlplane. Use the shared `controlplane.ingress` and set `useLegacyGRPCEndpoints` to false ## enabled: false ## @param controlplane.ingressAPI.pathType Ingress path type @@ -1159,7 +1163,7 @@ cas: annotations: {} serviceAPI: - ## @param cas.serviceAPI.type Service type + ## @param cas.serviceAPI.type Deprecated gRPC-only Service type. Use the shared `cas.service` and set `useLegacyGRPCEndpoints` to false type: ClusterIP ## @param cas.serviceAPI.ports.http cas service HTTP port @@ -1338,7 +1342,7 @@ cas: ## ref: http://kubernetes.io/docs/user-guide/ingress/ ingressAPI: - ## @param cas.ingressAPI.enabled Enable ingress record generation for controlplane + ## @param cas.ingressAPI.enabled Enable the deprecated gRPC-only ingress for CAS. Use the shared `cas.ingress` and set `useLegacyGRPCEndpoints` to false ## enabled: false ## @param cas.ingressAPI.pathType Ingress path type