Skip to content

Commit

Permalink
Add support for external syslog servers
Browse files Browse the repository at this point in the history
External servers can be configured with

  spec:
    adminLogTargets:
    - host: xx.xx.xx.xx
      port: 1514
      protocol: udp
    tenantLogTargets:
    ...

JIRA: OSPRH-8233
  • Loading branch information
gthiemonge committed Jul 5, 2024
1 parent 5116ecf commit cc2eb2c
Show file tree
Hide file tree
Showing 8 changed files with 203 additions and 7 deletions.
34 changes: 34 additions & 0 deletions api/bases/octavia.openstack.org_octaviarsyslogs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ spec:
description: OctaviaRsyslogSpec defines common state for all Octavia Amphora
Controllers
properties:
adminLogTargets:
description: AdminLogTargets is a list of OctaviaRsyslogTarget, the
admin logs are forwarded to those targets
items:
properties:
host:
type: string
port:
type: integer
protocol:
type: string
required:
- host
- port
- protocol
type: object
type: array
containerImage:
default: quay.io/podified-antelope-centos9/openstack-rsyslog:current-podified
description: ContainerImage - Amphora Controller Container Image URL
Expand Down Expand Up @@ -133,6 +150,23 @@ spec:
description: 'ServiceUser - service user name (TODO: beagles, do we
need this at all)'
type: string
tenantLogTargets:
description: TenantLogTargets is a list of OctaviaRsyslogTarget, the
tenant logs are forwarded to those targets
items:
properties:
host:
type: string
port:
type: integer
protocol:
type: string
required:
- host
- port
- protocol
type: object
type: array
required:
- serviceAccount
type: object
Expand Down
34 changes: 34 additions & 0 deletions api/bases/octavia.openstack.org_octavias.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,23 @@ spec:
description: OctaviaRsyslog - Spec definition for the Octavia Rsyslog
agent for the Octavia deployment
properties:
adminLogTargets:
description: AdminLogTargets is a list of OctaviaRsyslogTarget,
the admin logs are forwarded to those targets
items:
properties:
host:
type: string
port:
type: integer
protocol:
type: string
required:
- host
- port
- protocol
type: object
type: array
containerImage:
default: quay.io/podified-antelope-centos9/openstack-rsyslog:current-podified
description: ContainerImage - Amphora Controller Container Image
Expand Down Expand Up @@ -994,6 +1011,23 @@ spec:
description: 'ServiceUser - service user name (TODO: beagles,
do we need this at all)'
type: string
tenantLogTargets:
description: TenantLogTargets is a list of OctaviaRsyslogTarget,
the tenant logs are forwarded to those targets
items:
properties:
host:
type: string
port:
type: integer
protocol:
type: string
required:
- host
- port
- protocol
type: object
type: array
required:
- serviceAccount
type: object
Expand Down
14 changes: 14 additions & 0 deletions api/v1beta1/octaviarsyslog_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ type OctaviaRsyslogSpecCore struct {
// +kubebuilder:default={"octavia"}
// NetworkAttachments is a list of NetworkAttachment resource names to expose the services to the given network
NetworkAttachments []string `json:"networkAttachments,omitempty"`

// +kubebuilder:validation:Optional
// AdminLogTargets is a list of OctaviaRsyslogTarget, the admin logs are forwarded to those targets
AdminLogTargets []OctaviaRsyslogTarget `json:"adminLogTargets,omitempty"`

// +kubebuilder:validation:Optional
// TenantLogTargets is a list of OctaviaRsyslogTarget, the tenant logs are forwarded to those targets
TenantLogTargets []OctaviaRsyslogTarget `json:"tenantLogTargets,omitempty"`
}

// OctaviaRsyslogStatus defines the observed state of the Octavia Amphora Controller
Expand Down Expand Up @@ -112,6 +120,12 @@ type OctaviaRsyslogList struct {
Items []OctaviaRsyslog `json:"items"`
}

type OctaviaRsyslogTarget struct {
Host string `json:"host"`
Port int `json:"port"`
Protocol string `json:"protocol"`
}

func init() {
SchemeBuilder.Register(&OctaviaRsyslog{}, &OctaviaRsyslogList{})
}
Expand Down
25 changes: 25 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

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

