Skip to content

Commit 079b5cf

Browse files
committed
bugfix: disallow users from creating a vCluster in the platform namespace
1 parent 90f9dbc commit 079b5cf

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

chart/templates/service.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
{{- if .Values.controlPlane.service.enabled }}
1+
{{- $platform_svc_exists := lookup "v1" "Service" .Release.Namespace "loft" }}
2+
{{- if $platform_svc_exists }}
3+
{{- fail (printf "a vCluster platform installation exists in the namespace '%s'. Aborting install" .Release.Namespace) }}
4+
{{- else if .Values.controlPlane.service.enabled }}
25
apiVersion: v1
36
kind: Service
47
metadata:

pkg/cli/create_helm.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ func CreateHelm(ctx context.Context, options *CreateOptions, globalFlags *flags.
164164
return fmt.Errorf("get current helm release: %w", err)
165165
}
166166

167+
_, err = cmd.kubeClient.CoreV1().Services(globalFlags.Namespace).Get(ctx, "loft", metav1.GetOptions{})
168+
if err == nil {
169+
return fmt.Errorf("a vCluster platform installation exists in the namespace '%s'. Aborting install", globalFlags.Namespace)
170+
} else if !kerrors.IsNotFound(err) {
171+
return fmt.Errorf("get plaform service: %w", err)
172+
}
173+
167174
// check if vcluster already exists
168175
if !cmd.Upgrade {
169176
if isVClusterDeployed(release) {

0 commit comments

Comments
 (0)