Build coturn-dns and use it
This commit is contained in:
parent
4f7ca7edeb
commit
cbc2e4f147
|
|
@ -169,4 +169,23 @@ pipelines:
|
||||||
- pipe: atlassian/kubectl-run:1.1.2
|
- pipe: atlassian/kubectl-run:1.1.2
|
||||||
variables:
|
variables:
|
||||||
KUBE_CONFIG: $KUBE_CONFIG_STG
|
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
|
||||||
|
|
|
||||||
|
|
@ -18,33 +18,46 @@ def validIPAddress(IP: str) -> str:
|
||||||
return "Invalid"
|
return "Invalid"
|
||||||
|
|
||||||
while(True):
|
while(True):
|
||||||
ips=[]
|
ips_set = set()
|
||||||
|
|
||||||
pods = v1.list_namespaced_pod(namespace="coturn")
|
pods = v1.list_namespaced_pod(namespace="coturn")
|
||||||
|
|
||||||
for i in pods.items:
|
for i in pods.items:
|
||||||
|
if not i.spec.node_name:
|
||||||
|
continue
|
||||||
node_status = v1.read_node(name=i.spec.node_name)
|
node_status = v1.read_node(name=i.spec.node_name)
|
||||||
for adr in node_status.status.addresses:
|
for adr in node_status.status.addresses:
|
||||||
# only collect IPv4 addresses, because we are only updating A records here
|
# only collect IPv4 addresses, because we are only updating A records here
|
||||||
if adr.type=="ExternalIP" and validIPAddress(adr.address) == "IPv4":
|
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))
|
print("Node IPs: "+str(ips))
|
||||||
|
|
||||||
|
if not ips:
|
||||||
|
print("No IPs found to update. Sleeping.")
|
||||||
|
time.sleep(60)
|
||||||
|
continue
|
||||||
|
|
||||||
client = boto3.client('route53')
|
client = boto3.client('route53')
|
||||||
response = client.change_resource_record_sets(
|
try:
|
||||||
HostedZoneId=HOSTED_ZONE,
|
response = client.change_resource_record_sets(
|
||||||
ChangeBatch= {
|
HostedZoneId=HOSTED_ZONE,
|
||||||
'Comment': 'COTURN NODES',
|
ChangeBatch= {
|
||||||
'Changes': [
|
'Comment': 'COTURN NODES',
|
||||||
{
|
'Changes': [
|
||||||
'Action': 'UPSERT',
|
{
|
||||||
'ResourceRecordSet': {
|
'Action': 'UPSERT',
|
||||||
'Name': COTURN_DOMAIN_NAME,
|
'ResourceRecordSet': {
|
||||||
'Type': 'A',
|
'Name': COTURN_DOMAIN_NAME,
|
||||||
'TTL': 300,
|
'Type': 'A',
|
||||||
'ResourceRecords': ips
|
'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)
|
time.sleep(60)
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
domain: "staging.video.jamkazam.com"
|
domain: "staging.video.jamkazam.com"
|
||||||
# The docker image tag for coturn-dns in GCR
|
# The docker image tag for coturn-dns in GCR
|
||||||
coturn_dns_image_tag: 1.0.9
|
coturn_dns_image_tag: 1.0.10
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue