forked from pivotal-cf/docs-pks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-sinks.html.md.erb
470 lines (339 loc) · 15.4 KB
/
create-sinks.html.md.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
---
title: Creating Sink Resources
owner: PKS
---
This topic describes how to create a sink resource for a Kubernetes cluster
provisioned with <%= vars.product_full %> or for a namespace within a
cluster.
## <a id='overview'></a>Overview
Sink resources enable <%= vars.product_short %> users to collect
logs and metrics. You can create the following types of sink resources:
<%= partial 'sink-resources' %>
## <a id='prerequisites'></a>Prerequisites
Before creating a sink resource, do the following:
* If you want to create a `ClusterLogSink` or `LogSink` resource, ensure that the **Enable Log Sink Resources** checkbox is selected in the <%= vars.product_tile %> tile.
* If you want to create a `ClusterMetricSink` or `MetricSink` resource, ensure that the **Enable Metric Sink Resources** checkbox is selected in the <%= vars.product_tile %> tile.
For more information, see the <%= vars.product_short %> installation topic
for your IaaS:
* [Installing <%= vars.product_short %> on vSphere](installing-pks-vsphere.html)
* [Installing <%= vars.product_short %> on vSphere with NSX-T Integration](installing-nsx-t.html)
* [Installing <%= vars.product_short %> on GCP](installing-pks-gcp.html)
* [Installing <%= vars.product_short %> on AWS](installing-pks-aws.html)
* [Installing <%= vars.product_short %> on Azure](installing-pks-azure.html)
### <a name='cli-prereqs'></a> CLI Requirements
To create and manage sink resources, you must install the Kubernetes CLI, <code>kubectl</code>.
Alternately, to manage `ClusterLogSink` resources with the PKS CLI, you must use PKS CLI v1.3 or later.
For installation instructions, see <a href="installing-kubectl-cli.html">Installing the Kubernetes CLI</a>
and <a href="installing-pks-cli.html">Installing the PKS CLI</a>.
## <a id='define-resource'></a>Create Sinks
You can create log and metric sinks for clusters and namespaces.
* If you want to create a `ClusterLogSink`, see
[ClusterLogSink Resources](#define-cluster-log-sink) below.
* If you want to create a `LogSink`, see
[LogSink Resources](#define-log-sink) below.
* If you want to create a `ClusterMetricSink`, see
[ClusterMetricSink Resources](#define-cluster-metric-sink) below.
* If you want to create a `MetricSink`, see
[MetricSink Resources](#define-metric-sink) below.
<p class="note"><strong>Note:</strong> Log sinks created in <%= vars.product_short %> do not support UDP connections.</p>
### <a id='define-cluster-log-sink'></a>ClusterLogSink Resources
`ClusterLogSink` resources enable you to capture logs from your clusters.
To create and manage `ClusterLogSink` resources, you can:
* [Create ClusterLogSink Resource with the PKS CLI](#cluster-sink-pks)
* [Create a Syslog ClusterLogSink Resource with YAML and kubectl](#syslog-cluster-sink)
* [Create a Webhook ClusterLogSink Resource with YAML and kubectl](#webhook-cluster-sink)
<p class="note"><strong>Note:</strong> <%= vars.product_short %> requires a secure connection
for log forwarding. To forward logs using an unsecured connection, see
<a href="#unsecured-sink-configuration">Unsecured ClusterLogSink and LogSink Log Forwarding</a> below.</p>
#### <a id='cluster-sink-pks'></a> Create ClusterLogSink Resource with the PKS CLI
To create and apply a log sink to a cluster, run the following command:
```
pks create-sink CLUSTER-NAME \
syslog-tls://YOUR-LOG-DESTINATION:YOUR-LOG-DESTINATION-PORT
```
Where:
* `CLUSTER-NAME` is the name of your cluster.
* `YOUR-LOG-DESTINATION` is the URL or IP address of your log management service.
* `YOUR-LOG-DESTINATION-PORT` is the port number of your log management service.
<p class="note"><strong>Note:</strong> The sink commands, such as <code>pks create-sink</code> and <code>pks delete-sink</code>,
are deprecated in the PKS CLI. <%= vars.product_short %> will remove these commands in a future release.</p>
For example:
<pre class="terminal">
$ pks create-sink my-cluster syslog-tls://example.com:12345
</pre>
If you do not specify a name, the command creates
a log sink resource in the cluster that shares the same name as the cluster.
To provide a name for the log sink resources in your cluster, run the following command.
```
pks create-sink CLUSTER-NAME --name YOUR-SINK \
syslog-tls://YOUR-LOG-DESTINATION:YOUR-LOG-DESTINATION-PORT
```
Where:
* `CLUSTER-NAME` is the name of your cluster.
* `YOUR-SINK` is the name of the log sink you want to create.
* `YOUR-LOG-DESTINATION` is the URL or IP address of your log management service.
* `YOUR-LOG-DESTINATION-PORT` is the port number of your log management service.
For example:
<pre class="terminal">
$ pks create-sink my-cluster --name second-sink syslog-tls://example.org:54321
</pre>
Specifying a name is useful if you need to manage multiple log sink resources in your cluster.
#### <a id='syslog-cluster-sink'></a> Create a Syslog ClusterLogSink Resource with YAML and kubectl
A syslog `ClusterLogSink` resource delivers logs using the TCP-based syslog protocol.
To define a syslog `ClusterLogSink` resource with YAML and `kubectl`, perform the following steps:
1. Create a YAML file that specifies your log destination in the following format:
```
apiVersion: pksapi.io/v1beta1
kind: ClusterLogSink
metadata:
name: YOUR-SINK-NAME
spec:
type: syslog
host: YOUR-LOG-DESTINATION
port: YOUR-LOG-DESTINATION-PORT
enable_tls: true
```
Where:
* `YOUR-SINK` is a name you choose for your sink.
* `YOUR-LOG-DESTINATION` is the URL or IP address of your log management service.
* `YOUR-LOG-DESTINATION-PORT` is the port number of your log management service.
<p class="note"><strong>Note:</strong> <code>enable_tls</code> must be <code>true</code>.</p>
1. Save the YAML file with an appropriate file name. For example, `my-cluster-sink.yml`.
1. Apply the `ClusterLogSink` resource to your cluster by running the following command:
```
kubectl apply -f MY-SINK.yml
```
Where `MY-SINK.yml` is the name of your YAML file.
For example:
<pre class='terminal'>
$ kubectl apply -f my-cluster-sink.yml
</pre>
#### <a id='webhook-cluster-sink'></a> Create a Webhook ClusterLogSink Resource with YAML and kubectl
A webhook `ClusterLogSink` resource batches logs into 1 second units, wraps the resulting payload in JSON, and uses the POST method to deliver the logs to the address of your log management service.
To define a webhook `ClusterLogSink` resource with YAML and `kubectl`, perform the following steps:
1. Create a YAML file that specifies your log destination in the following format:
```
apiVersion: pksapi.io/v1beta1
kind: ClusterLogSink
metadata:
name: YOUR-SINK-NAME
spec:
type: webhook
url: YOUR-LOG-DESTINATION
```
Where:
* `YOUR-SINK-NAME` is a name you choose for your sink.
* `YOUR-LOG-DESTINATION` is the URL or IP address of your log management service.
1. Save the YAML file with an appropriate filename. For example, `my-cluster-sink.yml`.
1. Apply the `ClusterLogSink` resource to your cluster by running the following command:
```
kubectl apply -f MY-SINK.yml
```
Where `MY-SINK.yml` is the name of your YAML file.
For example:
<pre class='terminal'>
$ kubectl apply -f my-cluster-sink.yml
</pre>
### <a id='define-log-sink'></a> LogSink Resources
A `LogSink` resource filters logs by namespace within a cluster.
You can use only `kubectl` to create and manage log sinks for namespaces.
#### <a id='sink-kubectl'></a> Create a LogSink Resource with YAML and kubectl
To define a `LogSink` resource with YAML and `kubectl`, perform the following steps:
1. Create a YAML file that specifies your log destination in the following format:
```
apiVersion: pksapi.io/v1beta1
kind: LogSink
metadata:
name: YOUR-SINK
namespace: YOUR-NAMESPACE
spec:
type: syslog
host: YOUR-LOG-DESTINATION
port: YOUR-LOG-DESTINATION-PORT
enable_tls: true
```
Where:
* `YOUR-SINK` is a name you choose for your log sink.
* `YOUR-NAMESPACE` is the name of your namespace.
* `YOUR-LOG-DESTINATION` is the URL or IP address of your log management service.
* `YOUR-LOG-DESTINATION-PORT` is the port number of your log management service.
<p class="note"><strong>Note:</strong> <code>enable_tls</code> must be <code>true</code>.</p>
1. Save the YAML file with an appropriate file name. For example, `my-namespace-sink.yml`.
1. Apply the `LogSink` resource to your cluster by running the following command:
```
kubectl apply -f MY-SINK.yml
```
Where `MY-SINK.yml` is the name of your YAML file.
For example:
<pre class='terminal'>
$ kubectl apply -f my-namespace-sink.yml
</pre>
### <a name='unsecured-sink-configuration'></a>Unsecured ClusterLogSink and LogSink Log Forwarding
By default, <%= vars.product_short %> requires a secure connection for `ClusterLogSink` and `LogSink` log forwarding.
To forward `ClusterLogSink` and `LogSink` logs using an unsecured connection, you must first disable log forwarding validation.
1. To disable sink forwarding validation, run the following command:
```
kubectl delete validatingwebhookconfigurations validator.pksapi.io
```
<p class="note warning"><strong>Warning:</strong> Disabling secure log forwarding is not recommended.</p>
### <a id='define-cluster-metric-sink'></a> ClusterMetricSink Resources
A `ClusterMetricSink` resource collects metrics from a cluster using the [Kubernetes Input Plugin]
(https://github.com/influxdata/telegraf/tree/master/plugins/inputs/kubernetes) and writes them to one or more outputs
that you specify in the configuration of your `ClusterMetricSink`.
For a list of supported metrics and output plugins,
see [Metrics](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/kubernetes#metrics)
and [Output Plugins](https://github.com/influxdata/telegraf#output-plugins) in the telegraf GitHub repository.
You can use only `kubectl` to create and manage metric sinks for clusters.
#### <a id='default'></a> Create a ClusterMetricSink Resource with YAML and kubectl
To define a `ClusterMetricSink` resource with YAML and `kubectl`, perform the following steps:
1. Create a YAML file in the following format:
```
apiVersion: pksapi.io/v1beta1
kind: ClusterMetricSink
metadata:
name: YOUR-SINK
spec:
inputs:
outputs:
- type: YOUR-OUTPUT-PLUGIN
```
Where:
* `YOUR-SINK` is a name you choose for your sink.
* `YOUR-OUTPUT-PLUGIN` is the name of the output plugin you want to use for your metrics.
<p class="note"><strong>Note:</strong> You can leave the <code>inputs</code> field blank.
This field is configured to include metrics from the Kubelet by default.</p>
For example:
```
apiVersion: pksapi.io/v1beta1
kind: ClusterMetricSink
metadata:
name: http
spec:
inputs:
outputs:
- type: http
url: https:example.com
method: POST
data_format: json
```
1. Save the YAML file with an appropriate filename. For example, `my-cluster-metric-sink.yml`.
1. Apply the `ClusterMetricSink` resource to your cluster by running the following command:
```
kubectl apply -f MY-SINK.yml
```
Where `MY-SINK.yml` is the name of your YAML file.
For example:
<pre class='terminal'>
$ kubectl apply -f my-cluster-metric-sink.yml
</pre>
### <a id='define-metric-sink'></a> MetricSink Resources
A `MetricSink` resource collects metrics from a namespace within a cluster.
You can use only `kubectl` to create and manage metric sinks for namespaces.
#### <a id='metric-sink'></a> Create a MetricSink Resource with YAML and kubectl
To define a `MetricSink` resource with YAML and `kubectl`, perform the following steps:
1. Create a YAML file in the following format:
```
apiVersion: pksapi.io/v1beta1
kind: MetricSink
metadata:
name: YOUR-SINK
namespace: YOUR-NAMESPACE
spec:
inputs:
outputs:
- type: YOUR-OUTPUT-PLUGIN
```
Where:
* `YOUR-SINK` is a name you choose for your sink.
* `YOUR-NAMESPACE` is the name of your namespace.
* `YOUR-OUTPUT-PLUGIN` is the name of the output plugin you want to use for your metrics.
<p class="note"><strong>Note:</strong> You can leave the <code>inputs</code> field blank.
This field is configured to include all <code>prometheus.io/scrape</code> annotations set to <code>true</code> by default.</p>
For example:
```
apiVersion: pksapi.io/v1beta1
kind: MetricSink
metadata:
name: http
spec:
inputs:
outputs:
- type: http
url: https:example.com
method: POST
data_format: json
```
1. Save the YAML file with an appropriate filename. For example, `my-metric-sink.yml`.
1. Apply the `MetricSink` resource to your cluster by running the following command:
```
kubectl apply -f MY-SINK.yml
```
Where `MY-SINK.yml` is the name of your YAML file.
For example:
<pre class='terminal'>
$ kubectl apply -f my-metric-sink.yml
</pre>
## <a id='list-sinks'></a> List Sinks
To list sinks for clusters and namespaces, use the commands in the following sections.
###<a id="cluster-log-sink-list"></a> ClusterLogSink Resources
To list log sinks deployed to your cluster, run the following command:
```
pks sinks CLUSTER-NAME
```
Where `CLUSTER-NAME` corresponds to the name of your cluster.
Alternately, you can use `kubectl`:
```
kubectl get clusterlogsinks
```
### <a id="log-sink-list"></a> LogSink Resources
To list namespace log sinks, run the following command:
```
kubectl get logsinks
```
### <a id="cluster-metric-sink-list"></a> ClusterMetricSink Resources
To list metric sinks deployed to your cluster, run the following command:
```
kubectl get clustermetricsinks
```
### <a id="metric-sink-list"></a> MetricSink Resources
To list namespace metric sinks, run the following command:
```
kubectl get metricsinks
```
## <a id='delete-sinks'></a> Delete Sinks
To delete sinks for clusters and namespaces, use the commands in the following sections.
### <a id='cluster-log-sink-delete'></a> ClusterLogSink Resources
To delete a cluster log sink, run the following PKS CLI command:
```
pks delete-sink CLUSTER-NAME --name YOUR-SINK
```
Where:
* `CLUSTER-NAME` is the name of your cluster.
* `YOUR-SINK` is the name of your sink.
Alternately, you can use `kubectl`:
```
kubectl delete clusterlogsink YOUR-SINK
```
Where `YOUR-SINK` is the name of your sink.
### <a id='log-sink-delete'></a> LogSink Resources
To delete a namespace log sink using `kubectl`, run the following command:
```
kubectl delete logsink YOUR-SINK
```
Where `YOUR-SINK` is the name of your logsink.
### <a id="cluster-metric-sink-delete"></a> ClusterMetricSink Resources
To delete a metric sink deployed to your cluster, use the following command:
```
kubectl delete clustermetricsink YOUR-SINK
```
Where `YOUR-SINK` is the name of your sink.
### <a id="metric-sink-delete"></a> MetricSink Resources
To delete a namespace metric sink, use the following command:
```
kubectl delete metricsink YOUR-SINK
```
Where `YOUR-SINK` is the name of your sink.
## <a id="related-links"></a> Related Links
For more information about sinks in <%= vars.product_short %>, see the following topics:
* For information about using sinks for monitoring, see [Monitoring <%= vars.product_short %> with Sinks](./monitor-sinks.html).
* For information about sink architecture, see [Sink Architecture in <%= vars.product_short %>](sink-architecture.html).