-
Notifications
You must be signed in to change notification settings - Fork 2
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
Completed a working alpha for the operator #11
Changes from 14 commits
2a76cac
c98a961
3e74edb
c7b3821
5bbd68d
8a74821
b4e0035
aaeed36
6962d63
6910d3d
74f9885
2e6db52
929bc73
807d5ee
aad66a5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,42 @@ metadata: | |
creationTimestamp: null | ||
name: manager-role | ||
rules: | ||
- apiGroups: | ||
- logging.banzaicloud.io | ||
resources: | ||
- clusterflows | ||
- clusteroutputs | ||
- flows | ||
- outputs | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
isala404 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
- update | ||
- watch | ||
- apiGroups: | ||
- logging.banzaicloud.io | ||
resources: | ||
- clusterflows/status | ||
- flows/status | ||
verbs: | ||
- get | ||
- patch | ||
- update | ||
- apiGroups: | ||
- logging.banzaicloud.io | ||
resources: | ||
- output | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is output listed twice? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this was created by kubebuilder I will see why it's doing that |
||
- update | ||
- watch | ||
- apiGroups: | ||
- loggingplumber.isala.me | ||
resources: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: busybox-echo | ||
labels: | ||
loggingplumber.isala.me/test: simulations | ||
spec: | ||
containers: | ||
- name: busybox | ||
image: busybox | ||
command: ["sh", "-c", "x=1; while [ $x -gt -1 ]; do echo \"{'count': '$(( x++ ))', 'date': '$(date)'}\" && sleep 5; done"] | ||
--- | ||
apiVersion: logging.banzaicloud.io/v1beta1 | ||
kind: Flow | ||
metadata: | ||
name: busybox-echo | ||
labels: | ||
loggingplumber.isala.me/test: simulations | ||
spec: | ||
localOutputRefs: | ||
- busybox-echo | ||
match: | ||
- select: | ||
labels: | ||
loggingplumber.isala.me/test: invalid | ||
- select: | ||
labels: | ||
loggingplumber.isala.me/test: simulations | ||
paynejacob marked this conversation as resolved.
Show resolved
Hide resolved
|
||
filters: | ||
- record_modifier: | ||
records: | ||
- foo: "bar" | ||
- grep: | ||
regexp: | ||
- key: first | ||
pattern: /^5\d\d$/ | ||
--- | ||
apiVersion: logging.banzaicloud.io/v1beta1 | ||
kind: Output | ||
metadata: | ||
name: busybox-echo | ||
labels: | ||
loggingplumber.isala.me/test: simulations | ||
spec: | ||
http: | ||
endpoint: "http://logging-plumber-log-aggregator.default.svc/busybox-echo/" | ||
buffer: | ||
flush_interval: 10s | ||
flush_mode: interval | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: logging-plumber-log-aggregator | ||
labels: | ||
loggingplumber.isala.me/test: simulations | ||
spec: | ||
type: ClusterIP | ||
ports: | ||
- port: 80 | ||
targetPort: http | ||
protocol: TCP | ||
name: http | ||
selector: | ||
app.kubernetes.io/name: logging-plumber-log-aggregator | ||
app.kubernetes.io/managed-by: rancher-logging-explorer | ||
app.kubernetes.io/created-by: logging-plumber | ||
loggingplumber.isala.me/component: log-aggregator |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package controllers | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
flowv1beta1 "github.com/banzaicloud/logging-operator/pkg/sdk/api/v1beta1" | ||
v1 "k8s.io/api/core/v1" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
"sigs.k8s.io/controller-runtime/pkg/log" | ||
) | ||
|
||
func (r *FlowTestReconciler) cleanUpResources(ctx context.Context, flowTestName string) error { | ||
logger := log.FromContext(ctx) | ||
|
||
matchingLabels := &client.MatchingLabels{"loggingplumber.isala.me/flowtest": flowTestName} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should pull this into a function in case we ever change our label There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will get addressed in #16 |
||
|
||
var podList v1.PodList | ||
if err := r.List(ctx, &podList, matchingLabels); client.IgnoreNotFound(err) != nil { | ||
paynejacob marked this conversation as resolved.
Show resolved
Hide resolved
|
||
logger.Error(err, fmt.Sprintf("failed to get provisioned %s", podList.Kind)) | ||
return err | ||
} | ||
|
||
for _, resource := range podList.Items { | ||
if err := r.Delete(ctx, &resource); client.IgnoreNotFound(err) != nil { | ||
logger.Error(err, fmt.Sprintf("failed to delete a provisioned %s", resource.Kind), "uuid", resource.GetUID(), "name", resource.GetName()) | ||
return err | ||
} | ||
logger.V(1).Info(fmt.Sprintf("%s deleted", resource.Kind), "uuid", resource.GetUID(), "name", resource.GetName()) | ||
} | ||
|
||
var configMapList v1.ConfigMapList | ||
if err := r.List(ctx, &configMapList, matchingLabels); client.IgnoreNotFound(err) != nil { | ||
logger.Error(err, fmt.Sprintf("failed to get provisioned %s", configMapList.Kind)) | ||
return err | ||
} | ||
|
||
for _, resource := range configMapList.Items { | ||
if err := r.Delete(ctx, &resource); client.IgnoreNotFound(err) != nil { | ||
logger.Error(err, fmt.Sprintf("failed to delete a provisioned %s", resource.Kind), "uuid", resource.GetUID(), "name", resource.GetName()) | ||
return err | ||
} | ||
logger.V(1).Info(fmt.Sprintf("%s deleted", resource.Kind), "uuid", resource.GetUID(), "name", resource.GetName()) | ||
} | ||
|
||
var flows flowv1beta1.FlowList | ||
if err := r.List(ctx, &flows, &client.MatchingLabels{"loggingplumber.isala.me/flowtest": flowTestName}); client.IgnoreNotFound(err) != nil { | ||
logger.Error(err, fmt.Sprintf("failed to get provisioned %s", flows.Kind)) | ||
//return err | ||
} | ||
|
||
for _, resource := range flows.Items { | ||
if err := r.Delete(ctx, &resource); client.IgnoreNotFound(err) != nil { | ||
logger.Error(err, fmt.Sprintf("failed to delete a provisioned %s", resource.Kind), "uuid", resource.GetUID(), "name", resource.GetName()) | ||
return err | ||
} | ||
logger.V(1).Info(fmt.Sprintf("%s deleted", resource.Kind), "uuid", resource.GetUID(), "name", resource.GetName()) | ||
} | ||
|
||
var outputs flowv1beta1.OutputList | ||
if err := r.List(ctx, &outputs, &client.MatchingLabels{"loggingplumber.isala.me/flowtest": flowTestName}); client.IgnoreNotFound(err) != nil { | ||
logger.Error(err, fmt.Sprintf("failed to get provisioned %s", outputs.Kind)) | ||
//return err | ||
} | ||
|
||
for _, resource := range outputs.Items { | ||
if err := r.Delete(ctx, &resource); client.IgnoreNotFound(err) != nil { | ||
logger.Error(err, fmt.Sprintf("failed to delete a provisioned %s", resource.Kind), "uuid", resource.GetUID(), "name", resource.GetName()) | ||
return err | ||
} | ||
logger.V(1).Info(fmt.Sprintf("%s deleted", resource.Kind), "uuid", resource.GetUID(), "name", resource.GetName()) | ||
} | ||
|
||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will revert this back with the next PR. For now I wannted have the working alpha on the main branch