# THIS FILE IS AUTO-GENERATED DO NOT EDIT apiVersion: apps/v1 kind: Deployment metadata: labels: k8s-app: stackdriver-heapster version: v1.6.1 name: heapster namespace: stackdriver-agents spec: replicas: 1 selector: matchLabels: k8s-app: stackdriver-heapster strategy: rollingUpdate: maxSurge: 1 maxUnavailable: 1 type: RollingUpdate template: metadata: creationTimestamp: null labels: k8s-app: stackdriver-heapster version: v1.6.1 spec: containers: - env: - name: CLUSTER_NAME valueFrom: configMapKeyRef: name: cluster-config key: cluster_name - name: CLUSTER_LOCATION valueFrom: configMapKeyRef: name: cluster-config key: cluster_location - name: GOOGLE_APPLICATION_CREDENTIALS valueFrom: configMapKeyRef: name: google-cloud-config key: credentials_path command: - /heapster - --source=kubernetes.summary_api:https://kubernetes.default?kubeletHttps=true&kubeletPort=10250&insecure=true - --sink=stackdriver:?cluster_name=$(CLUSTER_NAME)&cluster_location=$(CLUSTER_LOCATION)&zone=$(CLUSTER_LOCATION)&use_old_resources=false&use_new_resources=true&min_interval_sec=100&batch_export_timeout_sec=110 image: gcr.io/stackdriver-agents/heapster-amd64:v1.6.1 imagePullPolicy: Always livenessProbe: failureThreshold: 3 httpGet: path: /healthz port: 8082 scheme: HTTP initialDelaySeconds: 180 periodSeconds: 10 successThreshold: 1 timeoutSeconds: 5 name: heapster resources: limits: cpu: 88m memory: 204Mi requests: cpu: 88m memory: 204Mi terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: - mountPath: /etc/google-cloud/ name: google-cloud-config - command: - /pod_nanny - --cpu=80m - --extra-cpu=0.5m - --memory=140Mi - --extra-memory=4Mi - --threshold=5 - --deployment=heapster - --container=heapster - --poll-period=300000 - --estimator=exponential env: - name: MY_POD_NAME valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.name - name: MY_POD_NAMESPACE valueFrom: fieldRef: apiVersion: v1 fieldPath: metadata.namespace image: gcr.io/google_containers/addon-resizer:1.7 imagePullPolicy: IfNotPresent name: heapster-nanny resources: limits: cpu: 50m memory: 112360Ki requests: cpu: 50m memory: 112360Ki terminationMessagePath: /dev/termination-log terminationMessagePolicy: File dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} serviceAccount: heapster serviceAccountName: heapster terminationGracePeriodSeconds: 30 volumes: - configMap: defaultMode: 420 name: google-cloud-config name: google-cloud-config --- apiVersion: apps/v1 kind: DaemonSet metadata: labels: app: stackdriver-logging-agent name: stackdriver-logging-agent namespace: stackdriver-agents spec: selector: matchLabels: app: stackdriver-logging-agent template: metadata: labels: app: stackdriver-logging-agent spec: containers: - env: - name: NODE_NAME valueFrom: fieldRef: apiVersion: v1 fieldPath: spec.nodeName - name: K8S_NODE_NAME valueFrom: fieldRef: apiVersion: v1 fieldPath: spec.nodeName - name: GOOGLE_APPLICATION_CREDENTIALS valueFrom: configMapKeyRef: name: google-cloud-config key: credentials_path - name: CLUSTER_NAME valueFrom: configMapKeyRef: name: cluster-config key: cluster_name - name: CLUSTER_LOCATION valueFrom: configMapKeyRef: name: cluster-config key: cluster_location image: gcr.io/stackdriver-agents/stackdriver-logging-agent:1.10.1 imagePullPolicy: IfNotPresent livenessProbe: exec: command: - /bin/sh - -c - | LIVENESS_THRESHOLD_SECONDS=${LIVENESS_THRESHOLD_SECONDS:-300}; STUCK_THRESHOLD_SECONDS=${LIVENESS_THRESHOLD_SECONDS:-900}; if [ ! -e /var/run/google-fluentd/buffers ]; then exit 1; fi; touch -d "${STUCK_THRESHOLD_SECONDS} seconds ago" /tmp/marker-stuck; if [[ -z "$(find /var/run/google-fluentd/buffers -type f -newer /tmp/marker-stuck -print -quit)" ]]; then rm -rf /var/run/google-fluentd/buffers; exit 1; fi; touch -d "${LIVENESS_THRESHOLD_SECONDS} seconds ago" /tmp/marker-liveness; if [[ -z "$(find /var/run/google-fluentd/buffers -type f -newer /tmp/marker-liveness -print -quit)" ]]; then exit 1; fi; failureThreshold: 3 initialDelaySeconds: 600 periodSeconds: 60 successThreshold: 1 timeoutSeconds: 1 name: logging-agent resources: limits: cpu: "1" memory: 300Mi requests: cpu: 100m memory: 200Mi terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: - mountPath: /var/run name: varrun - mountPath: /var/log name: varlog - mountPath: /var/lib/docker/containers name: varlibdockercontainers readOnly: true - mountPath: /etc/google-fluentd/google-fluentd.conf subPath: google-fluentd.conf name: output-config-volume - mountPath: /etc/google-fluentd/config.d name: input-config-volume - mountPath: /etc/google-cloud/ name: google-cloud-config serviceAccount: logging-agent serviceAccountName: logging-agent dnsPolicy: ClusterFirst restartPolicy: Always schedulerName: default-scheduler securityContext: {} tolerations: - operator: "Exists" effect: "NoExecute" - operator: "Exists" effect: "NoSchedule" volumes: - hostPath: path: /var/run type: "" name: varrun - hostPath: path: /var/log type: "" name: varlog - hostPath: path: /var/lib/docker/containers type: "" name: varlibdockercontainers - configMap: defaultMode: 420 name: logging-agent-output-config name: output-config-volume - configMap: defaultMode: 420 name: logging-agent-input-config name: input-config-volume - configMap: defaultMode: 420 name: google-cloud-config name: google-cloud-config updateStrategy: rollingUpdate: maxUnavailable: 1 type: RollingUpdate --- # Config map for Logging Agent input and corresponding filter plugins. apiVersion: v1 kind: ConfigMap metadata: name: logging-agent-input-config namespace: stackdriver-agents data: 1.containers.input.conf: |- # This configuration file for Fluentd is used # to watch changes to Docker log files that live in the # directory /var/lib/docker/containers/ and are symbolically # linked to from the /var/log/containers directory using names that capture the # pod name and container name. These logs are then submitted to # Google Cloud Logging which assumes the installation of the cloud-logging plug-in. # # Example # ======= # A line in the Docker log file might look like this JSON: # # {"log":"2014/09/25 21:15:03 Got request with path wombat\\n", # "stream":"stderr", # "time":"2014-09-25T21:15:03.499185026Z"} # # The original tag is derived from the log file's location. # For example a Docker container's logs might be in the directory: # /var/lib/docker/containers/997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b # and in the file: # 997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b-json.log # where 997599971ee6... is the Docker ID of the running container. # The Kubernetes kubelet makes a symbolic link to this file on the host # machine in the /var/log/containers directory which includes the pod name, # the namespace name and the Kubernetes container name: # synthetic-logger-0.25lps-pod_default_synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log # -> # /var/lib/docker/containers/997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b/997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b-json.log # The /var/log directory on the host is mapped to the /var/log directory in the container # running this instance of Fluentd and we end up collecting the file: # /var/log/containers/synthetic-logger-0.25lps-pod_default_synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log # This results in the tag: # var.log.containers.synthetic-logger-0.25lps-pod_default_synth-lgr-997599971ee6366d4a5920d25b79286ad45ff37a74494f262e3bc98d909d0a7b.log # where 'synthetic-logger-0.25lps-pod' is the pod name, 'default' is the # namespace name, 'synth-lgr' is the container name and '997599971ee6..' is # the container ID. # The record reformer is used to extract pod_name, namespace_name and # container_name from the tag and set them in a local_resource_id in the # format of: # 'k8s_container...'. # The reformer also changes the tags to 'stderr' or 'stdout' based on the # value of 'stream'. # local_resource_id is later used by google_cloud plugin to determine the # monitored resource to ingest logs against. # Json Log Example: # {"log":"[info:2016-02-16T16:04:05.930-08:00] Some log text here\n","stream":"stdout","time":"2016-02-17T00:04:05.931087621Z"} # CRI Log Example: # 2016-02-17T00:04:05.931087621Z stdout F [info:2016-02-16T16:04:05.930-08:00] Some log text here @type tail path /var/log/containers/*.log pos_file /var/run/google-fluentd/pos-files/gcp-containers.pos # Tags at this point are in the format of: # reform.var.log.containers.__-.log tag reform.* read_from_head true @type multi_format format json time_key time time_format %Y-%m-%dT%H:%M:%S.%NZ format /^(? @type parser format /^(?\w)(? # This plugin uses environment variables KUBERNETES_SERVICE_HOST and # KUBERNETES_SERVICE_PORT to talk to the API server. These environment # variables are added by kubelet automatically. @type kubernetes_metadata # Interval in seconds to dump cache stats locally in the Fluentd log. stats_interval 300 # TTL in seconds of each cached element. cache_ttl 30 # Skip fetching unused metadata. skip_container_metadata true skip_master_url true skip_namespace_metadata true # We have to use record_modifier because only this plugin supports complex # logic to modify record the way we need. @type record_modifier enable_ruby true # Extract "kubernetes"->"labels" and set them as # "logging.googleapis.com/labels". Prefix these labels with # "k8s-pod" to distinguish with other labels and avoid # label name collision with other types of labels. _dummy_ ${if record.is_a?(Hash) && record.has_key?('kubernetes') && record['kubernetes'].has_key?('labels') && record['kubernetes']['labels'].is_a?(Hash); then; record["logging.googleapis.com/labels"] = record['kubernetes']['labels'].map{ |k, v| ["k8s-pod/#{k}", v]}.to_h; end; nil} # Delete this dummy field and the rest of "kubernetes" and "docker". remove_keys _dummy_,kubernetes,docker @type record_reformer enable_ruby true # Extract local_resource_id from tag for 'k8s_container' monitored # resource. The format is: # 'k8s_container...'. "logging.googleapis.com/local_resource_id" ${"k8s_container.#{tag_suffix[4].rpartition('.')[0].split('_')[1]}.#{tag_suffix[4].rpartition('.')[0].split('_')[0]}.#{tag_suffix[4].rpartition('.')[0].split('_')[2].rpartition('-')[0]}"} # Rename the field 'log' to a more generic field 'message'. This way the # fluent-plugin-google-cloud knows to flatten the field as textPayload # instead of jsonPayload after extracting 'time', 'severity' and # 'stream' from the record. message ${record['log']} # If 'severity' is not set, assume stderr is ERROR and stdout is INFO. severity ${record['severity'] || if record['stream'] == 'stderr' then 'ERROR' else 'INFO' end} tag ${if record['stream'] == 'stderr' then 'raw.stderr' else 'raw.stdout' end} remove_keys stream,log # Detect exceptions in the log output and forward them as one log entry. @type detect_exceptions remove_tag_prefix raw message message stream "logging.googleapis.com/local_resource_id" multiline_flush_interval 5 max_bytes 500000 max_lines 1000 2.pods.input.conf: |- # This configuration file for Fluentd is used # to watch changes to Kubernetes pod log files live in the # directory /var/log/pods/NAMESPACE_NAME_UID. The file name # is used to capture the pod namespace, name and uid. These # logs are then submitted to Google Cloud Logging with a # local_resource_id 'k8s_pod..' # which assumes the installation of the cloud-logging plug-in. @type tail path /var/log/pods/*/*.log pos_file /var/run/google-fluentd/pos-files/gcp-pods.pos # Tags at this point are in the format of: # pods.reform.var.log.pods.__..log tag pods.reform.* read_from_head true @type none @type record_reformer enable_ruby true # Extract local_resource_id from tag for 'k8s_pod' monitored # resource. The format is: # 'k8s_pod..'. "logging.googleapis.com/local_resource_id" ${"k8s_pod.#{tag_suffix[5].rpartition('.')[0].split('_')[0]}.#{tag_suffix[5].rpartition('.')[0].split('_')[1]}"} # Use the log file name as the tag. Currently only `gvisor` log is supported. tag ${"#{tag_suffix[5].rpartition('.')[0].rpartition('.')[2]}"} 7.system.input.conf: |- # Example: # Dec 21 23:17:22 gke-foo-1-1-4b5cbd14-node-4eoj startupscript: Finished running startup script /var/run/google.startup.script @type tail format syslog path /var/log/startupscript.log pos_file /var/run/google-fluentd/pos-files/gcp-startupscript.pos tag startupscript # Example: # I1118 21:26:53.975789 6 proxier.go:1096] Port "nodePort for kube-system/default-http-backend:http" (:31429/tcp) was open before and is still needed @type tail format multiline multiline_flush_interval 5s format_firstline /^\w\d{4}/ format1 /^(?\w)(?