73 lines
1.7 KiB
Python
73 lines
1.7 KiB
Python
import paramiko
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect('140.44.4.11', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
|
|
|
def run(cmd):
|
|
_, o, e = c.exec_command(cmd)
|
|
return o.read().decode().strip()
|
|
|
|
test_script = """
|
|
cat << 'EOF' | kubectl apply -f -
|
|
apiVersion: apps/v1
|
|
kind: DaemonSet
|
|
metadata:
|
|
name: node-exporter
|
|
namespace: kube-system
|
|
labels:
|
|
app.kubernetes.io/name: node-exporter
|
|
spec:
|
|
selector:
|
|
matchLabels:
|
|
app.kubernetes.io/name: node-exporter
|
|
template:
|
|
metadata:
|
|
labels:
|
|
app.kubernetes.io/name: node-exporter
|
|
spec:
|
|
hostNetwork: true
|
|
hostPID: true
|
|
tolerations:
|
|
- operator: "Exists"
|
|
containers:
|
|
- name: node-exporter
|
|
image: prom/node-exporter:v1.8.2
|
|
args:
|
|
- "--path.procfs=/host/proc"
|
|
- "--path.sysfs=/host/sys"
|
|
- "--path.rootfs=/host/root"
|
|
- "--web.listen-address=0.0.0.0:9100"
|
|
ports:
|
|
- name: metrics
|
|
containerPort: 9100
|
|
hostPort: 9100
|
|
volumeMounts:
|
|
- name: proc
|
|
mountPath: /host/proc
|
|
readOnly: true
|
|
- name: sys
|
|
mountPath: /host/sys
|
|
readOnly: true
|
|
- name: root
|
|
mountPath: /host/root
|
|
readOnly: true
|
|
volumes:
|
|
- name: proc
|
|
hostPath:
|
|
path: /proc
|
|
- name: sys
|
|
hostPath:
|
|
path: /sys
|
|
- name: root
|
|
hostPath:
|
|
path: /
|
|
EOF
|
|
|
|
kubectl rollout status daemonset/node-exporter -n kube-system --timeout=60s
|
|
"""
|
|
|
|
print(run(test_script))
|
|
c.close()
|
|
|