HEX
Server: LiteSpeed
System: Linux cp4.porkbun.com 5.14.0-611.20.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jan 14 06:35:04 EST 2026 x86_64
User: vxblllubpkafjsjw (1110)
PHP: 8.4.19
Disabled: NONE
Upload Files
File: //usr/lib/python3.9/site-packages/sos/report/plugins/__pycache__/microk8s.cpython-39.opt-1.pyc
a

�>�h��@s6ddlZddlZddlmZmZGdd�dee�ZdS)�N)�Plugin�UbuntuPluginc@s4eZdZdZdZdZdZdZdZdd�Z	dd	�Z
d
S)�Microk8saThe Microk8s plugin collects the current status of the microk8s
    snap on a Ubuntu machine.

    It will collect logs from journald related to the snap.microk8s
    units as well as run microk8s commands to retrieve the configuration,
    status, version and loaded plugins.
    zThe lightweight Kubernetes�microk8s)�	container)rc
s�jdd�gd�}��ddg����fdd�|D��d}|�d	�}��d
|�d��d}�j|dd
���|�d�|�d�|�d�g�d}|�d	�}|�d�}|�d�}|�d|�d|�d|�d�}	ddd�ddgdd�ddd�g}
ztt|ddd��P}|��}t�d |�}
|
D]&}|
�d!|��d"|��dgd#���qWd�n1�sT0YWn<t	�y�}z"��
d$|�d%|���WYd}~n
d}~00|
D]h}|	}|�d&g�}|D]}|�d'|��}�q�t�
|�d(��}|�d)�}�j|�d'|��d*|��d
��q�dS)+Nzsnap.microk8s.*)Zunits)zaddons repo listZconfigzctr plugins lszctr plugins ls -d�status�versionz!/var/snap/microk8s/current/args/*�4/var/snap/microk8s/current/credentials/client.configcsg|]}�j�d|���qS)� )�microk8s_cmd)�.0Zsubcmd��self��?/usr/lib/python3.9/site-packages/sos/report/plugins/microk8s.py�
<listcomp>2sz"Microk8s.setup.<locals>.<listcomp>z1/var/snap/microk8s/current/var/kubernetes/backendz/cluster.crtzopenssl x509 -in z -noout -datesZls_microk8s_dqlite_dir)Zsuggest_filenamez
/info.yamlz
/cluster.yamlz/failure-domainz!/snap/microk8s/current/bin/dqlitez/cluster.keyz -c z -k z -s file://z k8sz.cluster)�query�suggested_file_suffixz-f jsonz.cluster_-f_json)r�optsrz.leader�rzutf-8)�encodingz#Address:\s*(\d+\.\d+\.\d+\.\d+:\d+)z
.describe z
.describe_)rrrzFailed to parse z: rr
rrZ
microk8s_sql_)Zadd_journalZ
add_copy_specZadd_cmd_outputZadd_dir_listing�open�read�re�findall�append�	ExceptionZ	add_alert�get�json�dumps)rZmicrok8s_subcmdsZcrt_dirZ
dqlite_crtZdb_pathZ
dqlite_binZcert�keyZserversZ
dqlite_cmdZqueriesZcluster_definitionZclusterZnodesZnode�eZquery_entryZsql_cmdr�optrZfile_suffixrr
r�setup"s���

���


������0,
�zMicrok8s.setupcCs@d}|�|j|d�gd�}dd�|��d�}|�d|d�dS)	Nz((certificate-authority-data:|token:)\s.*z\1 "**********")zcertificate-authority-datazclient-certificate-datazclient-key-data�tokenz(^\s*(�|z
)\s*:\s*)(.*)r	z\1*********)Zdo_cmd_output_subr�joinZdo_path_regex_sub)rZrsubZprotect_keysZ	key_regexrrr�postprocs�zMicrok8s.postprocN)�__name__�
__module__�__qualname__�__doc__Z
short_descZplugin_nameZprofilesZpackagesrr#r'rrrrrs]r)rrZsos.report.pluginsrrrrrrr�<module>s