Excellent software and practical tutorials
Amazon Lightsail Free VPS Application Tutorial for Three Months
Lightsail It is an easy-to-useVirtual Private Servers(VPS), which provides simple management of cloud resources such as containers at a predictable low price. Create a website or application in just a few clicks. Automatically configure networking, access, and security environments. Quickly create custom websites and use preconfigured applications such as WordPress, Magento, Prestashop and Joomla, you can build and personalize your blog, e-commerce or personal website in just a few clicks.
Try Lightsail for free for 3 months, for a limited time.Amazon Lightsail is extending its free tier for customers to include three months of free use of select bundles.
Amazon Lightsail. It is currently used AWS The easiest way to get your applications running on your own virtual server in minutes. Today, we added the possibility to deploy container-based workloads on Amazon Lightsail. You can now deploy your container images to the cloud with the same simplicity and bundled pricing that Amazon Lightsail offers for your virtual servers.
Try Lightsail for free
Before trying Lightsail for free, you must first have an Amazon Cloud account. Click the link below to apply for an Amazon Cloud account.
For specific application steps, please refer to:Amazon Free Cloud Server Account Application Process
Amazon Lightsail AWS is an easy-to-use cloud service that provides you with everything you need to deploy an application or website for a cost-effective, easy-to-understand monthly plan. It is ideal for deploying simple workloads, websites, or getting started with AWS. Lightsail Customers include developers, small businesses, or startups who want to quickly get started with the cloud and AWS. You can always adopt a broad range of AWS services later as you become more familiar with the AWS Cloud.
Lightsail In the background Amazon Elastic Compute Cloud (EC2),Amazon Relational Database Service (RDS),Application Load Balancer and other AWS services. It provides the levels of security, reliability, and scalability that you expect from AWS.
- Deploy to Lightsail You canSix operating systems(4 Linux Release,FreeBSD or Windows), seven applications (e.g. WordPress,Drupal,Joomla,Plesk…) and seven types of stacks (e.g. Node.js,Lamp,GitLab,Django…). However Docker What about containers?
- From now on,Amazon Lightsail Provide developers with an easy way to deploy their containers to the cloud. You only need to provide a Docker image and we will automatically containerize it for you.Amazon Lightsail It provides you with an HTTPS endpoint that can serve applications running in cloud containers. It automatically sets up a load-balanced TLS endpoints and handles TLS certificates. It automatically replaces unresponsive containers for you and assigns a DNS name, maintain the old version until the new version is running smoothly and ready to go live, etc.
Let's go through the simple Python Let's deploy a web application as a container to see how it works. Assuming you have installed AWS Command Line Interface (CLI) and Docker. Python is not required, it will only be installed in the container.
I first used Flask simple application frameworkCreate a Python REST API. Any programming language and framework that can run inside a container will work. I chose Python and Flask because they are simple and concise.
You can safely copy/paste the following commands:
I then create a Dockerfile that contains the steps and information needed to build a container image:
# create a Dockerfile echo ' FROM python:3 ADD helloworld.py / RUN pip install flask RUN pip install flask_restful EXPOSE 8080 CMD [ "python", "./helloworld.py"] ' > Dockerfile
Now I can build my container:
docker build -t lightsail-hello-world
The build command outputs many lines as it builds the container, eventually ending with the following message (the actual ID will be different):
Successfully built 7848e055edff Successfully tagged lightsail-hello-world:latest
I tested it by starting the container on my laptop:
docker run -it --rm -p 8080:8080 lightsail-hello-world
and connect your browser to localhost:8080
When I am happy with the application, I push the container to Docker Hub.
docker tag lightsail-hello-world sebsto/lightsail-hello-world docker login docker push sebsto/lightsail-hello-world
Now, I'm already Docker Hub Now that the container is ready, let's create it. Lightsail Container services.
I pointed my browser to Amazon Lightsail ConsoleI can see that the container services are deployed and I can manage them. To create a new service, I click Create container service(Create container service):
Lightsail container console
On the next screen, I select the container size to use based on the vCPU and memory available to the application. I also select the number of container instances I want to run in parallel for reasons of high availability or scalability. I can change the number of container instances or their capabilities (vCPU and RAM) at any time without interrupting service. Both parameters affect the price AWS charges each month. The price is displayed on the screen and adjusts dynamically, as shown in the following video.
A little further down the screen, I choose to skip the deployment for now. I name the service ("hello-world”). I click Create container service(Create container service).
After creating the service, I click Create your first deployment(Create first deployment) to create a deployment. A deployment is a specific container image and version combination that I want to deploy on the service I just created.
I chose a name for my image and then used the format user/ :tag
Provide the address of the image. This is also where I can enter environment variables, port mappings, or launch commands.
My container provides network services on port TCP 8080, so I added that port to the deployment configuration.Open PortsConfiguration specifies which ports and protocols are open to other systems in the container network. Other containers or VMs can only open ports if the ports are explicitly configured in the console orpublic
In my Dockerfile
None of these ports are exposed to the public internet.
But in this example, I also want Lightsail to route traffic from the public internet into this container. So I’ll make this container a hello-world The endpoint for the service is added. The endpoint is automatically configured for TLS, there are no certificates to install or manage.
I can add up to 10 containers for a single deployment. When I’m ready, I click Save and deploy(Save and deploy).
After some time, my deployment is active and I can test the endpoint.
The endpoint DNS address is in the upper right corner of the console. I can configure my own DNS domain name if I have to.
I open another tab in my browser and point it to the https endpoint URL:
When I have to deploy a new version, I again use the console to modify the deployment. I have spared you the details of modifying the application code, building, and pushing the new version container.
sebsto/lightsail-hello-world:v2
A second container image version is available. I return to Amazon Lightsail Console, click Deployments(Deploy), then click Modify your Deployments(Modify Deployment). I enter the full name of the new version of the container image, including the tag, and click Save and Deploy(Save and deploy).
After some time, the new version is deployed and automatically activated.
I open a new tab in my browser and point it to Amazon Lightsail The endpoint URI is provided in the upper right corner of the console. I observe that the JSON version is different. It now has a value of
2
ofVersion
property.
When I have a problem with my deployment, Amazon Lightsail The last deployment is automatically kept active to avoid any service interruption. I can also manually activate the previous deployment version to undo any unwanted changes.
I just came from Docker Hub I deployed my first container image. I can also use AWS Command Line Interface (CLI) Manage my services and deploy local container images from my laptop. To push container images directly from your laptop to my Amazon Lightsail Container service, I mustInstall LightSail controller plugin. (TL;DR curl
,cp
and chmod
All are suitable for your use here, I also maintain a DockerFile to use the CLI inside the container).
To create, list, or delete a container service, I type:
aws lightsail create-container-service --service-name myservice --power nano --scale 1 aws lightsail get-container-services { "containerServices": [{ "containerServiceName": "myservice", "arn": "arn:aws:lightsail:us-west-2:012345678901:ContainerService/1b50c121-eac7-4ee2-9078-425b0665b3d7", "createdAt": "2020-07-31T09:36:48.226999998Z", "location": { "availabilityZone": "all", "regionName": "us-west-2" }, "resourceType": "ContainerService", "power": "nano", "powerId": "", "state": "READY", "scale": 1, "privateDomainName": "", "isDisabled": false, "roleArn": "" }] } aws lightsail delete-container-service --service myservice
I can also deploy container images directly from my laptop using the CLI.Install lightsailctl
.
# Build the new version of my image (v3) docker build -t sebsto/lightsail-hello-world:v3 . # Push the new image. aws lightsail push-container-image --service-name hello-world --label hello-world --image sebsto/lightsail-hello-world:v3
After a while, I see the following output:
Image "sebsto/lightsail-hello-world:v3" registered. Refer to this image as ":hello-world.hello-world.1" in deployments.
I created one lc.json
file to hold the deployment configuration details. It matches the options I see on the console. I reported the previous commandimage
The name given in the attribute:
{ "serviceName": "hello-world", "containers": { "hello-world": { "image": ":hello-world.hello-world.1", "ports": { "8080": "HTTP" } } }, "publicEndpoint": { "containerName": "hello-world", "containerPort": 8080 } }
Finally, I create a new service version with the following command:
aws lightsail create-container-service-deployment --cli-input-json file://lc.json
I can query the deployment status using the following command
aws lightsail get-container-services ... "nextDeployment": { "version": 4, "state": "ACTIVATING", "containers": { "hello-world": { "image": ":hello-world.hello-world.1", "command": [], "environment": {}, "ports": { "8080": "HTTP" } } }, ...
After a while, the status changes to ACTIVE
(Active), I can test my endpoint.
curl https://hello-world.nxxxxxxxxxxx.lightsail.ec2.aws.dev/ {"message": "Hello Flask API World!", "version": 3}
If you plan to later deploy the container to Amazon ECS or Amazon Elastic Kubernetes Service, no changes are required. You can pull container images from the repository just like using Amazon Lightsail Same.
You can provide Amazon Lightsail Deploy the container to all AWS regions in Lightsail As of today,US East (Ohio),US East (N. Virginia),US West (Oregon),Asia Pacific (Mumbai),Asia Pacific (Seoul),Asia Pacific (Singapore),Asia Pacific (Sydney),Asia Pacific (Tokyo),Canada (Central),Europe (Frankfurt),Europe (Ireland),Europe (London)andEurope (Paris)Regional offer.
As usual, use Amazon Lightsail hour,PricingEasy to understand and predictable.Amazon Lightsail Containers have a fixed price per container per month, depending on the size of the container (the vCPU/memory combination you use). You pay a pro-rated amount for the time you keep the service running. The monthly price is the maximum price you would be charged if the service were running 24/7. Prices are the same in all AWS regions. Prices range from $7 per month for a Nano container (512MB of memory and 0.25 vCPU) to $160 per month for an X-Large container (8GB of memory and 4 vCPU cores). This price includes not only the container itself, but also the load balancer, DNS, and a generous data transfer layer. Details and prices for other AWS regions are at Lightsail pricing pagesuperior.
Amazon account, fromAmazon Lightsail offers a three-month free trial period from the date of application. Hurry up and apply for registrationLightsail Free TrialBar,I can't wait to find out what you'll be doing in Amazon Lightsail What solutions are built and deployed on containers!
Reference original text: clickhereView original article