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
1 change: 1 addition & 0 deletions pkg/cmd/install/hubaddon/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func NewCmd(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, stream
}

cmd.Flags().StringVar(&o.names, "names", "", "Names of the built-in add-on to install (comma separated). The built-in add-ons are: application-manager, governance-policy-framework")
cmd.Flags().StringVar(&o.values.Namespace, "namespace", "open-cluster-management", "Namespace of the built-in add-on to install. Default to open-cluster-management")
cmd.Flags().StringVar(&o.outputFile, "output-file", "", "The generated resources will be copied in the specified file")

return cmd
Expand Down
23 changes: 20 additions & 3 deletions pkg/cmd/install/hubaddon/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import (
)

const (
ocmNamespace = "open-cluster-management"
invalidNamespace = "no-such-ns"
ocmNamespace = "open-cluster-management"

invalidAddon = "no-such-addon"
channelDeployment = "multicluster-operators-channel"
subscriptionDeployment = "multicluster-operators-subscription"
propagatorDeployment = "governance-policy-propagator"
Expand All @@ -33,7 +36,7 @@ var _ = ginkgo.Describe("install hub-addon", func() {

o := Options{
values: Values{
hubAddons: []string{"no-such-addon"},
hubAddons: []string{invalidAddon},
},
}

Expand All @@ -57,9 +60,22 @@ var _ = ginkgo.Describe("install hub-addon", func() {
}, consistentlyTimeout, consistentlyInterval).Should(gomega.HaveOccurred())
})

ginkgo.It("Should not create any built-in add-on deployment(s) because it's not a valid namespace", func() {
o := Options{
values: Values{
Namespace: invalidNamespace,
hubAddons: []string{appMgrAddonName},
},
}

err := o.runWithClient(kubeClient, apiExtensionsClient, dynamicClient, false)
gomega.Expect(err).Should(gomega.HaveOccurred())
})

ginkgo.It("Should deploy the built in application-manager add-on deployments in open-cluster-management namespace successfully", func() {
o := Options{
values: Values{
Namespace: ocmNamespace,
hubAddons: []string{appMgrAddonName},
},
}
Expand All @@ -84,10 +100,11 @@ var _ = ginkgo.Describe("install hub-addon", func() {
}, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred())
})

ginkgo.It("Should deploy the built-in governance-policy-framework add-on deployments in open-cluster-management namespace successfully", func() {
ginkgo.It("Should deploy the built-in governance-policy-framework add-on deployments in open-cluster-management-hub namespace successfully", func() {
o := Options{
values: Values{
hubAddons: []string{policyFrameworkAddonName},
Namespace: ocmNamespace,
},
}

Expand Down
2 changes: 2 additions & 0 deletions pkg/cmd/install/hubaddon/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type Options struct {
//Values: The values used in the template
type Values struct {
hubAddons []string
// Namespace to install
Namespace string
}

func newOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *Options {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
subjects:
- kind: ServiceAccount
name: multicluster-operators-subscription
namespace: open-cluster-management
namespace: {{ .Namespace }}
roleRef:
kind: ClusterRole
name: multicluster-operators-subscription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: multicluster-operators-appsub-summary
namespace: open-cluster-management
namespace: {{ .Namespace }}
labels:
name: multicluster-operators-appsub-summary
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: multicluster-operators-channel
namespace: open-cluster-management
namespace: {{ .Namespace }}
labels:
name: multicluster-operators-channel
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: multicluster-operators-placementrule
namespace: open-cluster-management
namespace: {{ .Namespace }}
labels:
name: multicluster-operators-placementrule
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: multicluster-operators-subscription
namespace: open-cluster-management
namespace: {{ .Namespace }}
labels:
name: multicluster-operators-subscription
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
labels:
name: multicluster-operators-subscription
name: multicluster-operators-subscription
namespace: open-cluster-management
namespace: {{ .Namespace }}
spec:
ports:
- port: 8443
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: multicluster-operators-subscription
namespace: open-cluster-management
namespace: {{ .Namespace }}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ roleRef:
subjects:
- kind: ServiceAccount
name: policy-addon-ctrl-controller-manager
namespace: open-cluster-management
namespace: {{ .Namespace }}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
app: governance-policy-addon-controller
control-plane: controller-manager
name: governance-policy-addon-controller
namespace: open-cluster-management
namespace: {{ .Namespace }}
spec:
replicas: 1
selector:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
labels:
app: governance-policy-addon-controller
name: policy-addon-ctrl-leader-election-role
namespace: open-cluster-management
namespace: {{ .Namespace }}
rules:
- apiGroups:
- ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ metadata:
labels:
app: governance-policy-addon-controller
name: policy-addon-ctrl-leader-election-rolebinding
namespace: open-cluster-management
namespace: {{ .Namespace }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: policy-addon-ctrl-leader-election-role
subjects:
- kind: ServiceAccount
name: policy-addon-ctrl-controller-manager
namespace: open-cluster-management
namespace: {{ .Namespace }}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ metadata:
labels:
app: governance-policy-addon-controller
name: policy-addon-ctrl-controller-manager
namespace: open-cluster-management
namespace: {{ .Namespace }}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ roleRef:
subjects:
- kind: ServiceAccount
name: governance-policy-propagator
namespace: open-cluster-management
namespace: {{ .Namespace }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: governance-policy-propagator
namespace: open-cluster-management
namespace: {{ .Namespace }}
spec:
replicas: 1
selector:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: governance-policy-propagator-leader-election-role
namespace: open-cluster-management
namespace: {{ .Namespace }}
rules:
- apiGroups:
- ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: governance-policy-propagator-leader-election-rolebinding
namespace: open-cluster-management
namespace: {{ .Namespace }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: governance-policy-propagator-leader-election-role
subjects:
- kind: ServiceAccount
name: governance-policy-propagator
namespace: open-cluster-management
namespace: {{ .Namespace }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ apiVersion: v1
kind: ServiceAccount
metadata:
name: governance-policy-propagator
namespace: open-cluster-management
namespace: {{ .Namespace }}