Replicated Registry Proxy Pattern For Helm Charts A Comprehensive Guide
This document outlines a pattern for vendors to configure their first-party and third-party Helm charts to utilize images distributed through the Replicated registry. This approach ensures that applications deployed through Replicated can seamlessly access container images, regardless of their original source, and benefit from features like image caching, security scanning, and access control provided by Replicated.
Understanding the Replicated Registry Proxy
The Replicated registry proxy acts as an intermediary between your application and container image registries (such as Docker Hub, Quay.io, or private registries). It allows you to pull images through the Replicated platform, which offers several advantages:
- Centralized Image Management: Manage all your application's images through a single point, simplifying updates and security patching.
- Improved Reliability: Replicated caches images, reducing reliance on external registries and ensuring faster deployments, even during network outages.
- Enhanced Security: Replicated provides security scanning and vulnerability analysis for container images, helping you identify and mitigate potential risks.
- Access Control: Control which images can be accessed and deployed within your environment, ensuring compliance and security.
The Replicated registry proxy is particularly beneficial when deploying applications in air-gapped environments or environments with limited internet connectivity. It allows you to distribute your application and its dependencies without relying on external registries.
Helm Chart Configuration
To leverage the Replicated registry proxy, you need to configure your Helm charts to use the appropriate image URLs. This involves modifying the image
fields in your deployment manifests and providing users with the necessary values to configure the proxy.
Helm Templates for Image URLs
The core of this pattern lies in templating the repository and registry portions of the image URL within your Helm charts. This allows end-users to easily configure the image source through the values.yaml
file, ensuring flexibility and adaptability across different deployment environments.
In your Helm templates (e.g., templates/deployment.yaml
), you should use template directives to dynamically construct the image URL. This typically involves using Helm's Values
object to access user-defined variables.
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "my-app.fullname" . }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "my-app.name" . }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "my-app.name" . }}
spec:
containers:
- name: {{ .Chart.Name }}
image:
{{- if .Values.image.registry }}
{{ .Values.image.registry }}/
{{- end }}
{{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
In this example:
.Values.image.registry
: Represents the registry URL (e.g.,proxy.replicated.com/your-vendor
)..Values.image.repository
: Represents the image repository (e.g.,my-app
)..Values.image.tag
: Represents the image tag (e.g.,1.0.0
).- The
{{- if .Values.image.registry }}
block conditionally prepends the registry URL if it's defined in thevalues.yaml
file. This allows users to switch between using the Replicated registry proxy and a direct image pull from the original registry.
Values File Inputs for End Users
The values.yaml
file provides the user-facing configuration for your Helm chart. To enable the Replicated registry proxy, you need to define the necessary values in this file.
Here's an example of a values.yaml
file that configures the Replicated registry proxy:
replicaCount: 1
image:
registry: "proxy.replicated.com/your-vendor" # **Important:** Replace `your-vendor` with your Replicated vendor name.
repository: "my-app"
tag: "1.0.0"
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 80
Key Points:
- The
image.registry
value is set to the Replicated registry proxy URL, which follows the formatproxy.replicated.com/your-vendor
. It's crucial to replaceyour-vendor
with your actual Replicated vendor name. - The
image.repository
andimage.tag
values specify the image name and tag within the Replicated registry. - By providing these values, end-users can easily configure their application to use images distributed through the Replicated registry.
Example with Embedded Clusters (EC) and the proxy
Field
Replicated Embedded Clusters (EC) introduce a proxy
field within the values.yaml
to streamline the configuration of the registry proxy. This field simplifies the process and makes it more intuitive for end-users.
Here's an example demonstrating the use of the proxy
field:
replicaCount: 1
image:
repository: "my-app"
tag: "1.0.0"
pullPolicy: IfNotPresent
proxy:
registry: "proxy.replicated.com/your-vendor" # **Important:** Replace `your-vendor` with your Replicated vendor name.
service:
type: ClusterIP
port: 80
In this example:
- The
proxy.registry
field explicitly defines the Replicated registry proxy URL. - The
image.registry
field is no longer required, as the proxy setting is handled separately. - The Helm template needs to be adjusted slightly to utilize the
proxy.registry
value. The updated template snippet would look like this:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "my-app.fullname" . }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: {{ include "my-app.name" . }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "my-app.name" . }}
spec:
containers:
- name: {{ .Chart.Name }}
image:
{{- if .Values.proxy.registry }}
{{ .Values.proxy.registry }}/
{{- end }}
{{ .Values.image.repository }}:{{ .Values.image.tag }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 8080
protocol: TCP
Benefits of using the proxy
field:
- Improved Readability: The
proxy
field clearly separates the registry proxy configuration from other image settings, making thevalues.yaml
file easier to understand. - Simplified Configuration: End-users only need to specify the proxy registry URL in one place, reducing the risk of errors.
- Enhanced Flexibility: The
proxy
field can be extended to support additional proxy-related settings in the future.
Best Practices and Considerations
- Vendor Name: Always replace
your-vendor
with your actual Replicated vendor name in theproxy.registry
orimage.registry
values. - Image Tags: Use specific image tags (e.g.,
1.0.0
) instead oflatest
to ensure consistent deployments. - Image Pull Policy: Set the
imagePullPolicy
toIfNotPresent
orAlways
based on your specific requirements.IfNotPresent
is generally recommended for production environments to minimize unnecessary image pulls. - Security Scanning: Leverage Replicated's security scanning features to identify vulnerabilities in your container images.
- Air-Gapped Environments: The Replicated registry proxy is particularly valuable in air-gapped environments. Ensure that you have properly configured Replicated to pull images into the registry in these scenarios.
- Third-Party Charts: This pattern can be applied to both first-party and third-party Helm charts. When using third-party charts, carefully review the chart's documentation and modify the
values.yaml
file accordingly.
Conclusion
By implementing the Replicated registry proxy pattern, you can streamline image management, improve application reliability, enhance security, and simplify deployments in various environments. This approach empowers vendors to deliver their applications with confidence, knowing that their images are securely distributed and readily available to their customers. The introduction of the proxy
field in Embedded Clusters further simplifies the configuration process, making it even easier for end-users to leverage the benefits of the Replicated registry proxy.
By using Helm templates over the repository/registry portions of an image URL, and providing appropriate values file inputs, you can ensure a smooth and efficient deployment experience for your users. Remember to always replace your-vendor
with your actual Replicated vendor name. The new proxy
field, especially when used with Embedded Clusters (EC), significantly simplifies the process by providing a dedicated field for the registry proxy configuration.
This comprehensive guide provides a robust framework for configuring your Helm charts to effectively utilize the Replicated registry proxy. By adhering to the outlined best practices and leveraging the provided examples, you can ensure a seamless and secure image distribution process for your applications. The use of the proxy
field, as demonstrated, not only enhances readability but also simplifies the configuration process, making it easier for end-users to manage their image sources. This pattern is crucial for vendors aiming to provide a reliable and secure deployment experience for their customers, particularly in environments with limited or no internet access. Furthermore, centralizing image management through the Replicated registry proxy allows for better control over image versions and security policies, ultimately leading to a more robust and manageable application deployment lifecycle. The conditional logic in the Helm templates, which uses {{- if .Values.proxy.registry }}
or {{- if .Values.image.registry }}
, adds an extra layer of flexibility, allowing users to switch between the Replicated registry proxy and other registries as needed. This adaptability is essential for accommodating diverse deployment scenarios and preferences. In summary, this pattern not only solves the immediate challenge of configuring Helm charts for the Replicated registry proxy but also lays the groundwork for a more scalable and secure application deployment strategy. By embracing this pattern, vendors can significantly enhance their ability to deliver high-quality software while maintaining control over their intellectual property and ensuring the security of their applications.
FAQ
How to Configure Helm Charts for Replicated Registry Proxy?
To configure Helm charts for the Replicated registry proxy, you need to template the repository and registry portions of the image URL within your Helm charts. This involves modifying the image
fields in your deployment manifests and providing users with the necessary values in the values.yaml
file to configure the proxy. For Embedded Clusters (EC), the new proxy
field should be shown and demonstrated for simplified configuration.
What values file inputs are required for installing applications through the Replicated registry?
The values.yaml
file needs to include the registry URL in the format proxy.replicated.com/your-vendor
, where your-vendor
is your Replicated vendor name. Additionally, you need to specify the image repository and tag. For EC, the proxy.registry
field can be used to define the Replicated registry proxy URL, simplifying the configuration.
How does the new proxy
field in Embedded Clusters simplify registry proxy configuration?
The proxy
field in Embedded Clusters simplifies the configuration by providing a dedicated field, proxy.registry
, for specifying the Replicated registry proxy URL. This separates the proxy configuration from other image settings, making the values.yaml
file more readable and reducing the risk of errors. The Helm templates need to be adjusted to utilize the proxy.registry
value.