Skip to content

Commit

Permalink
Pin the OCM version for add-ons (#280)
Browse files Browse the repository at this point in the history
* Pin the OCM version for add-ons

Signed-off-by: Dale Haiducek <[email protected]>

* Adapt for backward compatibility

Add back individual sync controllers so that versions
prior to v0.9.0 can deploy.

This reverts and modifies commit 257c6fd

Signed-off-by: Dale Haiducek <[email protected]>

Signed-off-by: Dale Haiducek <[email protected]>
  • Loading branch information
dhaiducek authored Oct 25, 2022
1 parent acb1e52 commit 4a4add3
Show file tree
Hide file tree
Showing 11 changed files with 86 additions and 14 deletions.
3 changes: 2 additions & 1 deletion pkg/cmd/install/hubaddon/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ 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.values.Namespace, "namespace", "open-cluster-management", "Namespace of the built-in add-on to install. Defaults to open-cluster-management")
cmd.Flags().StringVar(&o.outputFile, "output-file", "", "The generated resources will be copied in the specified file")
cmd.Flags().StringVar(&o.bundleVersion, "bundle-version", "default", "The image version tag to use when deploying the hub add-on")

return cmd
}
13 changes: 13 additions & 0 deletions pkg/cmd/install/hubaddon/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"k8s.io/client-go/kubernetes"
"open-cluster-management.io/clusteradm/pkg/cmd/install/hubaddon/scenario"
"open-cluster-management.io/clusteradm/pkg/helpers"
"open-cluster-management.io/clusteradm/pkg/helpers/version"
)

const (
Expand Down Expand Up @@ -44,6 +45,18 @@ func (o *Options) validate() error {
}
}

versionBundle, err := version.GetVersionBundle(o.bundleVersion)

if err != nil {
klog.Errorf("unable to retrieve version "+o.bundleVersion, err)
return err
}

o.values.BundleVersion = BundleVersion{
AppAddon: versionBundle.AppAddon,
PolicyAddon: versionBundle.PolicyAddon,
}

return nil
}

