2026-09-12 12:41
Status:
Tags: IBM IBM Application Development using Microservices and Serverless IBM Full Stack Software Developer Professional Certificate Serverless Micro-Services System Infrastructure Back End DevOps Web Development
ADMS - Module 4 - Create and Deploy Microservices using Serverless
==Create and Deploy Microservices using Serverless
-
IBM Cloud Engine:
- Challenges of self-hosting Microservices
- Generally, once you have all of your microservices created and tested in a local environment, you then need to go ahead and try to move on with them into production and what not
- This means that you have to actually correctly set them up and get them ready for production, which can be difficult on a self-hosted environment as you have to include all of the proper assets, dependencies, and all other such items correctly
- You then need to actually manage the real life infrastructure, like choosing your databases and their storage, choosing the correct operating system and making the images/cluster management, and so on and so forth
- You have to manage your own dynamic scaling and your own dynamic scaling capabilities
- You will need to deploy a large number of microservices that communicate with other microservices, this can be a large attack surface that you would need to defend against on your own terms and means, which can be difficult
- You will need to have your own logging and monitoring set up that you need to create in order to run the microservices correctly
- Example imaging you have a python-based microservice and what not, in order to provide the required service, it cannot be done directly, it requires a web server interface, or entry point to call the microservice
- For a python based services there are TWO
- Web Server Gateway Interface (WSGI) which is the web standard for web servers made in python, it supports synchronous calls only
- Asynchronous Server Gateway Interface (ASGI) is basically the same thing, except for the fact that it actually handles async calls
- Both of these given services would need to be running on a given form of infrastructure in order to be able to handle and communicate the server responsibilities for your microservices, like a laptop, desktop, server, etc
- IBM Cloud Code Engine is basically a serverless architecture system that allows for developers to focus solely on actual code development without having to worry about underlying data or infrastructure
- You just “push code and it is done”
- It runs your workloads like microservices batch jobs or whatever the fuck you generally want
- You primarily use it for three reasons
- Deploy an application
- push source code, have it get built, and then have it get deployed
- Creating and running batch jobs like performing data analytics or something like that
- Can generally even do all three
- Challenges of self-hosting Microservices
-
Project, Application, Build, and Jobs:
- Project in IBM Cloud Engine is a grouping that basically contains different entities like build, app, job, certificate and all of that good stuff
- It provides a namespace for the entities so you can generally separate them from other projects, it can do things like separate out different components of your application
- It also gives you access control and auditing of resources for the entire instance of your application
- Application- your code will run inside of the application, and it can do things like listen to HTTP requests and send out REST APIs as well
- they are also able to communicate with
WebSocketas well, which is a communication based protocol based on TCP, which is basically the standard connect interface for ports and live sockets - Code Engine manages it’s own cluster sort of, and is basically able to scale your application up or down by running more instances of your app code basically
- Build or an image build is basically a mechanism in which you can build an image from your source code, this is then created into a container image, which is in essence the container made with the image you built, and has all of the dependencies for your source code and what not, configuration and everything
- This is generally done through a standard
dockerfileor a cloud nativebuildpackwhere they have their own version of image and container creation - You can then deploy out this image into your cloud application and then have it exist as well, an application
- Job is a one time execution of your build or application, basically the time that a function runs one
- It is similar to an application but think of it more so as something that exists for your function to run once
- It can have one or more instance like an Application, it can be things like data processing, machine learning training jobs, reporting jobs, and all of that good stuff
-
Building Container Images for Microservices:
-
What is a Container?
- A container is a small standalone all-inclusive executable software unit. Basically, think of it sort of like a miniature VM that runs on the operating system level, sharing the hardware alongside the main operating system
- Generally, they are all inclusive and come with all of the needed code and dependencies that are used to run the code
- They are great because once set up they can basically run anywhere alongside basically every single operating system
- Because they are generally specialized and do not need to emulate any hardware, they are very small in size, fast, and portable, which makes the great for microservices architecture
-
Docker
- This is a popular platform for building and running containers, this is done using something called
dockerfile, and is generally the main platform and format that people use - It has a large amount of third party tools and even an interact Cli that allows for someone to be able to create containers, outline their shape, and run them/share them as well
- It is also, for the sake of this module, the main container technology used in the IBM cloud
- This is a popular platform for building and running containers, this is done using something called
-
Building a Docker container image
-
You need to make sure you have all of your source code all good and working, and all of the dependencies for it as well
-
If you want to deploy it, what you would have to do is set up a container that your code can run in, which is done via the
dockerfile -
The
Dockerfileis basically like a blueprint or instructions for how to construct the container image of your source code, and how it should run, this image is a file that contains all of the needed assets, like source code, libraries, and dependencies, they are also only read only -
Think of a container image sort of like the class definition of a function, and then a container of that container image sort of like a class instance, thats actually a really good way to think about it
-
-
The first line of a docker file would have a
FROM <baseimage>which is basically going to decide a base image for you to pull from, generally from a main docker hub repository or something like that, but then you give instructions on how to modify it -
You then need to copy over all of your source code into the image, which done via the
copy /path/to/your/app/code, also usingENVin order to set whatever environment variables you might want, like the port to listen out on -
You can then run inner command line things inside of the container using the
RUNcommand, so something like instantiating the entire server or running it, or installing dependencies, basically all of that jazz -
You can then have the
CMDcommand at the end, you can only have one and this basically actually runs the command you specify inside of the host terminal -
You can actually also push all of these images after building them, basically sort of just a repo that can hold and host a bunch of different images
-
This can be great for the storage, sharing, or reusing of different container images that you might create, these are generally called registries and what not
-
-
-
Deploying and Running Applications:
- Inside of the deployment for this serverless architecture, or this cloud engine or whatever the fuck that they are using, there is basically two different ways of deploying your application, and they are both basically the same
- Either you actually build the image yourself with the docker file and the whole command and everything that you want, and then upload it to a registry so they can pull it and run it
- Or you can just hand over the source code you made to them, with a given docker file that dictates how to build the code, and then they build and push and run the code for you, essentially the same thing, the only difference is who actually builds the bitch
- The Cloud Engine has a CLI and UI interface that basically lets you do this through there, which is just one of those little convenience life things
- Although do let it be known that after the application is deployed on the IBM Cloud Code Engine, then they will provide you with the URL that you want to give you the access for either a homepage or your API endpoint
- To create an application in the console, you give a name, specify out a the way in which you want the code to run, the image reference/registry access if you want to do it that way
- You can then also test out more stuff like the port and what not
- You can then run and test your application through their fucky wucky UI, this is just a shill thing for their thing, its pretty intuitive, just look up the CLI commands in the documentation if you ever decided to use this over amazon for some fuck as reason
==Summary
- Self-hosted microservices can be very complex and challenging
- IBM Cloud Code Engine is a fully managed platform that takes care of all the hard deployment work, allowing developers to focus on their code
- IBM Cloud Code Engine has three main use cases: 1) deploy applications, 2) build and deploy applications, and 3) run jobs
- A project is a grouping of Code Engine entities such as applications, jobs, and builds
- An application runs your code to serve HTTP requests or to create WebSocket sessions
- A build is a process to create a container image from your source code
- A job runs one or more instances of your executable code
- A container is a standalone executable software unit packaged with all its dependencies
- Docker is a popular container building and running platform
- You can compose a Dockerfile to instruct the Docker platform to build a container image
- After the container image is built, it can be pushed to the container registry and then be pulled by its image name
- You can create a Cloud Engine application either from a pushed container image or a source code repository
- As per your preference, you can choose to use the IBM Cloud Console or IBM Cloud CLI to perform the application deployment tasks
==Glossary
| Term | Definition |
|---|---|
| ASGI | Asynchronous Server Gateway Interface - web server interface to call microservice asynchronously |
| Buildpack | Contains executables to perform tasks such as inspecting source code, creating a build plan, or executing the build plan to produce a container image |
| CaaS | Containers as a Service |
| Code Engine | Abstracts the operational burden of building, deploying, and managing workloads so that developers can focus on code development |
| Container | A standalone, all-inclusive, and executable unit of software packaged with libraries, dependencies, and runtimes |
| Container image | An immutable file containing all the application assets like source code, libraries, and dependencies necessary for an application to run |
| Docker | A software platform for building and running applications as containers |
| Dockerfile | A text file that includes all the commands to build a docker container image |
| IBM Cloud CLI | IBM Cloud command line interface |
| IBM Cloud Console | A well-designed web portal for end users to conveniently manage their IBM cloud services, including the Code Engine |
| Job | Runs executable code one time and exits |
| PaaS | Platform as a Service |
| Repository | A group of related container images |
| TCP | Transmission Control Protocol |
| TLS | Transport Layer Service |
| WebSocket | A communication protocol based on Transmission Control Protocol |
| WSGI | Web Server Gateway Interface - Python standard for communication between web servers and web applications or microservices |





