|
| 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 server |
| 6 | + |
| 7 | +import ( |
| 8 | + "fmt" |
| 9 | + "math" |
| 10 | + "time" |
| 11 | + |
| 12 | + "github.com/gitpod-io/gitpod/installer/pkg/common" |
| 13 | + |
| 14 | + certmanagerv1 "github.com/jetstack/cert-manager/pkg/apis/certmanager/v1" |
| 15 | + cmmeta "github.com/jetstack/cert-manager/pkg/apis/meta/v1" |
| 16 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 17 | + "k8s.io/apimachinery/pkg/runtime" |
| 18 | +) |
| 19 | + |
| 20 | +func authPKI(ctx *common.RenderContext) ([]runtime.Object, error) { |
| 21 | + serverAltNames := []string{ |
| 22 | + fmt.Sprintf("gitpod.%s", ctx.Namespace), |
| 23 | + fmt.Sprintf("%s.%s.svc", Component, ctx.Namespace), |
| 24 | + Component, |
| 25 | + fmt.Sprintf("%s-dev", Component), |
| 26 | + } |
| 27 | + |
| 28 | + return []runtime.Object{ |
| 29 | + &certmanagerv1.Certificate{ |
| 30 | + TypeMeta: common.TypeMetaCertificate, |
| 31 | + ObjectMeta: metav1.ObjectMeta{ |
| 32 | + Name: AuthPKISecretName, |
| 33 | + Namespace: ctx.Namespace, |
| 34 | + Labels: common.DefaultLabels(Component), |
| 35 | + }, |
| 36 | + Spec: certmanagerv1.CertificateSpec{ |
| 37 | + Duration: &metav1.Duration{ |
| 38 | + Duration: time.Duration(math.MaxInt64), // never expire automatically |
| 39 | + }, |
| 40 | + SecretName: AuthPKISecretName, |
| 41 | + DNSNames: serverAltNames, |
| 42 | + IssuerRef: cmmeta.ObjectReference{ |
| 43 | + Name: common.CertManagerCAIssuer, |
| 44 | + Kind: certmanagerv1.ClusterIssuerKind, |
| 45 | + Group: "cert-manager.io", |
| 46 | + }, |
| 47 | + PrivateKey: &certmanagerv1.CertificatePrivateKey{ |
| 48 | + Encoding: certmanagerv1.PKCS8, |
| 49 | + Size: 4096, |
| 50 | + Algorithm: certmanagerv1.RSAKeyAlgorithm, |
| 51 | + }, |
| 52 | + SecretTemplate: &certmanagerv1.CertificateSecretTemplate{ |
| 53 | + Labels: common.DefaultLabels(Component), |
| 54 | + }, |
| 55 | + }, |
| 56 | + }, |
| 57 | + }, nil |
| 58 | +} |
0 commit comments