Learning Library

← Back to Library

Robust Cloud API Architecture with IaC

Key Points

  • Source control (typically Git) serves as the central artifact repository and infrastructure‑as‑code hub, storing server config files, API definition files, and pipeline scripts for the entire system.
  • Defining all environment specifications (development, test, production) and pipeline tasks in the repository enables versioned, repeatable builds and easy reconstruction of any failed component.
  • A developer pushes an updated API definition (e.g., “api 4”) to the repo, triggering a webhook that starts an automated pipeline to promote the API through the defined environments.
  • The pipeline’s first task checks the Kubernetes cluster for the required test environment and creates it (with specified CPU, memory, and storage) if it does not already exist, ensuring consistent progression toward production.

Full Transcript

# Robust Cloud API Architecture with IaC **Source:** [https://www.youtube.com/watch?v=sKfep-UmZeM](https://www.youtube.com/watch?v=sKfep-UmZeM) **Duration:** 00:10:30 ## Summary - Source control (typically Git) serves as the central artifact repository and infrastructure‑as‑code hub, storing server config files, API definition files, and pipeline scripts for the entire system. - Defining all environment specifications (development, test, production) and pipeline tasks in the repository enables versioned, repeatable builds and easy reconstruction of any failed component. - A developer pushes an updated API definition (e.g., “api 4”) to the repo, triggering a webhook that starts an automated pipeline to promote the API through the defined environments. - The pipeline’s first task checks the Kubernetes cluster for the required test environment and creates it (with specified CPU, memory, and storage) if it does not already exist, ensuring consistent progression toward production. ## Sections - [00:00:00](https://www.youtube.com/watch?v=sKfep-UmZeM&t=0s) **Source Control Foundations for Cloud APIs** - Whitney Lee explains how to use a Git‑based artifact repository to store configuration files, API definitions, and pipeline scripts, treating the infrastructure as code to enable visibility and collaboration when building a cloud‑based API solution. - [00:03:46](https://www.youtube.com/watch?v=sKfep-UmZeM&t=226s) **Automated API Promotion Pipeline** - Describes a webhook‑triggered CI/CD pipeline that creates a test Kubernetes environment, deploys the new API, runs tests, and prepares it for production promotion. ## Full Transcript
0:00what is an efficient yet robust way to 0:03architect an api solution in the cloud 0:06my name is whitney lee i'm on the cloud 0:08team here at ibm 0:11let's talk about the foundation of our 0:14system 0:15for me that's source control source 0:17control 0:18is also can be called an artifact 0:20repository 0:21and the most popular version is git 0:25so what do we want to store in our 0:27repository 0:29we want to store all the artifacts 0:30related to our 0:32what will eventually be our final system 0:35so 0:35a good example would be server 0:37configuration files 0:40so for example we'd want to store 0:43a file for our development environment 0:48one for our test environment this is our 0:52server configuration file 0:55and one for our production environment 1:04that's a great start what else do we 1:06want to store in our artifact repository 1:09well if we're building an api solution 1:12we're going to want to store all of the 1:13artifacts related to our apis 1:15so our api definition files 1:20so we have a definition file for api 1:241. for api 2 1:30and for api 76 1:34just kidding api 3. 1:39okay so i also know 1:42in my final system i want to have 1:45pipeline builds 1:46so now's a good time to define the tasks 1:48in the 1:49in the pipeline file for that 1:52so we'll build task 1 2:01task 2 2:05and then we're also going to want our 2:07pipeline 2:08run file to be defined here in our 2:11source control 2:17so source control is great it's also 2:20called 2:20infrastructure as code because we're 2:22defining the infrastructure of our 2:24system 2:25before that system is even built this 2:27provides 2:28visibility into what's happening and 2:30great collaboration 2:31in the team in addition if any of the 2:34pieces of the system 2:36fail they can be rebuilt very easily 2:38from our definition files 2:42so let's build out our cluster a 2:45kubernetes cluster just like any 2:47ours is going to have 2:50we'll have physical resources so we'll 2:53have memory 2:54and cpu for our nodes 2:58and then we'll need physical disk space 3:00for storage 3:02too 3:06so that's the physical resources behind 3:08our cluster 3:12and then let's think about where we want 3:15to start let's start with our 3:17development environment 3:19so we'll build the development 3:21environment in our cluster 3:23and that's going to be built according 3:26to the definition the specifications 3:28we've already defined in our repository 3:32so let's say we have a developer 3:35and our developer is working on a new 3:38api 3:39and that new api very cleverly is going 3:43to be called api 4. 3:45and the developer is using our dev 3:46environment to work that out 3:50so let's say a developer feels like api 3:524 3:53is ready to go what we want is a 3:56pipeline build 3:57that's going to take that that api 4 4:01and promote it all the way up to 4:03production 4:04so that pipeline bill is going to need 4:06to get triggered 4:08and so we'll in this case we'll trigger 4:10it by having our developer 4:12when the api is ready to push that 4:14definition file 4:16into our source control 4:20so that's going to trigger a web hook 4:23which is going to trigger 4:24our pipeline build so let's say 4:28task one of our pipeline build maybe 4:30that task 4:31job is to check our kubernetes 4:34environment 4:35look for an environment called 4:38called test and if there's not one there 4:40to build one according to the specs 4:43defined in our 4:44test server configuration file so 4:47our task is gonna our task one is gonna 4:50trigger 4:51a build of a test environment 4:56then let's say task two what it does is 4:58whatever api triggered the web hook 5:01that triggered the pipeline build it's 5:04gonna put that api into the test 5:06environment and run a suite of tests 5:08on that api so in that way this one 5:12pipeline build that 5:13was defined here has promoted our api 5:17from dev environment to the test 5:19environment 5:23great now our api is ready to go to 5:25production 5:26or not we can do more to make sure 5:30it is ready before it goes all the way 5:32to our production site 5:34so what let's say we have our production 5:37environments built in our cluster 5:41and that production environment already 5:43has our apis one two and three in it 5:48what we can do is also build a canary 5:52environment 5:54so we'll define our canary environment 5:56in our repo 5:59and we want our canary environment to be 6:02an exact 6:02replica of our production environment 6:10so our canary environment also then has 6:13a apis one two and three 6:14already running so what we can do here 6:18let's consider our end user 6:22our end user wants to make a call 6:25into our cluster that call is going to 6:28go through 6:29a gateway to get into the cluster 6:35and then that gateway is going to send 6:37the traffic 6:38to a load balancer 6:42the load balancer is going to 6:46divide where the traffic goes between 6:48prod and canary 6:50so for a canary environment it might 6:52route 6:53say one percent of traffic to the canary 6:55environment 6:57it could be any number you choose but 6:58it's going to be a small percentage and 7:00then the rest of the traffic will go 7:01into production 7:04so in this way the api 4 7:07once it's in the canary environment it 7:10experiences some real-world 7:12web traffic to make sure it is ready 7:15before it's promoted 7:16all the way into production 7:21something else that i think would be 7:23important to build into our api solution 7:25would be logging and metrics collecting 7:31so we can collect logging and metrics 7:33from all of the environments that we've 7:35built 7:36we can and we will and we should 7:39and with those logging in metrics we can 7:44go one step further and use tools like 7:47prometheus 7:49or grafana 7:52to put those metrics in a ui in a human 7:56readable form 7:57with graphs and manipulated 8:00in a way that best serves the company's 8:02interests 8:05so the players that are interested in 8:06the system would be 8:08a business analyst for example that 8:10person 8:12would definitely want especially be 8:14interested in the graphics and the 8:15insights 8:16that the logging in the metrics provide 8:19an operations manager 8:22that person would be interested in our 8:25and metrics but also interested in the 8:27infrastructure as code and what's going 8:29on 8:29technically and then we might have an 8:32architect too 8:34who's keeping an eye on the source 8:36control and on the system as a whole 8:40so what's worth mentioning here is this 8:43is all built on a kubernetes cluster 8:48but the tools like the pipeline build 8:52the load balancer the logging and 8:54metrics collecting 8:55and displayed those are all going to be 8:58third-party tools that are installed and 9:01maintained 9:02separately from the kubernetes cluster 9:03itself 9:05the other choice is to use a robust 9:08platform like 9:09openshift that's built on top of 9:11kubernetes 9:14and with openshift pipeline tools 9:17load balancers logging in metrics and 9:20wall based access 9:21control are all built into the platform 9:24and maintained 9:25with the platform in addition to a host 9:28of other benefits 9:30so in conclusion this solution 9:33is beneficial because it uses 9:35infrastructure as code 9:37which provides collaboration visibility 9:40and a source of truth if any piece of 9:43the system should go down 9:45we also have rapid api promotion from 9:48dev 9:48all the way up through production and 9:50you have control over that you don't 9:52have to use pipelines 9:53for every step of the way but you 9:55definitely can and not only is it rapid 9:58but it is very low risk because it's 10:00tested in a test environment 10:01and tested again as a canary deployment 10:04and then finally we have the logging in 10:06metrics collection and display 10:08thank you if you have questions please 10:11drop us a line below 10:13if you want to see more videos like this 10:15in the future please like 10:16and subscribe and don't forget you can 10:19grow your skills and earn a badge with 10:21ibm 10:22cloud labs which are free browser-based 10:25interactive kubernetes labs