Path: blob/main/install/installer/pkg/components/docker-registry/helm.go
2501 views
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34package dockerregistry56import (7"fmt"8"strconv"9"strings"1011"github.com/gitpod-io/gitpod/installer/pkg/common"12"github.com/gitpod-io/gitpod/installer/pkg/helm"13"github.com/gitpod-io/gitpod/installer/third_party/charts"14"helm.sh/helm/v3/pkg/cli/values"15"k8s.io/utils/pointer"16)1718var Helm = common.CompositeHelmFunc(19helm.ImportTemplate(charts.DockerRegistry(), helm.TemplateConfig{}, func(cfg *common.RenderContext) (*common.HelmConfig, error) {20secretHash, err := common.ObjectHash(common.DockerRegistryHash(cfg))21if err != nil {22return nil, err23}2425repository := cfg.RepoName(common.ThirdPartyContainerRepo(cfg.Config.Repository, common.DockerRegistryURL), "library/registry")2627registryValues := []string{28helm.KeyValue(fmt.Sprintf("docker-registry.podAnnotations.%s", strings.Replace(common.AnnotationConfigChecksum, ".", "\\.", -1)), secretHash),29helm.KeyValue("docker-registry.fullnameOverride", RegistryName),30helm.KeyValue("docker-registry.service.port", strconv.Itoa(common.ProxyContainerHTTPSPort)),31helm.KeyValue("docker-registry.tlsSecretName", BuiltInRegistryCerts),32helm.KeyValue("docker-registry.image.repository", repository),33helm.KeyValue("docker-registry.serviceAccount.name", Component),34}3536if len(cfg.Config.ImagePullSecrets) > 0 {37// This chart doesn't add in the "name/value" pair format38for k, v := range cfg.Config.ImagePullSecrets {39registryValues = append(registryValues, helm.KeyValue(fmt.Sprintf("docker-registry.imagePullSecrets[%d].name", k), v.Name))40}41}4243// Append the custom parameters44registryValues = helm.CustomizeAnnotation(registryValues, "docker-registry.podAnnotations", cfg, Component, common.TypeMetaDeployment)45registryValues = helm.CustomizeLabel(registryValues, "docker-registry.podLabels", cfg, Component, common.TypeMetaDeployment)46registryValues = helm.CustomizeAnnotation(registryValues, "docker-registry.service.annotations", cfg, Component, common.TypeMetaService)47registryValues = helm.CustomizeEnvvar(registryValues, "docker-registry.extraEnvVars", cfg, Component)4849inCluster := pointer.BoolDeref(cfg.Config.ContainerRegistry.InCluster, false)50s3Storage := cfg.Config.ContainerRegistry.S3Storage51enablePersistence := "true"5253if inCluster && s3Storage != nil {54enablePersistence = "false"55registryValues = append(registryValues,56helm.KeyValue("docker-registry.s3.region", s3Storage.Region),57helm.KeyValue("docker-registry.s3.bucket", s3Storage.Bucket),58helm.KeyValue("docker-registry.s3.regionEndpoint", s3Storage.Endpoint),59helm.KeyValue("docker-registry.s3.encrypt", "true"),60helm.KeyValue("docker-registry.s3.secure", "true"),61helm.KeyValue("docker-registry.storage", "s3"),62helm.KeyValue("docker-registry.secrets.s3.secretRef", s3Storage.Certificate.Name),63helm.KeyValue("docker-registry.secrets.haSharedSecret", cfg.Values.InternalRegistrySharedSecret),64)65}6667tolerations, err := helm.WithTolerationWorkspaceComponentNotReadyYaml(cfg)68if err != nil {69return nil, err70}71tolerationsTemplate, err := helm.KeyFileValue("docker-registry.tolerations", tolerations)72if err != nil {73return nil, err74}7576registryValues = append(registryValues, helm.KeyValue("docker-registry.persistence.enabled", enablePersistence))7778return &common.HelmConfig{79Enabled: inCluster,80Values: &values.Options{81Values: registryValues,82// This is too complex to be sent as a string83FileValues: []string{84tolerationsTemplate,85},86},87}, nil88}),89)909192