From a6370965fc70e5ff7ea2ffc23203049f8e35724d Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Tue, 11 Jun 2024 16:09:31 -0400 Subject: [PATCH 1/9] scaffold for deployment/service with flag for creation upon startup Signed-off-by: Troy Connor --- controllers/types.go | 11 +++++++++++ main.go | 26 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/controllers/types.go b/controllers/types.go index fbaa75e1..5ab160d9 100644 --- a/controllers/types.go +++ b/controllers/types.go @@ -5,6 +5,9 @@ import ( installationv1 "get.porter.sh/porter/gen/proto/go/porterapis/installation/v1alpha1" "google.golang.org/grpc" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) type PorterClient interface { @@ -15,3 +18,11 @@ type PorterClient interface { type ClientConn interface { Close() error } + +var GrpcDeployment = &appsv1.Deployment{ + ObjectMeta: metav1.ObjectMeta{}, +} + +var GrpcService = &corev1.Service{ + ObjectMeta: metav1.ObjectMeta{}, +} diff --git a/main.go b/main.go index c918722e..227a3010 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "flag" "os" @@ -9,10 +10,12 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth" + "golang.org/x/sync/errgroup" "k8s.io/apimachinery/pkg/runtime" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/healthz" "sigs.k8s.io/controller-runtime/pkg/log/zap" "sigs.k8s.io/controller-runtime/pkg/metrics/server" @@ -34,14 +37,17 @@ func init() { } func main() { + ctx := context.Background() var metricsAddr string var enableLeaderElection bool var probeAddr string + var createGrpc bool flag.StringVar(&metricsAddr, "metrics-bind-address", ":8080", "The address the metric endpoint binds to.") flag.StringVar(&probeAddr, "health-probe-bind-address", ":8081", "The address the probe endpoint binds to.") flag.BoolVar(&enableLeaderElection, "leader-elect", false, "Enable leader election for controller manager. "+ "Enabling this will ensure there is only one active controller manager.") + flag.BoolVar(&createGrpc, "create-grpc", true, "create grpc deployment for use in operator") opts := zap.Options{ Development: true, } @@ -116,6 +122,26 @@ func main() { os.Exit(1) } + if createGrpc { + g, ctx := errgroup.WithContext(ctx) + g.Go(func() error { + k8sClient := mgr.GetClient() + return k8sClient.Create(ctx, controllers.GrpcDeployment, &client.CreateOptions{}) + }) + + g.Go(func() error { + k8sClient := mgr.GetClient() + return k8sClient.Create(ctx, controllers.GrpcService, &client.CreateOptions{}) + }) + + go func() { + if err := g.Wait(); err != nil { + setupLog.Error(err, "error with async operation of creating grpc deployment") + os.Exit(1) + } + }() + } + setupLog.Info("starting manager") if err := mgr.Start(ctrl.SetupSignalHandler()); err != nil { setupLog.Error(err, "problem running manager") From 5eeb5786a33be4b1a9fced39cbf88ac3c5863376 Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Wed, 12 Jun 2024 17:52:04 -0400 Subject: [PATCH 2/9] only create deployment if not found Signed-off-by: Troy Connor --- main.go | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 227a3010..eb5b9ddb 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,11 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth" "golang.org/x/sync/errgroup" + appsv1 "k8s.io/api/apps/v1" + corev1 "k8s.io/api/core/v1" + apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/types" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" ctrl "sigs.k8s.io/controller-runtime" @@ -126,12 +130,29 @@ func main() { g, ctx := errgroup.WithContext(ctx) g.Go(func() error { k8sClient := mgr.GetClient() - return k8sClient.Create(ctx, controllers.GrpcDeployment, &client.CreateOptions{}) + // GET deployment to see if it exists first before creating it + deployment := &appsv1.Deployment{} + err := k8sClient.Get(ctx, types.NamespacedName{Name: controllers.GrpcDeployment.Name, Namespace: controllers.GrpcDeployment.Namespace}, deployment) + if err != nil { + if apierrors.IsNotFound(err) { + return k8sClient.Create(ctx, controllers.GrpcDeployment, &client.CreateOptions{}) + } + } + // NOTE: Don't crash, just don't deploy if Get fails for any other reason than not found + return nil }) g.Go(func() error { k8sClient := mgr.GetClient() - return k8sClient.Create(ctx, controllers.GrpcService, &client.CreateOptions{}) + service := &corev1.Service{} + err := k8sClient.Get(ctx, types.NamespacedName{Name: controllers.GrpcService.Name, Namespace: controllers.GrpcService.Namespace}, service) + if err != nil { + if apierrors.IsNotFound(err) { + return k8sClient.Create(ctx, controllers.GrpcService, &client.CreateOptions{}) + } + } + // NOTE: Don't crash, just don't deploy if Get fails for any other reason than not found + return nil }) go func() { From 8bf94dd57a609ab82c94d24bc92a4c5191e97c09 Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Mon, 17 Jun 2024 17:38:45 -0400 Subject: [PATCH 3/9] add cm and log when complete Signed-off-by: Troy Connor --- controllers/types.go | 21 +++++++++++++++++++-- main.go | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/controllers/types.go b/controllers/types.go index 5ab160d9..7ebf6d3b 100644 --- a/controllers/types.go +++ b/controllers/types.go @@ -10,6 +10,10 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) +const ( + PorterNamespace = "porter-operator-system" +) + type PorterClient interface { ListInstallations(ctx context.Context, in *installationv1.ListInstallationsRequest, opts ...grpc.CallOption) (*installationv1.ListInstallationsResponse, error) ListInstallationLatestOutputs(ctx context.Context, in *installationv1.ListInstallationLatestOutputRequest, opts ...grpc.CallOption) (*installationv1.ListInstallationLatestOutputResponse, error) @@ -20,9 +24,22 @@ type ClientConn interface { } var GrpcDeployment = &appsv1.Deployment{ - ObjectMeta: metav1.ObjectMeta{}, + ObjectMeta: metav1.ObjectMeta{ + Name: "", + Namespace: PorterNamespace, + }, } var GrpcService = &corev1.Service{ - ObjectMeta: metav1.ObjectMeta{}, + ObjectMeta: metav1.ObjectMeta{ + Name: "", + Namespace: PorterNamespace, + }, +} + +var GrpcConfigMap = &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: "", + Namespace: PorterNamespace, + }, } diff --git a/main.go b/main.go index eb5b9ddb..244116a6 100644 --- a/main.go +++ b/main.go @@ -127,6 +127,7 @@ func main() { } if createGrpc { + // TODO: should this be one go routine or several? g, ctx := errgroup.WithContext(ctx) g.Go(func() error { k8sClient := mgr.GetClient() @@ -135,6 +136,7 @@ func main() { err := k8sClient.Get(ctx, types.NamespacedName{Name: controllers.GrpcDeployment.Name, Namespace: controllers.GrpcDeployment.Namespace}, deployment) if err != nil { if apierrors.IsNotFound(err) { + setupLog.Info("creating grpc deployment") return k8sClient.Create(ctx, controllers.GrpcDeployment, &client.CreateOptions{}) } } @@ -148,6 +150,7 @@ func main() { err := k8sClient.Get(ctx, types.NamespacedName{Name: controllers.GrpcService.Name, Namespace: controllers.GrpcService.Namespace}, service) if err != nil { if apierrors.IsNotFound(err) { + setupLog.Info("creating grpc service") return k8sClient.Create(ctx, controllers.GrpcService, &client.CreateOptions{}) } } @@ -155,11 +158,26 @@ func main() { return nil }) + g.Go(func() error { + k8sClient := mgr.GetClient() + cm := &corev1.ConfigMap{} + err := k8sClient.Get(ctx, types.NamespacedName{Name: controllers.GrpcConfigMap.Name, Namespace: controllers.GrpcConfigMap.Namespace}, cm) + if err != nil { + if apierrors.IsNotFound(err) { + setupLog.Info("creating grpc configmap") + return k8sClient.Create(ctx, controllers.GrpcConfigMap, &client.CreateOptions{}) + } + } + // NOTE: Don't crash, just don't deploy if Get fails for any other reason than not found + return nil + }) + go func() { if err := g.Wait(); err != nil { setupLog.Error(err, "error with async operation of creating grpc deployment") os.Exit(1) } + setupLog.Info("grpc server has been created") }() } From 16ee64d84057d6b70c3f073de24510a5d543af7e Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Mon, 24 Jun 2024 18:18:06 -0400 Subject: [PATCH 4/9] create deployment spec Signed-off-by: Troy Connor --- controllers/types.go | 49 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/controllers/types.go b/controllers/types.go index 7ebf6d3b..7fead576 100644 --- a/controllers/types.go +++ b/controllers/types.go @@ -7,11 +7,14 @@ import ( "google.golang.org/grpc" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" ) const ( PorterNamespace = "porter-operator-system" + PorterGRPCName = "porter-grpc-service" ) type PorterClient interface { @@ -25,8 +28,52 @@ type ClientConn interface { var GrpcDeployment = &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ - Name: "", + Name: PorterGRPCName, Namespace: PorterNamespace, + Labels: map[string]string{ + "app": "porter-grpc-service", + }, + }, + Spec: appsv1.DeploymentSpec{ + Replicas: ptr.To(int32(1)), + Selector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "app": "porter-grpc-service", + }, + }, + Template: corev1.PodTemplateSpec{ + Spec: corev1.PodSpec{ + Containers: []corev1.Container{ + { + Name: "porter-grpc-service", + Image: "ghcr.io/bdegeeter/porter/server:v1.0.0-alpha.5-794-g7168418d", + Ports: []corev1.ContainerPort{ + { + Name: "grpc", + ContainerPort: 3001, + }, + }, + Args: []string{"server", "run"}, + VolumeMounts: []corev1.VolumeMount{ + { + MountPath: "/porter-config", + Name: "porter-grpc-service-config-volume", + }, + }, + Resources: corev1.ResourceRequirements{ + Limits: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("2000m"), + corev1.ResourceMemory: resource.MustParse("512Mi"), + }, + Requests: corev1.ResourceList{ + corev1.ResourceCPU: resource.MustParse("100m"), + corev1.ResourceMemory: resource.MustParse("32Mi"), + }, + }, + }, + }, + }, + }, }, } From 9ed0cf73cd9725535c29666628d29d521c1c6e33 Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Tue, 25 Jun 2024 10:01:33 -0400 Subject: [PATCH 5/9] create service,confimap and volumes for deployment Signed-off-by: Troy Connor --- controllers/types.go | 47 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/controllers/types.go b/controllers/types.go index 7fead576..e0822b49 100644 --- a/controllers/types.go +++ b/controllers/types.go @@ -9,6 +9,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/utils/ptr" ) @@ -72,6 +73,21 @@ var GrpcDeployment = &appsv1.Deployment{ }, }, }, + Volumes: []corev1.Volume{ + { + Name: "porter-grpc-service-config-volume", + VolumeSource: corev1.VolumeSource{ + ConfigMap: &corev1.ConfigMapVolumeSource{ + Items: []corev1.KeyToPath{ + { + Key: "config", + Path: "config.yaml", + }, + }, + }, + }, + }, + }, }, }, }, @@ -79,14 +95,41 @@ var GrpcDeployment = &appsv1.Deployment{ var GrpcService = &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ - Name: "", + Name: PorterGRPCName, Namespace: PorterNamespace, + Labels: map[string]string{ + "app": "porter-grpc-service", + }, + }, + Spec: corev1.ServiceSpec{ + Ports: []corev1.ServicePort{ + { + Protocol: corev1.ProtocolTCP, + TargetPort: intstr.FromString("3001"), + Port: int32(3001), + }, + }, + Selector: map[string]string{"app": "porter-grpc-service"}, + Type: corev1.ServiceTypeClusterIP, }, } var GrpcConfigMap = &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Name: "", + Name: "porter-grpc-service-config", Namespace: PorterNamespace, }, + Data: map[string]string{ + "config": ConfigmMapConfig, + }, } + +var ConfigmMapConfig = ` +default-secrets-plugin: "kubernetes.secrets" +default-storage: "mongodb" +storage: + - name: "mongodb" + plugin: "mongodb" + config: + url: "mongodb://root:demopasswd@porter-operator-mongodb.demo.svc.cluster.local" +` From 8902e0234f7427b150b29e89e315261f3ff0d690 Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Wed, 26 Jun 2024 14:05:27 -0400 Subject: [PATCH 6/9] handle conflict if resource already exists Signed-off-by: Troy Connor --- controllers/types.go | 10 +++++++++- main.go | 40 +++++++++++++++------------------------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/controllers/types.go b/controllers/types.go index e0822b49..8e47fdf6 100644 --- a/controllers/types.go +++ b/controllers/types.go @@ -43,6 +43,11 @@ var GrpcDeployment = &appsv1.Deployment{ }, }, Template: corev1.PodTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: map[string]string{ + "app": "porter-grpc-service", + }, + }, Spec: corev1.PodSpec{ Containers: []corev1.Container{ { @@ -78,6 +83,9 @@ var GrpcDeployment = &appsv1.Deployment{ Name: "porter-grpc-service-config-volume", VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ + LocalObjectReference: corev1.LocalObjectReference{ + Name: "porter-grpc-service-config", + }, Items: []corev1.KeyToPath{ { Key: "config", @@ -105,7 +113,7 @@ var GrpcService = &corev1.Service{ Ports: []corev1.ServicePort{ { Protocol: corev1.ProtocolTCP, - TargetPort: intstr.FromString("3001"), + TargetPort: intstr.FromInt(3001), Port: int32(3001), }, }, diff --git a/main.go b/main.go index 244116a6..195a6376 100644 --- a/main.go +++ b/main.go @@ -11,11 +11,8 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth" "golang.org/x/sync/errgroup" - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/types" utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" ctrl "sigs.k8s.io/controller-runtime" @@ -131,28 +128,22 @@ func main() { g, ctx := errgroup.WithContext(ctx) g.Go(func() error { k8sClient := mgr.GetClient() - // GET deployment to see if it exists first before creating it - deployment := &appsv1.Deployment{} - err := k8sClient.Get(ctx, types.NamespacedName{Name: controllers.GrpcDeployment.Name, Namespace: controllers.GrpcDeployment.Namespace}, deployment) + err := k8sClient.Create(ctx, controllers.GrpcConfigMap, &client.CreateOptions{}) if err != nil { - if apierrors.IsNotFound(err) { - setupLog.Info("creating grpc deployment") - return k8sClient.Create(ctx, controllers.GrpcDeployment, &client.CreateOptions{}) + if apierrors.IsAlreadyExists(err) { + setupLog.Error(err, "configmap already exists, not creating") + return nil } + setupLog.Error(err, "error creating configmap") } - // NOTE: Don't crash, just don't deploy if Get fails for any other reason than not found - return nil - }) - g.Go(func() error { - k8sClient := mgr.GetClient() - service := &corev1.Service{} - err := k8sClient.Get(ctx, types.NamespacedName{Name: controllers.GrpcService.Name, Namespace: controllers.GrpcService.Namespace}, service) + err = k8sClient.Create(ctx, controllers.GrpcDeployment, &client.CreateOptions{}) if err != nil { - if apierrors.IsNotFound(err) { - setupLog.Info("creating grpc service") - return k8sClient.Create(ctx, controllers.GrpcService, &client.CreateOptions{}) + if apierrors.IsAlreadyExists(err) { + setupLog.Error(err, "deployment already exists, not creating") + return nil } + setupLog.Error(err, "error creating configmap") } // NOTE: Don't crash, just don't deploy if Get fails for any other reason than not found return nil @@ -160,15 +151,14 @@ func main() { g.Go(func() error { k8sClient := mgr.GetClient() - cm := &corev1.ConfigMap{} - err := k8sClient.Get(ctx, types.NamespacedName{Name: controllers.GrpcConfigMap.Name, Namespace: controllers.GrpcConfigMap.Namespace}, cm) + err := k8sClient.Create(ctx, controllers.GrpcService, &client.CreateOptions{}) if err != nil { - if apierrors.IsNotFound(err) { - setupLog.Info("creating grpc configmap") - return k8sClient.Create(ctx, controllers.GrpcConfigMap, &client.CreateOptions{}) + if apierrors.IsAlreadyExists(err) { + setupLog.Error(err, "service already exists, not creating") + return nil } + setupLog.Error(err, "error creating service") } - // NOTE: Don't crash, just don't deploy if Get fails for any other reason than not found return nil }) From 14280fdcee3c1585e00e4a98cfbcefedde7a6ece Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Thu, 27 Jun 2024 11:07:29 -0400 Subject: [PATCH 7/9] update manager role to allow creation of deployment, service and configmap Signed-off-by: Troy Connor --- config/rbac/role.yaml | 60 +++++++++++++++++++++++++++++++++++++++++++ main.go | 13 +++++----- 2 files changed, 66 insertions(+), 7 deletions(-) diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 861a103b..190fcdc3 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -16,6 +16,42 @@ rules: - patch - update - watch +- apiGroups: + - "" + resources: + - configmaps + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - apps + resources: + - deployments + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - "" + resources: + - services + verbs: + - create + - delete + - get + - list + - patch + - update + - watch - apiGroups: - "" resources: @@ -158,6 +194,30 @@ rules: - get - patch - update +- apiGroups: + - "" + resources: + - events + verbs: + - create + - delete + - get + - list + - patch + - update + - watch +- apiGroups: + - coordination.k8s.io + resources: + - leases + verbs: + - create + - delete + - get + - list + - patch + - update + - watch - apiGroups: - getporter.org resources: diff --git a/main.go b/main.go index 195a6376..b066b112 100644 --- a/main.go +++ b/main.go @@ -124,26 +124,25 @@ func main() { } if createGrpc { - // TODO: should this be one go routine or several? g, ctx := errgroup.WithContext(ctx) g.Go(func() error { k8sClient := mgr.GetClient() err := k8sClient.Create(ctx, controllers.GrpcConfigMap, &client.CreateOptions{}) if err != nil { if apierrors.IsAlreadyExists(err) { - setupLog.Error(err, "configmap already exists, not creating") + setupLog.Info("configmap already exists, not creating") return nil } - setupLog.Error(err, "error creating configmap") + setupLog.Info("error creating configmap, %s", err.Error()) } err = k8sClient.Create(ctx, controllers.GrpcDeployment, &client.CreateOptions{}) if err != nil { if apierrors.IsAlreadyExists(err) { - setupLog.Error(err, "deployment already exists, not creating") + setupLog.Info("deployment already exists, not creating") return nil } - setupLog.Error(err, "error creating configmap") + setupLog.Info("error creating deployment, %s", err.Error()) } // NOTE: Don't crash, just don't deploy if Get fails for any other reason than not found return nil @@ -154,10 +153,10 @@ func main() { err := k8sClient.Create(ctx, controllers.GrpcService, &client.CreateOptions{}) if err != nil { if apierrors.IsAlreadyExists(err) { - setupLog.Error(err, "service already exists, not creating") + setupLog.Info("service already exists, not creating") return nil } - setupLog.Error(err, "error creating service") + setupLog.Info("error creating service, %s", err.Error()) } return nil }) From 3ec5f36f5347786f557e64e55d1b731b88dd3a38 Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Tue, 2 Jul 2024 16:17:05 -0400 Subject: [PATCH 8/9] change image and command for grpc server Signed-off-by: Troy Connor --- controllers/types.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controllers/types.go b/controllers/types.go index 8e47fdf6..59a88fdd 100644 --- a/controllers/types.go +++ b/controllers/types.go @@ -52,14 +52,14 @@ var GrpcDeployment = &appsv1.Deployment{ Containers: []corev1.Container{ { Name: "porter-grpc-service", - Image: "ghcr.io/bdegeeter/porter/server:v1.0.0-alpha.5-794-g7168418d", + Image: "ghcr.io/getporter/server:v1.1.0", Ports: []corev1.ContainerPort{ { Name: "grpc", ContainerPort: 3001, }, }, - Args: []string{"server", "run"}, + Args: []string{"api-server", "run"}, VolumeMounts: []corev1.VolumeMount{ { MountPath: "/porter-config", From 1d5cecba7c42dcc017e92415cd7b5d9428720b84 Mon Sep 17 00:00:00 2001 From: Troy Connor Date: Wed, 10 Jul 2024 16:06:59 -0400 Subject: [PATCH 9/9] remove PorterNamespace and use const for image Signed-off-by: Troy Connor --- controllers/types.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/controllers/types.go b/controllers/types.go index 59a88fdd..65329059 100644 --- a/controllers/types.go +++ b/controllers/types.go @@ -14,8 +14,8 @@ import ( ) const ( - PorterNamespace = "porter-operator-system" - PorterGRPCName = "porter-grpc-service" + PorterGRPCName = "porter-grpc-service" + PorterDeploymentImage = "ghcr.io/getporter/server:v1.1.0" ) type PorterClient interface { @@ -30,7 +30,7 @@ type ClientConn interface { var GrpcDeployment = &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: PorterGRPCName, - Namespace: PorterNamespace, + Namespace: operatorNamespace, Labels: map[string]string{ "app": "porter-grpc-service", }, @@ -52,7 +52,7 @@ var GrpcDeployment = &appsv1.Deployment{ Containers: []corev1.Container{ { Name: "porter-grpc-service", - Image: "ghcr.io/getporter/server:v1.1.0", + Image: PorterDeploymentImage, Ports: []corev1.ContainerPort{ { Name: "grpc", @@ -104,7 +104,7 @@ var GrpcDeployment = &appsv1.Deployment{ var GrpcService = &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Name: PorterGRPCName, - Namespace: PorterNamespace, + Namespace: operatorNamespace, Labels: map[string]string{ "app": "porter-grpc-service", }, @@ -125,7 +125,7 @@ var GrpcService = &corev1.Service{ var GrpcConfigMap = &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "porter-grpc-service-config", - Namespace: PorterNamespace, + Namespace: operatorNamespace, }, Data: map[string]string{ "config": ConfigmMapConfig,