Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workspaces UI #38

Merged
merged 9 commits into from
Aug 26, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -1243,4 +1243,4 @@ Outputs:
PersistentVolumeId:
Description: Id of the new persistent volume created for AI Unlimited
Value: !Ref AiUnlimitedVolume
Condition: USENEWPERSISTENTVOLUME
Condition: USENEWPERSISTENTVOLUME
153 changes: 148 additions & 5 deletions deployments/aws/templates/ai-unlimited/ai-unlimited-with-nlb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Metadata:
- AiUnlimitedSchedulerVersion
- AiUnlimitedSchedulerHttpPort
- AiUnlimitedSchedulerGrpcPort
- AiUnlimitedUiPort
- AiUnlimitedUiVersion
- Label:
default: Persistent volume
Parameters:
Expand Down Expand Up @@ -125,6 +127,14 @@ Parameters:
MinValue: 0
MaxValue: 65535

AiUnlimitedUiPort:
Description: port to access the AI Unlimited UI.
Type: Number
Default: 80
ConstraintDescription: must be a valid ununsed port between 0 and 65535.
MinValue: 0
MaxValue: 65535

AiUnlimitedGrpcPort:
Description: port to access the AI Unlimited API.
Type: Number
Expand All @@ -136,7 +146,12 @@ Parameters:
AiUnlimitedVersion:
Description: Which version of AI Unlimited to deploy, uses container version tags, defaults to "latest"
Type: String
Default: v0.2.23
Default: v0.3.0

AiUnlimitedUiVersion:
Description: Which version of AI Unlimited UI to deploy, uses container version tags, defaults to "latest"
Type: String
Default: v0.0.3

AiUnlimitedSchedulerVersion:
Description: Which version of AI Unlimited Scheduler to deploy, uses container version tags, defaults to "latest"
Expand Down Expand Up @@ -364,6 +379,8 @@ Conditions:
- !Ref IamRoleName
- ""

PortIsNotEighty: !Not [!Equals [!Ref AiUnlimitedUiPort, 80]]

Resources:
AiUnlimitedVolume:
DeletionPolicy: !Ref PersistentVolumeDeletionPolicy
Expand Down Expand Up @@ -405,9 +422,12 @@ Resources:
- prepare_new_storage
- !Ref AWS::NoValue
- bind_storage
- create_init_api_key
- mount_storage
- install_docker
- configure_workspaces_ui_service
- configure_ai_unlimited_service
- start_workspaces_ui_service
- start_ai_unlimited_service
- configure_ai_unlimited_scheduler_service
- start_ai_unlimited_scheduler_service
Expand All @@ -423,6 +443,12 @@ Resources:
command: !Sub |
#!/bin/bash -xe
/usr/sbin/mkfs -t ext4 /dev/nvme1n1
create_init_api_key:
commands:
run_command:
command: !Sub |
#!/bin/bash -xe
echo "TD_VCD_INIT_API_KEY=$(LC_ALL=C tr -dc A-Za-z0-9 </dev/urandom | head -c 64)" > /tmp/init_api_key.txt
bind_storage:
commands:
fstab:
Expand Down Expand Up @@ -461,6 +487,49 @@ Resources:
docker:
enabled: "true"
ensureRunning: "true"
configure_workspaces_ui_service:
files:
/usr/lib/systemd/system/workspaces-ui.service:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be ai-unlimited-ui.service instead workspaces-ui.service

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was changing the ui name from "workspaces-ui" to "ai-unlimited-ui" and version on my next commit. waiting for the image to be ready and UI fix to test and push them all at once.

content: !Sub |
[Unit]
Description=workspaces-ui

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be AI Unlimited UI instead of workspaces-ui

After=docker.service
Requires=docker.service
StartLimitInterval=200
StartLimitBurst=10

[Service]
TimeoutStartSec=0
Restart=always
RestartSec=2

ExecStartPre=-/bin/bash -c '/usr/bin/docker network create -d bridge ai_unlimited || true'
ExecStartPre=-/usr/bin/mkdir -p /etc/td/workspaces-ui
EnvironmentFile=/tmp/init_api_key.txt
ExecStartPre=-/usr/bin/docker stop %n || true
ExecStartPre=-/usr/bin/docker rm %n || true
ExecStartPre=/usr/bin/docker pull teradata/ai-unlimited-workspaces-ui:${ AiUnlimitedUiVersion }
ExecStart=/usr/bin/docker run \
-e accept_license=Y \
-e PLATFORM=aws \
-e TD_VCD_UI_PORT=${ AiUnlimitedUiPort } \
-e TD_VCD_API_PORT=3282 \
-e TD_VCD_AUTH_PORT=3000 \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the HTTP and gRPC Port are a variables, these ports should be too.

-e TD_VCD_AUTH_PORT=${ AiUnlimitedHttpPort } \
-e TD_VCD_API_PORT=${ AiUnlimitedGrpcPort }  \

-e TD_VCD_INIT_API_KEY \
-p ${ AiUnlimitedUiPort }:80 \
--network ai_unlimited \
--rm --name %n teradata/ai-unlimited-workspaces-ui:${ AiUnlimitedUiVersion }
[Install]
WantedBy=multi-user.target
group: root
mode: "000400"
owner: root
start_workspaces_ui_service:
services:
systemd:
workspaces-ui:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, should be ai-unlimited-ui instead of workspaces-ui

