Build coturn-dns and use it

This commit is contained in:
Seth Call 2026-01-06 20:45:02 -06:00
parent 4f7ca7edeb
commit cbc2e4f147
3 changed files with 51 additions and 19 deletions

View File

@ -169,4 +169,23 @@ pipelines:
- pipe: atlassian/kubectl-run:1.1.2
variables:
KUBE_CONFIG: $KUBE_CONFIG_STG
KUBECTL_COMMAND: '-n coturn-dns rollout status -w deployment/coturn-dns'
KUBECTL_COMMAND: '-n coturn-dns rollout status -w deployment/coturn-dns'
custom:
build-and-push-coturn-dns:
- variables:
- name: VERSION
default: "1.0.10"
- step:
name: Build and Push coturn-dns
image: google/cloud-sdk:alpine
script:
# Authenticating with the service account key file
- echo $GCLOUD_API_KEYFILE | base64 -d > ./gcloud-api-key.json
- gcloud auth activate-service-account --key-file gcloud-api-key.json
- gcloud config set project $GCLOUD_PROJECT
- cat ./gcloud-api-key.json | docker login -u _json_key --password-stdin https://gcr.io
# Build and Push Docker image
- docker build . --file docker/coturn-dns/Dockerfile --tag "gcr.io/${GCLOUD_PROJECT}/coturn-dns:${VERSION}"
- docker push "gcr.io/${GCLOUD_PROJECT}/coturn-dns:${VERSION}"
services:
- docker

View File

@ -18,33 +18,46 @@ def validIPAddress(IP: str) -> str:
return "Invalid"
while(True):
ips=[]
ips_set = set()
pods = v1.list_namespaced_pod(namespace="coturn")
for i in pods.items:
if not i.spec.node_name:
continue
node_status = v1.read_node(name=i.spec.node_name)
for adr in node_status.status.addresses:
# only collect IPv4 addresses, because we are only updating A records here
if adr.type=="ExternalIP" and validIPAddress(adr.address) == "IPv4":
ips.append({'Value': adr.address})
ips_set.add(adr.address)
ips = [{'Value': ip} for ip in sorted(list(ips_set))]
print("Node IPs: "+str(ips))
if not ips:
print("No IPs found to update. Sleeping.")
time.sleep(60)
continue
client = boto3.client('route53')
response = client.change_resource_record_sets(
HostedZoneId=HOSTED_ZONE,
ChangeBatch= {
'Comment': 'COTURN NODES',
'Changes': [
{
'Action': 'UPSERT',
'ResourceRecordSet': {
'Name': COTURN_DOMAIN_NAME,
'Type': 'A',
'TTL': 300,
'ResourceRecords': ips
}
}]
})
try:
response = client.change_resource_record_sets(
HostedZoneId=HOSTED_ZONE,
ChangeBatch= {
'Comment': 'COTURN NODES',
'Changes': [
{
'Action': 'UPSERT',
'ResourceRecordSet': {
'Name': COTURN_DOMAIN_NAME,
'Type': 'A',
'TTL': 300,
'ResourceRecords': ips
}
}]
})
print("Successfully updated Route53: " + str(response['ChangeInfo']['Id']))
except Exception as e:
print(f"Error updating Route53: {e}")
time.sleep(60)

View File

@ -1,3 +1,3 @@
domain: "staging.video.jamkazam.com"
# The docker image tag for coturn-dns in GCR
coturn_dns_image_tag: 1.0.9
coturn_dns_image_tag: 1.0.10