readCoreV1NamespacedPodLog method

Future<String> readCoreV1NamespacedPodLog({
  1. String? container,
  2. bool? follow,
  3. bool? insecureSkipTLSVerifyBackend,
  4. int? limitBytes,
  5. required String name,
  6. required String namespace,
  7. bool? pretty,
  8. bool? previous,
  9. int? sinceSeconds,
  10. int? tailLines,
  11. bool? timestamps,
})

Read log of the specified Pod.

container The container for which to stream logs. Defaults to only container if there is one container in the pod.

follow Follow the log stream of the pod. Defaults to false.

insecureSkipTLSVerifyBackend InsecureSkipTLSVerifyBackend indicates that the apiserver should not confirm the validity of the serving certificate of the backend it is connecting to. This will make the HTTPS connection between the apiserver and the backend insecure. This means the apiserver cannot verify the log data it is receiving came from the real kubelet. If the kubelet is configured to verify the apiserver's TLS credentials, it does not mean the connection to the real kubelet is vulnerable to a man in the middle attack (e.g. an attacker could not intercept the actual log data coming from the real kubelet).

limitBytes If set, the number of bytes to read from the server before terminating the log output. This may not display a complete final line of logging, and may return slightly more or slightly less than the specified limit.

name Name of the Pod.

namespace Object name and auth scope, such as for teams and projects.

pretty If true, then the output is pretty printed.

previous Return previous terminated container logs. Defaults to false.

sinceSeconds A relative time in seconds before the current time from which to show logs. If this value precedes the time a pod was started, only logs since the pod start will be returned. If this value is in the future, no logs will be returned. Only one of sinceSeconds or sinceTime may be specified.

tailLines If set, the number of lines from the end of the logs to show. If not specified, logs are shown from the creation of the container or sinceSeconds or sinceTime.

timestamps If true, add an RFC3339 or RFC3339Nano timestamp at the beginning of every line of log output. Defaults to false.

Implementation

Future<String> readCoreV1NamespacedPodLog({
  String? container,
  bool? follow,
  bool? insecureSkipTLSVerifyBackend,
  int? limitBytes,
  required String name,
  required String namespace,
  bool? pretty,
  bool? previous,
  int? sinceSeconds,
  int? tailLines,
  bool? timestamps,
}) async {
  final queryStrings = <String, Object>{};
  if (container != null) {
    queryStrings['container'] = container;
  }
  if (follow != null) {
    queryStrings['follow'] = follow;
  }
  if (insecureSkipTLSVerifyBackend != null) {
    queryStrings['insecureSkipTLSVerifyBackend'] =
        insecureSkipTLSVerifyBackend;
  }
  if (limitBytes != null) {
    queryStrings['limitBytes'] = limitBytes;
  }
  if (pretty != null) {
    queryStrings['pretty'] = pretty;
  }
  if (previous != null) {
    queryStrings['previous'] = previous;
  }
  if (sinceSeconds != null) {
    queryStrings['sinceSeconds'] = sinceSeconds;
  }
  if (tailLines != null) {
    queryStrings['tailLines'] = tailLines;
  }
  if (timestamps != null) {
    queryStrings['timestamps'] = timestamps;
  }

  final query =
      queryStrings.isEmpty ? '' : '?${_joinQueryStrings(queryStrings)}';

  final result = await _getJsonString(
      '/api/v1/namespaces/$namespace/pods/$name/log$query');
  return result;
}