Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions api/v1beta1/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,16 @@ type KustomizationRef struct {
// +kubebuilder:validation:Minimum=1
// +optional
Tier int32 `json:"tier,omitempty"`

// SkipNamespaceCreation indicates whether Sveltos should skip creating the namespace
// for namespaced resources defined in this KustomizationRef.
// This field is ignored for cluster-scoped resources.
// By default, Sveltos attempts to get or create the target namespace if it does not exist.
// Setting this to true avoids those calls, which is necessary when Sveltos lacks
// permissions to manage namespaces at the cluster level.
// +kubebuilder:default:=false
// +optional
SkipNamespaceCreation bool `json:"skipNamespaceCreation,omitempty"`
}

// StopMatchingBehavior indicates what will happen when Cluster stops matching
Expand Down Expand Up @@ -641,6 +651,16 @@ type PolicyRef struct {
// +kubebuilder:validation:Minimum=1
// +optional
Tier int32 `json:"tier,omitempty"`

// SkipNamespaceCreation indicates whether Sveltos should skip creating the namespace
// for namespaced resources defined in this PolicyRef.
// This field is ignored for cluster-scoped resources.
// By default, Sveltos attempts to get or create the target namespace if it does not exist.
// Setting this to true avoids those calls, which is necessary when Sveltos lacks
// permissions to manage namespaces at the cluster level.
// +kubebuilder:default:=false
// +optional
SkipNamespaceCreation bool `json:"skipNamespaceCreation,omitempty"`
}