Expand Down
28 changes: 28 additions & 0 deletions pkg/cmd/install/hubaddon/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
const (
invalidNamespace = "no-such-ns"
ocmNamespace = "open-cluster-management"
ocmVersion = "latest"

invalidAddon = "no-such-addon"
channelDeployment = "multicluster-operators-channel"
Expand All @@ -22,6 +23,26 @@ const (
)

var _ = ginkgo.Describe("install hub-addon", func() {
ginkgo.Context("validate", func() {

ginkgo.It("Should not create any built-in add-on deployment(s) because it's not a valid add-on name", func() {
o := Options{
names: invalidAddon,
}

err := o.validate()
gomega.Expect(err).To(gomega.HaveOccurred())
})

ginkgo.It("Should not create any built-in add-on deployment(s) because it's not a valid version", func() {
o := Options{
bundleVersion: "invalid",
}

err := o.validate()
gomega.Expect(err).Should(gomega.HaveOccurred())
})
})

ginkgo.Context("runWithClient", func() {

Expand Down Expand Up @@ -62,6 +83,7 @@ var _ = ginkgo.Describe("install hub-addon", func() {

ginkgo.It("Should not create any built-in add-on deployment(s) because it's not a valid namespace", func() {
o := Options{
bundleVersion: ocmVersion,
values: Values{
Namespace: invalidNamespace,
hubAddons: []string{appMgrAddonName},
Expand All @@ -77,6 +99,9 @@ var _ = ginkgo.Describe("install hub-addon", func() {
values: Values{
Namespace: ocmNamespace,
hubAddons: []string{appMgrAddonName},
BundleVersion: BundleVersion{
AppAddon: ocmVersion,
},
},
}

Expand Down Expand Up @@ -105,6 +130,9 @@ var _ = ginkgo.Describe("install hub-addon", func() {
values: Values{
hubAddons: []string{policyFrameworkAddonName},
Namespace: ocmNamespace,
BundleVersion: BundleVersion{
PolicyAddon: ocmVersion,
},
},
}

Expand Down
16 changes: 13 additions & 3 deletions pkg/cmd/install/hubaddon/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,25 @@ type Options struct {
//A list of comma separated addon names
names string
//The file to output the resources will be sent to the file.
outputFile string
values Values
outputFile string
values Values
bundleVersion string
}

//Values: The values used in the template
type BundleVersion struct {
// app image version
AppAddon string
// policy image version
PolicyAddon string
}

// Values: The values used in the template
type Values struct {
hubAddons []string
// Namespace to install
Namespace string
// Version to install
BundleVersion BundleVersion
}

func newOptions(clusteradmFlags *genericclioptionsclusteradm.ClusteradmFlags, streams genericclioptions.IOStreams) *Options {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
serviceAccountName: multicluster-operators-subscription
containers:
- name: multicluster-operators-appsub-summary
image: quay.io/open-cluster-management/multicloud-operators-subscription:latest
image: quay.io/open-cluster-management/multicloud-operators-subscription:{{ .BundleVersion.AppAddon }}
ports:
- containerPort: 9443
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
serviceAccountName: multicluster-operators-subscription
containers:
- name: multicluster-operators-channel
image: quay.io/open-cluster-management/multicloud-operators-channel:latest
image: quay.io/open-cluster-management/multicloud-operators-channel:{{ .BundleVersion.AppAddon }}
ports:
- containerPort: 7443
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
serviceAccountName: multicluster-operators-subscription
containers:
- name: multicluster-operators-placementrule
image: quay.io/open-cluster-management/multicloud-operators-subscription:latest
image: quay.io/open-cluster-management/multicloud-operators-subscription:{{ .BundleVersion.AppAddon }}
ports:
- containerPort: 6443
command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ spec:
serviceAccountName: multicluster-operators-subscription
containers:
- name: multicluster-operators-subscription
image: quay.io/open-cluster-management/multicloud-operators-subscription:latest
image: quay.io/open-cluster-management/multicloud-operators-subscription:{{ .BundleVersion.AppAddon }}
ports:
- containerPort: 8443
command:
- /usr/local/bin/multicluster-operators-subscription
- --sync-interval=60
- --agent-image=quay.io/open-cluster-management/multicloud-operators-subscription:latest
- --agent-image=quay.io/open-cluster-management/multicloud-operators-subscription:{{ .BundleVersion.AppAddon }}
imagePullPolicy: IfNotPresent
env:
- name: WATCH_NAMESPACE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ spec:
fieldRef:
fieldPath: metadata.name
- name: CONFIG_POLICY_CONTROLLER_IMAGE
value: quay.io/open-cluster-management/config-policy-controller:latest
value: quay.io/open-cluster-management/config-policy-controller:{{ .BundleVersion.PolicyAddon }}
- name: GOVERNANCE_POLICY_SPEC_SYNC_IMAGE
value: quay.io/open-cluster-management/governance-policy-spec-sync:{{ .BundleVersion.PolicyAddon }}
- name: GOVERNANCE_POLICY_STATUS_SYNC_IMAGE
value: quay.io/open-cluster-management/governance-policy-status-sync:{{ .BundleVersion.PolicyAddon }}
- name: GOVERNANCE_POLICY_TEMPLATE_SYNC_IMAGE
value: quay.io/open-cluster-management/governance-policy-template-sync:{{ .BundleVersion.PolicyAddon }}
- name: GOVERNANCE_POLICY_FRAMEWORK_ADDON_IMAGE
value: quay.io/open-cluster-management/governance-policy-framework-addon:{{ .BundleVersion.PolicyAddon }}
- name: KUBE_RBAC_PROXY_IMAGE
value: registry.redhat.io/openshift4/ose-kube-rbac-proxy:v4.10
- name: GOVERNANCE_POLICY_FRAMEWORK_ADDON_IMAGE
value: quay.io/open-cluster-management/governance-policy-framework-addon:latest
image: quay.io/open-cluster-management/governance-policy-addon-controller:latest
image: quay.io/open-cluster-management/governance-policy-addon-controller:{{ .BundleVersion.PolicyAddon }}
imagePullPolicy: IfNotPresent
name: manager
resources:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
fieldPath: metadata.name
- name: OPERATOR_NAME
value: governance-policy-propagator
image: quay.io/open-cluster-management/governance-policy-propagator:latest
image: quay.io/open-cluster-management/governance-policy-propagator:{{ .BundleVersion.PolicyAddon }}
imagePullPolicy: Always
name: governance-policy-propagator
ports:
Expand Down
14 changes: 14 additions & 0 deletions pkg/helpers/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ type VersionBundle struct {
Placement string
Work string
Operator string
AppAddon string
PolicyAddon string
}

var defaultBundleVersion = "0.9.0"
Expand All @@ -32,6 +34,8 @@ func GetVersionBundle(version string) (VersionBundle, error) {
Placement: "latest",
Work: "latest",
Operator: "latest",
AppAddon: "latest",
PolicyAddon: "latest",
}

// predefined bundle version
Expand All @@ -41,34 +45,44 @@ func GetVersionBundle(version string) (VersionBundle, error) {
Placement: "v0.2.0",
Work: "v0.5.0",
Operator: "v0.5.0",
AppAddon: "v0.5.0",
PolicyAddon: "v0.8.0",
}

versionBundleList["0.6.0"] = VersionBundle{
Registration: "v0.6.0",
Placement: "v0.3.0",
Work: "v0.6.0",
Operator: "v0.6.0",
AppAddon: "v0.6.0",
PolicyAddon: "v0.8.0",
}

versionBundleList["0.7.0"] = VersionBundle{
Registration: "v0.7.0",
Placement: "v0.4.0",
Work: "v0.7.0",
Operator: "v0.7.0",
AppAddon: "v0.7.0",
PolicyAddon: "v0.8.0",
}

versionBundleList["0.8.0"] = VersionBundle{
Registration: "v0.8.0",
Placement: "v0.8.0",
Work: "v0.8.0",
Operator: "v0.8.0",
AppAddon: "v0.8.0",
PolicyAddon: "v0.8.0",
}

versionBundleList["0.9.0"] = VersionBundle{
Registration: "v0.9.0",
Placement: "v0.9.0",
Work: "v0.9.0",
Operator: "v0.9.0",
AppAddon: "v0.9.0",
PolicyAddon: "v0.9.0",
}

// default
Expand Down

0 comments on commit 4a4add3

Please sign in to comment.