Skip to content

Commit

Permalink
feat: Adding ServiceAccountName for EventBus StatefulSet. Closes #957 (
Browse files Browse the repository at this point in the history
…#956)

Signed-off-by: Carlos <[email protected]>
  • Loading branch information
Carlosgova authored Nov 16, 2020
1 parent f983c4c commit 7f474ef
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 86 deletions.
4 changes: 1 addition & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ Argo Events is native to Kubernetes so you'll need a running Kubernetes cluster.
### Requirements
- Golang 1.13
- Docker
- [dep](https://golang.github.io/dep/docs/installation.html)

### Installation & Setup

Expand All @@ -33,7 +32,6 @@ cd $GOPATH/src/github.com/argoproj/argo-events
#### 2. Vendor dependencies
```
GO111MODULE=on go get github.com/cloudevents/sdk-go
dep ensure -vendor-only
```

#### 3. Start Minikube and point Docker Client to Minikube's Docker Daemon
Expand All @@ -57,7 +55,7 @@ If you're making a change to the `pkg/apis` package, please ensure you re-run t

```
go get github.com/ahmetb/gen-crd-api-reference-docs
cd $GOPATH/github.com/ahmetb/gen-crd-api-reference-docs
cd $GOPATH/src/github.com/ahmetb/gen-crd-api-reference-docs
go build
```

Expand Down
12 changes: 12 additions & 0 deletions api/event-bus.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions api/event-bus.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions controllers/eventbus/installer/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,11 @@ func (i *natsInstaller) buildStatefulSetSpec(serviceName, configmapName, authSec
Labels: podTemplateLabels,
},
Spec: corev1.PodSpec{
NodeSelector: i.eventBus.Spec.NATS.Native.NodeSelector,
Tolerations: i.eventBus.Spec.NATS.Native.Tolerations,
SecurityContext: i.eventBus.Spec.NATS.Native.SecurityContext,
ImagePullSecrets: i.eventBus.Spec.NATS.Native.ImagePullSecrets,
NodeSelector: i.eventBus.Spec.NATS.Native.NodeSelector,
Tolerations: i.eventBus.Spec.NATS.Native.Tolerations,
SecurityContext: i.eventBus.Spec.NATS.Native.SecurityContext,
ImagePullSecrets: i.eventBus.Spec.NATS.Native.ImagePullSecrets,
ServiceAccountName: i.eventBus.Spec.NATS.Native.ServiceAccountName,
Volumes: []corev1.Volume{
{
Name: "config-volume",
Expand Down
18 changes: 18 additions & 0 deletions controllers/eventbus/installer/nats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ var (
Name: "test",
},
},
ServiceAccountName: "test",
},
},
},
Expand Down Expand Up @@ -237,3 +238,20 @@ func TestBuildPersistStatefulSetSpec(t *testing.T) {
assert.True(t, len(ss.Spec.Template.Spec.ImagePullSecrets) > 0)
})
}

func TestBuildServiceAccountStatefulSetSpec(t *testing.T) {
t.Run("installation with Service Account Name", func(t *testing.T) {
cl := fake.NewFakeClient(testEventBus)
installer := &natsInstaller{
client: cl,
eventBus: testEventBus,
streamingImage: testStreamingImage,
metricsImage: testMetricsImage,
labels: testLabels,
logger: logging.NewArgoEventsLogger(),
}
ss, err := installer.buildStatefulSet("svcName", "cmName", "secretName")
assert.NoError(t, err)
assert.True(t, len(ss.Spec.Template.Spec.ServiceAccountName) > 0)
})
}
200 changes: 121 additions & 79 deletions pkg/apis/eventbus/v1alpha1/generated.pb.go

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions pkg/apis/eventbus/v1alpha1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions pkg/apis/eventbus/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pkg/apis/eventbus/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ type NativeStrategy struct {
// +patchMergeKey=name
// +patchStrategy=merge
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,12,rep,name=imagePullSecrets"`
// ServiceAccountName to apply to NATS StatefulSet
// +optional
ServiceAccountName string `json:"serviceAccountName,omitempty" protobuf:"bytes,13,opt,name=serviceAccountName"`
}

// ContainerTemplate defines customized spec for a container
Expand Down

0 comments on commit 7f474ef

Please sign in to comment.