34 changes: 34 additions & 0 deletions config/crd/bases/octavia.openstack.org_octaviarsyslogs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,23 @@ spec:
description: OctaviaRsyslogSpec defines common state for all Octavia Amphora
Controllers
properties:
adminLogTargets:
description: AdminLogTargets is a list of OctaviaRsyslogTarget, the
admin logs are forwarded to those targets
items:
properties:
host:
type: string
port:
type: integer
protocol:
type: string
required:
- host
- port
- protocol
type: object
type: array
containerImage:
default: quay.io/podified-antelope-centos9/openstack-rsyslog:current-podified
description: ContainerImage - Amphora Controller Container Image URL
Expand Down Expand Up @@ -133,6 +150,23 @@ spec:
description: 'ServiceUser - service user name (TODO: beagles, do we
need this at all)'
type: string
tenantLogTargets:
description: TenantLogTargets is a list of OctaviaRsyslogTarget, the
tenant logs are forwarded to those targets
items:
properties:
host:
type: string
port:
type: integer
protocol:
type: string
required:
- host
- port
- protocol
type: object
type: array
required:
- serviceAccount
type: object
Expand Down
34 changes: 34 additions & 0 deletions config/crd/bases/octavia.openstack.org_octavias.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,23 @@ spec:
description: OctaviaRsyslog - Spec definition for the Octavia Rsyslog
agent for the Octavia deployment
properties:
adminLogTargets:
description: AdminLogTargets is a list of OctaviaRsyslogTarget,
the admin logs are forwarded to those targets
items:
properties:
host:
type: string
port:
type: integer
protocol:
type: string
required:
- host
- port
- protocol
type: object
type: array
containerImage:
default: quay.io/podified-antelope-centos9/openstack-rsyslog:current-podified
description: ContainerImage - Amphora Controller Container Image
Expand Down Expand Up @@ -994,6 +1011,23 @@ spec:
description: 'ServiceUser - service user name (TODO: beagles,
do we need this at all)'
type: string
tenantLogTargets:
description: TenantLogTargets is a list of OctaviaRsyslogTarget,
the tenant logs are forwarded to those targets
items:
properties:
host:
type: string
port:
type: integer
protocol:
type: string
required:
- host
- port
- protocol
type: object
type: array
required:
- serviceAccount
type: object
Expand Down
3 changes: 2 additions & 1 deletion controllers/octaviarsyslog_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ func (r *OctaviaRsyslogReconciler) generateServiceConfigMaps(
}

templateParameters := map[string]interface{}{}
templateParameters["LogTargets"] = []string{}
templateParameters["AdminLogTargets"] = instance.Spec.AdminLogTargets
templateParameters["TenantLogTargets"] = instance.Spec.TenantLogTargets

spec := instance.Spec
templateParameters["ServiceUser"] = spec.ServiceUser
Expand Down
32 changes: 26 additions & 6 deletions templates/octaviarsyslog/config/10-octavia.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,50 @@ module(load="imudp")
input(type="imudp" address="0.0.0.0" port="514")
input(type="imudp" address="::" port="514")

{{ if .TenantLogTargets }}
ruleset(name="tenant_forwarding" queue.type="linkedList" queue.size="10000") {
{{ range $index, $val := .TenantLogTargets }}
action(type="omfwd"
target="{{ $val.Host }}"
port="{{ $val.Port }}"
protocol="{{ $val.Protocol }}"
action.resumeRetryCount="5"
action.resumeInterval="2"
{{ if $index }}action.execOnlyWhenPreviousIsSuspended="on"{{- end }})
{{- end }}
}
{{- end }}

{{ if .AdminLogTargets }}
ruleset(name="admin_forwarding" queue.type="linkedList" queue.size="10000") {
{{ range $index, $val := .LogTargets }}
{{ range $index, $val := .AdminLogTargets }}
action(type="omfwd"
target="{{ $val.Host }}"
port="{{ $val.Port }}"
protocol="udp"
protocol="{{ $val.Protocol }}"
action.resumeRetryCount="5"
action.resumeInterval="2"
{{ if $index }}action.execOnlyWhenPreviousIsSuspended="on"{{- end }})
{{- end }}
}
{{- end }}

module(load="omstdout")

# Output the amphora tenant traffic flow logs
if ($inputname == "imudp" and $syslogfacility-text == "local0" and $syslogseverity-text == "info" and $hostname startswith "amphora") then {
action(type="omstdout")
#action(type="omfile" FileCreateMode="0644" File="/var/log/octavia/octavia-tenant-traffic.log")
# call tenant_forwarding
{{ if .TenantLogTargets }}
call tenant_forwarding
{{ end }}
stop
}

# Output the amphora administrative logs
if ($inputname == "imudp" and $syslogfacility-text != "local0" and $hostname startswith "amphora") then {
action(type="omstdout")
#action(type="omfile" FileCreateMode="0644" File="/var/log/octavia/octavia-amphora.log")
# call admin_forwarding
{{ if .AdminLogTargets }}
call admin_forwarding
{{ end }}
stop
}

0 comments on commit cc2eb2c

Please sign in to comment.