From 3c5bd39c0ac65769129e603867f09119dae67626 Mon Sep 17 00:00:00 2001 From: Avi Zimmerman Date: Fri, 20 Oct 2023 20:33:52 +0300 Subject: [PATCH 1/2] feat: allow to customize service name --- apis/app/v1/vdicluster_app_util.go | 3 +++ apis/app/v1/vdicluster_types.go | 3 +++ config/crd/bases/app.kvdi.io_vdiclusters.yaml | 4 ++++ deploy/bundle.yaml | 3 +++ 4 files changed, 13 insertions(+) diff --git a/apis/app/v1/vdicluster_app_util.go b/apis/app/v1/vdicluster_app_util.go index f0c07320..210240ce 100644 --- a/apis/app/v1/vdicluster_app_util.go +++ b/apis/app/v1/vdicluster_app_util.go @@ -31,6 +31,9 @@ import ( // GetAppName returns the name of the kVDI app deployment for this VDICluster. func (c *VDICluster) GetAppName() string { + if c.Spec.App != nil && c.Spec.App.ServiceName != "" { + return c.Spec.App.ServiceName + } return fmt.Sprintf("%s-app", c.GetName()) } diff --git a/apis/app/v1/vdicluster_types.go b/apis/app/v1/vdicluster_types.go index 07e4e98c..b0f229f2 100644 --- a/apis/app/v1/vdicluster_types.go +++ b/apis/app/v1/vdicluster_types.go @@ -112,6 +112,9 @@ type AppConfig struct { AuditLog bool `json:"auditLog,omitempty"` // The number of app replicas to run Replicas int32 `json:"replicas,omitempty"` + // ServiceName is the name of the service to create for the app instance. + // Defaults to `{vdi-name}-app`. + ServiceName string `json:"serviceName,omitempty"` // The type of service to create in front of the app instance. // Defaults to `LoadBalancer`. ServiceType corev1.ServiceType `json:"serviceType,omitempty"` diff --git a/config/crd/bases/app.kvdi.io_vdiclusters.yaml b/config/crd/bases/app.kvdi.io_vdiclusters.yaml index d9a092c4..52484e97 100644 --- a/config/crd/bases/app.kvdi.io_vdiclusters.yaml +++ b/config/crd/bases/app.kvdi.io_vdiclusters.yaml @@ -84,6 +84,10 @@ spec: type: string description: Extra annotations to apply to the app service. type: object + serviceName: + description: ServiceName is the name of the service to create + for the app instance. Defaults to `{vdi-name}-app`. + type: string serviceType: description: The type of service to create in front of the app instance. Defaults to `LoadBalancer`. diff --git a/deploy/bundle.yaml b/deploy/bundle.yaml index 4178e634..b51ca35b 100644 --- a/deploy/bundle.yaml +++ b/deploy/bundle.yaml @@ -1523,6 +1523,9 @@ spec: type: string description: Extra annotations to apply to the app service. type: object + serviceName: + description: ServiceName is the name of the service to create for the app instance. Defaults to `{vdi-name}-app`. + type: string serviceType: description: The type of service to create in front of the app instance. Defaults to `LoadBalancer`. type: string From 52a1673be7e0946bc4122e995608b8da5a7b49bf Mon Sep 17 00:00:00 2001 From: Avi Zimmerman Date: Fri, 20 Oct 2023 20:34:43 +0300 Subject: [PATCH 2/2] fix: panic in render app deployment --- pkg/resources/app/app_deployment.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/resources/app/app_deployment.go b/pkg/resources/app/app_deployment.go index a484fc23..e8cdfea6 100644 --- a/pkg/resources/app/app_deployment.go +++ b/pkg/resources/app/app_deployment.go @@ -103,7 +103,7 @@ func newAppContainerForCR(instance *appv1.VDICluster) corev1.Container { if instance.EnableCORS() { args = append(args, "--enable-cors") } - if instance.Spec.App.TLS != nil && instance.Spec.App.TLS.Disable { + if instance.Spec.App != nil && instance.Spec.App.TLS != nil && instance.Spec.App.TLS.Disable { args = append(args, "--disable-tls") } return corev1.Container{