Path: blob/main/install/installer/pkg/components/spicedb/objects.go
2501 views
// Copyright (c) 2023 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 spicedb56import (7"fmt"8"net"9"strconv"1011"github.com/gitpod-io/gitpod/installer/pkg/common"12"github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental"13corev1 "k8s.io/api/core/v1"14"k8s.io/apimachinery/pkg/runtime"15)1617func Objects(ctx *common.RenderContext) ([]runtime.Object, error) {1819spiceDBConfig := getExperimentalSpiceDBConfig(ctx)20if spiceDBConfig == nil {21return nil, nil22}2324return common.CompositeRenderFunc(25deployment,26service,27common.DefaultServiceAccount(Component),28migrations,29networkpolicy,30bootstrap,31role,32rolebinding,33)(ctx)34}3536func getExperimentalSpiceDBConfig(ctx *common.RenderContext) *experimental.SpiceDBConfig {37webappCfg := common.ExperimentalWebappConfig(ctx)3839if webappCfg == nil || webappCfg.SpiceDB == nil {40return nil41}4243return webappCfg.SpiceDB44}4546func Env(ctx *common.RenderContext) []corev1.EnvVar {47cfg := getExperimentalSpiceDBConfig(ctx)48if cfg == nil {49return nil50}5152return []corev1.EnvVar{53{54Name: "SPICEDB_ADDRESS",55Value: net.JoinHostPort(fmt.Sprintf("%s.%s.svc.cluster.local", Component, ctx.Namespace), strconv.Itoa(ContainerGRPCPort)),56},57{58Name: "SPICEDB_PRESHARED_KEY",59ValueFrom: &corev1.EnvVarSource{60SecretKeyRef: &corev1.SecretKeySelector{61LocalObjectReference: corev1.LocalObjectReference{62Name: cfg.SecretRef,63},64Key: SecretPresharedKeyName,65},66},67},68}69}707172