LATEST VERSION: v1.4 - RELEASE NOTES
Pivotal Container Service v1.3

Creating Sink Resources

This topic describes how to create a sink resource for a Kubernetes cluster provisioned with Pivotal Container Service (PKS) or for a namespace within a cluster.

Sink resources enable PKS users to configure destinations for logs transported following the Syslog Protocol defined in RFC 5424.

Prerequisites

Before you can create a sink resource for a PKS-provisioned Kubernetes cluster or a namespace within a cluster, you must ensure that the Enable Sink Resources checkbox is selected in the PKS tile. Selecting this checkbox enables clusters and namespaces to send logs to sinks.

For more information, see the Logging section of the PKS installation topic for your IaaS:

CLI Requirements

To create and manage sink resources, you must install the Kubernetes CLI, kubectl.

Alternately, to manage ClusterSink resources, you can use the PKS CLI v1.3 or later.

For installation instructions, see Installing the Kubernetes CLI and Installing the PKS CLI.

Create Sinks

You can create sinks for clusters and namespaces. A namespace sink filters logs by namespace within a cluster.

Note: Sinks created in PKS only support TCP connections. UDP connections are not currently supported.

ClusterSink Resources

To create and manage ClusterSink resources, you can use either the PKS CLI, pks,
or the Kubernetes CLI, kubectl.

If you use the PKS CLI, you must use PKS CLI v1.3 or later.

Create ClusterSink Resource with the PKS CLI

To create and apply a 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.

For example:

$ pks create-sink my-cluster syslog-tls://example.com:12345

If you do not specify a name, the command creates a sink resource in the cluster that shares the same name as the cluster.

To provide a name for the 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 sink you wish 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.

For example:

$ pks create-sink my-cluster --name second-sink syslog-tls://example.org:54321

Specifying a name is useful if you need to manage multiple sink resources in your cluster.

Create a ClusterSink Resource with YAML and kubectl

To define a ClusterSink resource with YAML and kubectl, perform the following steps:

  1. Create a YAML file that specifies your log destination in the following format:

    apiVersion: apps.pivotal.io/v1beta1
    kind: ClusterSink
    metadata:
       name: YOUR-SINK
    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.
  2. Save the YAML file with an appropriate file name. For example, my-cluster-sink.yml.

  3. Apply the ClusterSink 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:

    $ kubectl apply -f my-cluster-sink.yml
    

Sink Resources

A Sink resource filters logs by namespace within a cluster.

Currently you can only use kubectl to create and manage namespace sinks.

Create a Sink Resource with YAML and kubectl

To define a Sink resource with YAML and kubectl, perform the following steps:

  1. Create a YAML file that specifies your log destination in the following format:

    apiVersion: apps.pivotal.io/v1beta1
    kind: Sink
    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 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.
  2. Save the YAML file with an appropriate file name. For example, my-namespace-sink.yml.

  3. Apply the Sink 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:

    $ kubectl apply -f my-namespace-sink.yml
    

List Sinks

To list sinks for clusters and namespaces, use the commands in the following sections.

ClusterSink Resources

Use the following command to list sinks deployed to your cluster:

pks sinks CLUSTER-NAME

Where CLUSTER-NAME corresponds to the name of your cluster.

Alternately, you can use kubectl:

kubectl get clustersinks

Sink Resources

Use the following command to list namespace sinks:

kubectl get sinks

This command lists the Sink resources deployed to a namespace.

Delete Sinks

To delete sinks for clusters and namespaces, use the commands in the following sections.

ClusterSink Resources

Use the following command to delete all sinks deployed to your cluster:

pks delete-sink CLUSTER-NAME 

Where CLUSTER-NAME is the name of your cluster.

To delete a specific sink, specify the name of the sink you wish to delete:

pks delete-sink CLUSTER-NAME --name YOUR-SINK

Where YOUR-SINK is the name of your sink.

Alternately, you can use kubectl:

kubectl delete clustersink YOUR-SINK

Where YOUR-SINK is the name of your sink.

Sink Resources

Use the following command to delete a namespace sink:

kubectl delete sink YOUR-SINK

Where YOUR-SINK is the name of your sink.

For more information on sinks in PKS, see the following topics:


Please send any feedback you have to pks-feedback@pivotal.io.

Create a pull request or raise an issue on the source for this page in GitHub