-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mcoa: add support for MCO installing CLO
- Loading branch information
1 parent
40d69e8
commit 6726f70
Showing
14 changed files
with
239 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
...tors/multiclusterobservability/manifests/base/cluster-logging-operator/kustomization.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resources: | ||
- namespace.yaml | ||
- operator_group.yaml | ||
- subscription.yaml |
5 changes: 5 additions & 0 deletions
5
operators/multiclusterobservability/manifests/base/cluster-logging-operator/namespace.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: openshift-logging | ||
spec: {} |
9 changes: 9 additions & 0 deletions
9
...ors/multiclusterobservability/manifests/base/cluster-logging-operator/operator_group.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: operators.coreos.com/v1 | ||
kind: OperatorGroup | ||
metadata: | ||
name: openshift-logging | ||
namespace: openshift-logging | ||
annotations: | ||
olm.providedAPIs: ClusterLogForwarder.v1.logging.openshift.io,ClusterLogging.v1.logging.openshift.io | ||
spec: | ||
upgradeStrategy: Default |
11 changes: 11 additions & 0 deletions
11
...ators/multiclusterobservability/manifests/base/cluster-logging-operator/subscription.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: operators.coreos.com/v1alpha1 | ||
kind: Subscription | ||
metadata: | ||
name: cluster-logging | ||
namespace: openshift-logging | ||
spec: | ||
channel: stable-5.9 | ||
installPlanApproval: Automatic | ||
name: cluster-logging | ||
source: redhat-operators | ||
sourceNamespace: openshift-marketplace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
operators/multiclusterobservability/pkg/rendering/renderer_clo.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
// Copyright (c) Red Hat, Inc. | ||
// Copyright Contributors to the Open Cluster Management project | ||
// Licensed under the Apache License 2.0 | ||
|
||
package rendering | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
"sigs.k8s.io/kustomize/api/resource" | ||
|
||
rendererutil "github.com/stolostron/multicluster-observability-operator/operators/pkg/rendering" | ||
) | ||
|
||
const ( | ||
cloSubscriptionChannel = "stable-5.9" | ||
) | ||
|
||
func (r *MCORenderer) newCLORenderer() { | ||
r.renderCLOFns = map[string]rendererutil.RenderFn{ | ||
"Namespace": r.renderer.RenderNamespace, | ||
"Subscription": r.renderSubscription, | ||
"OperatorGroup": r.renderOperatorGroup, | ||
} | ||
} | ||
|
||
func (r *MCORenderer) renderSubscription( | ||
res *resource.Resource, | ||
namespace string, | ||
labels map[string]string, | ||
) (*unstructured.Unstructured, error) { | ||
m, err := res.Map() | ||
if err != nil { | ||
return nil, err | ||
} | ||
u := &unstructured.Unstructured{Object: m} | ||
|
||
cLabels := u.GetLabels() | ||
if cLabels == nil { | ||
cLabels = make(map[string]string) | ||
} | ||
for k, v := range labels { | ||
cLabels[k] = v | ||
} | ||
u.SetLabels(cLabels) | ||
|
||
return u, nil | ||
} | ||
func (r *MCORenderer) renderOperatorGroup( | ||
res *resource.Resource, | ||
namespace string, | ||
labels map[string]string, | ||
) (*unstructured.Unstructured, error) { | ||
m, err := res.Map() | ||
if err != nil { | ||
return nil, err | ||
} | ||
u := &unstructured.Unstructured{Object: m} | ||
|
||
cLabels := u.GetLabels() | ||
if cLabels == nil { | ||
cLabels = make(map[string]string) | ||
} | ||
for k, v := range labels { | ||
cLabels[k] = v | ||
} | ||
u.SetLabels(cLabels) | ||
|
||
return u, nil | ||
} | ||
|
||
func (r *MCORenderer) renderCLOTemplates( | ||
templates []*resource.Resource, | ||
namespace string, | ||
labels map[string]string, | ||
) ([]*unstructured.Unstructured, error) { | ||
uobjs := []*unstructured.Unstructured{} | ||
for _, template := range templates { | ||
render, ok := r.renderMCOAFns[template.GetKind()] | ||
if !ok { | ||
m, err := template.Map() | ||
if err != nil { | ||
return []*unstructured.Unstructured{}, err | ||
} | ||
uobjs = append(uobjs, &unstructured.Unstructured{Object: m}) | ||
continue | ||
} | ||
uobj, err := render(template.DeepCopy(), namespace, labels) | ||
if err != nil { | ||
return []*unstructured.Unstructured{}, err | ||
} | ||
if uobj == nil { | ||
continue | ||
} | ||
uobjs = append(uobjs, uobj) | ||
|
||
} | ||
|
||
return uobjs, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters