kubernetes.core.k8s_log – Fetch logs from Kubernetes resources¶
Note
This plugin is part of the kubernetes.core collection (version 1.2.1).
To install it use: ansible-galaxy collection install kubernetes.core
.
To use it in a playbook, specify: kubernetes.core.k8s_log
.
New in version 0.10.0: of kubernetes.core
Synopsis¶
Use the OpenShift Python client to perform read operations on K8s log endpoints.
Authenticate using either a config file, certificates, password or token.
Supports check mode.
Analogous to kubectl logs or oc logs
Note
This module has a corresponding action plugin.
Requirements¶
The below requirements are needed on the host that executes this module.
python >= 2.7
openshift >= 0.6
PyYAML >= 3.11
Parameters¶
Notes¶
Note
The OpenShift Python client wraps the K8s Python client, providing full access to all of the APIS and models available on both platforms. For API version details and additional information visit https://github.com/openshift/openshift-restclient-python
To avoid SSL certificate validation errors when
validate_certs
is True, the full certificate chain for the API server must be provided viaca_cert
or in the kubeconfig file.
Examples¶
- name: Get a log from a Pod
kubernetes.core.k8s_log:
name: example-1
namespace: testing
register: log
# This will get the log from the first Pod found matching the selector
- name: Log a Pod matching a label selector
kubernetes.core.k8s_log:
namespace: testing
label_selectors:
- app=example
register: log
# This will get the log from a single Pod managed by this Deployment
- name: Get a log from a Deployment
kubernetes.core.k8s_log:
api_version: apps/v1
kind: Deployment
namespace: testing
name: example
register: log
# This will get the log from a single Pod managed by this DeploymentConfig
- name: Get a log from a DeploymentConfig
kubernetes.core.k8s_log:
api_version: apps.openshift.io/v1
kind: DeploymentConfig
namespace: testing
name: example
register: log
Return Values¶
Common return values are documented here, the following are the fields unique to this module:
Key | Returned | Description |
---|---|---|
log
string
|
success |
The text log of the object
|
log_lines
list
/ elements=string
|
success |
The log of the object, split on newlines
|
Authors¶
Fabian von Feilitzsch (@fabianvf)