solutions/guardrails/configs/log-sinks/pubsub-sink.yaml (43 lines of code) (raw):
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#########
# PubSub Log Sink
apiVersion: logging.cnrm.cloud.google.com/v1beta1
kind: LoggingLogSink
metadata:
name: pubsub-logsink
namespace: config-control # kpt-set: ${management-namespace}
annotations:
config.kubernetes.io/depends-on: pubsub.cnrm.cloud.google.com/namespaces/guardrails/PubSubTopic/logginglogsink-org # kpt-set: pubsub.cnrm.cloud.google.com/namespaces/${management-namespace}/PubSubTopic/logginglogsink-org,resourcemanager.cnrm.cloud.google.com/namespaces/${management-namespace}/Project/${guardrails-project-id}
spec:
destination:
pubSubTopicRef:
name: logginglogsink-org
namespace: guardrails # kpt-set: ${management-namespace}
includeChildren: true
organizationRef:
external: "0000000000" # kpt-set: ${org-id}
---
#########
# PubSub Instance
apiVersion: pubsub.cnrm.cloud.google.com/v1beta1
kind: PubSubTopic
metadata:
name: logginglogsink-org
namespace: config-control # kpt-set: ${management-namespace}
annotations:
cnrm.cloud.google.com/project-id: project-id # kpt-set: ${guardrails-project-id}
config.kubernetes.io/depends-on: resourcemanager.cnrm.cloud.google.com/namespaces/config-control/Project/guardrails-project-id # kpt-set: resourcemanager.cnrm.cloud.google.com/namespaces/${management-namespace}/Project/${guardrails-project-id}
---
# PubSub Audit Log Viewer
apiVersion: iam.cnrm.cloud.google.com/v1beta1
kind: IAMPartialPolicy
metadata:
name: pubsub-sink-writer
namespace: config-control # kpt-set: ${management-namespace}
annotations:
config.kubernetes.io/depends-on: logging.cnrm.cloud.google.com/namespaces/config-control/LoggingLogSink/pubsub-logsink # kpt-set: logging.cnrm.cloud.google.com/namespaces/${management-namespace}/LoggingLogSink/pubsub-logsink
spec:
resourceRef:
apiVersion: pubsub.cnrm.cloud.google.com/v1beta1
kind: PubSubTopic
name: logginglogsink-org
bindings:
- role: roles/pubsub.editor
members:
- memberFrom:
logSinkRef:
name: pubsub-logsink