Skip to content

Commit 5aac6ae

Browse files
authored
Add defaultNamespace in pkgi/app crs (#1317)
Signed-off-by: Praveen Rewar <[email protected]>
1 parent 96bbb58 commit 5aac6ae

File tree

18 files changed

+581
-178
lines changed

18 files changed

+581
-178
lines changed

config/config/crds.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ spec:
160160
description: Specifies namespace in destination cluster (optional)
161161
type: string
162162
type: object
163+
defaultNamespace:
164+
description: Specifies the default namespace to install the App resources, by default this is same as the App's namespace (optional; v0.48.0+)
165+
type: string
163166
deploy:
164167
items:
165168
properties:
@@ -773,6 +776,9 @@ spec:
773776
description: Specifies namespace in destination cluster (optional)
774777
type: string
775778
type: object
779+
defaultNamespace:
780+
description: Specifies the default namespace to install the App resources, by default this is same as the App's namespace (optional; v0.48.0+)
781+
type: string
776782
deploy:
777783
items:
778784
properties:
@@ -1502,6 +1508,9 @@ spec:
15021508
description: Specifies namespace in destination cluster (optional)
15031509
type: string
15041510
type: object
1511+
defaultNamespace:
1512+
description: Specifies the default namespace to install the Package resources, by default this is same as the PackageInstall namespace (optional; v0.48.0+)
1513+
type: string
15051514
noopDelete:
15061515
description: When NoopDelete set to true, PackageInstall deletion should delete PackageInstall/App CR but preserve App's associated resources.
15071516
type: boolean

hack/dependencies.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,19 @@
2222
repo: vmware-tanzu/carvel-kbld
2323
urlTemplate: https://github.com/vmware-tanzu/carvel-{{.Name}}/releases/download/{{.Version}}/{{.Name}}-{{.OS}}-{{.Arch}}
2424
version: v0.37.4
25+
# To be updated after official kapp release
2526
- checksums:
2627
darwin:
27-
amd64: e71048d2b11a2c10258079cc134d7d2c2b6584429202a6212306380d3a8c0a30
28-
arm64: 3660dd8efe83c1356e05255307fa6f65825ba694d96b93bc38c6a43d7e6d7a8c
28+
amd64: ac1f2bd9f43f0d77465f8f4e4b2540a498c6fd3228d7e8452e360d66e04344c7
29+
arm64: 0954a8343d1ef7dac131e2212efd6ff1e2f39c898a242f280c4889e6acfc38e3
2930
linux:
30-
amd64: b253ea9cf6add07f9497955147dc12e8612c24c36dc9929c9a4fecdc76752bd3
31-
arm64: 25491298f6783a8b337d2ebdecf749f7750cf10260fe37086315a9c7da0b558f
31+
amd64: cc1cca783173badd5e74edc1f10decfcae85525cfece73b3d43acfda1eaccbe5
32+
arm64: 59a8ddcacf82cec055f0ca9e66b1ea90ade138792db1b1ddaa72d653cc6d93ba
3233
dev: true
3334
name: kapp
3435
repo: vmware-tanzu/carvel-kapp
3536
urlTemplate: https://github.com/vmware-tanzu/carvel-{{.Name}}/releases/download/{{.Version}}/{{.Name}}-{{.OS}}-{{.Arch}}
36-
version: v0.58.0
37+
version: v0.59.0
3738
- checksums:
3839
darwin:
3940
amd64: 6a5290066d8fbe26aa0603902825bbca55b97f011e97949677eb937ace2d2e3e

pkg/apis/kappctrl/v1alpha1/generated.pb.go

Lines changed: 201 additions & 160 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kappctrl/v1alpha1/generated.proto

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kappctrl/v1alpha1/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ type AppSpec struct {
7676
// (optional; default=false; v0.18.0+)
7777
// +optional
7878
NoopDelete bool `json:"noopDelete,omitempty" protobuf:"varint,9,opt,name=noopDelete"`
79+
// Specifies the default namespace to install the App resources, by default this is
80+
// same as the App's namespace (optional; v0.48.0+)
81+
// +optional
82+
DefaultNamespace string `json:"defaultNamespace,omitempty" protobuf:"bytes,10,opt,name=defaultNamespace"`
7983
}
8084

8185
// +k8s:openapi-gen=true

pkg/apis/packaging/v1alpha1/package_install.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ type PackageInstallSpec struct {
7575
// associated resources.
7676
// +optional
7777
NoopDelete bool `json:"noopDelete,omitempty"`
78+
// Specifies the default namespace to install the Package resources, by default this is
79+
// same as the PackageInstall namespace (optional; v0.48.0+)
80+
// +optional
81+
DefaultNamespace string `json:"defaultNamespace,omitempty"`
7882
}
7983

8084
type PackageRef struct {

pkg/apiserver/openapi/zz_generated.openapi.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/app/app_deploy.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ func (a *App) trySaveMetadata(kapp *ctldep.Kapp) {
146146
func (a *App) newKapp(kapp v1alpha1.AppDeployKapp, cancelCh chan struct{}) (*ctldep.Kapp, error) {
147147

148148
return a.deployFactory.NewKapp(kapp, a.app.Spec.ServiceAccountName,
149-
a.app.Spec.Cluster, cancelCh, kubeconfig.AccessLocation{Name: a.app.Name, Namespace: a.app.Namespace})
149+
a.app.Spec.Cluster, cancelCh, kubeconfig.AccessLocation{Name: a.app.Name, Namespace: a.app.Namespace},
150+
a.app.Spec.DefaultNamespace, a.app.Namespace,
151+
)
150152
}
151153

152154
type cancelCondition func(v1alpha1.App) bool

pkg/componentinfo/component_info.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (ci *ComponentInfo) KubernetesVersion(serviceAccountName string, specCluste
5050
return ci.parseAndScrubVersion(v.String())
5151

5252
case specCluster != nil:
53-
accessInfo, err := ci.clusterAccess.ClusterAccess(serviceAccountName, specCluster, kubeconfig.AccessLocation{Name: objMeta.Name, Namespace: objMeta.Namespace})
53+
accessInfo, err := ci.clusterAccess.ClusterAccess(serviceAccountName, specCluster, kubeconfig.AccessLocation{Name: objMeta.Name, Namespace: objMeta.Namespace}, "")
5454
if err != nil {
5555
return semver.Version{}, err
5656
}

pkg/deploy/factory.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,22 @@ func NewFactory(coreClient kubernetes.Interface, kubeconfig *kubeconfig.Kubeconf
3636

3737
// NewKapp configures and returns a deployer of type Kapp
3838
func (f Factory) NewKapp(opts v1alpha1.AppDeployKapp, saName string,
39-
clusterOpts *v1alpha1.AppCluster, cancelCh chan struct{}, location kubeconfig.AccessLocation) (*Kapp, error) {
39+
clusterOpts *v1alpha1.AppCluster, cancelCh chan struct{}, location kubeconfig.AccessLocation,
40+
defaultNamespace string, appNamespace string) (*Kapp, error) {
4041

41-
clusterAccess, err := f.kubeconfig.ClusterAccess(saName, clusterOpts, location)
42+
clusterAccess, err := f.kubeconfig.ClusterAccess(saName, clusterOpts, location, defaultNamespace)
4243
if err != nil {
4344
return nil, err
4445
}
4546

4647
const suffix string = ".app"
4748
return NewKapp(suffix, opts, clusterAccess,
48-
f.globalKappDeployRawOpts(), cancelCh, f.cmdRunner), nil
49+
f.globalKappDeployRawOpts(), cancelCh, f.cmdRunner, appNamespace), nil
4950
}
5051

5152
// NewKappPrivileged is used for package repositories where users aren't required to provide
5253
// a service account, so it will install resources using its own privileges.
53-
func (f Factory) NewKappPrivilegedForPackageRepository(opts v1alpha1.AppDeployKapp, clusterAccess kubeconfig.AccessInfo, cancelCh chan struct{}) (*Kapp, error) {
54+
func (f Factory) NewKappPrivilegedForPackageRepository(opts v1alpha1.AppDeployKapp, clusterAccess kubeconfig.AccessInfo, cancelCh chan struct{}, appNamespace string) (*Kapp, error) {
5455

5556
const suffix string = ".pkgr"
5657

@@ -61,7 +62,7 @@ func (f Factory) NewKappPrivilegedForPackageRepository(opts v1alpha1.AppDeployKa
6162
DangerousUsePodServiceAccount: true,
6263
}
6364

64-
return NewKapp(suffix, opts, kconfAccess, f.globalKappDeployRawOpts(), cancelCh, f.cmdRunner), nil
65+
return NewKapp(suffix, opts, kconfAccess, f.globalKappDeployRawOpts(), cancelCh, f.cmdRunner, appNamespace), nil
6566
}
6667

6768
func (f Factory) globalKappDeployRawOpts() []string {

0 commit comments

Comments
 (0)