type Clusters struct {
Expand Down
5 changes: 3 additions & 2 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clusterprofiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,16 @@ spec:
When expressed as templates, the values are filled in using information from
resources within the management cluster before deployment (Cluster)
type: string
skipNamespaceCreation:
default: false
description: |-
SkipNamespaceCreation indicates whether Sveltos should skip creating the namespace
for namespaced resources defined in this KustomizationRef.
This field is ignored for cluster-scoped resources.
By default, Sveltos attempts to get or create the target namespace if it does not exist.
Setting this to true avoids those calls, which is necessary when Sveltos lacks
permissions to manage namespaces at the cluster level.
type: boolean
targetNamespace:
description: |-
TargetNamespace sets or overrides the namespace in the
Expand Down Expand Up @@ -991,6 +1001,16 @@ spec:
Defaults to 'None', which translates to the root path of the SourceRef.
Used only for GitRepository;OCIRepository;Bucket
type: string
skipNamespaceCreation:
default: false
description: |-
SkipNamespaceCreation indicates whether Sveltos should skip creating the namespace
for namespaced resources defined in this PolicyRef.
This field is ignored for cluster-scoped resources.
By default, Sveltos attempts to get or create the target namespace if it does not exist.
Setting this to true avoids those calls, which is necessary when Sveltos lacks
permissions to manage namespaces at the cluster level.
type: boolean
tier:
default: 100
description: |-
Expand Down
40 changes: 40 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clusterpromotions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,16 @@ spec:
When expressed as templates, the values are filled in using information from
resources within the management cluster before deployment (Cluster)
type: string
skipNamespaceCreation:
default: false
description: |-
SkipNamespaceCreation indicates whether Sveltos should skip creating the namespace
for namespaced resources defined in this KustomizationRef.
This field is ignored for cluster-scoped resources.
By default, Sveltos attempts to get or create the target namespace if it does not exist.
Setting this to true avoids those calls, which is necessary when Sveltos lacks
permissions to manage namespaces at the cluster level.
type: boolean
targetNamespace:
description: |-
TargetNamespace sets or overrides the namespace in the
Expand Down Expand Up @@ -892,6 +902,16 @@ spec:
Defaults to 'None', which translates to the root path of the SourceRef.
Used only for GitRepository;OCIRepository;Bucket
type: string
skipNamespaceCreation:
default: false
description: |-
SkipNamespaceCreation indicates whether Sveltos should skip creating the namespace
for namespaced resources defined in this PolicyRef.
This field is ignored for cluster-scoped resources.
By default, Sveltos attempts to get or create the target namespace if it does not exist.
Setting this to true avoids those calls, which is necessary when Sveltos lacks
permissions to manage namespaces at the cluster level.
type: boolean
tier:
default: 100
description: |-
Expand Down Expand Up @@ -1613,6 +1633,16 @@ spec:
Defaults to 'None', which translates to the root path of the SourceRef.
Used only for GitRepository;OCIRepository;Bucket
type: string
skipNamespaceCreation:
default: false
description: |-
SkipNamespaceCreation indicates whether Sveltos should skip creating the namespace
for namespaced resources defined in this PolicyRef.
This field is ignored for cluster-scoped resources.
By default, Sveltos attempts to get or create the target namespace if it does not exist.
Setting this to true avoids those calls, which is necessary when Sveltos lacks
permissions to manage namespaces at the cluster level.
type: boolean
tier:
default: 100
description: |-
Expand Down Expand Up @@ -1844,6 +1874,16 @@ spec:
Defaults to 'None', which translates to the root path of the SourceRef.
Used only for GitRepository;OCIRepository;Bucket
type: string
skipNamespaceCreation:
default: false
description: |-
SkipNamespaceCreation indicates whether Sveltos should skip creating the namespace
for namespaced resources defined in this PolicyRef.
This field is ignored for cluster-scoped resources.
By default, Sveltos attempts to get or create the target namespace if it does not exist.
Setting this to true avoids those calls, which is necessary when Sveltos lacks
permissions to manage namespaces at the cluster level.
type: boolean
tier:
default: 100
description: |-
Expand Down
20 changes: 20 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clustersummaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,16 @@ spec:
When expressed as templates, the values are filled in using information from
resources within the management cluster before deployment (Cluster)
type: string
skipNamespaceCreation:
default: false
description: |-
SkipNamespaceCreation indicates whether Sveltos should skip creating the namespace
for namespaced resources defined in this KustomizationRef.
This field is ignored for cluster-scoped resources.
By default, Sveltos attempts to get or create the target namespace if it does not exist.
Setting this to true avoids those calls, which is necessary when Sveltos lacks
permissions to manage namespaces at the cluster level.
type: boolean
targetNamespace:
description: |-
TargetNamespace sets or overrides the namespace in the
Expand Down Expand Up @@ -1029,6 +1039,16 @@ spec:
Defaults to 'None', which translates to the root path of the SourceRef.
Used only for GitRepository;OCIRepository;Bucket
type: string
skipNamespaceCreation:
default: false
description: |-
SkipNamespaceCreation indicates whether Sveltos should skip creating the namespace
for namespaced resources defined in this PolicyRef.
This field is ignored for cluster-scoped resources.
By default, Sveltos attempts to get or create the target namespace if it does not exist.
Setting this to true avoids those calls, which is necessary when Sveltos lacks
permissions to manage namespaces at the cluster level.
type: boolean
tier:
default: 100
description: |-
Expand Down
20 changes: 20 additions & 0 deletions config/crd/bases/config.projectsveltos.io_profiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,16 @@ spec:
When expressed as templates, the values are filled in using information from
resources within the management cluster before deployment (Cluster)
type: string
skipNamespaceCreation:
default: false
description: |-
SkipNamespaceCreation indicates whether Sveltos should skip creating the namespace
for namespaced resources defined in this KustomizationRef.
This field is ignored for cluster-scoped resources.
By default, Sveltos attempts to get or create the target namespace if it does not exist.
Setting this to true avoids those calls, which is necessary when Sveltos lacks
permissions to manage namespaces at the cluster level.
type: boolean
targetNamespace:
description: |-
TargetNamespace sets or overrides the namespace in the
Expand Down Expand Up @@ -991,6 +1001,16 @@ spec:
Defaults to 'None', which translates to the root path of the SourceRef.
Used only for GitRepository;OCIRepository;Bucket
type: string
skipNamespaceCreation:
default: false
description: |-
SkipNamespaceCreation indicates whether Sveltos should skip creating the namespace
for namespaced resources defined in this PolicyRef.
This field is ignored for cluster-scoped resources.
By default, Sveltos attempts to get or create the target namespace if it does not exist.
Setting this to true avoids those calls, which is necessary when Sveltos lacks
permissions to manage namespaces at the cluster level.
type: boolean
tier:
default: 100
description: |-
Expand Down
4 changes: 4 additions & 0 deletions controllers/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,7 @@ var (
var (
GetSortedKeys = getSortedKeys
)

type (
ReferencedObject = referencedObject
)
6 changes: 4 additions & 2 deletions controllers/handlers_kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,8 @@ func deployKustomizeResources(ctx context.Context, c client.Client, remoteRestCo
Name: kustomizationRef.Name,
}
localReports, err = deployUnstructured(ctx, true, localConfig, c, objectsToDeployLocally,
ref, kustomizationRef.Tier, libsveltosv1beta1.FeatureKustomize, clusterSummary, []string{}, logger)
ref, kustomizationRef.Tier, kustomizationRef.SkipNamespaceCreation, libsveltosv1beta1.FeatureKustomize,
clusterSummary, []string{}, logger)
if err != nil {
logger.V(logs.LogInfo).Info(fmt.Sprintf("failed to deploy to management cluster %v", err))
return localReports, nil, err
Expand All @@ -1020,7 +1021,8 @@ func deployKustomizeResources(ctx context.Context, c client.Client, remoteRestCo
}

remoteReports, err = deployUnstructured(ctx, false, remoteRestConfig, remoteClient, objectsToDeployRemotely,
ref, kustomizationRef.Tier, libsveltosv1beta1.FeatureKustomize, clusterSummary, []string{}, logger)
ref, kustomizationRef.Tier, kustomizationRef.SkipNamespaceCreation, libsveltosv1beta1.FeatureKustomize,
clusterSummary, []string{}, logger)
if err != nil {
logger.V(logs.LogInfo).Info(fmt.Sprintf("failed to deploy to remote cluster %v", err))
return localReports, remoteReports, err
Expand Down
Loading