Skip to content

Commit

Permalink
Merge pull request #1538 from kube-logging/master-release-4.4
Browse files Browse the repository at this point in the history
Release 4.4 to master
  • Loading branch information
pepov authored Oct 16, 2023
2 parents 314ffac + b2a6fb2 commit 53881d3
Show file tree
Hide file tree
Showing 21 changed files with 449 additions and 67 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ debug: manager ## Remote debug

.PHONY: docker-build
docker-build: ## Build the docker image
docker image inspect ${IMG} && echo "docker image ${IMG} already built" || ${DOCKER} build . -t ${IMG}
${DOCKER} build . -t ${IMG}
@echo "updating kustomize image patch file for manager resource"
sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml

Expand Down
117 changes: 116 additions & 1 deletion charts/logging-operator/crds/logging.banzaicloud.io_loggings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,24 @@ spec:
storage: false
subresources:
status: {}
- name: v1beta1
- additionalPrinterColumns:
- description: Logging reference
jsonPath: .spec.loggingRef
name: LoggingRef
type: string
- description: Control namespace
jsonPath: .spec.controlNamespace
name: ControlNamespace
type: string
- description: Watched namespaces
jsonPath: .status.watchNamespaces
name: WatchNamespaces
type: string
- description: Number of problems
jsonPath: .status.problemsCount
name: Problems
type: integer
name: v1beta1
schema:
openAPIV3Schema:
properties:
Expand Down Expand Up @@ -5097,6 +5114,98 @@ spec:
tag:
type: string
type: object
resources:
properties:
claims:
items:
properties:
name:
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: object
securityContext:
properties:
allowPrivilegeEscalation:
type: boolean
capabilities:
properties:
add:
items:
type: string
type: array
drop:
items:
type: string
type: array
type: object
privileged:
type: boolean
procMount:
type: string
readOnlyRootFilesystem:
type: boolean
runAsGroup:
format: int64
type: integer
runAsNonRoot:
type: boolean
runAsUser:
format: int64
type: integer
seLinuxOptions:
properties:
level:
type: string
role:
type: string
type:
type: string
user:
type: string
type: object
seccompProfile:
properties:
localhostProfile:
type: string
type:
type: string
required:
- type
type: object
windowsOptions:
properties:
gmsaCredentialSpec:
type: string
gmsaCredentialSpecName:
type: string
hostProcess:
type: boolean
runAsUserName:
type: string
type: object
type: object
type: object
podManagementPolicy:
type: string
Expand Down Expand Up @@ -17918,6 +18027,12 @@ spec:
items:
type: string
type: array
problemsCount:
type: integer
watchNamespaces:
items:
type: string
type: array
type: object
type: object
served: true
Expand Down
117 changes: 116 additions & 1 deletion config/crd/bases/logging.banzaicloud.io_loggings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,24 @@ spec:
storage: false
subresources:
status: {}
- name: v1beta1
- additionalPrinterColumns:
- description: Logging reference
jsonPath: .spec.loggingRef
name: LoggingRef
type: string
- description: Control namespace
jsonPath: .spec.controlNamespace
name: ControlNamespace
type: string
- description: Watched namespaces
jsonPath: .status.watchNamespaces
name: WatchNamespaces
type: string
- description: Number of problems
jsonPath: .status.problemsCount
name: Problems
type: integer
name: v1beta1
schema:
openAPIV3Schema:
properties:
Expand Down Expand Up @@ -5097,6 +5114,98 @@ spec:
tag:
type: string
type: object
resources:
properties:
claims:
items:
properties:
name:
type: string
required:
- name
type: object
type: array
x-kubernetes-list-map-keys:
- name
x-kubernetes-list-type: map
limits:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
requests:
additionalProperties:
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
type: object
type: object
securityContext:
properties:
allowPrivilegeEscalation:
type: boolean
capabilities:
properties:
add:
items:
type: string
type: array
drop:
items:
type: string
type: array
type: object
privileged:
type: boolean
procMount:
type: string
readOnlyRootFilesystem:
type: boolean
runAsGroup:
format: int64
type: integer
runAsNonRoot:
type: boolean
runAsUser:
format: int64
type: integer
seLinuxOptions:
properties:
level:
type: string
role:
type: string
type:
type: string
user:
type: string
type: object
seccompProfile:
properties:
localhostProfile:
type: string
type:
type: string
required:
- type
type: object
windowsOptions:
properties:
gmsaCredentialSpec:
type: string
gmsaCredentialSpecName:
type: string
hostProcess:
type: boolean
runAsUserName:
type: string
type: object
type: object
type: object
podManagementPolicy:
type: string
Expand Down Expand Up @@ -17918,6 +18027,12 @@ spec:
items:
type: string
type: array
problemsCount:
type: integer
watchNamespaces:
items:
type: string
type: array
type: object
type: object
served: true
Expand Down
21 changes: 16 additions & 5 deletions controllers/logging/logging_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,8 @@ func (r *LoggingReconciler) dynamicDefaults(ctx context.Context, log logr.Logger
if err := r.Client.List(ctx, &nodes); err != nil {
log.Error(err, "listing nodes")
}
if logging.Spec.SyslogNGSpec != nil && len(nodes.Items) > 0 {
logging.Spec.SyslogNGSpec.MaxConnections = len(nodes.Items) * 10
if logging.Spec.SyslogNGSpec.MaxConnections > 512 {
logging.Spec.SyslogNGSpec.MaxConnections = 512
}
if logging.Spec.SyslogNGSpec != nil && logging.Spec.SyslogNGSpec.MaxConnections == 0 {
logging.Spec.SyslogNGSpec.MaxConnections = max(100, min(1000, len(nodes.Items)*10))
}
}

Expand Down Expand Up @@ -535,3 +532,17 @@ func reconcileRequestsForLoggingRef(loggings []loggingv1beta1.Logging, loggingRe
}
return
}

