Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Commit of Basic Operator for Logstash #6404

Merged
merged 46 commits into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ce56d6a
Initial Commit of ECK for Logstash
robbavey Feb 10, 2023
02a5451
Comment out certs for HTTPS for now
robbavey Feb 10, 2023
b72182f
Fix up linter issus
robbavey Feb 10, 2023
9cf0a45
Generate API docs
robbavey Feb 10, 2023
4d62ab5
First set of unit tests
robbavey Feb 13, 2023
cf1379c
Fix goimports
robbavey Feb 13, 2023
e5a4621
Add version check
robbavey Feb 13, 2023
a74da1d
Add e2e tests
robbavey Feb 14, 2023
d3878a5
Temporarily take out probes
robbavey Feb 14, 2023
cd7f8f6
Revert "Temporarily take out probes"
robbavey Feb 15, 2023
793ff28
Revert "Add e2e tests"
robbavey Feb 15, 2023
1a83870
Fix linter
robbavey Feb 15, 2023
d3edd1e
Add logstash config details
robbavey Feb 15, 2023
4e4303d
Fix up typos
robbavey Feb 15, 2023
50e834e
Revert "Revert "Add e2e tests""
robbavey Feb 15, 2023
2692661
Revert "Revert "Temporarily take out probes""
robbavey Feb 15, 2023
865d06a
Tidying up
robbavey Feb 16, 2023
84dd489
Add Logstash to sample and stack tests
robbavey Feb 16, 2023
12430d9
Added basic logstash verification
robbavey Feb 16, 2023
d2ac277
Fix readiness probe
robbavey Feb 16, 2023
214f63d
Tidy up
robbavey Feb 16, 2023
b9cb06a
Update config/crds/v1/patches/kustomization.yaml
kaisecheng Feb 22, 2023
51f2bad
Update pkg/apis/logstash/v1alpha1/name.go
kaisecheng Feb 22, 2023
b52d9ee
change HTTPConfig to []LogstashService
kaisecheng Feb 23, 2023
94b84b5
webhook check all rules
kaisecheng Feb 23, 2023
1cfb725
remove building config from existing config in Secret
kaisecheng Feb 23, 2023
bb79c17
rename k8sutils EmitErrorEvent() to MaybeEmitErrorEvent()
kaisecheng Feb 23, 2023
8ec1501
remove nil error in StatefulSet
kaisecheng Feb 23, 2023
aec57e4
remove APIError struct in test
kaisecheng Feb 23, 2023
b27445c
add license header
kaisecheng Feb 23, 2023
746a307
lint
kaisecheng Feb 24, 2023
822f0ab
reconcileConfig return error
kaisecheng Feb 24, 2023
0a37afe
change the default Service to headless service
kaisecheng Feb 24, 2023
df96068
fix service test
kaisecheng Feb 24, 2023
4c414bd
fix podTemplate and doc generation
kaisecheng Feb 27, 2023
018dfbc
Fix Service tests
robbavey Feb 27, 2023
de1fb22
Update comments to reflect change from HTTPConfig to LogstashService
robbavey Feb 27, 2023
41612f7
Update pkg/controller/logstash/service.go
robbavey Feb 27, 2023
a0d176a
remove duplicate err check
kaisecheng Feb 28, 2023
b9610da
Add support for overriding "default" service
robbavey Feb 28, 2023
0c9409a
Replace 'default' service name with 'api'
robbavey Feb 28, 2023
6167cb7
merge from feature/logstash
robbavey Feb 28, 2023
d4c5e05
Add tests and checks for services and endpoints
robbavey Mar 2, 2023
1f77430
Update pkg/apis/logstash/v1alpha1/webhook.go
robbavey Mar 2, 2023
b677c65
Update pkg/controller/logstash/service.go
robbavey Mar 2, 2023
a797940
Addressing code review comments
robbavey Mar 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import (
"strings"
"time"

logstashv1alpha1 "github.com/elastic/cloud-on-k8s/v2/pkg/apis/logstash/v1alpha1"
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/logstash"

"github.com/go-logr/logr"
"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down Expand Up @@ -847,6 +850,7 @@ func registerControllers(mgr manager.Manager, params operator.Parameters, access
{name: "Agent", registerFunc: agent.Add},
{name: "Maps", registerFunc: maps.Add},
{name: "StackConfigPolicy", registerFunc: stackconfigpolicy.Add},
{name: "Logstash", registerFunc: logstash.Add},
}

