Files
SnarfCode/scripts/apply_36.py

66 lines
1.3 KiB
Python

import paramiko
import sys
sys.stdout.reconfigure(encoding='utf-8')
key_path = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("140.44.4.11", username="root", key_filename=key_path, timeout=5)
cmd = """
k3s kubectl -n dns delete svc pihole-dns-vip pihole-web-vip --wait=false
sleep 2
cat << 'EOF' | k3s kubectl apply -f -
apiVersion: v1
kind: Service
metadata:
name: pihole-dns-vip
namespace: dns
annotations:
metallb.universe.tf/loadBalancerIPs: 140.44.4.36
metallb.universe.tf/allow-shared-ip: "aerodrome-dns-key"
labels:
app: pihole
spec:
type: LoadBalancer
selector:
app: pihole
ports:
- name: dns-udp
port: 53
targetPort: 53
protocol: UDP
- name: dns-tcp
port: 53
targetPort: 53
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: pihole-web-vip
namespace: dns
annotations:
metallb.universe.tf/loadBalancerIPs: 140.44.4.36
metallb.universe.tf/allow-shared-ip: "aerodrome-dns-key"
labels:
app: pihole
spec:
type: LoadBalancer
selector:
app: pihole
ports:
- name: web-http
port: 80
targetPort: 80
protocol: TCP
EOF
sleep 3
k3s kubectl -n dns get svc
"""
stdin, stdout, stderr = c.exec_command(cmd)
print(stdout.read().decode('utf-8'))
c.close()