func min(a, b int) int {
if a < b {
return a
}
return b
}

func max(a, b int) int {
if a > b {
return a
}
return b
}
30 changes: 30 additions & 0 deletions controllers/logging/loggingroute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ import (

"emperror.dev/errors"
"github.com/go-logr/logr"
apitypes "k8s.io/apimachinery/pkg/types"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

"github.com/kube-logging/logging-operator/pkg/resources/fluentbit"
Expand Down Expand Up @@ -89,3 +93,29 @@ func (r *LoggingRouteReconciler) Reconcile(ctx context.Context, req ctrl.Request

return ctrl.Result{}, nil
}

func SetupLoggingRouteWithManager(mgr ctrl.Manager, logger logr.Logger) error {
// In case we receive an update about a logging resource
// we better notify all the logging routes to check if their target list has changed
// rather than complicate the watch logic here.
// The number and processing time of logging routes is not expected to cause issues.
loggingRequestMapper := handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []reconcile.Request {
var requests []reconcile.Request
if _, ok := obj.(*loggingv1beta1.Logging); ok {
var lrList loggingv1beta1.LoggingRouteList
if err := mgr.GetClient().List(ctx, &lrList); err != nil {
logger.Error(err, "failed to list logging route resources")
return nil
}
for _, lr := range lrList.Items {
requests = append(requests, reconcile.Request{NamespacedName: apitypes.NamespacedName{Name: lr.Name}})
}
}
return requests
})

return ctrl.NewControllerManagedBy(mgr).
For(&loggingv1beta1.LoggingRoute{}).
Watches(&loggingv1beta1.Logging{}, loggingRequestMapper, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Complete(NewLoggingRouteReconciler(mgr.GetClient(), logger))
}
12 changes: 12 additions & 0 deletions docs/configuration/crds/v1beta1/fluentd_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,16 @@ Container image to use for the fluentd placeholder pod

Default: -

### resources (*corev1.ResourceRequirements, optional) {#fluentddrainconfig-resources}

Configurable resource requirements for the drainer sidecar container. Default 20m cpu request, 20M memory limit

Default: -

### securityContext (*corev1.SecurityContext, optional) {#fluentddrainconfig-securitycontext}

Configurable security context, uses fluentd pods' security context by default

Default: -


Loading

0 comments on commit 53881d3

Please sign in to comment.