Skip to main content

Use the proxy registry with Helm CLI installations

This topic describes how to configure your application to use the Replicated proxy registry with Helm CLI installations. For more information about the proxy registry, see About the Replicated Proxy Registry. For more information about installing applications distributed with Replicated using Helm, see About Helm Installations with Replicated.

Overview​

During Helm CLI installations with Replicated, after customers provide their unique license ID, a global.replicated.dockerconfigjson field that contains a base64 encoded Docker configuration file is automatically injected in the Helm chart values. For more information about how Kubernetes uses the kubernetes.io/dockerconfigjson Secret type to provide authentication for a private registry, see Pull an Image from a Private Registry in the Kubernetes documentation.

The Replicated SDK automatically uses this value to create an image pull secret named enterprise-pull-secret. You can configure your Helm chart to use enterprise-pull-secret to authenticate with the Replicated proxy registry so that your application images can be proxied.

note

The image used by the Replicated SDK is automatically proxied through the proxy registry. No additional configuration is required.

Prerequisite​

Include the Replicated SDK version 1.15.0 or later as a dependency of your Helm chart. See Install the SDK as a Subchart in Install the Replicated SDK.

If you want to create your own pull secret instead of using the enterprise-pull-secret created by the SDK (such as if you manage the pull secret externally), see (Optional) Create Your Own Pull Secret on this page.

Configure your application to use the proxy registry​

To configure your application to use the proxy registry with Helm CLI installations:

  1. In the Vendor Portal, go to Image Registries > Add external registry and provide read-only credentials for each registry that hosts images your application uses. This allows Replicated to access the images through the proxy registry.

    This includes public registries such as Docker Hub (docker.io), quay.io, and public.ecr.aws. The proxy registry only pulls from upstream registries that you add, so pulls from any registry that you haven't added fail. See Add Credentials for an External Registry in Connecting to an External Registry.

    Link a new registry in the Vendor Portal
  2. (Recommended) Go to Custom Domains > Add custom domain and add a custom domain for the proxy registry. See Use Custom Domains.

  3. For each Helm chart used by your application, in the Helm chart's values.yaml file, update the registry for any private or third-party images to use the Replicated proxy registry URL. The upstream registry for each image, including public registries such as Docker Hub, must already be added as an external registry in the Vendor Portal.

    The proxy registry URL has the following format: DOMAIN/proxy/APP_SLUG/UPSTREAM_REGISTRY/IMAGE_PATH

    Where:

    • DOMAIN is either proxy.replicated.com or your custom domain
    • APP_SLUG is the unique slug of your application
    • UPSTREAM_REGISTRY/IMAGE_PATH is the full upstream image path. For example, ghcr.io/my-org/my-image or docker.io/bitnami/postgresql.

    The following examples demonstrate how to rewrite the registry depending on if you use separate values for the registry and repository or a single value for the full image name:

    Example (Separate values for image registry and repository)
    # Current values.yaml
    api:
    image:
    registry: ghcr.io
    repository: cloudnative-pg/cloudnative-pg
    # New values.yaml
    api:
    image:
    # proxy.replicated.com or your custom domain
    registry: proxy.replicated.com/proxy/app-slug/ghcr.io
    repository: cloudnative-pg/cloudnative-pg
    Example (Single value for full image name)
    # Current values.yaml
    initImage: docker.io/library/busybox:1.36
    # New values.yaml
    # proxy.replicated.com or your custom domain
    initImage: proxy.replicated.com/proxy/app-slug/docker.io/library/busybox:1.36

    Some third-party charts, such as Bitnami charts, check that each image comes from the chart's original registry and repository. If you rewrite an image to the Replicated proxy registry or to a local or customer-managed registry, the chart fails to render with an error that includes "Original containers have been substituted for unrecognized ones." Some chart versions also fail if you change only the repository, such as to docker.io/bitnamilegacy/postgresql. These checks are part of the chart, not Replicated, and they can change between chart versions.

    important

    Set the following value in the chart's values.yaml file or in the HelmChart custom resource builder key. If you set it only in the HelmChart values or optionalValues key, the air gap bundle build can fail, because the build renders the chart with only the chart's default values and the builder key.

    To skip the check, add the following to the chart's values.yaml file. Use this nested form. Helm ignores a single dotted key such as global.security.allowInsecureImages: true.

    global:
    security:
    allowInsecureImages: true

    Despite its name, this setting only skips the chart's image check. It does not change how images are pulled.

  4. In your chart _helper.tpl, add the following Helm helper. This helper creates an imagePullSecrets value that lists both the Replicated enterprise-pull-secret as well as any global or chart-level pull secrets provided by your customers. Using this helper supports use cases where customers need to provide one or more pull secrets in addition to the enterprise-pull-secret, such as in air gap installations where images are pushed to a private regitsry in the air-gapped environment.

    {{/*
    Image pull secrets
    */}}
    {{- define "replicated.imagePullSecrets" -}}
    {{- $pullSecrets := list }}

    {{- with ((.Values.global).imagePullSecrets) -}}
    {{- range . -}}
    {{- if kindIs "map" . -}}
    {{- $pullSecrets = append $pullSecrets .name -}}
    {{- else -}}
    {{- $pullSecrets = append $pullSecrets . -}}
    {{- end }}
    {{- end -}}
    {{- end -}}

    {{/* use image pull secrets provided as values */}}
    {{- with .Values.images -}}
    {{- range .pullSecrets -}}
    {{- if kindIs "map" . -}}
    {{- $pullSecrets = append $pullSecrets .name -}}
    {{- else -}}
    {{- $pullSecrets = append $pullSecrets . -}}
    {{- end -}}
    {{- end -}}
    {{- end -}}

    {{/* use the pull secret created by the SDK */}}
    {{- if hasKey ((.Values.global).replicated) "dockerconfigjson" }}
    {{- $pullSecrets = append $pullSecrets "enterprise-pull-secret" -}}
    {{- end -}}


    {{- if (not (empty $pullSecrets)) -}}
    imagePullSecrets:
    {{- range $pullSecrets | uniq }}
    - name: {{ . }}
    {{- end }}
    {{- end }}
    {{- end -}}
  5. Use your helper to include the image pull secrets in any manifests that reference the image.

    Example:

    apiVersion: v1
    kind: Pod
    spec:
    # Add the pull secret with your helper
    {{- include "replicated.imagePullSecrets" . | nindent 6 }}
    containers:
    - name: api
    # Access the registry, repository, and tag fields from the values file
    image: {{ .Values.images.api.registry }}/{{ .Values.images.api.repository }}:{{ .Values.images.api.tag }}
  6. If your application is deployed as multiple Helm charts, repeat the previous steps to modify image references and add the pull secret for each of your charts.

  7. Package your Helm chart and add it to a release. Promote the release to a development channel. See Managing Releases with Vendor Portal.

  8. Install in a development environment to test your changes. See Install with Helm.

