Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/install/installer/pkg/components/docker-registry/certificate.go
2501 views
1
// Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
package dockerregistry
6
7
import (
8
"fmt"
9
10
"github.com/gitpod-io/gitpod/installer/pkg/common"
11
certmanagerv1 "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1"
12
cmmeta "github.com/jetstack/cert-manager/pkg/apis/meta/v1"
13
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14
"k8s.io/apimachinery/pkg/runtime"
15
"k8s.io/utils/pointer"
16
)
17
18
func certificate(ctx *common.RenderContext) ([]runtime.Object, error) {
19
if !pointer.BoolDeref(ctx.Config.ContainerRegistry.InCluster, false) {
20
return nil, nil
21
}
22
23
return []runtime.Object{&certmanagerv1.Certificate{
24
TypeMeta: common.TypeMetaCertificate,
25
ObjectMeta: metav1.ObjectMeta{
26
Name: BuiltInRegistryCerts,
27
Namespace: ctx.Namespace,
28
Labels: common.DefaultLabels(Component),
29
},
30
Spec: certmanagerv1.CertificateSpec{
31
Duration: common.InternalCertDuration,
32
SecretName: BuiltInRegistryCerts,
33
IssuerRef: cmmeta.ObjectReference{
34
Name: common.CertManagerCAIssuer,
35
Kind: certmanagerv1.ClusterIssuerKind,
36
Group: "cert-manager.io",
37
},
38
DNSNames: []string{
39
fmt.Sprintf("registry.%s.svc.cluster.local", ctx.Namespace),
40
},
41
SecretTemplate: &certmanagerv1.CertificateSecretTemplate{
42
Labels: common.DefaultLabels(Component),
43
},
44
},
45
}}, nil
46
}
47
48