enabled: "true"
ensureRunning: "true"
configure_ai_unlimited_service:
files:
/usr/lib/systemd/system/ai-unlimited.service:
Expand All @@ -477,13 +546,14 @@ Resources:
Restart=always
RestartSec=2
ExecStartPre=-/usr/bin/mkdir -p /etc/td/ai-unlimited
ExecStartPre=-/usr/bin/docker exec %n stop || true
EnvironmentFile=/tmp/init_api_key.txt
ExecStartPre=-/usr/bin/docker stop %n || true
ExecStartPre=-/usr/bin/docker rm %n || true
ExecStartPre=-/bin/bash -c '/usr/bin/docker network create -d bridge ai_unlimited || true'
ExecStartPre=/usr/bin/docker pull teradata/ai-unlimited-workspaces:${ AiUnlimitedVersion }
ExecStart=/usr/bin/docker run \
-e accept_license=Y \
-e PLATFORM=aws \
-e TD_VCD_INIT_API_KEY \
-v /etc/td/ai-unlimited:/etc/td \
-p ${ AiUnlimitedHttpPort }:3000 \
-p ${ AiUnlimitedGrpcPort }:3282 \
Expand Down Expand Up @@ -516,7 +586,7 @@ Resources:
TimeoutStartSec=0
Restart=always
RestartSec=2
ExecStartPre=-/usr/bin/docker exec %n stop || true
ExecStartPre=-/usr/bin/docker stop %n || true
ExecStartPre=-/usr/bin/docker rm %n || true
ExecStartPre=/usr/bin/docker pull teradata/ai-unlimited-scheduler:latest
ExecStart=/usr/bin/docker run \
Expand Down Expand Up @@ -625,6 +695,21 @@ Resources:
- HASSECURITYGROUP
- !Ref SecurityGroup
- !Ref AWS::NoValue
- FromPort: !Ref AiUnlimitedUiPort
IpProtocol: tcp
ToPort: !Ref AiUnlimitedUiPort
CidrIp: !If
- HASCIDR
- !Ref AccessCIDR
- !Ref AWS::NoValue
SourcePrefixListId: !If
- HASPREFIXLIST
- !Ref PrefixList
- !Ref AWS::NoValue
SourceSecurityGroupId: !If
- HASSECURITYGROUP
- !Ref SecurityGroup
- !Ref AWS::NoValue
Condition: HASCIDRORPREFIXLISTORSECGROUP

LoadBalancerSchedulerSecurityGroup:
Expand Down Expand Up @@ -692,6 +777,16 @@ Resources:
Port: !Ref AiUnlimitedGrpcPort
Protocol: TCP

AiUnlimitedUIListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- Type: forward
TargetGroupArn: !Ref AiUnlimitedUITargetGroup
LoadBalancerArn: !Ref LoadBalancer
Port: !Ref AiUnlimitedUiPort
Protocol: TCP

AiUnlimitedSchedulerHTTPListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
Expand Down Expand Up @@ -746,6 +841,40 @@ Resources:
Port: !Ref AiUnlimitedHttpPort
VpcId: !Ref Vpc

AiUnlimitedUITargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
HealthCheckIntervalSeconds: 30
HealthCheckProtocol: HTTP
HealthCheckTimeoutSeconds: 15
Name: !Join
- '-'
- - !Select
- 4
- !Split
- '-'
- !Select
- 2
- !Split
- /
- !Ref AWS::StackId
- td-aiu
- ui
- api
Port: !Ref AiUnlimitedUiPort
Protocol: TCP
TargetGroupAttributes:
- Key: stickiness.enabled
Value: true
- Key: stickiness.type
Value: source_ip
- Key: deregistration_delay.timeout_seconds
Value: "20"
Targets:
- Id: !Ref AiUnlimitedServer
Port: !Ref AiUnlimitedUiPort
VpcId: !Ref Vpc

AiUnlimitedGRPCTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Expand Down Expand Up @@ -866,6 +995,10 @@ Resources:
FromPort: !Ref AiUnlimitedGrpcPort
ToPort: !Ref AiUnlimitedGrpcPort
SourceSecurityGroupId: !GetAtt LoadBalancerAiUnlimitedSecurityGroup.GroupId
- IpProtocol: tcp
FromPort: !Ref AiUnlimitedUiPort
ToPort: !Ref AiUnlimitedUiPort
SourceSecurityGroupId: !GetAtt LoadBalancerAiUnlimitedSecurityGroup.GroupId
- !If
- HASSECURITYGROUP
- IpProtocol: tcp
Expand All @@ -880,6 +1013,13 @@ Resources:
ToPort: !Ref AiUnlimitedGrpcPort
SourceSecurityGroupId: !Ref SecurityGroup
- !Ref AWS::NoValue
- !If
- HASSECURITYGROUP
- IpProtocol: tcp
FromPort: !Ref AiUnlimitedUiPort
ToPort: !Ref AiUnlimitedUiPort
SourceSecurityGroupId: !Ref SecurityGroup
- !Ref AWS::NoValue

AiUnlimitedSchedulerSecurityGroup:
Type: AWS::EC2::SecurityGroup
Expand Down Expand Up @@ -1148,7 +1288,10 @@ Outputs:

AiUnlimitedUiAccess:
Description: Loadbalancer access endpoint for AI Unlimited UI Access
Value: !Sub http://${ LoadBalancer.DNSName }:${ AiUnlimitedHttpPort }
Value: !If
- PortIsNotEighty
- !Sub "http://${ LoadBalancer.DNSName }:${ AiUnlimitedUiPort }/landing"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UI have a health check too. Use "http://${ LoadBalancer.DNSName }:${ AiUnlimitedUiPort }/healtcheck.

There is a typo, that I will change in a PR this week, should be /healthcheck 😄

- !Sub "http://${ LoadBalancer.DNSName }"

AiUnlimitedApiAccess:
Description: Loadbalancer access endpoint for AI Unlimited API Access
Expand Down
Loading
Loading