(Optional) Create your own image pull secret​

You can optionally create your own image pull secret to authenticate with the Replicated proxy registry instead of using the enterprise-pull-secret that is automatically created by the Replicated SDK. You might want to create your own pull secret if you manage the pull secret externally.

To create a pull secret for the proxy registry:

  1. In your Helm chart values.yaml file, set the Replicated SDK's createPullSecret value to false. When createPullSecret is false, the SDK does not automatically create the enterprise-pull-secret during installation.

    # Your Helm chart values.yaml

    replicated:
    createPullSecret: false
  2. In your Helm chart templates, add a YAML file that evaluates if the global.replicated.dockerconfigjson value is set, and then writes the rendered value into a Secret on the cluster, as shown below.

    The following example names the Secret enterprise-pull-secret. If you use a different name, be sure to update any Helm helpers and image references in your chart accordingly. Do not use replicated for the name of the image pull secret because the Replicated SDK automatically creates a Secret named replicated. Using the same name causes an error.

    # templates/enterprise-pull-secret.yaml

    {{- $global := default dict .Values.global -}}
    {{- $replicated := default dict (index $global "replicated") -}}
    {{- if hasKey $replicated "dockerconfigjson" }}
    apiVersion: v1
    kind: Secret
    metadata:
    name: enterprise-pull-secret
    type: kubernetes.io/dockerconfigjson
    data:
    .dockerconfigjson: {{ .Values.global.replicated.dockerconfigjson }}
    {{ end }}
  3. Complete the steps in Configure Your Application to Pull Images Through the Proxy Registry to create and use a Helm helper to add the enterprise-pull-secret that you created to image references in your chart.