Skip to content

Commit

Permalink
Merge branch 'main' into move_code_part_6
Browse files Browse the repository at this point in the history
  • Loading branch information
muralov committed Nov 24, 2023
2 parents e93404a + 8d64f22 commit 48310ed
Show file tree
Hide file tree
Showing 17 changed files with 515 additions and 222 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN go mod download
COPY cmd/main.go cmd/main.go
COPY api/ api/
COPY internal/controller/ internal/controller/
COPY internal/label/ internal/label/
COPY pkg/ pkg/
COPY testing/ testing/
COPY options/ options/
Expand Down
14 changes: 10 additions & 4 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ namespace: kyma-system
#namePrefix: eventing-

# Labels to add to all resources and selectors.
#labels:
#- includeSelectors: true
# pairs:
# someName: someValue
labels:
- includeSelectors: false
pairs:
app.kubernetes.io/component: eventing-manager
app.kubernetes.io/created-by: eventing-manager
app.kubernetes.io/instance: eventing-manager
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/name: eventing-manager
app.kubernetes.io/part-of: Kyma
control-plane: eventing-manager

resources:
- ../crd
Expand Down
1 change: 1 addition & 0 deletions config/ui-extensions/eventing/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ configMapGenerator:
options:
disableNameSuffixHash: true
labels:
app.kubernetes.io/created-by: eventing-manager
app.kubernetes.io/name: eventings.operator.kyma-project.io
busola.io/extension: resource
busola.io/extension-version: "0.5"
1 change: 1 addition & 0 deletions config/ui-extensions/subscriptions/subscriptions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metadata:
name: subscriptions
namespace: kube-public
labels:
app.kubernetes.io/created-by: eventing-manager
app.kubernetes.io/name: subscriptions
busola.io/extension: resource
busola.io/extension-version: '0.5'
Expand Down
9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/kelseyhightower/envconfig v1.4.0
github.com/kyma-incubator/api-gateway v0.0.0-20220819093753-296e6704d413
github.com/kyma-project/kyma/common/logging v0.0.0-20231113125307-562a57ab5198
github.com/kyma-project/nats-manager v1.0.2
github.com/kyma-project/nats-manager v1.0.3-0.20231124103356-1904d89ab2b2
github.com/mitchellh/hashstructure/v2 v2.0.2
github.com/nats-io/nats-server/v2 v2.10.5
github.com/nats-io/nats.go v1.31.0
Expand Down Expand Up @@ -83,6 +83,7 @@ require (
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/rogpeppe/go-internal v1.11.0 // indirect
github.com/rs/zerolog v1.29.0 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
Expand All @@ -95,13 +96,13 @@ require (
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.15.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/term v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.4.0 // indirect
golang.org/x/tools v0.13.0 // indirect
golang.org/x/tools v0.14.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect
Expand All @@ -117,7 +118,7 @@ require (
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/kyma-incubator/api-gateway => github.com/kyma-project/api-gateway v0.0.0-20220819093753-296e6704d413
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ github.com/kyma-project/api-gateway v0.0.0-20220819093753-296e6704d413 h1:fkGKNO
github.com/kyma-project/api-gateway v0.0.0-20220819093753-296e6704d413/go.mod h1:5kBV6C2JEaapjTAn10Mo81Te4e6LN3epexUCSLXgQLI=
github.com/kyma-project/kyma/common/logging v0.0.0-20231113125307-562a57ab5198 h1:xz4kPj7u51OgP+0f58OeaQlyiGm6AwEHALjbiLeK3Ec=
github.com/kyma-project/kyma/common/logging v0.0.0-20231113125307-562a57ab5198/go.mod h1:JGb5RBi8Uz+RZ/jf54+qA+RqY6uPQBJ8pO1w3KSwm1Q=
github.com/kyma-project/nats-manager v1.0.2 h1:uJiVrLFFqnOsnz1IGNn76fm5cQoK+4L8GxP829mX2C8=
github.com/kyma-project/nats-manager v1.0.2/go.mod h1:gC0W/C2NgpmVnG/5v5f76ijNw5aloQLEkSuVOElB9gk=
github.com/kyma-project/nats-manager v1.0.3-0.20231124103356-1904d89ab2b2 h1:P8SMLPxQMCnPlwGMpqid5ofHPO2dvybu94F8K32GNmw=
github.com/kyma-project/nats-manager v1.0.3-0.20231124103356-1904d89ab2b2/go.mod h1:asVMhM0flO8aRcllmgABSuoPL+X9kdJ7tp8JPSPzpkk=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
Expand Down Expand Up @@ -269,8 +269,8 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4=
github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o=
github.com/onsi/ginkgo/v2 v2.13.1 h1:LNGfMbR2OVGBfXjvRZIZ2YCTQdGKtPLvuI1rMCCj3OU=
github.com/onsi/ginkgo/v2 v2.13.1/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
Expand All @@ -293,8 +293,8 @@ github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO
github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI=
github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M=
github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA=
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w=
github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
Expand Down Expand Up @@ -402,8 +402,8 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -464,8 +464,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ=
golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down Expand Up @@ -587,8 +587,8 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.13.0 h1:Iey4qkscZuv0VvIt8E0neZjtPVQFSc870HQ448QgEmQ=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down Expand Up @@ -752,5 +752,5 @@ sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMm
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/structured-merge-diff/v4 v4.3.0 h1:UZbZAZfX0wV2zr7YZorDz6GXROfDFj6LvqCRm4VUVKk=
sigs.k8s.io/structured-merge-diff/v4 v4.3.0/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
1 change: 0 additions & 1 deletion internal/controller/operator/eventing/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ const (
NatsServerNotAvailableMsg = "NATS server is not available"
natsClientPort = 4222

AppLabelValue = eventing.PublisherName
PublisherSecretEMSHostKey = "ems-publish-host"

TokenEndpointFormat = "%s?grant_type=%s&response_type=token"
Expand Down
3 changes: 2 additions & 1 deletion internal/controller/operator/eventing/eventmesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"k8s.io/apimachinery/pkg/types"

"github.com/kyma-project/eventing-manager/api/operator/v1alpha1"
"github.com/kyma-project/eventing-manager/internal/label"
"github.com/kyma-project/eventing-manager/pkg/env"
"github.com/kyma-project/eventing-manager/pkg/eventing"
subscriptionmanager "github.com/kyma-project/eventing-manager/pkg/subscriptionmanager/manager"
Expand Down Expand Up @@ -297,7 +298,7 @@ func getSecretForPublisher(eventMeshSecret *corev1.Secret) (*corev1.Secret, erro
secret := newSecret(eventing.PublisherName, eventMeshSecret.Namespace)

secret.Labels = map[string]string{
eventing.AppLabelKey: AppLabelValue,
label.KeyName: label.ValueEventingPublisherProxy,
}

if _, ok := eventMeshSecret.Data["messaging"]; !ok {
Expand Down
3 changes: 2 additions & 1 deletion internal/controller/operator/eventing/eventmesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/fake"

"github.com/kyma-project/eventing-manager/internal/label"
"github.com/kyma-project/eventing-manager/pkg/env"
managermocks "github.com/kyma-project/eventing-manager/pkg/eventing/mocks"
"github.com/kyma-project/eventing-manager/pkg/logger"
Expand Down Expand Up @@ -628,7 +629,7 @@ func Test_GetSecretForPublisher(t *testing.T) {
Name: eventing.PublisherName,
Namespace: "test-namespace",
Labels: map[string]string{
eventing.AppLabelKey: eventing.PublisherName,
label.KeyName: label.ValueEventingPublisherProxy,
},
},
StringData: map[string]string{
Expand Down
16 changes: 16 additions & 0 deletions internal/label/label.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package label

const (
KeyComponent = "app.kubernetes.io/component"
KeyCreatedBy = "app.kubernetes.io/created-by"
KeyInstance = "app.kubernetes.io/instance"
KeyManagedBy = "app.kubernetes.io/managed-by"
KeyName = "app.kubernetes.io/name"
KeyPartOf = "app.kubernetes.io/part-of"
KeyBackend = "eventing.kyma-project.io/backend"
KeyDashboard = "kyma-project.io/dashboard"

ValueEventingPublisherProxy = "eventing-publisher-proxy"
ValueEventingManager = "eventing-manager"
ValueEventing = "eventing"
)
49 changes: 33 additions & 16 deletions pkg/eventing/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"

"github.com/kyma-project/eventing-manager/api/operator/v1alpha1"
"github.com/kyma-project/eventing-manager/internal/label"
"github.com/kyma-project/eventing-manager/pkg/env"
"github.com/kyma-project/eventing-manager/pkg/utils"
)
Expand All @@ -21,18 +22,12 @@ const (
livenessTimeoutSecs = int32(1)
livenessPeriodSecs = int32(2)
eventMeshNamespacePrefix = "/"
InstanceLabelKey = "app.kubernetes.io/instance"
InstanceLabelValue = "eventing"
DashboardLabelKey = "kyma-project.io/dashboard"
DashboardLabelValue = "eventing"
BackendLabelKey = "eventing.kyma-project.io/backend"
publisherPortName = "http"
publisherPortNum = int32(8080)
publisherMetricsPortName = "http-metrics"
publisherMetricsPortNum = int32(9090)
PublisherName = "eventing-publisher-proxy"

AppLabelKey = "app.kubernetes.io/name"
PublisherSecretClientIDKey = "client-id"
PublisherSecretClientSecretKey = "client-secret"
PublisherSecretTokenEndpointKey = "token-endpoint"
Expand All @@ -56,6 +51,7 @@ func newNATSPublisherDeployment(
eventing,
publisherConfig,
WithLabels(GetPublisherDeploymentName(*eventing), v1alpha1.NatsBackendType),
WithSelector(GetPublisherDeploymentName(*eventing)),
WithContainers(publisherConfig, eventing),
WithNATSEnvVars(natsConfig, publisherConfig, eventing),
WithLogEnvVars(publisherConfig, eventing),
Expand All @@ -72,6 +68,7 @@ func newEventMeshPublisherDeployment(
eventing,
publisherConfig,
WithLabels(GetPublisherDeploymentName(*eventing), v1alpha1.EventMeshBackendType),
WithSelector(GetPublisherDeploymentName(*eventing)),
WithContainers(publisherConfig, eventing),
WithBEBEnvVars(GetPublisherDeploymentName(*eventing), publisherConfig, eventing),
WithLogEnvVars(publisherConfig, eventing),
Expand Down Expand Up @@ -126,19 +123,39 @@ func getPodSecurityContext() *v1.PodSecurityContext {
}
}

func WithLabels(publisherName string, backendType v1alpha1.BackendType) DeployOpt {
labels := map[string]string{
AppLabelKey: publisherName,
InstanceLabelKey: InstanceLabelValue,
DashboardLabelKey: DashboardLabelValue,
func getLabels(publisherName string, backendType v1alpha1.BackendType) map[string]string {
return map[string]string{
label.KeyComponent: label.ValueEventingManager,
label.KeyCreatedBy: label.ValueEventingManager,
label.KeyInstance: label.ValueEventing,
label.KeyManagedBy: label.ValueEventingManager,
label.KeyName: publisherName,
label.KeyPartOf: label.ValueEventingManager,
label.KeyBackend: fmt.Sprint(getECBackendType(backendType)),
label.KeyDashboard: label.ValueEventing,
}
}

func WithLabels(publisherName string, backendType v1alpha1.BackendType) DeployOpt {
return func(d *appsv1.Deployment) {
d.Spec.Selector = metav1.SetAsLabelSelector(labels)
labels := getLabels(publisherName, backendType)
d.ObjectMeta.Labels = labels
d.Spec.Template.ObjectMeta.Labels = labels
}
}

// label the event-publisher proxy with the backendType label
labels[BackendLabelKey] = fmt.Sprint(getECBackendType(backendType))
d.ObjectMeta.Labels = labels
func getSelector(publisherName string) *metav1.LabelSelector {
labels := map[string]string{
label.KeyInstance: label.ValueEventing,
label.KeyName: publisherName,
label.KeyDashboard: label.ValueEventing,
}
return metav1.SetAsLabelSelector(labels)
}

func WithSelector(publisherName string) DeployOpt {
return func(d *appsv1.Deployment) {
d.Spec.Selector = getSelector(publisherName)
}
}

Expand All @@ -157,7 +174,7 @@ func WithAffinity(publisherName string) DeployOpt {
Weight: 100,
PodAffinityTerm: v1.PodAffinityTerm{
LabelSelector: &metav1.LabelSelector{
MatchLabels: map[string]string{AppLabelKey: publisherName},
MatchLabels: map[string]string{label.KeyName: publisherName},
},
TopologyKey: "kubernetes.io/hostname",
},
Expand Down
Loading

0 comments on commit 48310ed

Please sign in to comment.