for _, c := range controllers {
Expand Down Expand Up @@ -925,14 +929,15 @@ func garbageCollectSoftOwnedSecrets(ctx context.Context, k8sClient k8s.Client) {
defer span.End()

if err := reconciler.GarbageCollectAllSoftOwnedOrphanSecrets(ctx, k8sClient, map[string]client.Object{
esv1.Kind: &esv1.Elasticsearch{},
apmv1.Kind: &apmv1.ApmServer{},
kbv1.Kind: &kbv1.Kibana{},
entv1.Kind: &entv1.EnterpriseSearch{},
beatv1beta1.Kind: &beatv1beta1.Beat{},
agentv1alpha1.Kind: &agentv1alpha1.Agent{},
emsv1alpha1.Kind: &emsv1alpha1.ElasticMapsServer{},
policyv1alpha1.Kind: &policyv1alpha1.StackConfigPolicy{},
esv1.Kind: &esv1.Elasticsearch{},
apmv1.Kind: &apmv1.ApmServer{},
kbv1.Kind: &kbv1.Kibana{},
entv1.Kind: &entv1.EnterpriseSearch{},
beatv1beta1.Kind: &beatv1beta1.Beat{},
agentv1alpha1.Kind: &agentv1alpha1.Agent{},
emsv1alpha1.Kind: &emsv1alpha1.ElasticMapsServer{},
policyv1alpha1.Kind: &policyv1alpha1.StackConfigPolicy{},
logstashv1alpha1.Kind: &logstashv1alpha1.Logstash{},
}); err != nil {
log.Error(err, "Orphan secrets garbage collection failed, will be attempted again at next operator restart.")
return
Expand Down Expand Up @@ -973,6 +978,7 @@ func setupWebhook(
&kbv1.Kibana{},
&kbv1beta1.Kibana{},
&emsv1alpha1.ElasticMapsServer{},
&logstashv1alpha1.Logstash{},
}
for _, obj := range webhookObjects {
if err := commonwebhook.SetupValidatingWebhookWithConfig(&commonwebhook.Config{
Expand Down
611 changes: 611 additions & 0 deletions config/crds/v1/all-crds.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions config/crds/v1/bases/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ resources:
- agent.k8s.elastic.co_agents.yaml
- maps.k8s.elastic.co_elasticmapsservers.yaml
- stackconfigpolicy.k8s.elastic.co_stackconfigpolicies.yaml
- logstash.k8s.elastic.co_logstashes.yaml
8,018 changes: 8,018 additions & 0 deletions config/crds/v1/bases/logstash.k8s.elastic.co_logstashes.yaml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions config/crds/v1/patches/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,12 @@ patchesJson6902:
kind: CustomResourceDefinition
name: elasticmapsservers.maps.k8s.elastic.co
path: maps-patches.yaml
# custom patches for Logstash
- target:
group: apiextensions.k8s.io
version: v1
kind: CustomResourceDefinition
name: logstashes.logstash.k8s.elastic.co
path: logstash-patches.yaml


7 changes: 7 additions & 0 deletions config/crds/v1/patches/logstash-patches.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Using `kubectl apply` stores the complete CRD file as an annotation,
# which may be too big for the annotations size limit.
# One way to mitigate this problem is to remove the (huge) podTemplate properties from the CRD.
# It also avoids the problem of having any k8s-version specific field in the Pod schema,
# that would maybe not match the user's k8s version.
- op: remove
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/podTemplate/properties
13 changes: 13 additions & 0 deletions config/e2e/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,19 @@ rules:
- update
- patch
- delete
- apiGroups :
- logstash.k8s.elastic.co
resources:
- logstashes
- logstashes/status
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- storage.k8s.io
resources:
Expand Down
15 changes: 15 additions & 0 deletions config/samples/logstash/logstash.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: logstash.k8s.elastic.co/v1alpha1
kind: Logstash
metadata:
name: logstash-sample
spec:
count: 3
version: 8.6.1
config:
log.level: info
api.http.host: "0.0.0.0"
queue.type: memory
podTemplate:
spec:
containers:
- name: logstash
46 changes: 46 additions & 0 deletions config/samples/logstash/logstash_svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: elasticsearch-sample
spec:
version: 8.6.1
nodeSets:
- name: default
count: 3
config:
node.store.allow_mmap: false
---
apiVersion: logstash.k8s.elastic.co/v1alpha1
kind: Logstash
metadata:
name: logstash-sample
spec:
count: 2
version: 8.6.1
config:
log.level: info
api.http.host: "0.0.0.0"
queue.type: memory
services:
- name: api
service:
spec:
type: ClusterIP
ports:
- port: 9600
name: "api"
protocol: TCP
targetPort: 9600
- name: beats
service:
spec:
type: ClusterIP
ports:
- port: 5044
name: "filebeat"
protocol: TCP
targetPort: 5044
- port: 5045
name: "winlogbeat"
protocol: TCP
targetPort: 5045
22 changes: 22 additions & 0 deletions config/webhook/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,28 @@ webhooks:
resources:
- kibanas
sideEffects: None
- admissionReviewVersions:
- v1
- v1beta1
clientConfig:
service:
name: webhook-service
namespace: system
path: /validate-logstash-k8s-elastic-co-v1alpha1-logstash
failurePolicy: Ignore
matchPolicy: Exact
name: elastic-logstash-validation-v1alpha1.k8s.elastic.co
rules:
- apiGroups:
- logstash.k8s.elastic.co
apiVersions:
- v1alpha1
operations:
- CREATE
- UPDATE
resources:
- logstashes
sideEffects: None
- admissionReviewVersions:
- v1alpha1
clientConfig:
Expand Down
Loading