diff --git a/COMPONENT_VERSION b/COMPONENT_VERSION index c8e38b6140..10c2c0c3d6 100644 --- a/COMPONENT_VERSION +++ b/COMPONENT_VERSION @@ -1 +1 @@ -2.9.0 +2.10.0 diff --git a/REMEDIATE.md b/REMEDIATE.md index 0fb3e09e16..8e3eef69c5 100644 --- a/REMEDIATE.md +++ b/REMEDIATE.md @@ -37,4 +37,7 @@ ### Thu Apr 6 23:33:50 EDT 2023 -### Wed Oct 11 01:29:03 EDT 2023 \ No newline at end of file +### Wed Oct 11 01:29:03 EDT 2023 + +### Wed Nov 29 23:59:40 EST 2023 +- Rebuild for 2.10 branch \ No newline at end of file diff --git a/collectors/metrics/Containerfile.operator b/collectors/metrics/Containerfile.operator new file mode 100644 index 0000000000..816eb371d7 --- /dev/null +++ b/collectors/metrics/Containerfile.operator @@ -0,0 +1,61 @@ +# Copyright Contributors to the Open Cluster Management project +# Licensed under the Apache License 2.0 + +FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_8_1.20 AS builder + +WORKDIR /workspace +COPY go.sum go.mod ./ +COPY ./collectors/metrics ./collectors/metrics +COPY ./operators/pkg ./operators/pkg +COPY ./operators/multiclusterobservability/api ./operators/multiclusterobservability/api +RUN CGO_ENABLED=1 go build -a -installsuffix cgo -v -o metrics-collector ./collectors/metrics/cmd/metrics-collector/main.go + +FROM registry.access.redhat.com/ubi8/ubi-minimal:latest + +ARG VCS_REF +ARG VCS_URL +ARG IMAGE_NAME +ARG IMAGE_DESCRIPTION +ARG IMAGE_DISPLAY_NAME +ARG IMAGE_NAME_ARCH +ARG IMAGE_MAINTAINER +ARG IMAGE_VENDOR +ARG IMAGE_VERSION +ARG IMAGE_RELEASE +ARG IMAGE_SUMMARY +ARG IMAGE_OPENSHIFT_TAGS + +LABEL org.label-schema.vendor="Red Hat" \ + org.label-schema.name="$IMAGE_NAME_ARCH" \ + org.label-schema.description="$IMAGE_DESCRIPTION" \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.license="Red Hat Advanced Cluster Management for Kubernetes EULA" \ + org.label-schema.schema-version="1.0" \ + name="$IMAGE_NAME" \ + maintainer="$IMAGE_MAINTAINER" \ + vendor="$IMAGE_VENDOR" \ + version="$IMAGE_VERSION" \ + release="$IMAGE_RELEASE" \ + description="$IMAGE_DESCRIPTION" \ + summary="$IMAGE_SUMMARY" \ + io.k8s.display-name="$IMAGE_DISPLAY_NAME" \ + io.k8s.description="$IMAGE_DESCRIPTION" \ + io.openshift.tags="$IMAGE_OPENSHIFT_TAGS" + +RUN microdnf update &&\ + microdnf install ca-certificates vi --nodocs &&\ + mkdir /licenses &&\ + microdnf clean all + +USER 1001:1001 + +COPY --from=builder /workspace/metrics-collector /usr/bin/ + +# standalone required parameters +ENV FROM_CA_FILE="/from/service-ca.crt" +ENV INTERVAL="60s" +ENV MATCH_FILE="/metrics/match-file" +ENV LIMIT_BYTES=1073741824 + +CMD ["/bin/bash", "-c", "/usr/bin/metrics-collector --from ${FROM} --from-ca-file ${FROM_CA_FILE} --from-token ${FROM_TOKEN} --to-upload ${TO_UPLOAD} --id ${TENANT_ID} --label cluster=${CLUSTER_NAME} --label clusterID=${CLUSTER_ID} --match-file ${MATCH_FILE} --interval ${INTERVAL} --limit-bytes=${LIMIT_BYTES}"] diff --git a/loaders/dashboards/Containerfile.operator b/loaders/dashboards/Containerfile.operator new file mode 100644 index 0000000000..1c774d30df --- /dev/null +++ b/loaders/dashboards/Containerfile.operator @@ -0,0 +1,55 @@ +# Copyright Contributors to the Open Cluster Management project +# Licensed under the Apache License 2.0 + +FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_8_1.20 AS builder + +WORKDIR /workspace +COPY go.sum go.mod ./loaders/dashboards ./ +COPY ./loaders/dashboards ./loaders/dashboards + +RUN CGO_ENABLED=1 go build -a -installsuffix cgo -v -o main loaders/dashboards/cmd/main.go + +FROM registry.access.redhat.com/ubi8/ubi-minimal:latest + +ARG VCS_REF +ARG VCS_URL +ARG IMAGE_NAME +ARG IMAGE_DESCRIPTION +ARG IMAGE_DISPLAY_NAME +ARG IMAGE_NAME_ARCH +ARG IMAGE_MAINTAINER +ARG IMAGE_VENDOR +ARG IMAGE_VERSION +ARG IMAGE_RELEASE +ARG IMAGE_SUMMARY +ARG IMAGE_OPENSHIFT_TAGS + +LABEL org.label-schema.vendor="Red Hat" \ + org.label-schema.name="$IMAGE_NAME_ARCH" \ + org.label-schema.description="$IMAGE_DESCRIPTION" \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.license="Red Hat Advanced Cluster Management for Kubernetes EULA" \ + org.label-schema.schema-version="1.0" \ + name="$IMAGE_NAME" \ + maintainer="$IMAGE_MAINTAINER" \ + vendor="$IMAGE_VENDOR" \ + version="$IMAGE_VERSION" \ + release="$IMAGE_RELEASE" \ + description="$IMAGE_DESCRIPTION" \ + summary="$IMAGE_SUMMARY" \ + io.k8s.display-name="$IMAGE_DISPLAY_NAME" \ + io.k8s.description="$IMAGE_DESCRIPTION" \ + io.openshift.tags="$IMAGE_OPENSHIFT_TAGS" + +WORKDIR / + +RUN microdnf update -y && microdnf clean all + +USER 1001:1001 + +COPY --from=builder /workspace/main grafana-dashboard-loader + +EXPOSE 3002 + +ENTRYPOINT ["/grafana-dashboard-loader"] diff --git a/operators/endpointmetrics/Containerfile.operator b/operators/endpointmetrics/Containerfile.operator new file mode 100644 index 0000000000..bf31741515 --- /dev/null +++ b/operators/endpointmetrics/Containerfile.operator @@ -0,0 +1,58 @@ +# Copyright (c) 2021 Red Hat, Inc. +# Copyright Contributors to the Open Cluster Management project. +FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_8_1.20 AS builder + +WORKDIR /workspace +COPY go.sum go.mod ./ +COPY ./operators/endpointmetrics ./operators/endpointmetrics +COPY ./operators/multiclusterobservability/api ./operators/multiclusterobservability/api +COPY ./operators/pkg ./operators/pkg + +RUN CGO_ENABLED=1 go build -a -installsuffix cgo -o build/_output/bin/endpoint-monitoring-operator operators/endpointmetrics/main.go + +FROM registry.access.redhat.com/ubi8/ubi-minimal:latest + +ARG VCS_REF +ARG VCS_URL +ARG IMAGE_NAME +ARG IMAGE_DESCRIPTION +ARG IMAGE_DISPLAY_NAME +ARG IMAGE_NAME_ARCH +ARG IMAGE_MAINTAINER +ARG IMAGE_VENDOR +ARG IMAGE_VERSION +ARG IMAGE_RELEASE +ARG IMAGE_SUMMARY +ARG IMAGE_OPENSHIFT_TAGS + +LABEL org.label-schema.vendor="Red Hat" \ + org.label-schema.name="$IMAGE_NAME_ARCH" \ + org.label-schema.description="$IMAGE_DESCRIPTION" \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.license="Red Hat Advanced Cluster Management for Kubernetes EULA" \ + org.label-schema.schema-version="1.0" \ + name="$IMAGE_NAME" \ + maintainer="$IMAGE_MAINTAINER" \ + vendor="$IMAGE_VENDOR" \ + version="$IMAGE_VERSION" \ + release="$IMAGE_RELEASE" \ + description="$IMAGE_DESCRIPTION" \ + summary="$IMAGE_SUMMARY" \ + io.k8s.display-name="$IMAGE_DISPLAY_NAME" \ + io.k8s.description="$IMAGE_DESCRIPTION" \ + io.openshift.tags="$IMAGE_OPENSHIFT_TAGS" + +ENV OPERATOR=/usr/local/bin/endpoint-monitoring-operator \ + USER_UID=1001 \ + USER_NAME=endpoint-monitoring-operator + +RUN microdnf update -y && microdnf clean all + +COPY ./operators/endpointmetrics/manifests /usr/local/manifests + +# install operator binary +COPY --from=builder /workspace/build/_output/bin/endpoint-monitoring-operator ${OPERATOR} +USER ${USER_UID} + +ENTRYPOINT ["/usr/local/bin/endpoint-monitoring-operator"] diff --git a/operators/multiclusterobservability/Containerfile.operator b/operators/multiclusterobservability/Containerfile.operator new file mode 100644 index 0000000000..5cd6801a24 --- /dev/null +++ b/operators/multiclusterobservability/Containerfile.operator @@ -0,0 +1,62 @@ +# Copyright Contributors to the Open Cluster Management project +# Licensed under the Apache License 2.0 + +FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_8_1.20 AS builder + +WORKDIR /workspace +COPY go.sum go.mod ./ +COPY ./operators/multiclusterobservability ./operators/multiclusterobservability +COPY ./operators/pkg ./operators/pkg + +RUN CGO_ENABLED=1 go build -a -installsuffix cgo -o bin/manager operators/multiclusterobservability/main.go + +FROM registry.access.redhat.com/ubi8/ubi-minimal:latest + +ARG VCS_REF +ARG VCS_URL +ARG IMAGE_NAME +ARG IMAGE_DESCRIPTION +ARG IMAGE_DISPLAY_NAME +ARG IMAGE_NAME_ARCH +ARG IMAGE_MAINTAINER +ARG IMAGE_VENDOR +ARG IMAGE_VERSION +ARG IMAGE_RELEASE +ARG IMAGE_SUMMARY +ARG IMAGE_OPENSHIFT_TAGS + +LABEL org.label-schema.vendor="Red Hat" \ + org.label-schema.name="$IMAGE_NAME_ARCH" \ + org.label-schema.description="$IMAGE_DESCRIPTION" \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.license="Red Hat Advanced Cluster Management for Kubernetes EULA" \ + org.label-schema.schema-version="1.0" \ + name="$IMAGE_NAME" \ + maintainer="$IMAGE_MAINTAINER" \ + vendor="$IMAGE_VENDOR" \ + version="$IMAGE_VERSION" \ + release="$IMAGE_RELEASE" \ + description="$IMAGE_DESCRIPTION" \ + summary="$IMAGE_SUMMARY" \ + io.k8s.display-name="$IMAGE_DISPLAY_NAME" \ + io.k8s.description="$IMAGE_DESCRIPTION" \ + io.openshift.tags="$IMAGE_OPENSHIFT_TAGS" + +ENV OPERATOR=/usr/local/bin/mco-operator \ + USER_UID=1001 \ + USER_NAME=mco + +RUN microdnf update -y && microdnf clean all + +# install templates +COPY ./operators/multiclusterobservability/manifests /usr/local/manifests + +# install the prestop script +COPY ./operators/multiclusterobservability/prestop.sh /usr/local/bin/prestop.sh + +# install operator binary +COPY --from=builder /workspace/bin/manager ${OPERATOR} +USER ${USER_UID} + +ENTRYPOINT ["/usr/local/bin/mco-operator"] diff --git a/operators/multiclusterobservability/controllers/placementrule/manifestwork.go b/operators/multiclusterobservability/controllers/placementrule/manifestwork.go index c85289f27d..b8d185664c 100644 --- a/operators/multiclusterobservability/controllers/placementrule/manifestwork.go +++ b/operators/multiclusterobservability/controllers/placementrule/manifestwork.go @@ -325,31 +325,6 @@ func createManifestWorks( } } - // If ProxyConfig is specified as part of addonConfig, set the proxy envs - if clusterName != localClusterName { - for i := range spec.Containers { - container := &spec.Containers[i] - if addonConfig.Spec.ProxyConfig.HTTPProxy != "" { - container.Env = append(container.Env, corev1.EnvVar{ - Name: "HTTP_PROXY", - Value: addonConfig.Spec.ProxyConfig.HTTPProxy, - }) - } - if addonConfig.Spec.ProxyConfig.HTTPSProxy != "" { - container.Env = append(container.Env, corev1.EnvVar{ - Name: "HTTPS_PROXY", - Value: addonConfig.Spec.ProxyConfig.HTTPSProxy, - }) - } - if addonConfig.Spec.ProxyConfig.NoProxy != "" { - container.Env = append(container.Env, corev1.EnvVar{ - Name: "NO_PROXY", - Value: addonConfig.Spec.ProxyConfig.NoProxy, - }) - } - } - } - if hasCustomRegistry { oldImage := container.Image newImage, err := imageRegistryClient.Cluster(clusterName).ImageOverride(oldImage) @@ -360,6 +335,32 @@ func createManifestWorks( } } } + for i := range spec.Containers { + if spec.Containers[i].Name == "endpoint-observability-operator" { + container := &spec.Containers[i] + + if clusterName != localClusterName { + if addonConfig.Spec.ProxyConfig.HTTPProxy != "" { + container.Env = append(container.Env, corev1.EnvVar{ + Name: "HTTP_PROXY", + Value: addonConfig.Spec.ProxyConfig.HTTPProxy, + }) + } + if addonConfig.Spec.ProxyConfig.HTTPSProxy != "" { + container.Env = append(container.Env, corev1.EnvVar{ + Name: "HTTPS_PROXY", + Value: addonConfig.Spec.ProxyConfig.HTTPSProxy, + }) + } + if addonConfig.Spec.ProxyConfig.NoProxy != "" { + container.Env = append(container.Env, corev1.EnvVar{ + Name: "NO_PROXY", + Value: addonConfig.Spec.ProxyConfig.NoProxy, + }) + } + } + } + } log.Info(fmt.Sprintf("Cluster: %+v, Spec.NodeSelector (after): %+v", clusterName, spec.NodeSelector)) log.Info(fmt.Sprintf("Cluster: %+v, Spec.Tolerations (after): %+v", clusterName, spec.Tolerations)) dep.Spec.Template.Spec = spec diff --git a/operators/multiclusterobservability/controllers/placementrule/placementrule_controller.go b/operators/multiclusterobservability/controllers/placementrule/placementrule_controller.go index abe3d49853..952b3b8224 100644 --- a/operators/multiclusterobservability/controllers/placementrule/placementrule_controller.go +++ b/operators/multiclusterobservability/controllers/placementrule/placementrule_controller.go @@ -539,6 +539,34 @@ func (r *PlacementRuleReconciler) SetupWithManager(mgr ctrl.Manager) error { clusterPred := getClusterPreds() + // Watch changes for AddonDeploymentConfig + AddonDeploymentPred := predicate.Funcs{ + CreateFunc: func(e event.CreateEvent) bool { + //if e.Object.GetName() == defaultAddonDeploymentConfig.Name && + // e.Object.GetNamespace() == defaultAddonDeploymentConfig.Namespace { + // log.Info("default AddonDeploymentConfig is created") + // return true + //} + return true + }, + UpdateFunc: func(e event.UpdateEvent) bool { + if e.ObjectNew.GetName() == defaultAddonDeploymentConfig.Name && + e.ObjectNew.GetNamespace() == defaultAddonDeploymentConfig.Namespace { + log.Info("default AddonDeploymentConfig is updated") + return true + } + return false + }, + DeleteFunc: func(e event.DeleteEvent) bool { + if e.Object.GetName() == defaultAddonDeploymentConfig.Name && + e.Object.GetNamespace() == defaultAddonDeploymentConfig.Namespace { + log.Info("default AddonDeploymentConfig is deleted") + return true + } + return false + }, + } + obsAddonPred := predicate.Funcs{ CreateFunc: func(e event.CreateEvent) bool { return false @@ -829,6 +857,20 @@ func (r *PlacementRuleReconciler) SetupWithManager(mgr ctrl.Manager) error { // secondary watch for alertmanager accessor serviceaccount Watches(&source.Kind{Type: &corev1.ServiceAccount{}}, &handler.EnqueueRequestForObject{}, builder.WithPredicates(amAccessorSAPred)) + // watch for AddonDeploymentConfig + if _, err := r.RESTMapper.RESTMapping(schema.GroupKind{Group: addonv1alpha1.GroupVersion.Group, Kind: "AddOnDeploymentConfig"}, addonv1alpha1.GroupVersion.Version); err == nil { + ctrBuilder = ctrBuilder.Watches( + &source.Kind{Type: &addonv1alpha1.AddOnDeploymentConfig{}}, + handler.EnqueueRequestsFromMapFunc(func(obj client.Object) []reconcile.Request { + return []reconcile.Request{ + {NamespacedName: types.NamespacedName{ + Name: config.AddonDeploymentConfigUpdateName, + }}, + } + }), + builder.WithPredicates(AddonDeploymentPred), + ) + } manifestWorkGroupKind := schema.GroupKind{Group: workv1.GroupVersion.Group, Kind: "ManifestWork"} if _, err := r.RESTMapper.RESTMapping(manifestWorkGroupKind, workv1.GroupVersion.Version); err == nil { workPred := getManifestworkPred() @@ -937,7 +979,8 @@ func StartPlacementController(mgr manager.Manager, crdMap map[string]bool) error func isReconcileRequired(request ctrl.Request, managedCluster string) bool { if request.Name == config.MCOUpdatedRequestName || request.Name == config.MCHUpdatedRequestName || - request.Name == config.ClusterManagementAddOnUpdateName { + request.Name == config.ClusterManagementAddOnUpdateName || + request.Name == config.AddonDeploymentConfigUpdateName { return true } if request.Namespace == config.GetDefaultNamespace() || diff --git a/operators/multiclusterobservability/controllers/placementrule/placementrule_controller_test.go b/operators/multiclusterobservability/controllers/placementrule/placementrule_controller_test.go index d9f54b7214..7c884db3a2 100644 --- a/operators/multiclusterobservability/controllers/placementrule/placementrule_controller_test.go +++ b/operators/multiclusterobservability/controllers/placementrule/placementrule_controller_test.go @@ -11,6 +11,8 @@ import ( "strings" "testing" + appsv1 "k8s.io/api/apps/v1" + ocinfrav1 "github.com/openshift/api/config/v1" operatorv1 "github.com/openshift/api/operator/v1" routev1 "github.com/openshift/api/route/v1" @@ -177,7 +179,7 @@ func TestObservabilityAddonController(t *testing.T) { }, } objs := []runtime.Object{mco, pull, newConsoleRoute(), newTestObsApiRoute(), newTestAlertmanagerRoute(), newTestIngressController(), newTestRouteCASecret(), newCASecret(), newCertSecret(mcoNamespace), NewMetricsAllowListCM(), - NewAmAccessorSA(), NewAmAccessorTokenSecret(), newManagedClusterAddon(), deprecatedRole, newClusterMgmtAddon(), + NewAmAccessorSA(), NewAmAccessorTokenSecret(), deprecatedRole, newClusterMgmtAddon(), newAddonDeploymentConfig(defaultAddonConfigName, namespace), newAddonDeploymentConfig(addonConfigName, namespace)} c := fake.NewClientBuilder().WithRuntimeObjects(objs...).Build() r := &PlacementRuleReconciler{Client: c, Scheme: s, CRDMap: map[string]bool{config.IngressControllerCRD: true}} @@ -234,6 +236,69 @@ func TestObservabilityAddonController(t *testing.T) { t.Fatalf("reconcile: (%v)", err) } + foundAddonDeploymentConfig := &addonv1alpha1.AddOnDeploymentConfig{} + err = c.Get(context.TODO(), types.NamespacedName{Namespace: namespace, Name: defaultAddonConfigName}, foundAddonDeploymentConfig) + if err != nil { + t.Fatalf("Failed to get addondeploymentconfig %s: (%v)", name, err) + } + + //Change proxyconfig in addondeploymentconfig + foundAddonDeploymentConfig.Spec.ProxyConfig = addonv1alpha1.ProxyConfig{ + HTTPProxy: "http://test1.com", + HTTPSProxy: "https://test1.com", + NoProxy: "test.com", + } + + err = c.Update(context.TODO(), foundAddonDeploymentConfig) + if err != nil { + t.Fatalf("Failed to update addondeploymentconfig %s: (%v)", name, err) + } + + req = ctrl.Request{ + NamespacedName: types.NamespacedName{ + Name: config.AddonDeploymentConfigUpdateName, + }, + } + + _, err = r.Reconcile(context.TODO(), req) + if err != nil { + t.Fatalf("reconcile after updating addondeploymentconfig: (%v)", err) + } + + foundManifestwork := &workv1.ManifestWork{} + err = c.Get(context.TODO(), types.NamespacedName{Name: namespace + workNameSuffix, Namespace: namespace}, foundManifestwork) + if err != nil { + t.Fatalf("Failed to get manifestwork %s: (%v)", namespace, err) + } + for _, manifest := range foundManifestwork.Spec.Workload.Manifests { + obj, _ := util.GetObject(manifest.RawExtension) + if obj.GetObjectKind().GroupVersionKind().Kind == "Deployment" { + //Check the proxy env variables + deployment := obj.(*appsv1.Deployment) + spec := deployment.Spec.Template.Spec + for _, c := range spec.Containers { + if c.Name == "endpoint-observability-operator" { + env := c.Env + for _, e := range env { + if e.Name == "HTTP_PROXY" { + if e.Value != "http://test1.com" { + t.Fatalf("HTTP_PROXY is not set correctly: expected %s, got %s", "http://test1.com", e.Value) + } + } else if e.Name == "HTTPS_PROXY" { + if e.Value != "https://test1.com" { + t.Fatalf("HTTPS_PROXY is not set correctly: expected %s, got %s", "https://test1.com", e.Value) + } + } else if e.Name == "NO_PROXY" { + if e.Value != "test.com" { + t.Fatalf("NO_PROXY is not set correctly: expected %s, got %s", "test.com", e.Value) + } + } + } + } + } + } + } + err = c.Delete(context.TODO(), mco) if err != nil { t.Fatalf("Failed to delete mco: (%v)", err) @@ -310,7 +375,7 @@ func TestObservabilityAddonController(t *testing.T) { // test mco-disable-alerting annotation // 1. Verify that alertmanager-endpoint in secret hub-info-secret in the ManifestWork is not null t.Logf("check alertmanager endpoint is not null") - foundManifestwork := &workv1.ManifestWork{} + foundManifestwork = &workv1.ManifestWork{} err = c.Get(context.TODO(), types.NamespacedName{Name: namespace + workNameSuffix, Namespace: namespace}, foundManifestwork) if err != nil { t.Fatalf("Failed to get manifestwork %s: (%v)", namespace, err) @@ -553,6 +618,11 @@ func newAddonDeploymentConfig(name, namespace string) *addonv1alpha1.AddOnDeploy "kubernetes.io/os": "linux", }, }, + ProxyConfig: addonv1alpha1.ProxyConfig{ + HTTPProxy: "http://foo.com", + HTTPSProxy: "https://foo.com", + NoProxy: "bar.com", + }, }, } } diff --git a/operators/multiclusterobservability/pkg/config/config.go b/operators/multiclusterobservability/pkg/config/config.go index 7f9efe9da3..d1440bc7eb 100644 --- a/operators/multiclusterobservability/pkg/config/config.go +++ b/operators/multiclusterobservability/pkg/config/config.go @@ -56,6 +56,7 @@ const ( MCHUpdatedRequestName = "mch-updated-request" MCOUpdatedRequestName = "mco-updated-request" ClusterManagementAddOnUpdateName = "clustermgmtaddon-updated-request" + AddonDeploymentConfigUpdateName = "addondc-updated-request" MulticloudConsoleRouteName = "multicloud-console" ImageManifestConfigMapNamePrefix = "mch-image-manifest-" OCMManifestConfigMapTypeLabelKey = "ocm-configmap-type" diff --git a/operators/multiclusterobservability/pkg/util/clustermanagementaddon.go b/operators/multiclusterobservability/pkg/util/clustermanagementaddon.go index 20bd844a3f..d49bda5142 100644 --- a/operators/multiclusterobservability/pkg/util/clustermanagementaddon.go +++ b/operators/multiclusterobservability/pkg/util/clustermanagementaddon.go @@ -40,6 +40,7 @@ func CreateClusterManagementAddon(c client.Client) ( found := &addonv1alpha1.ClusterManagementAddOn{} err = c.Get(context.TODO(), types.NamespacedName{Name: ObservabilityController}, found) if err != nil && errors.IsNotFound(err) { + if err := c.Create(context.TODO(), clusterManagementAddon); err != nil { log.Error(err, "Failed to create observability-controller clustermanagementaddon ") return nil, err diff --git a/operators/multiclusterobservability/tests/manifests b/operators/multiclusterobservability/tests/manifests new file mode 120000 index 0000000000..f6ae72e904 --- /dev/null +++ b/operators/multiclusterobservability/tests/manifests @@ -0,0 +1 @@ +/Users/coquadro/work/multicluster-observability-operator/operators/multiclusterobservability/manifests \ No newline at end of file diff --git a/proxy/Containerfile.operator b/proxy/Containerfile.operator new file mode 100644 index 0000000000..8bf966d194 --- /dev/null +++ b/proxy/Containerfile.operator @@ -0,0 +1,52 @@ +# Copyright Contributors to the Open Cluster Management project + +FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_8_1.20 AS builder + +WORKDIR /workspace +COPY go.sum go.mod ./ +COPY ./proxy ./proxy + +RUN CGO_ENABLED=1 go build -a -installsuffix cgo -v -o main proxy/cmd/main.go + +FROM registry.access.redhat.com/ubi8/ubi-minimal:latest + +ARG VCS_REF +ARG VCS_URL +ARG IMAGE_NAME +ARG IMAGE_DESCRIPTION +ARG IMAGE_DISPLAY_NAME +ARG IMAGE_NAME_ARCH +ARG IMAGE_MAINTAINER +ARG IMAGE_VENDOR +ARG IMAGE_VERSION +ARG IMAGE_RELEASE +ARG IMAGE_SUMMARY +ARG IMAGE_OPENSHIFT_TAGS + +LABEL org.label-schema.vendor="Red Hat" \ + org.label-schema.name="$IMAGE_NAME_ARCH" \ + org.label-schema.description="$IMAGE_DESCRIPTION" \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vcs-url=$VCS_URL \ + org.label-schema.license="Red Hat Advanced Cluster Management for Kubernetes EULA" \ + org.label-schema.schema-version="1.0" \ + name="$IMAGE_NAME" \ + maintainer="$IMAGE_MAINTAINER" \ + vendor="$IMAGE_VENDOR" \ + version="$IMAGE_VERSION" \ + release="$IMAGE_RELEASE" \ + description="$IMAGE_DESCRIPTION" \ + summary="$IMAGE_SUMMARY" \ + io.k8s.display-name="$IMAGE_DISPLAY_NAME" \ + io.k8s.description="$IMAGE_DESCRIPTION" \ + io.openshift.tags="$IMAGE_OPENSHIFT_TAGS" + +WORKDIR / + +USER 1001:1001 + +COPY --from=builder /workspace/main rbac-query-proxy + +EXPOSE 3002 + +ENTRYPOINT ["/rbac-query-proxy"] diff --git a/tests/Containerfile.operator b/tests/Containerfile.operator new file mode 100644 index 0000000000..70b47f4e0a --- /dev/null +++ b/tests/Containerfile.operator @@ -0,0 +1,50 @@ +# Copyright Contributors to the Open Cluster Management project +# Licensed under the Apache License 2.0 + +FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_8_1.20 AS builder + +WORKDIR /workspace +# copy go tests into build image +COPY go.sum go.mod ./ +COPY ./tests ./tests + +# compile go tests in build image +RUN go install github.com/onsi/ginkgo/ginkgo@v1.14.2 && go mod vendor && ginkgo build ./tests/pkg/tests/ + +# create new docker image to hold built artifacts +FROM registry.access.redhat.com/ubi8/ubi-minimal:latest + +# run as non-root +USER 1001:1001 + +# expose env vars for runtime +ENV KUBECONFIG "/opt/.kube/config" +ENV IMPORT_KUBECONFIG "/opt/.kube/import-kubeconfig" +ENV OPTIONS "/resources/options.yaml" +ENV REPORT_FILE "/results/results.xml" +ENV GINKGO_DEFAULT_FLAGS "-slowSpecThreshold=120 -timeout 7200s" +ENV GINKGO_NODES "1" +ENV GINKGO_FLAGS="" +ENV GINKGO_FOCUS="" +ENV GINKGO_SKIP="Integration" +ENV SKIP_INTEGRATION_CASES="true" +ENV IS_CANARY_ENV="true" + +# install ginkgo into built image +COPY --from=builder /go/bin/ /usr/local/bin + +# oc exists in the base image. copy oc into built image +COPY --from=builder /usr/local/bin/oc /usr/local/bin/oc +RUN oc version + +WORKDIR /workspace/opt/tests/ +# copy compiled tests into built image +COPY --from=builder /workspace/tests/pkg/tests/tests.test ./observability-e2e-test.test +COPY ./examples /examples +COPY --from=builder /workspace/tests/format-results.sh . + +VOLUME /results + + +# execute compiled ginkgo tests +CMD ["/bin/bash", "-c", "ginkgo --v --focus=${GINKGO_FOCUS} --skip=${GINKGO_SKIP} -nodes=${GINKGO_NODES} --reportFile=${REPORT_FILE} -x -debug -trace observability-e2e-test.test -- -v=3 ; ./format-results.sh ${REPORT_FILE}"] diff --git a/tools/simulator/alert-forward/Containerfile.operator b/tools/simulator/alert-forward/Containerfile.operator new file mode 100644 index 0000000000..a62af5ed65 --- /dev/null +++ b/tools/simulator/alert-forward/Containerfile.operator @@ -0,0 +1,25 @@ +# Copyright Contributors to the Open Cluster Management project +# Licensed under the Apache License 2.0 + +FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_8_1.20 AS builder + +WORKDIR /workspace +COPY go.sum go.mod ./ +COPY tools/simulator/alert-forward/main.go tools/simulator/alert-forward/main.go + +RUN CGO_ENABLED=1 go build -a -installsuffix cgo -o bin/alert-forwarder tools/simulator/alert-forward/main.go + +FROM registry.access.redhat.com/ubi8/ubi-minimal:latest + +ENV MAIN_BINARY=/usr/local/bin/alert-forwarder \ + USER_UID=1001 \ + USER_NAME=alert-forwarder + +# install the binary +COPY --from=builder /workspace/bin/alert-forwarder ${MAIN_BINARY} +COPY tools/simulator/alert-forward/alerts.json /tmp/ + +USER ${USER_UID} + +ENTRYPOINT ["/usr/local/bin/alert-forwarder"] + diff --git a/tools/simulator/metrics-collector/metrics-extractor/Containerfile.operator b/tools/simulator/metrics-collector/metrics-extractor/Containerfile.operator new file mode 100644 index 0000000000..207bcdc5d0 --- /dev/null +++ b/tools/simulator/metrics-collector/metrics-extractor/Containerfile.operator @@ -0,0 +1,48 @@ +# Copyright Contributors to the Open Cluster Management project +# Licensed under the Apache License 2.0 + +FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_8_1.20 AS builder + +RUN GOBIN=/usr/local/bin go install github.com/brancz/gojsontoyaml@latest + + +FROM registry.access.redhat.com/ubi8/ubi-minimal:latest +RUN mkdir /metrics-extractor +RUN mkdir /ocp-tools +RUN microdnf install wget -y \ + && microdnf clean all +RUN microdnf install tar gzip jq bc -y\ + && microdnf clean all + +USER 1001:1001 + +RUN wget https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable-4.13/openshift-client-linux.tar.gz -P /ocp-tools +WORKDIR /ocp-tools +RUN chmod 644 /ocp-tools +RUN tar xvf openshift-client-linux.tar.gz oc kubectl +RUN rm openshift-client-linux.tar.gz +RUN cp oc /usr/local/bin +RUN cp kubectl /usr/local/bin + +COPY --from=builder /usr/local/bin/gojsontoyaml /usr/local/bin/ + +WORKDIR /metrics-extractor +ARG METRICS_ALLOW_LIST_URL="https://raw.githubusercontent.com/stolostron/multicluster-observability-operator/main/operators/multiclusterobservability/manifests/base/config/metrics_allowlist.yaml" +ARG METRICS_JSON_OUT=/metrics-extractor/metrics.json +ARG RECORDINGRULES_JSON_OUT=/metrics-extractor/recordingrules.json +ARG GOJSONTOYAML_BIN=/usr/local/bin/gojsontoyaml + + +RUN export matches=$(curl -L $METRICS_ALLOW_LIST_URL | $GOJSONTOYAML_BIN --yamltojson | jq -r '.data."metrics_list.yaml"' | $GOJSONTOYAML_BIN --yamltojson | jq -r '.matches' | jq '"{" + .[] + "}"') && \ + export names=$(curl -L $METRICS_ALLOW_LIST_URL | $GOJSONTOYAML_BIN --yamltojson | jq -r '.data."metrics_list.yaml"' | $GOJSONTOYAML_BIN --yamltojson | jq -r '.names' | jq '"{__name__=\"" + .[] + "\"}"') && \ + echo $matches $names | jq -s . > $METRICS_JSON_OUT && \ + export recordingrules=$(curl -L $METRICS_ALLOW_LIST_URL | $GOJSONTOYAML_BIN --yamltojson | jq -r '.data."metrics_list.yaml"' | $GOJSONTOYAML_BIN --yamltojson | jq '.recording_rules[]') && \ + echo $recordingrules | jq -s . > ${RECORDINGRULES_JSON_OUT} + + + +COPY ./extract-metrics-data.sh /metrics-extractor/ +RUN chmod 744 /metrics-extractor + + +CMD [ "/bin/bash", "/metrics-extractor/extract-metrics-data.sh" ]