adds coturn node register script
This commit is contained in:
parent
f6db936e8c
commit
faaa2d98fc
|
|
@ -0,0 +1,10 @@
|
||||||
|
FROM python:3
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY k8s/coturn-dns/requirements.txt requirements.txt
|
||||||
|
RUN pip3 install -r requirements.txt
|
||||||
|
|
||||||
|
COPY k8s/coturn-dns/ .
|
||||||
|
|
||||||
|
CMD [ "python3", "register-nodes.py"]
|
||||||
|
|
@ -0,0 +1,38 @@
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
import boto3
|
||||||
|
import time
|
||||||
|
|
||||||
|
HOSTED_ZONE="Z00156242SK162FEXDPVF"
|
||||||
|
CLUSTER_ID="29062"
|
||||||
|
POOL_ID="49934"
|
||||||
|
TOKEN={"Authorization": "Bearer a821bb97039cbd8b259e19ef9f7ea7a4e295a7399e00709fc27cad2b1f3742f4"}
|
||||||
|
|
||||||
|
while(True):
|
||||||
|
r = requests.get("https://api.linode.com/v4/lke/clusters/"+CLUSTER_ID+"/pools/"+POOL_ID, headers=TOKEN)
|
||||||
|
|
||||||
|
ips=[]
|
||||||
|
|
||||||
|
for node in r.json()['nodes']:
|
||||||
|
ip = requests.get("https://api.linode.com/v4/linode/instances/"+str(node['instance_id'])+"/ips", headers=TOKEN)
|
||||||
|
#print(ip.json())
|
||||||
|
ips.append({'Value': ip.json()['ipv4']['public'][0]['address']})
|
||||||
|
|
||||||
|
print("Node IPs: "+str(ips))
|
||||||
|
client = boto3.client('route53')
|
||||||
|
response = client.change_resource_record_sets(
|
||||||
|
HostedZoneId=HOSTED_ZONE,
|
||||||
|
ChangeBatch= {
|
||||||
|
'Comment': 'COTURN NODES',
|
||||||
|
'Changes': [
|
||||||
|
{
|
||||||
|
'Action': 'UPSERT',
|
||||||
|
'ResourceRecordSet': {
|
||||||
|
'Name': 'coturn.staging.video.jamkazam.com',
|
||||||
|
'Type': 'A',
|
||||||
|
'TTL': 300,
|
||||||
|
'ResourceRecords': ips
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
})
|
||||||
|
time.sleep(60)
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
boto3
|
||||||
|
requests
|
||||||
Loading…
Reference in New Issue