Prepare the template compute instance
Create /usr/local/bin/warmup. Instance specific setting goes here.
cat << EOF > /usr/local/bin/warmup
#!/bin/sh
# warmup: sync displayName data into our index and mark as healthy for load balancer
DISPLAY_NAME=`curl -H "Authorization: Bearer Oracle" -Ls http://169.254.169.254/opc/v2/instance/displayName`
cat << EOF > /opt/oracle/ords/config/ords/standalone/doc_root/index.html
<h3>$DISPLAY_NAME</h3>
<img style="max-width: 100%; height: auto; width: auto;" src="oci.jpg">
EOF
Create /etc/systemd/system/warmup.service
cat << EOF > /etc/systemd/system/warmup.service
[Unit]
After=network.target
[Service]
ExecStart=/usr/local/bin/warmup
[Install]
WantedBy=default.target
EOF
Setup warmup as service
systemctl start warmup
systemctl enable warmup
systemctl status warmup
Reboot the instance and ensure everything comes up. If okay, then Create Custom Image from this instance, ords-as-v1
Create instance-config-ords-as-v1.json, fix compartmentId, ssh_authorized_keys, imageId
cat << EOF > instance-config-ords-as-v1.json
{
"instanceType": "compute",
"launchDetails": {
"compartmentId": "ocid1.compartment.oc1..aaaaaaaarocn3npultgruh5iwghhvor6s3kairokq4mil5bp52va6qkk7x6a",
"createVnicDetails": {
},
"metadata": {
"ssh_authorized_keys": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDuPoZBbXjC/5ojt+ECoIj5KGmLHWPPreWcjkp/1metOBgRv8f6W7w615+kRcrrdtyB5Tk6MzIs6CmF8RZ1BkkSankhHG62aKkqXn7T9VDenvEHaJpJqQRkhkYzJKyYqL+04O942gSgv8Kpw1IpFWvznfelf30xaxQzcLa0tMjYvOmqTmeAndEM3E1ZVMcEq3r3OlTTjCyfBPsdRPV2hFClvQziueRrUF61lhLotPUkCKxc6Iie+OpqW5hhU8vypFT0MAB6hoTH7EO7BGmQWInQlO3Pt4m7q9dNSee731TzRceDFa5cC/uigeAFgjEY8lwM5CFrcgMW3n3B3BpfumQv PC@PCLAPPY"
},
"shape": "VM.Standard.E3.Flex",
"shapeConfig": {
"memoryInGBs": 16.0,
"ocpus": 1.0
},
"sourceDetails": {
"bootVolumeSizeInGBs": null,
"imageId": "ocid1.image.oc1.ca-toronto-1.aaaaaaaabpzh6hlkg7jrdmm4eghhzhb3pwbk7pevvkn2cxqm3pk7s46fjn5q",
"sourceType": "image"
}
}
}
EOF
Instance Pool Setup
Create instance configuration via OCI
oci compute-management instance-configuration create --instance-details file://instance-config-ords-as-v1.json --compartment-id ocid1.compartment.oc1..aaaaaaaarocn3npultgruh5iwghhvor6s3kairokq4mil5bp52va6qkk7x6a --display-name instance-config-ords-as-v1
# Get instance configuration details sample in JSON
oci compute-management instance-configuration create --generate-param-json-input instance-details
# Get instance configuration details
oci compute-management instance-configuration get --instance-configuration-id ocid1.instanceconfiguration.oc1.ca-toronto-1.aaaaaaaaxljbut4sn5hwqybubuarqr2lb5omshiog27bta4dcyvtydldetaa
From Instance Configurations, create Instance Pool, assign Load Balancer and create Autoscaling Configuration
Stress Test
We can run stress-ng on one instance, bring the CPU to 100% and wait to see auto scaling bring up a new instance within the Instance Pool.
No comments:
Post a Comment