-
Notifications
You must be signed in to change notification settings - Fork 2
/
namespace.go
31 lines (25 loc) · 941 Bytes
/
namespace.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package application
import (
"github.com/equinor/radix-operator/pkg/apis/kube"
"github.com/equinor/radix-operator/pkg/apis/utils"
"k8s.io/apimachinery/pkg/labels"
)
// createAppNamespace creates an app namespace with RadixRegistration as owner
func (app Application) createAppNamespace() error {
registration := app.registration
name := utils.GetAppNamespace(registration.Name)
nsLabels := map[string]string{
kube.RadixAppLabel: registration.Name,
kube.RadixEnvLabel: utils.AppNamespaceEnvName,
"snyk-service-account-sync": "radix-snyk-service-account",
}
nsLabels = labels.Merge(nsLabels, kube.NewAppNamespacePodSecurityStandardFromEnv().Labels())
ownerRef := app.getOwnerReference()
err := app.kubeutil.ApplyNamespace(name, nsLabels, ownerRef)
if err != nil {
logger.Errorf("Failed to create namespace %s: %v", name, err)
return err
}
logger.Infof("Created namespace %s", name)
return nil
}