Enabling caching proxy for builds
Konflux supports HTTP proxy caching to improve build performance. When enabled, container build operations can use a Squid HTTP proxy to cache layers, reducing build times for subsequent builds.
Prerequisites
The caching proxy requires Squid to be installed on the cluster. Cluster administrators can install Squid using the Helm chart from the caching repository.
How it works
The caching proxy feature uses two levels of configuration:
-
Pipeline level: The
enable-cache-proxyparameter controls whether a specific pipeline uses the caching proxy. -
Cluster level: A
cluster-configConfigMap in thekonflux-infonamespace provides the proxy configuration and can disable proxy usage cluster-wide.
The pipeline’s init task reads the configuration and emits HTTP_PROXY and NO_PROXY values to be used by the buildah task.
Enabling the caching proxy
The caching proxy is disabled by default. To enable the caching proxy for a component’s build pipeline, set the enable-cache-proxy pipeline parameter to true.
-
In the PipelineRun YAML files in the
.tektondirectory, set theenable-cache-proxyparameter totruein thespec.paramssection:spec: params: - name: enable-cache-proxy value: "true" -
Commit your changes to the repository of the component.
Cluster-level configuration
The caching proxy behavior can be configured at the cluster level using a ConfigMap named cluster-config in the konflux-info namespace. This ConfigMap is globally readable from all namespaces in the cluster, but writable only by the infrastructure team.
The ConfigMap supports the following keys:
allow-cache-proxy-
When set to
false, disables the caching proxy for all pipelines in the cluster, regardless of individual pipeline settings. When set totrueor unset, pipelines can use the proxy if they haveenable-cache-proxyset totrue.data: allow-cache-proxy: "true" http-proxy-
The HTTP proxy URL to use for builds. If not set, defaults to
squid.caching.svc.cluster.local:3128.data: http-proxy: "squid.caching.svc.cluster.local:3128" no-proxy-
A comma-separated list of hosts that should bypass the proxy. If not set, the init task uses a default list of common container registries.
data: no-proxy: "quay.io,registry.redhat.io,docker.io"
apiVersion: v1
kind: ConfigMap
metadata:
name: cluster-config
namespace: konflux-info
data:
allow-cache-proxy: "true"
http-proxy: "squid.caching.svc.cluster.local:3128"
no-proxy: "quay.io,registry.redhat.io,docker.io"
Configuration precedence
The caching proxy is enabled only when both of the following conditions are met:
-
The pipeline parameter
enable-cache-proxyis set totrue. -
The cluster-level
allow-cache-proxyis either set totrueor is unset.
If allow-cache-proxy is explicitly set to false at the cluster level, the proxy is disabled for all pipelines, even if individual pipelines have enable-cache-proxy set to true.
Logging
The init task logs the proxy configuration applied to the pipeline run and the reasoning for the applied settings. You can view these logs in the pipeline run’s init task output.
Fetching cluster-config from konflux-info namespace...
Cache proxy enabled (cluster-enabled: true, task-enable: true)
Setting HTTP_PROXY to squid.caching.svc.cluster.local:3128
Setting NO_PROXY to quay.io,registry.redhat.io,docker.io
Fetching cluster-config from konflux-info namespace...
Cache proxy disabled (cluster-enabled: true, task-enable: false)
Setting HTTP_PROXY to
Setting NO_PROXY to
If the cluster-config ConfigMap is not found, the init task logs a warning and proceeds with default values:
Warning: Failed to fetch cluster-config ConfigMap. Proceeding with defaults.