github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/pkg/kubernetes/artifacts.go (about) 1 package kubernetes 2 3 import ( 4 core "k8s.io/api/core/v1" 5 mach "k8s.io/apimachinery/pkg/apis/meta/v1" 6 7 "github.com/caos/orbos/mntr" 8 "github.com/caos/orbos/pkg/labels" 9 ) 10 11 func EnsureCaosSystemNamespace(monitor mntr.Monitor, client ClientInt) error { 12 13 monitor.Debug("Ensuring common artifacts") 14 15 return client.ApplyNamespace(&core.Namespace{ 16 ObjectMeta: mach.ObjectMeta{ 17 Name: "caos-system", 18 Labels: map[string]string{ 19 "name": "caos-system", 20 "app.kubernetes.io/part-of": "orbos", 21 }, 22 }, 23 }) 24 } 25 26 func EnsureOrbconfigSecret(monitor mntr.Monitor, client ClientInt, orbconfig []byte) error { 27 monitor.Debug("Ensuring configuration artifacts") 28 29 if err := EnsureCaosSystemNamespace(monitor, client); err != nil { 30 return err 31 } 32 33 if err := client.ApplySecret(&core.Secret{ 34 ObjectMeta: mach.ObjectMeta{ 35 Name: "caos", 36 Namespace: "caos-system", 37 Labels: map[string]string{ 38 "app.kubernetes.io/part-of": "orbos", 39 }, 40 }, 41 StringData: map[string]string{ 42 "orbconfig": string(orbconfig), 43 }, 44 }); err != nil { 45 return err 46 } 47 48 return nil 49 } 50 51 func toNameLabels(apiLabels *labels.API, operatorName string) *labels.Name { 52 return labels.MustForName(labels.MustForComponent(apiLabels, "operator"), operatorName) 53 } 54 55 func int32Ptr(i int32) *int32 { return &i } 56 func int64Ptr(i int64) *int64 { return &i } 57 func boolPtr(b bool) *bool { return &b }