<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: t.v.vignesh</title>
    <description>The latest articles on DEV Community by t.v.vignesh (@tvvignesh).</description>
    <link>https://dev.to/tvvignesh</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F202479%2F865ebacc-5c40-4eb3-8ea6-7be6e19257f2.jpg</url>
      <title>DEV Community: t.v.vignesh</title>
      <link>https://dev.to/tvvignesh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tvvignesh"/>
    <language>en</language>
    <item>
      <title>Infrastructure Engineering - Deployment Strategies</title>
      <dc:creator>t.v.vignesh</dc:creator>
      <pubDate>Sat, 13 Feb 2021 09:38:52 +0000</pubDate>
      <link>https://dev.to/timecampus/infrastructure-deployment-strategies-2h0k</link>
      <guid>https://dev.to/timecampus/infrastructure-deployment-strategies-2h0k</guid>
      <description>&lt;p&gt;&lt;em&gt;This blog is a part of a series on Kubernetes and its ecosystem where we will dive deep into the infrastructure one piece at a time&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now that we have answered all the basic questions in relation to Kubernetes and have also had a look at the various architectural patterns you can opt for, the next step to this puzzle is to figure out the deployment strategy which is of the right fit for you. And that is what we are going to discuss in this blog post.&lt;/p&gt;

&lt;p&gt;You might have seen people talk about Private Cloud, Public Cloud, On-Premise and Hybrid Cloud deployments. But with Kubernetes, a lot of these differences fade away since most of the differences between all these environments are typically not related to Kubernetes at all but to the infrastructure supporting Kubernetes deployments. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Public Cloud&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In a public cloud deployment, the cloud provider takes care of almost everything around your Kubernetes cluster giving you a near-unlimited scalability, lowest maintenance and lower costs since you are going to share all the resources with other tenants as well making it a great option for all businesses which does not host any highly confidential data and can manage on a shared infrastructure. &lt;/p&gt;

&lt;p&gt;Ultimately, the public cloud is all about maintaining a shared security model with both the cloud provider and the users playing significant roles. You can read about &lt;a href="https://cloud.google.com/blog/products/containers-kubernetes/exploring-container-security-the-shared-responsibility-model-in-gke-container-security-shared-responsibility-model-gke"&gt;GKE Shared Security Model&lt;/a&gt; or &lt;a href="https://services.google.com/fh/files/misc/gcp_pci_srm__apr_2019.pdf"&gt;GCP Shared Responsibility Model&lt;/a&gt;, &lt;a href="https://aws.amazon.com/compliance/shared-responsibility-model/"&gt;AWS Shared Responsibility Model&lt;/a&gt; and &lt;a href="https://docs.microsoft.com/en-us/azure/security/fundamentals/shared-responsibility"&gt;Azure Shared Responsibility Model&lt;/a&gt; to learn more about what different cloud providers say about the responsibilities they take and those that are offloaded to you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Private Cloud&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While there are soft-partitions typically in place in a public cloud, sharing of resources between multiple tenants have often been viewed as a security concern by some organizations along with some sectors like banking/finance, health and military having strict regulations in place on where and how you host data along with the various data localization laws that govern a respective region.&lt;/p&gt;

&lt;p&gt;In such cases, a private cloud can actually help you have more isolation and control of all resources (hardware and software) while allowing the cloud provider manage the resources for your tenant. It is like your own private data center in the cloud. While this adds a significant overhead to the pricing and also adds extra pieces to be managed by dedicated DevOps team, it can sometimes be worth it rather than having to manage everything on premise while also catering to workload elasticity.&lt;/p&gt;

&lt;p&gt;Not all cloud providers do support private cloud (remember that Virtual Private Cloud and Private Cloud are &lt;a href="https://www.secure-24.com/blog/virtual-private-cloud-vs-private-cloud-whats-the-difference/"&gt;quite different&lt;/a&gt;) with not many providers supporting private cloud without a VPC.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Virtual Private Cloud&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the typical go to option when you want to opt in for private cloud. A Virtual Private Cloud (VPC) is nothing but running a private cloud in the public cloud infrastructure with multiple tenants separated by different subnets, private IPs and peering essentially simulating a dedicated environment (while the underlying infrastructure is still shared).&lt;/p&gt;

&lt;p&gt;This would fit most of the use cases requiring compliance with all the regulations in place isolating the data transmission, processing and storage all in a private environment while being able to maintain the same cost as using a public cloud.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;On-Premise&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While there has been a huge cloud adoption over the years, on-premise systems still have its own place. They are being used to maintain the highest level of isolation, bolstering its own infrastructure, network, security, DNS and so on allowing the business to have complete control on all the infrastructure being used, reduce recurring costs, establish use-case specific network optimizations and even function in case of global failures from the other cloud providers making it a good bet if you are working with huge amounts of compute and data over long periods of time and have the resources to have on-premise datacenters in place. But do note that on-premise is &lt;a href="https://platform9.com/blog/kubernetes-on-premises-why-and-how/"&gt;not without challenges&lt;/a&gt; and its always better to have a cloud strategy to fall back to while trying to do it all on-premise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hybrid Deployments&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While there are a lot of deployment strategies in place, hybrid cloud stands out amongst others since it allows you to use multiple deployment models or cloud providers depending on your needs and make the complete system work together as one (for eg. you can use an on-premise deployment for regulated industries and a public cloud deployment for others, or you can use GCP in US and INDIA while you opt for AWS, Azure or Alibaba in CHINA).&lt;/p&gt;

&lt;p&gt;This is made possible by the very nature of Kubernetes being a standard portable platform across cloud providers, ability to manage infrastructure as code, ability to setup networking between them whenever needed with the help of &lt;a href="https://linkerd.io/2/features/multicluster/"&gt;multi-cluster service meshes&lt;/a&gt; and also due to the ability to orchestrate the deployments using &lt;a href="https://github.com/kubernetes-sigs/kubefed"&gt;Kubefed&lt;/a&gt; and &lt;a href="https://crossplane.io/"&gt;Crossplane&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;There has recently been new proprietary options in the market to enable such hybrid cloud deployments with services like &lt;a href="https://cloud.google.com/anthos"&gt;Google Anthos&lt;/a&gt;, &lt;a href="https://azure.microsoft.com/en-in/overview/azure-stack/"&gt;Azure Stack&lt;/a&gt; and &lt;a href="https://aws.amazon.com/outposts/"&gt;AWS Outposts&lt;/a&gt; in place for enterprises who is looking to start with this journey with most of the heavy lifting done by the cloud providers. But do watch out for the pricing since it can end up to be costly over long periods.&lt;/p&gt;

&lt;p&gt;Hybrid Deployments has to be done with great care since it adds a lot of complexity to the infrastructure you may have to manage also keeping in mind the pricing (eg. cross-region network calls may end up costing quite a lot)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Workload Portability&lt;/strong&gt;  &lt;/p&gt;

&lt;p&gt;Thinking of hybrid deployments brings us to workload portability because unless you have a portable workload, it may not be feasible to have hybrid deployment strategies. This also means that you have to reduce the dependence on proprietary services from your cloud providers as much as possible since you might have to end up doing cross-cloud or cross-region API calls otherwise if your other cloud provider or on-premise systems don't support it. Or sometimes you might even have to build out abstractions within your applications since not all the same service across multiple cloud providers does not often have the same APIs adding more complexity especially with hybrid architectures or you might have to use something like &lt;a href="https://crossplane.io/"&gt;Crossplane&lt;/a&gt; to enable this for you to some extent.&lt;/p&gt;

&lt;p&gt;But if all of these are not an issue, then Containers and an orchestration system like Kubernetes can always take care of workload portability especially with &lt;a href="https://opencontainers.org/"&gt;OCI&lt;/a&gt; now in place for containers and &lt;a href="https://github.com/container-storage-interface/spec/blob/master/spec.md"&gt;CSI&lt;/a&gt;, &lt;a href="https://github.com/containernetworking/cni"&gt;CNI&lt;/a&gt;, &lt;a href="https://github.com/kubernetes/cri-api"&gt;CRI&lt;/a&gt;, &lt;a href="https://smi-spec.io/"&gt;SMI&lt;/a&gt; for storage, networking, runtime and service mesh respectively creating a healthy standards based ecosystem for all thereby enabling workload portability without lock-in since for a workload to be truly portable, all the underlying resources should be portable without any/very limited changes.&lt;/p&gt;

&lt;p&gt;While Kubernetes constructs like Pod and Deployment don't lock you in to a respective provider, you have to take into account the underlying infrastructure from the cloud provider (storage, compute and networking) which can sometime impact the way in which K8 runs its workloads across providers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Best Practices&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are in your way to opt for a cloud provider, do make sure that you check out their best practices documentation which can really help you in understanding the ways in which you should organize and manage your resources for reaping the maximum benefit with future in mind. For instance, &lt;a href="https://cloud.google.com/docs/enterprise/best-practices-for-enterprise-organizations"&gt;use this&lt;/a&gt; for Google Cloud, &lt;a href="https://d1.awsstatic.com/whitepapers/architecture/AWS_Well-Architected_Framework.pdf"&gt;this&lt;/a&gt; for AWS, &lt;a href="https://docs.microsoft.com/en-us/azure/architecture/"&gt;this&lt;/a&gt; for Azure, this for &lt;a href="https://www.vmware.com/pdf/vmware-validated-design-20-reference-architecture-guide.pdf"&gt;VMWare&lt;/a&gt; and there are lot of case studies which can help as well as you start your journey.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bare Metal, Virtual Machines, Containers and Serverless&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The next question which you might have is, what is the best unit of deployment for me? Should I go bare metal or virtual machines or containers or serverless? This depends completely on your use case and the degree of abstraction and control you want over your infrastructure.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bare Metal: Bare metal servers are servers which does not have any &lt;a href="https://en.wikipedia.org/wiki/Hypervisor"&gt;hypervisor&lt;/a&gt; on top thereby making it a single tenant and has the complete control of storage, networking and compute is available to you. You get the benefit of more storage, faster deploy times, faster speeds, efficient container deployments since you don't have to deal with VMs in this case which can be a significant overhead over your host operating systems. But this also means that you have to end up opting for dedicated instances from your cloud provider which can cost you more since you have to account for the elasticity you may need in advance and also the fact that you have to manage everything by yourself (your cloud provider completely gets out of the picture once you have the bare metal server in place) which can add operational overhead if you don't have the right team and tools in place.&lt;/li&gt;
&lt;li&gt;Virtual Machines: Virtual machines have made multitenancy possible thereby reducing the costs for the users since hardware gets shared depending on the needs. The other thing about virtual machines is the ability to scale up/down whenever needed by adding more VMs and load balancing between them but this is not as elegant as containers or serverless since you also end up having an operating system to take care of in every VM that you add which can lead to operational nightmare during patches/upgrades, add to huge licensing costs in case you are going for a proprietary OS and at the same time is not efficient as containers since containers share the underlying compute, storage and networking better giving you the ability to spin up more containers for the same cost you are spending on your VM.&lt;/li&gt;
&lt;li&gt;Containers: Containers have literally brought about a revolution in DevSecOps and infrastructure and people started realizing the huge benefits with Docker pioneering the movement and making it accessible for all (even though it was in use before). Containers make it possible to isolate your workloads without having to worry about managing new virtual machines, have a consistent/reproducible deployment across multiple environments,  allow for efficient scalability, drastically reduce on the licensing costs and adding an orchestration system like Kubernetes or Swarm makes it even more powerful giving us the ability to treat containers like cattle and cater to all kinds of failures you can have in a typical distributed system. And this has truly changed the way we operate today but does require a significant tooling to be in place for it to work properly.&lt;/li&gt;
&lt;li&gt;Serverless: Serverless has long been seen as the final step to elastic computing. And while it seems ambitious, it cannot completely replace containers, virtual machines or bare metal deployments. It is to be seen as a great complement to them all considering the significant limitations they have. 
When you want to go for serverless you have to take into account a few things like &lt;a href="https://dev.toCold/Warm/Hot%20start"&gt;Cold/Warm/Hot start&lt;/a&gt; of serverless functions since that decides the latency of the response you are going to get, keep in mind that every cloud provider has a timeout for execution like &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/gettingstarted-limits.html"&gt;15 minutes in case of AWS&lt;/a&gt;, &lt;a href="https://cloud.google.com/functions/docs/concepts/exec#timeout"&gt;9 minutes in case of Google Cloud functions&lt;/a&gt;, &lt;a href="https://docs.microsoft.com/en-us/azure/azure-functions/functions-scale"&gt;10 minutes for Azure Functions&lt;/a&gt; and so on making it unsuitable for long running jobs. In addition to this, there are also restrictions to the programming languages you can use in your serverless function (unless you are opting in for a container based deployment which essentially makes it a container based deployment 🤔) . If you still want to use serverless for long running jobs, you might have to reach out to them for dedicated/premium plans or maintain your own serverless infrastructure within your Kubernetes cluster using something like &lt;a href="https://knative.dev/"&gt;KNative&lt;/a&gt;, &lt;a href="https://www.openfaas.com/"&gt;OpenFaas&lt;/a&gt;, &lt;a href="https://kubeless.io/"&gt;Kubeless&lt;/a&gt; or similar and setting your own limits.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As you might already realize from what we have discussed, the best way forward is to choose the right strategy for your use case rather and embracing hybrid strategies so that you can keep all the factors including performance, scalability, security, usability and costs in check.&lt;/p&gt;

&lt;p&gt;Looking for help or engineering consultancy? Feel free to reach out to me &lt;a href="https://twitter.com/techahoy"&gt;@techahoy&lt;/a&gt; or via &lt;a href="https://www.linkedin.com/in/tvvignesh"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And if this helped, do share this across with your friends, do hang around and follow us for more like this every week. See you all soon.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>cloud</category>
      <category>cloudnative</category>
      <category>docker</category>
    </item>
    <item>
      <title>Infrastructure Engineering - Architecting your Cloud Native Infrastructure</title>
      <dc:creator>t.v.vignesh</dc:creator>
      <pubDate>Sat, 13 Feb 2021 07:55:04 +0000</pubDate>
      <link>https://dev.to/timecampus/architecting-your-cloud-native-infrastructure-3npk</link>
      <guid>https://dev.to/timecampus/architecting-your-cloud-native-infrastructure-3npk</guid>
      <description>&lt;p&gt;&lt;em&gt;This blog is a part of a series on Kubernetes and its ecosystem where we will dive deep into the infrastructure one piece at a time&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the last blog, we explored the various questions one might have when starting off with Kubernetes and its ecosystem and did our best to answer them. Now that justice has been done to clear the clouded thoughts you may have, let us now dive into the next important step in our journey with Kubernetes and the infrastructure as a whole.&lt;/p&gt;

&lt;p&gt;In this blog, we will look at the best possible way to architect your infrastructure for your use case and the various decisions you may want to take depending on your constraints.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Architecture&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Quoting from one of our &lt;a href="https://dev.to/timecampus/graphql-diving-deep-4hnm"&gt;previous blog posts&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;"Your architecture hugely revolves around your use case and you have to be very careful in getting it right and take proper consultation if needed from experts. While it is very important to get it right before you start, mistakes can happen, and with a lot of research happening these days, you can often find any revolution happen any day which can make your old way of thinking obsolete.&lt;/p&gt;

&lt;p&gt;That is why, I would highly recommend you to &lt;strong&gt;Architect for Change&lt;/strong&gt; and make your architecture as &lt;strong&gt;Modular&lt;/strong&gt; as possible so that you have the flexibility to do incremental changes in the future if needed."&lt;/p&gt;

&lt;p&gt;Let's see how we would realize our goal of architecting our system considering a client-server model in mind.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Entrypoint - DNS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In any typical infrastructure (cloud native or not), the request has to be first resolved by the DNS server to return the IP address of the server as appropriate. This is where organizations like &lt;a href="https://www.iana.org/"&gt;IANA&lt;/a&gt; and &lt;a href="https://www.icann.org/"&gt;ICANN&lt;/a&gt; play a major role resolving the TLDs as needed with the various &lt;a href="https://en.wikipedia.org/wiki/Regional_Internet_registry"&gt;RIRs&lt;/a&gt; (Regional Internet Registries) it has which then gets routed to the appropriate registrar (say Godaddy, Bigrock, Google Domains, Namecheap, etc.) along with organizations like &lt;a href="https://www.ietf.org/"&gt;IETF&lt;/a&gt; defining the protocols and standards for the internet to work.&lt;/p&gt;

&lt;p&gt;Setting up your DNS should be based on the availability you would require. If you require higher availability, you may want to distribute your servers across multiple regions or cloud providers depending on the level of availability you would like to achieve and you have to configure the DNS records accordingly in order to support that.&lt;/p&gt;

&lt;p&gt;If you would like to know more about IANA, I would recommend you to watch this video: &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Lk5j25nmZKY"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Or this video from Eli&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/MIgFfV-prpA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Content Delivery Network (CDN)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In some cases, you might look forward to serve the users with minimum latency as possible and also reduce the load on your servers while doing the same by distributing a major portion of the traffic to the edge. This is where CDN plays a major role.&lt;/p&gt;

&lt;p&gt;Does the client frequently request a set of static assets from the server? Are you aiming to improve the speed of delivery of content to your users while also reducing the load on your servers?&lt;/p&gt;

&lt;p&gt;In such cases, a CDN at edge with a TTL serving a set of static assets based on constraints might actually help to both reduce the latency for users and load on your servers.&lt;/p&gt;

&lt;p&gt;Is all your content dynamic? Are you fine with serving content to users with some level of latency in favor of reduced complexity? Or is your app receiving low traffic?&lt;/p&gt;

&lt;p&gt;In such cases, a CDN might not make much sense to use and you can send all the traffic directly to the Global Load Balancer. But do note that having a CDN also does have the advantage of distributing the traffic which can be helpful in the event of DDOS attacks on your server.&lt;/p&gt;

&lt;p&gt;A lot of third party providers provide CDN services which includes &lt;a href="https://www.cloudflare.com/cdn"&gt;Cloudfare CDN&lt;/a&gt;, &lt;a href="https://www.fastly.com/"&gt;Fastly&lt;/a&gt;, &lt;a href="https://www.akamai.com/uk/en/cdn/"&gt;Akamai CDN&lt;/a&gt;, &lt;a href="https://www.stackpath.com/maxcdn/"&gt;Stackpath&lt;/a&gt; but there is a high chance that your cloud provider might also offer a CDN service like  &lt;a href="https://cloud.google.com/cdn"&gt;Cloud CDN&lt;/a&gt; from GCP, &lt;a href="https://aws.amazon.com/cloudfront/"&gt;CloudFront&lt;/a&gt; from Amazon, &lt;a href="https://docs.microsoft.com/en-us/azure/cdn/"&gt;Azure CDN&lt;/a&gt; from Azure and the list goes on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zpuaPC8a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pd8pobvjny3z3nz5q33c.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zpuaPC8a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pd8pobvjny3z3nz5q33c.PNG" alt="Edge Network"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Load Balancers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If there is a request which cannot be served by your CDN, the request enters your Load Balancer. And these can be either regional with Regional IPs or global with &lt;a href="https://en.wikipedia.org/wiki/Anycast"&gt;Anycast IPs&lt;/a&gt; and in some cases, you can also use load balancers to manage internal traffic.&lt;/p&gt;

&lt;p&gt;Apart from routing and proxying the traffic to the appropriate backend service, the Load balancer can also take care of responsibilities like &lt;a href="https://en.wikipedia.org/wiki/TLS_termination_proxy"&gt;SSL Termination&lt;/a&gt;, integrating with CDN and more making it an essential part to managing network traffic.&lt;/p&gt;

&lt;p&gt;While Hardware Load Balancers do exist, Software Load Balancers have been taking the lead thus far providing greater flexibility, cost reduction and scalability. &lt;/p&gt;

&lt;p&gt;Similar to CDNs, your cloud providers should be able to provide a load balancer as well for you (such as &lt;a href="https://cloud.google.com/load-balancing"&gt;GLB&lt;/a&gt; for GCP, &lt;a href="https://aws.amazon.com/elasticloadbalancing/"&gt;ELB&lt;/a&gt; for AWS, &lt;a href="https://docs.microsoft.com/en-us/azure/load-balancer/"&gt;ALB&lt;/a&gt; for Azure, etc.) but what is more interesting is that, you can provision these load balancers directly from Kubernetes constructs. For instance, creating an ingress in GKE (aka GKE ingress) also creates a GLB for you behind the scenes to receive the traffic and other features like CDN, SSL Redirects, etc. can also be setup just by configuring your ingress as seen &lt;a href="https://cloud.google.com/kubernetes-engine/docs/how-to/ingress-features"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While you should always start small, load balancers would allow you to scale incrementally having architectures like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7l7s8EO8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mpwi1rjoyxfozj7sdfky.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7l7s8EO8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mpwi1rjoyxfozj7sdfky.PNG" alt="Load Balancing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Networking &amp;amp; Security Architecture&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The next important thing to take care of in your architecture is the networking itself. You may want to go for a private cluster if you want to increase security by moderating the inbound and outbound traffic, mask IP addresses behind &lt;a href="https://en.wikipedia.org/wiki/Network_address_translation"&gt;NATs&lt;/a&gt;, isolate networks with multiple &lt;a href="https://en.wikipedia.org/wiki/Subnetwork"&gt;subnets&lt;/a&gt; across multiple &lt;a href="https://en.wikipedia.org/wiki/Virtual_private_cloud"&gt;VPCs&lt;/a&gt; and so on leading to a controlled environment which can possibly prevent security concerns in the future.&lt;/p&gt;

&lt;p&gt;How you setup your network would typically depend on the degree of flexibility you are looking for and how you are going to achieve it. Setting up the right networking is all about reducing the attack surface as much as possible while still allowing for regular operations.&lt;/p&gt;

&lt;p&gt;Protecting your infrastructure by setting up the right network also involves setting up firewalls with the right rules and restrictions so that you allow only the traffic as allowed to/from the respective backend services both inbound and outbound.&lt;/p&gt;

&lt;p&gt;In many cases, these private clusters can be protected by setting up &lt;a href="https://en.wikipedia.org/wiki/Bastion_host"&gt;Bastion Hosts&lt;/a&gt; and tunneling through them for doing all the operations in the cluster since all you have to expose to the public network is the Bastion (aka Jump host) which is typically setup in the same network as the cluster.&lt;/p&gt;

&lt;p&gt;Some cloud providers also provide custom solutions in their approach towards &lt;a href="https://cloud.google.com/beyondcorp"&gt;Zero Trust Security&lt;/a&gt;. For instance, GCP providers its users with &lt;a href="https://cloud.google.com/iap"&gt;Identity Aware Proxy&lt;/a&gt; (IAP) which can be used instead of typical &lt;a href="https://en.wikipedia.org/wiki/Virtual_private_network"&gt;VPN&lt;/a&gt; implementations.&lt;/p&gt;

&lt;p&gt;Now, while all these may not be required when you start off your journey architecting with Kubernetes, it is good to be aware of all these so that you can incrementally adopt these as and when needed.&lt;/p&gt;

&lt;p&gt;Once all of these are taken care of, the next step to networking would be setting up the networking within the cluster itself depending on your use case.&lt;/p&gt;

&lt;p&gt;It can involve things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Setting up the service discovery within the cluster (which is handled by default by &lt;a href="https://coredns.io/"&gt;CoreDNS&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Setting up a &lt;a href="https://smi-spec.io/"&gt;service mesh&lt;/a&gt; if needed (eg. &lt;a href="https://linkerd.io/"&gt;LinkerD&lt;/a&gt;, &lt;a href="https://istio.io/"&gt;Istio&lt;/a&gt;, &lt;a href="https://www.consul.io/"&gt;Consul&lt;/a&gt;, etc.)&lt;/li&gt;
&lt;li&gt;Setting up &lt;a href="https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/"&gt;Ingress controllers&lt;/a&gt; and API Gateways (eg. &lt;a href="https://kubernetes.github.io/ingress-nginx/"&gt;Nginx&lt;/a&gt;, &lt;a href="https://www.getambassador.io/"&gt;Ambassador&lt;/a&gt;, &lt;a href="https://konghq.com/solutions/kubernetes-ingress/"&gt;Kong&lt;/a&gt;, &lt;a href="https://docs.solo.io/gloo-edge/latest/installation/ingress/"&gt;Gloo&lt;/a&gt;, etc.)&lt;/li&gt;
&lt;li&gt;Setting up network plugins using &lt;a href="https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/"&gt;CNI&lt;/a&gt; facilitating networking within the cluster.&lt;/li&gt;
&lt;li&gt;Setting up &lt;a href="https://kubernetes.io/docs/concepts/services-networking/network-policies/"&gt;Network Policies&lt;/a&gt; moderating the inter-service communication and exposing the services as needed using the various &lt;a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types"&gt;service types&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Setting up inter-service communication between various services using protocols and tools like &lt;a href="https://grpc.io/"&gt;GRPC&lt;/a&gt;, &lt;a href="https://thrift.apache.org/"&gt;Thrift&lt;/a&gt; or &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP"&gt;HTTP&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Setting up A/B testing which can be easier if you use a service mesh like &lt;a href="https://istio.io/latest/docs/concepts/traffic-management/"&gt;Istio&lt;/a&gt; or &lt;a href="https://linkerd.io/2/features/traffic-split/"&gt;Linkerd&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you would like to look at some sample implementations, I would recommend looking at &lt;a href="https://github.com/terraform-google-modules/cloud-foundation-fabric"&gt;this&lt;/a&gt; repository which helps users setup all these different networking models in GCP including &lt;a href="https://github.com/terraform-google-modules/cloud-foundation-fabric/blob/master/networking/hub-and-spoke-peering"&gt;hub and spoke via peering&lt;/a&gt;, &lt;a href="https://github.com/terraform-google-modules/cloud-foundation-fabric/blob/master/networking/hub-and-spoke-vpn"&gt;hub and spoke via VPN&lt;/a&gt;, &lt;a href="https://github.com/terraform-google-modules/cloud-foundation-fabric/blob/master/networking/onprem-google-access-dns"&gt;DNS and Google Private Access for on-premises&lt;/a&gt;, &lt;a href="https://github.com/terraform-google-modules/cloud-foundation-fabric/blob/master/networking/shared-vpc-gke"&gt;Shared VPC with GKE support&lt;/a&gt;, &lt;a href="https://github.com/terraform-google-modules/cloud-foundation-fabric/blob/master/networking/ilb-next-hop"&gt;ILB as next hop&lt;/a&gt; and so on using &lt;a href="https://www.terraform.io/"&gt;Terraform&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the interesting thing about networking in cloud is that it need not be just be limited to the cloud provider within your region but can span across multiple providers across multiple regions as needed and this is where projects like &lt;a href="https://github.com/kubernetes-sigs/kubefed"&gt;Kubefed&lt;/a&gt;, &lt;a href="https://crossplane.io/"&gt;Crossplane&lt;/a&gt; definitely does help.&lt;/p&gt;

&lt;p&gt;If you would like to explore more on some of the best practices when setting up VPCs, subnets and the networking as a whole, I would recommend going through &lt;a href="https://cloud.google.com/solutions/best-practices-vpc-design"&gt;this&lt;/a&gt;, and the same concepts are applicable for any cloud provider you are onboard with.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Kubernetes Masters&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The masters are automatically managed by the cloud provider without any access to the users if you are using managed clusters like GKE, EKS, AKS and so on thereby lifting a lot of complexity away from the users. And if that is the case, you typically would not have to worry much about managing the masters. But you should be the one specifying the kind of master you would need (regional or zonal) depending on the fault tolerance and availability you require.&lt;/p&gt;

&lt;p&gt;If you are managing the masters yourselves rather than the cloud provider doing it for you, that is when you need to take care of many things like maintaining multiple masters as needed, backing up and encrypting the etcd store, setting up networking between the master and the various nodes in the clusters, patching your nodes periodically with the latest versions of OS, managing cluster upgrades to align with the upstream Kubernetes releases and so on and this is only recommended if you can afford to have a dedicated team which does just this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Site Reliability Engineering (SRE)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you maintain a complex infrastructure, it is very important to have the right observability stack in place so that you can find out errors even before they are noticed by your users, predict possible changes, identify anomalies and have the ability to drill down deep into where the issue exactly is. &lt;/p&gt;

&lt;p&gt;Now, this would require you to have agents which expose metrics as specific to the tool or application to be collected for analysis (which can either follow the push or pull mechanism). And if you are using service mesh with sidecars, they often do come with metrics without doing any custom instrumentation by yourself.&lt;/p&gt;

&lt;p&gt;In any such scenarios, a tool like &lt;a href="https://prometheus.io/"&gt;Prometheus&lt;/a&gt; can act as the time series database to collect all the metrics for you along with something like &lt;a href="https://opentelemetry.io/"&gt;OpenTelemetry&lt;/a&gt; to expose metrics from the application and the various tools using inbuilt exporters, &lt;a href="https://github.com/prometheus/alertmanager"&gt;Alertmanager&lt;/a&gt; to send notifications and alerts to multiple channels, &lt;a href="https://grafana.com/"&gt;Grafana&lt;/a&gt; as the dashboard to visualize everything at one place and so on giving users a complete visibility on the infrastructure as a whole.&lt;/p&gt;

&lt;p&gt;In summary, this is what the observability stack involving prometheus would look like (Source: &lt;a href="https://prometheus.io/docs/introduction/overview/"&gt;https://prometheus.io/docs/introduction/overview/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--S_zNGYIt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/767o2aneuwjd5e50ajz7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--S_zNGYIt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/767o2aneuwjd5e50ajz7.png" alt="Prometheus Stack"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Having complex systems like these also require the use of log aggregation systems so that all the logs can be streamed into a single place for easier debugging. This is where people tend to use the ELK or EFK stack with &lt;a href="https://www.elastic.co/logstash"&gt;Logstash&lt;/a&gt; or &lt;a href="https://www.fluentd.org/"&gt;FluentD&lt;/a&gt; doing the log aggregation and filtering for you based on your constraints. But there are new players in this space, like &lt;a href="https://grafana.com/oss/loki/"&gt;Loki&lt;/a&gt; and &lt;a href="https://grafana.com/docs/loki/latest/clients/promtail/"&gt;Promtail&lt;/a&gt; which does the same thing but in a different way.&lt;/p&gt;

&lt;p&gt;This is how log aggregation systems like FluentD simplify our architecture (Source: &lt;a href="https://www.fluentd.org/architecture"&gt;https://www.fluentd.org/architecture&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cd2FhhfY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9zzxt4wsd7ns3fe2z0jz.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cd2FhhfY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9zzxt4wsd7ns3fe2z0jz.PNG" alt="FluentD architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But what about tracing your request spanning across multiple microservices and tools? This is where distributed tracing also becomes very important especially considering the complexity that microservices comes with. And this is an area where tools like &lt;a href="https://zipkin.io/"&gt;Zipkin&lt;/a&gt; and &lt;a href="https://www.jaegertracing.io/"&gt;Jaeger&lt;/a&gt; have been pioneers with the recent entrant to this space being &lt;a href="https://grafana.com/oss/tempo/"&gt;Tempo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While log aggregation would give information from various sources, it does not necessarily give the context of the request and this is where doing tracing really helps. But do remember, adding tracing to your stack adds a significant overhead to your requests since the contexts have to be propagated between services along with the requests.&lt;/p&gt;

&lt;p&gt;This is how a typical distributed tracing architecture looks like (Source: &lt;a href="https://www.jaegertracing.io/docs/1.21/architecture/"&gt;https://www.jaegertracing.io/docs/1.21/architecture/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NxGP_Yk3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g0ye2p9li38fy4fevulv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NxGP_Yk3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g0ye2p9li38fy4fevulv.png" alt="Jaeger Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But site reliability does not end with just monitoring, visualization and alerting. You have to be ready to handle any failures in any part of the system with regular backups and failovers in place so that either there is no data loss or the extent of data loss is minimized. This is where tools like &lt;a href="https://velero.io/"&gt;Velero&lt;/a&gt; play a major role.&lt;/p&gt;

&lt;p&gt;Tools like Velero helps you to maintain periodic backups of various components in your cluster including your workloads, storage and more by leveraging the same Kubernetes constructs you use. This is how Velero's architecture looks like (Source: &lt;a href="https://velero.io/docs/v1.5/how-velero-works/"&gt;https://velero.io/docs/v1.5/how-velero-works/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ff4L9Gb_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g6fvyjvawvrir1t6zsmc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ff4L9Gb_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/g6fvyjvawvrir1t6zsmc.png" alt="Velero Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you notice, there is a backup controller which periodically does backup of the objects pushing the backups to a specific destination with the frequency based on the schedule you have set. This can be used for failovers and migrations since almost all objects are backed up (while you do have control to backup just what you need)&lt;/p&gt;

&lt;p&gt;Now, all these form some of the most important parts of the SRE stack and while there is more, this should be a good start.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Storage&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While it is easy to start off with storage in Kubernetes with Persistent Volumes, Persistent Volume Claims and Storage classes, it becomes difficult as we scale since storage may need to be clustered with increased in load, backed up, synced when splitting workloads across multiple clusters or regions making it a difficult problem to solve.&lt;/p&gt;

&lt;p&gt;Also there are a lot of different &lt;a href="https://kubernetes.io/docs/concepts/storage/storage-classes/#provisioner"&gt;storage provisioners&lt;/a&gt; and filesystems available which can vary a lot between cloud providers and this calls for a standard like &lt;a href="https://kubernetes-csi.github.io/docs/introduction.html"&gt;CSI&lt;/a&gt; which helps push most of the volume plugins out of tree thereby making it easy to maintain and evolve without the core being the bottleneck.&lt;/p&gt;

&lt;p&gt;This is what the CSI architecture typically looks like supporting various volume plugins and provisioners (Source: &lt;a href="https://kubernetes.io/blog/2018/08/02/dynamically-expand-volume-with-csi-and-kubernetes/"&gt;https://kubernetes.io/blog/2018/08/02/dynamically-expand-volume-with-csi-and-kubernetes/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--USUn0rLC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zxb1wn4svkveyapun4og.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--USUn0rLC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zxb1wn4svkveyapun4og.png" alt="CSI Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But how do we handle the part where we talked about Clustering, scale and various other problems which comes with storage? &lt;/p&gt;

&lt;p&gt;This is where file systems like &lt;a href="https://ceph.io/"&gt;Ceph&lt;/a&gt; has already proved itself being used for a long time in production by a lot of companies. But considering that it was not built with Kubernetes in mind and is very hard to deploy and manage, this is where a project like &lt;a href="https://rook.io/"&gt;Rook&lt;/a&gt; can really help. &lt;/p&gt;

&lt;p&gt;While Rook is not coupled to Ceph, and supports other filesystems like EdgeFS, NFS, etc. as well, Rook with Ceph CSI is like a match made in heaven. This is how the architecture of Rook with Ceph looks like (Source: &lt;a href="https://rook.io/docs/rook/v1.5/ceph-storage.html"&gt;https://rook.io/docs/rook/v1.5/ceph-storage.html&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ORGAnyt_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pywc5gwaik9kh8spvm3x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ORGAnyt_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/pywc5gwaik9kh8spvm3x.png" alt="Rook Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, Rook takes up the responsibility of installing, configuring and managing Ceph in the Kubernetes cluster and this becomes interesting since the storage is distributed underneath automatically as per the user preferences. But all this happens without the app being exposed to any complexity which lies underneath.&lt;/p&gt;

&lt;p&gt;You still request for a claim as you would typically do but it is just that your request is served by Rook and Ceph rather than the cloud provider itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Image Registry&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are onboard a cloud provider, there is a high chance that they already provide image registry as a service already (eg. &lt;a href="https://cloud.google.com/container-registry"&gt;GCR&lt;/a&gt;, &lt;a href="https://aws.amazon.com/ecr/"&gt;ECR&lt;/a&gt;, &lt;a href="https://azure.microsoft.com/en-in/services/container-registry/"&gt;ACR&lt;/a&gt;, etc.) which takes away all the complexity from you and you should be good to go and if your cloud provider does not provide one, you can also go for third party registries like &lt;a href="https://hub.docker.com/"&gt;Docker Hub&lt;/a&gt;, &lt;a href="https://quay.io/"&gt;Quay&lt;/a&gt;, etc.&lt;/p&gt;

&lt;p&gt;But what if you want to host your own registry?&lt;/p&gt;

&lt;p&gt;This may be needed if you either want to deploy your registry on premise, want to have more control over the registry itself or want to reduce costs associated with operations like vulnerability scanning.&lt;/p&gt;

&lt;p&gt;If this is the case, then going for a private image registry like &lt;a href="https://goharbor.io/"&gt;Harbor&lt;/a&gt; might actually help. This is what the architecture of Harbor looks like (Source: &lt;a href="https://goharbor.io/docs/1.10/install-config/harbor-ha-helm/"&gt;https://goharbor.io/docs/1.10/install-config/harbor-ha-helm/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MizEEtWQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ttyl8bnyh36awixd013t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MizEEtWQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ttyl8bnyh36awixd013t.png" alt="Harbor Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Harbor is an &lt;a href="https://opencontainers.org/"&gt;OCI&lt;/a&gt; compliant registry which is made of various components which includes &lt;a href="https://docs.docker.com/registry/"&gt;Docker registry V2&lt;/a&gt;, Harbor UI, &lt;a href="https://github.com/quay/clair"&gt;Clair&lt;/a&gt;, &lt;a href="https://github.com/theupdateframework/notary"&gt;Notary&lt;/a&gt;, backed by a cache like Redis and a database like Postgres. &lt;/p&gt;

&lt;p&gt;Ultimately, it provides you a user interface where you can manage various user accounts having access to the registry, push/pull images as you normally would, manage quotas, getting notified on events with webhooks, do vulnerability scanning with the help of Clair, sign the pushed images with the help of Notary and also handle operations like mirroring or replication of images across multiple image registries behind the scenes. All of this makes harbor a great fit for a private registry on Kubernetes and its great especially it being a graduated project from CNCF.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CI/CD Architecture&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Kubernetes acts as a great platform for hosting all your workloads at any scale but this also calls for a standard way of deploying them all with a streamlined CI/CD workflow. This is where setting up a pipeline like this can really help (Source: &lt;a href="https://thenewstack.io/ci-cd-with-kubernetes-tools-and-practices/"&gt;https://thenewstack.io/ci-cd-with-kubernetes-tools-and-practices/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---t0IOd2C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6qnz0vy1b221wgac5uk8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---t0IOd2C--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/6qnz0vy1b221wgac5uk8.png" alt="CI/CD Architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are using a third party service like &lt;a href="https://www.travis-ci.com/"&gt;Travis CI&lt;/a&gt;, &lt;a href="https://circleci.com/"&gt;Circle CI&lt;/a&gt;, &lt;a href="https://docs.gitlab.com/ee/ci/"&gt;Gitlab CI&lt;/a&gt; or &lt;a href="https://github.com/features/actions"&gt;Github Actions&lt;/a&gt;, they do come with their own CI runners which run on their own infrastructure requiring you to just define the steps in the pipeline you are looking to build. This would typically involve, building the image, scanning the image for possible vulnerabilities, running the tests and pushing it to the registry and in some cases provisioning a preview environment for approvals.&lt;/p&gt;

&lt;p&gt;Now, while the steps would typically remain the same if you are managing your own CI runners, you would need to configure them to be setup either within or outside your clusters with appropriate permissions to push the assets to the registry. For an example on using Skaffold and Gitlab with Kubernetes executor with GCR as the registry and GKE as the deployment target, you can have a look at &lt;a href="https://skaffold.dev/docs/tutorials/ci_cd/"&gt;this&lt;/a&gt; tutorial.&lt;/p&gt;

&lt;p&gt;With this, we have gone over the architecture of various important parts of the infrastructure taking different examples from Kubernetes and its ecosystem. As we have seen above, there are various tools as part of the CNCF stack addressing different problems with infrastructure and they are to be viewed like Lego blocks each focusing on a specific problem at hand and is to be viewed like a black box abstracting a lot of complexity underneath for you.&lt;/p&gt;

&lt;p&gt;This allows users to leverage Kubernetes in an incremental fashion rather than getting onboard all at once using just the tools you need from the entire stack depending on your use case. The ecosystem is still evolving especially with a lot of standards now in place allowing users to adopt it all without any kind of vendor lock-in at any point.&lt;/p&gt;

&lt;p&gt;If you have any questions or are looking for help or consultancy, feel free to reach out to me &lt;a href="https://www.twitter.com/techahoy"&gt;@techahoy&lt;/a&gt; or via &lt;a href="https://www.linkedin.com/in/tvvignesh"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>cloud</category>
      <category>architecture</category>
      <category>cloudnative</category>
    </item>
    <item>
      <title>Launching my Patreon Page</title>
      <dc:creator>t.v.vignesh</dc:creator>
      <pubDate>Sat, 16 Jan 2021 06:26:05 +0000</pubDate>
      <link>https://dev.to/tvvignesh/launching-my-patreon-page-4f4e</link>
      <guid>https://dev.to/tvvignesh/launching-my-patreon-page-4f4e</guid>
      <description>&lt;p&gt;Hi friends. As the title suggests, this is a blog post announcing the launch of my patreon page: &lt;a href="https://patreon.com/vignesh"&gt;https://patreon.com/vignesh&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the introductory video from me regarding the same:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/1CQss9SEaao"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;*Excuse me, since I repeatedly used the word Patreon many times instead of Patron in the video 😂&lt;/p&gt;

&lt;p&gt;While I truly believe that knowledge should be free for all, I also do believe that it should be sustainable over a long period of time for the creators to keep making amazing content for the community.&lt;/p&gt;

&lt;p&gt;This is where a platform like Patreon or Open Collective can really help as creators like me spend the valuable time creating quality content for all of the community.&lt;/p&gt;

&lt;p&gt;You might have seen some posts from me in &lt;a href="https://dev.to/tvvignesh"&gt;Dev.to&lt;/a&gt; or &lt;a href="https://medium.com/@tvvignesh"&gt;Medium&lt;/a&gt; and some live streams from my &lt;a href="https://www.youtube.com/channel/UCLnTH4GOCB5fXWoOfgklQwA"&gt;Youtube channel&lt;/a&gt; as well.&lt;/p&gt;

&lt;p&gt;While I would love to create content for all, I would also like to have more motivation and incentive to do so over a long term and as you might already agree, money can be a pretty good motivator 😉.. &lt;/p&gt;

&lt;p&gt;Just kidding, but its true.&lt;/p&gt;

&lt;p&gt;For all those who cannot afford, all the content will always be available free for everyone, but the patreon members will get access to the content 2 months in advance along with a host of other benefits as outlined in &lt;a href="https://www.patreon.com/vignesh"&gt;our tiers&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I don't want to monetize with ADs or paywalls at this point since that might hinder your experience as a user and hence am sticking to Patreon.&lt;/p&gt;

&lt;p&gt;I will maintain a consistent schedule to release content. The frequency of the content I release will depend on the number of Patreon members I get. The more the members, the higher the frequency.&lt;/p&gt;

&lt;p&gt;You can expect the first video to be released on the first week of February 2021 or as soon as I get 50 patrons, whichever comes first 😉&lt;/p&gt;

&lt;p&gt;While I do all of this, I also plan to take up part-time/freelance consultancy/advisory roles as mentioned in the video though it has limited availability since I spend most of my time working on my startup, &lt;a href="https://timecampus.com/"&gt;Timecampus&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you have any expectations on the content, do let me know (even if you don't want to opt in for Patreon). I would like to align with your interests and deliver what is of more value to you in the best way possible more than anything else.&lt;/p&gt;

&lt;p&gt;If you have any suggestions or would just like to have a quick chat with me, feel free to reach out to me anytime.&lt;/p&gt;

&lt;p&gt;Looking forward to creating awesome content for you.&lt;/p&gt;

&lt;p&gt;And if you want to reach out, this is where you can find me:&lt;/p&gt;

&lt;p&gt;LinkedIn: &lt;a href="https://www.linkedin.com/in/tvvignesh"&gt;https://www.linkedin.com/in/tvvignesh&lt;/a&gt;&lt;br&gt;
Twitter: &lt;a href="http://twitter.com/techahoy"&gt;http://twitter.com/techahoy&lt;/a&gt;&lt;br&gt;
Medium: &lt;a href="https://medium.com/@tvvignesh"&gt;https://medium.com/@tvvignesh&lt;/a&gt;&lt;br&gt;
Github: &lt;a href="https://github.com/tvvignesh"&gt;https://github.com/tvvignesh&lt;/a&gt;&lt;br&gt;
Dev.to: &lt;a href="https://dev.to/tvvignesh"&gt;https://dev.to/tvvignesh&lt;/a&gt;&lt;br&gt;
Instagram: &lt;a href="https://instagram.com/tvvignesh"&gt;https://instagram.com/tvvignesh&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cheers,&lt;br&gt;
Vignesh T.V.&lt;/p&gt;

&lt;p&gt;PS: I am not sure if Dev.to has tags for these kinds of posts. So, rather tagging it with the kind of content I will be releasing in my page.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>startup</category>
      <category>webdev</category>
      <category>cloud</category>
    </item>
    <item>
      <title>Infrastructure Engineering - Diving Deep</title>
      <dc:creator>t.v.vignesh</dc:creator>
      <pubDate>Fri, 15 Jan 2021 04:03:29 +0000</pubDate>
      <link>https://dev.to/timecampus/infrastructure-engineering-diving-deep-2jdd</link>
      <guid>https://dev.to/timecampus/infrastructure-engineering-diving-deep-2jdd</guid>
      <description>&lt;p&gt;&lt;em&gt;This blog is a part of a series on Kubernetes and its ecosystem where we will dive deep into the infrastructure one piece at a time&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So far we have gone through the various principles to keep in mind while working with Infrastructure as a whole and have also discussed the impact Kubernetes and its ecosystem has in our journey towards establishing a cloud native infrastructure.&lt;/p&gt;

&lt;p&gt;But considering there are a lot of tools and technologies in play to make this all happen, I am pretty sure that you would be left with a lot of questions unanswered. While we will be diving deeper through the entire ecosystem in this series, I feel that it is important to clear some of the clouded thoughts you may have. So, why not start proceed with this series with an FAQ (&lt;a href="https://medium.com/timecampus/graphql-diving-deep-c7c0abe608b2"&gt;similar to what I did for GraphQL&lt;/a&gt;)? That's what we will do here. I have put together a series of questions and have also answered them below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you are new to Kubernetes or Containers, I would recommend you to start with any of these resources before jumping into this blog post:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kubernetes.io/docs/home/"&gt;Kubernetes Official Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.tutorialspoint.com/kubernetes/index.htm"&gt;Kubernetes Tutorials&lt;/a&gt; from Tutorialspoint&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://ramitsurana.gitbook.io/awesome-kubernetes/docs"&gt;Kubernetes Awesome&lt;/a&gt; by Ramit Surana&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://cloud.google.com/kubernetes-engine/docs/tutorials"&gt;GKE&lt;/a&gt;, &lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/getting-started.html"&gt;EKS&lt;/a&gt;, &lt;a href="https://docs.microsoft.com/en-us/azure/aks/"&gt;AKS&lt;/a&gt;, &lt;a href="https://www.digitalocean.com/resources/kubernetes/"&gt;Digital Ocean&lt;/a&gt; tutorials&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.aquasec.com/cloud-native-academy/kubernetes-101/kubernetes-tutorials/"&gt;Tutorial collection&lt;/a&gt; aggregated by Aquasec&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you are comfortable with the basics, I would highly recommend you to stick to the Kubernetes Official Documentation since that acts as the single source of truth for everything Kubernetes. But if you are wanting to learn more or explore on the &lt;a href="https://www.cncf.io/projects/"&gt;various tools&lt;/a&gt; supporting Kubernetes, I would recommend going through their docs respectively. &lt;/p&gt;

&lt;p&gt;And if you really want to hear this all from industry experts and learn more by going through their case studies, I would highly recommend having a look at the &lt;a href="https://www.youtube.com/c/cloudnativefdn/videos"&gt;CNCF Youtube Channel&lt;/a&gt; which hosts tons of useful resources in relation to Kubernetes and its ecosystem (don't miss the Cloud Native/Kube Cons)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Cloud Native?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In our &lt;a href="https://medium.com/timecampus/infrastructure-engineering-the-kubernetes-way-35ed5b1f705e"&gt;last blog&lt;/a&gt; we did look at what Cloud Native is and what the stack looks like. The main reasons why you would want to go cloud native is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To achieve maximum scalability, but get there incrementally and do it either on demand or even automatically based on constraints&lt;/li&gt;
&lt;li&gt;Having systems which can better respond to faults rather than trying to avoid faults which is not possible when you scale a distributed system&lt;/li&gt;
&lt;li&gt;Avoid any sort of lock-in by adopting a vendor agnostic model leveraging standards, platforms like Kubernetes and other cloud native constructs available for you to use&lt;/li&gt;
&lt;li&gt;Accelerate the Inner Dev Loop and the complete cycle from application development to production by establishing standard automation and scalable CI/CD pipelines in place allowing for agile development and better release process and delivery of applications&lt;/li&gt;
&lt;li&gt;Have a high emphasis on the sanity and resilience of your application be it security, monitoring, logging, distributed tracing, backups/failovers and more by leveraging various tools and mechanisms already available as part of the cloud native stack.&lt;/li&gt;
&lt;li&gt;Handle different architectures be it private cloud, public cloud, on premise or even hybrid cloud without having to change too much in the application layer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, this would typically mean that it is highly recommended to go Cloud Native for almost &lt;strong&gt;everything&lt;/strong&gt; irrespective of your use case. Your adoption level of various tools and technologies may vary depending on your use case, but the principles do remain almost always the same.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I use Docker compose. How do I transition to Kubernetes?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are starting off, and have a lot of compose files to convert, then I would recommend trying out a tool like &lt;a href="https://kompose.io/"&gt;Kompose&lt;/a&gt; which will take in your compose files and generate the K8 yaml files for you simplifying your task from there.&lt;/p&gt;

&lt;p&gt;But this is recommended only when you start off as a beginner with Kubernetes. Once you start working closely with it, it is recommended to have your dev environment also as a K8 cluster (be it something like Minikube, Kind, MicroK8s, K3s or anything else for that matter) or even a remote K8 cluster like (GKE, AKS, EKS and so on). This is because you will get a consistent experience starting from development to production and you will have to get comfortable with it sooner or later if you use Kubernetes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I run a Kubernetes Cluster locally?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are a lot of options like we mentioned which helps us run K8 clusters locally. Some of the notable options would be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://minikube.sigs.k8s.io/docs/"&gt;Minikube&lt;/a&gt;: A one node K8 cluster running within a VM, maintained by Google Container Tools team. Can be pretty bulky if you are low on resources and you want to run multiple clusters on one machine and also take quite some time to start or stop the cluster. Has a high compatibility with upstream K8 versions&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://kind.sigs.k8s.io/docs/"&gt;Kind&lt;/a&gt;: Run Kubernetes clusters within Docker, a Kubernetes Sigs project, used as the tool to test Kubernetes itself. Starts and stops pretty quickly. Since there are different container runtimes like Docker and Podman, the behavior can be different in both, every node/control plane is hosted within its own container and leverages the docker networking for all the communication. Has a high compatibility with upstream K8 versions&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://k3s.io/"&gt;K3s&lt;/a&gt;: A lightweight stripped down version of Kubernetes, maintained by Rancher Labs, only stable features are shipped and without many plugins leading to a very low binary size, supports auto deployment. Has a high compatibility with upstream K8 versions but you may want to watch out if you are using alpha features/plugins since you have to install them manually for you to use.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://microk8s.io/"&gt;MicroK8s&lt;/a&gt;: A lightweight Kubernetes version from Canonical, packaged as a snap (so, you don't need a VM again), better compatible with Ubuntu than other distributions and not supported in distributions without Snap support.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are other options as well like &lt;a href="https://www.weave.works/oss/firekube/"&gt;Firekube&lt;/a&gt;, or you can even use &lt;a href="https://kubernetes.io/docs/reference/setup-tools/kubeadm/"&gt;Kubeadm&lt;/a&gt; directly if you want 🤔. Try everything and use what is best for you. &lt;/p&gt;

&lt;p&gt;But do remember that development and production K8 clusters can turn out to be pretty different. So, try testing in a staging environment before you ship something.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why do I need Helm?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you are starting off with Kubernetes, you may not need to use helm, in fact I would recommend you not to use when you start. You can just go with good old YAML files and get things working.&lt;/p&gt;

&lt;p&gt;But Helm provides a great value when you start diving more deeper, introducing multiple environments with multiple configurations, a packaging/release process, rollback or roll forward and also acts as a package manager helping you to use a lot of already available OSS tools out there by just changing the config as you need and use them.&lt;/p&gt;

&lt;p&gt;Considering that you don't need Tiller anymore starting with Helm 3, all you need is a client to work with Helm.&lt;/p&gt;

&lt;p&gt;In summary, Helm can help you with things like templating, packaging/release/versioning and also be a package manager for Kubernetes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I check-in secrets and credentials to my version control?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This has always been a major problem for developers and one of the main reasons behind a lot of attacks on systems like &lt;a href="https://www.securonix.com/securonix-threat-research-uber-hack-software-code-repository-vcs-leaked-credential-usage-detection/"&gt;this&lt;/a&gt; leading to a lot of concern on the way credentials are handled while still having the need to store it safely somewhere. &lt;/p&gt;

&lt;p&gt;This can be handled in multiple ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use a credential manager like &lt;a href="https://www.vaultproject.io/"&gt;Vault&lt;/a&gt; which can help you manage the secrets and sensitive data at one place&lt;/li&gt;
&lt;li&gt;Encrypt the confidential data/credentials with a Key Management Service (KMS) using a tool like &lt;a href="https://github.com/mozilla/sops"&gt;SOPS&lt;/a&gt; and checking in the encrypted credentials to the version control. For very confidential credentials you can also use a HSM (Hardware Security Module) which typically provides the highest level of physical security&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While you do this all, it is important to introduce tools in place in case accidents do happen. For instance, a service like Github does have the &lt;a href="https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/about-secret-scanning"&gt;ability to scan for secrets&lt;/a&gt; in the repositories and you may want to leverage it as well. And even after this, if the worst happens, pray for the best and revoke the compromised credentials.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I use a legacy stack. How do I make my application Cloud Native?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Making an application Cloud Native is a continuous process with opportunities always available for changes or improvements. The best way to start off is to take one component at a time and migrate rather than attempting an all-out migration which may not be feasible to start with. &lt;/p&gt;

&lt;p&gt;For instance, if you have a portion of the application which requires high scalability, try doing a lift and shift of the respective portion alone and see if the migration actually helps you by just driving a portion of the traffic to the new deployment and see how it behaves. This is where A/B testing or canary architectures with service mesh can actually help.&lt;/p&gt;

&lt;p&gt;To keep your application available while you complete your migration, it is also recommended to have a parallel existence of the legacy architecture as well in addition to the cloud native implementation.&lt;/p&gt;

&lt;p&gt;In many cases, making an application Cloud Native might require application changes or in very rare cases, a rewrite as well. So, make sure you evaluate all your options and step in with a clear feasibility study.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I build a Highly Available Kubernetes cluster?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In some mission critical cases, it might be needed to make your Kubernetes clusters highly available. But don't get too paranoid cause the more highly available your architecture is, the more complex it becomes. So, be thoughtful and assess if you really want it before you start off.&lt;/p&gt;

&lt;p&gt;Making a cluster highly available might need doing things like having multiple replicas of the masters splitting them across multiple different zones/regions with a syncing mechanism established between their respective etcd stores as well. It might also need provisioning different nodes across different regions so that any failure in one cluster in one region does not affect the traffic in the rest. You might want to check how to create a HA cluster with Kubeadm &lt;a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/high-availability/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Also, if you want your application to be highly available, you may want to maintain multiple replicas of your pods also making sure that they all don't end up on the same node by leveraging labels and pod affinity/anti-affinity.&lt;/p&gt;

&lt;p&gt;In addition to this, you may also want to scale your application at the load balancer level using a software based load balancer, leveraging DNS to make sure you don't end up sending all the traffic to the same place all the time, having static assets in the CDN which can help even when the server/cluster fails.&lt;/p&gt;

&lt;p&gt;In summary, the scalability and availability can be and should be done at multiple different layers depending on where your bottleneck or issues are.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I collaborate with my team in the same Kubernetes cluster?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are a lot of ways in which you can isolate workloads and still collaborate when you are working with your team using Kubernetes. While you can effectively use one cluster for every developer and some organizations do that which is nothing wrong since it provides a great isolation in workloads between team members, it may turn out to be unmaintainable and difficult to manage over a long time (especially if there is a single OPS team doing that) handling security patches/upgrades/managing auth and so on. To avoid such scenarios, some other ways to do this would be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Leverage Kubernetes Namespaces&lt;/strong&gt; - Allocating each namespace for a team member or a team as a whole and running your workloads within. While this can work very well for small teams or individuals, it becomes difficult to manage as the number of namespaces increase with increase in the number of teams/members using the cluster making it difficult for the admin to do operations like setup RBAC rules, remove unused namespaces, scale the cluster and so on. To simplify this, there are tools like &lt;a href="https://okteto.com/"&gt;Okteto&lt;/a&gt; keeping you sane while work on everything you have to.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Or if you have managed to have access to a separate namespace all for yourself, you can also end up using things like Swap Deployment and Proxy Deployment from &lt;a href="https://www.telepresence.io/"&gt;Telepresence&lt;/a&gt; effectively allowing you to develop your service locally in your system.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Leverage Same Namespace with Headers and Proxying&lt;/strong&gt; - While a single namespace can be used by multiple developers, things can become tricky especially if multiple developers are modifying the same service at the same time. So, one developer modifying something will in turn lead to unexpected results for an another developer since there is no isolation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where headers come in to the rescue. If you use a tool like &lt;a href="https://www.getambassador.io/docs/latest/topics/using/edgectl/"&gt;Service Preview&lt;/a&gt; or &lt;a href="https://code.visualstudio.com/docs/containers/bridge-to-kubernetes"&gt;Bridge for Kubernetes&lt;/a&gt;, this is exactly what they do. They leverage a sidecar like envoy to do the routing to a different instance of a service depending on the headers being used in the requests. This is powerful because, all you need is one namespace for everything without blocking any developer from doing any changes they would want.&lt;/p&gt;

&lt;p&gt;Or if none of this works for you, and you want complete control, you can spin up Kubernetes clusters locally and work with it with the help of tools like &lt;a href="https://tilt.dev/"&gt;Tilt&lt;/a&gt; or &lt;a href="https://skaffold.dev/"&gt;Skaffold&lt;/a&gt;. The choice is again yours depending on what you want to do.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I do Site Reliability Engineering (SRE) in my K8 cluster?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unlike what most people think, Site Reliability Engineering (SRE) encompasses a wide array of activities which also includes doing things like monitoring the system health, logging events, handling scalability, responding to incidents/failures in a timely and organized manner, building complex distributed systems and so on, that there is a whole website where Google talks about SRE &lt;a href="https://sre.google/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And even if doing all of this is required specifically if your use case is SLA critical, a lot of these are offloaded away from you if you use managed Kubernetes clusters (like GKE, AKS, EKS and so on) leaving a relatively less space to cover from your end. For instance, in case of GKE, Google manages the masters, and if you are subscribed to an update channel, they send you periodic updates with latest features both from GKE and the upstream versions, help you manage logging, monitoring and other operations with Google Cloud Operations suite (formerly Stackdriver) and so on helping you have a quick start.&lt;/p&gt;

&lt;p&gt;In addition to this, there are a lot of amazing tools which help with different SRE problems in their own way. For instance, you can use &lt;a href="https://prometheus.io/"&gt;Prometheus&lt;/a&gt; as your database to scrape and store time series metrics, &lt;a href="https://grafana.com/"&gt;Grafana&lt;/a&gt; to manage your dashboards, &lt;a href="https://www.fluentd.org/"&gt;FluentD&lt;/a&gt; or &lt;a href="https://grafana.com/oss/loki/"&gt;Loki&lt;/a&gt; to do log aggregation and conditional filtering, &lt;a href="https://opentelemetry.io/"&gt;OpenTelemetry&lt;/a&gt; to instrument and expose metrics in your application, &lt;a href="https://www.jaegertracing.io/"&gt;Jaeger&lt;/a&gt; to do distributed tracing, &lt;a href="https://velero.io/"&gt;Velero&lt;/a&gt; to manage backups and failovers and this list is long as we see different tools cater to different problems in SRE.&lt;/p&gt;

&lt;p&gt;We will talk more about this in our next blog post.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is there a dashboard I can use to visualize and manage my clusters?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The great news is, there are quite a few. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Some distributions of Kubernetes do come with its own &lt;a href="https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/"&gt;Default Dashboard UI&lt;/a&gt; giving you all the basic info and control you need with your cluster. But do note that it might not be enabled by default for security reasons.&lt;/li&gt;
&lt;li&gt;You can also use the dashboard provided by your cloud provider. In case of GKE, there is a great dashboard where you can drill down into every resource and manage it using the options provided to you which is really convenient when you want to do something very quick.&lt;/li&gt;
&lt;li&gt;Or you can also have an amazing tool like &lt;a href="https://octant.dev/"&gt;Octant&lt;/a&gt; take care of this for you. Assume this like a User Interface to your kubectl client.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are even more dashboards like &lt;a href="https://www.weave.works/oss/scope/"&gt;Weavescope&lt;/a&gt; and even more tools like &lt;a href="https://octopus.com/blog/alternative-kubernetes-dashboards"&gt;these&lt;/a&gt;. Just go for what gives you more visibility and control over your cluster with great usability and you should be good to go.&lt;/p&gt;

&lt;p&gt;But for power user operations, we would always recommend going for kubectl since that is the single tool which is used by almost all the clients out there to interact with the Kubernetes API Server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do I need a Service Mesh?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Service Mesh has garnered a lot of popularity these days especially after leaders like &lt;a href="https://linkerd.io/"&gt;Linkerd&lt;/a&gt;, &lt;a href="https://istio.io/"&gt;Istio&lt;/a&gt; and &lt;a href="https://www.consul.io/"&gt;Consul&lt;/a&gt; all have demonstrated a different way to do networking, authorization, logging, instrumentation, A/B Testing, MTLS and more with sidecars without having to modify the application code.&lt;/p&gt;

&lt;p&gt;While service mesh is really powerful, not every use case might need one, especially when you have very little services to manage. &lt;/p&gt;

&lt;p&gt;Adding a service mesh would need both a control plane and data plane to be setup with proxies being injected as sidecars to do the heavy lifting for you. While this might seem complex to start with, the benefits can be realized as soon as the number of services you manage increases and this is when you will reap all its rewards.&lt;/p&gt;

&lt;p&gt;Also once the &lt;a href="https://smi-spec.io/"&gt;SMI Spec&lt;/a&gt; is widely supported by all the mesh providers (there is a good support already), it would enforce a lot of standardization to the service mesh ecosystem avoiding the need to be coupled to an implementation. Do note that a sidecar might not be well supported always with the various tools you use with your application. For instance, adding a sidecar along with your database or event queue may or may not work depending on the protocol being used.&lt;/p&gt;

&lt;p&gt;But overall, it has a very promising future especially when adopted incrementally. So, in summary you don't need a mesh when you start but it is great to have once you have a significant number of services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I manage Authentication &amp;amp; Authorization for the cluster and various services within?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are various ways to do authentication and authorization and can vary depending on your context.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you want to add authentication or authorization within your application/service you can use any of the mechanisms as you see fit including JWT with OAuth2, sessions, cookies or even basic auth mechanisms. This would require writing logic within the service and also using libs to help you with this whenever needed and redoing this for every service where you need auth might be difficult to do while definitely possible. 
To make this simple, you can use tools like &lt;a href="https://www.openpolicyagent.org/"&gt;OPA&lt;/a&gt; as an SDK which can generalize a lot of things for you. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While OPA has native Golang support. Other languages are supported via &lt;a href="https://www.openpolicyagent.org/docs/latest/wasm/"&gt;WebAssembly&lt;/a&gt; (if you want to use OPA as an SDK)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The next way to add authentication/authorization is using Sidecars if you are using a service mesh or even OPA as a sidecar. This can offload the authentication/authorization away from your application leaving just the business logic within. This allows you to just inject the sidecars whenever needed without having to worry to much about how it might break your app. The sidecars can also things like MTLS, rate limiting and more as needed by your application.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you would like to do cluster level authorization to assign roles, policies and access controls, you can make use of either &lt;a href="https://github.com/open-policy-agent/gatekeeper"&gt;OPA Gatekeeper&lt;/a&gt; or rely on &lt;a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/"&gt;RBAC&lt;/a&gt; to get the job done for you&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How do I support hybrid cloud with the help of the Cloud Native Stack?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are onboard Kubernetes and the rest of the Cloud Native stack, then supporting hybrid cloud can be pretty easy provided you don't use services/APIs as specific to a cloud provider. Almost every big cloud provider out there supports managed Kubernetes as a service today which you can use and if you are very insistent, you can also spin up a VM and run your Kubernetes cluster within it and manage it yourself.&lt;/p&gt;

&lt;p&gt;Projects like &lt;a href="https://github.com/kubernetes-sigs/kubefed"&gt;Kubefed&lt;/a&gt; and &lt;a href="https://crossplane.io/"&gt;Crossplane&lt;/a&gt; are especially useful here since they help you to manage and orchestrate clusters and the requests you send across different cloud providers even if its going to be across regions.&lt;/p&gt;

&lt;p&gt;While these are the best tools to manage this kind of hybrid cloud scenarios, using a service mesh can also help if you have a Multicluster architecture like &lt;a href="https://istio.io/latest/docs/setup/install/multicluster/"&gt;this&lt;/a&gt; or &lt;a href="https://linkerd.io/2/features/multicluster/"&gt;this&lt;/a&gt; setup helping you to communicate across cloud providers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which container runtime should I use?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Kubernetes supports multiple container runtimes due to its adoption of pod as the basic unit of scheduling. While Docker was one of the runtimes so far, &lt;a href="https://kubernetes.io/blog/2020/12/02/dont-panic-kubernetes-and-docker/"&gt;it has been recently deprecated&lt;/a&gt; in favor of better standards like CRI removing the shim. The other recognized runtimes would be &lt;a href="https://containerd.io/"&gt;containerd&lt;/a&gt;, or even a low-level runtime like &lt;a href="https://github.com/opencontainers/runc"&gt;runc&lt;/a&gt;. You can read more about how they compare in &lt;a href="https://www.inovex.de/blog/containers-docker-containerd-nabla-kata-firecracker/"&gt;this&lt;/a&gt; post or even &lt;a href="https://www.ianlewis.org/en/container-runtimes-part-1-introduction-container-r"&gt;this&lt;/a&gt;. As they mention, today making a call to Docker engine will make a call to containerd which inturn makes a call to runc. The main difference lies in the fact that every runtime has a different level of abstractions and ultimately the lowest level of the hierarchy is going to be &lt;a href="https://linuxcontainers.org/lxc/introduction/"&gt;LXC&lt;/a&gt; which is based on C or &lt;a href="https://github.com/opencontainers/runc"&gt;runc&lt;/a&gt; which is based on Golang.&lt;/p&gt;

&lt;p&gt;While you can go for any runtime which supports your use case and also supported by your cloud provider, a great start to enabling this would be to build an OCI compliant image so that you can use that across with different runtimes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are the differences between CRI, CSI, CNI, SMI ? Why do they matter?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All of them are different standards meant to avoid possible complexities and vendor lock-in allowing for a great level of interoperability.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/kubernetes/cri-api"&gt;CRI&lt;/a&gt; (Container Runtime Interface) is a standard which helps establish interoperability within multiple container runtimes like containerd and others&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/container-storage-interface/spec"&gt;CSI&lt;/a&gt; (Container Storage Interface) is a standard which helps establish interoperability between multiple storage providers avoiding the need to have in-tree plugins within the core. So, any storage provider who supports CSI can work with Kubernetes without any issues. You can find a complete list of providers supporting CSI &lt;a href="https://kubernetes-csi.github.io/docs/drivers.html#production-drivers"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/containernetworking/cni"&gt;CNI&lt;/a&gt; (Container Networking Interface) is a standard which helps establish interoperability between multiple networking solutions again avoiding the need to have in-tree plugins within the core and separating container networking and execution. There are a lot of &lt;a href="https://github.com/containernetworking/cni#3rd-party-plugins"&gt;plugins&lt;/a&gt; and &lt;a href="https://github.com/containernetworking/cni#container-runtimes"&gt;runtimes&lt;/a&gt; which support CNI today.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://smi-spec.io/"&gt;SMI&lt;/a&gt; (Service Mesh Interface) is a standard which helps establish interoperability between various service mesh solutions like Linkerd, Istio, Consul and &lt;a href="https://github.com/servicemeshinterface/smi-spec#ecosystem"&gt;more&lt;/a&gt;. A lot of things like traffic access control, metrics, specs, splitting, etc. are also to be standardized so that users do not have to get locked in to a specific provider.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How do I use Kubernetes at the Edge or on IOT Devices?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Kubernetes has become so special that it is being now used in different kinds of environments including fighter planes and Raspberry PIs. This calls for a different way of thinking including adding support for offline operations and control, allowing a lightweight distribution which can run with restricted compute, run in different processor architectures and so on.&lt;/p&gt;

&lt;p&gt;Use cases like these are made possible by projects like &lt;a href="https://kubeedge.io/en/"&gt;KubeEdge&lt;/a&gt; , &lt;a href="https://k3s.io/"&gt;K3s&lt;/a&gt; and &lt;a href="https://github.com/virtual-kubelet/virtual-kubelet"&gt;Virtual Kubelets&lt;/a&gt;. You can read more about how they power the edge with different architectures and compromises &lt;a href="https://containerjournal.com/topics/container-networking/powering-edge-with-kubernetes-a-primer/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I start with Infrastructure as Code?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Infrastructure as Code (IaC) is not to be confused with Configuration Management though a lot of tools do have overlapping functionality providing features from both worlds.&lt;/p&gt;

&lt;p&gt;There are a lot of tools which helps you convert your Infrastructure as Code most notable of which are the likes of &lt;a href="https://www.terraform.io/"&gt;Terraform&lt;/a&gt;, &lt;a href="https://www.pulumi.com/"&gt;Pulumi&lt;/a&gt;, &lt;a href="https://www.ansible.com/"&gt;Ansible&lt;/a&gt;, &lt;a href="https://puppet.com/"&gt;Puppet&lt;/a&gt; and more each of which work differently. For instance, Terraform is declarative and uses HCL (Hashicorp Language) while Pulumi leverages the power of respective programming languages to do its job.&lt;/p&gt;

&lt;p&gt;The best way to start with Infrastructure as Code is to go for it incrementally as you normally would for any migration (unless you are starting from scratch). You also have a lot of community resources which can help you in the process. For instance, if you use Terraform, the &lt;a href="https://registry.terraform.io/"&gt;Terraform registry&lt;/a&gt; hosts a lot of &lt;a href="https://www.terraform.io/docs/modules/index.html"&gt;Terraform Modules&lt;/a&gt; from the community along with a wide support for a lot of providers which you can use. Interestingly, it also allows you to manage all the resources like deployments, services and so on in your K8 cluster if you want to do it the terraform way. So, the options are endless.&lt;/p&gt;

&lt;p&gt;But it only makes sense to adopt Infrastructure as Code if you are someone who truly leverages GitOps since it is always important to have any proposed change to your infrastructure properly reviewed by the respective stakeholders then applied also making sure that you avoid possible conflicts by using a locked state file checked in to a remote location like GCS or their respective cloud service.&lt;/p&gt;

&lt;p&gt;If you are someone who would want to adopt the DRY principles and would want to have maintainable code, a project like &lt;a href="https://terragrunt.gruntwork.io/"&gt;Terragrunt&lt;/a&gt; can actually help you with this.&lt;/p&gt;

&lt;p&gt;As we just saw, there are loads of options to go for. Just make sure that you review your changes properly before applying them without which it can cause disastrous effects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I do CI/CD and GitOps with Kubernetes?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There has been a lot of amazing projects in this area as of late, so much so that, there is now a &lt;a href="https://cd.foundation/"&gt;separate foundation&lt;/a&gt; dedicated to this. While projects like Jenkins were leaders before, the cloud native world has an interesting set of problems to be solved starting from even making your CI/CD pipeline scalable and adhere to all the cloud native principles we discussed. This is what has led to the rise of projects like &lt;a href="https://tekton.dev/"&gt;Tekton&lt;/a&gt; which was born out of &lt;a href="https://knative.dev/"&gt;KNative&lt;/a&gt;, &lt;a href="https://jenkins-x.io/"&gt;Jenkins-X&lt;/a&gt; (which also uses Tekton), &lt;a href="https://spinnaker.io/"&gt;Spinnaker&lt;/a&gt; and &lt;a href="https://docs.gitlab.com/ee/ci/"&gt;Gitlab CI&lt;/a&gt; with Kubernetes executors if you are on Gitlab, &lt;a href="https://github.com/features/actions"&gt;Github Actions&lt;/a&gt; if you are on Github and so on giving you a myriad of options like &lt;a href="https://fluxcd.io/"&gt;FluxCD&lt;/a&gt;, &lt;a href="https://argoproj.github.io/argo-cd/"&gt;ArgoCD&lt;/a&gt;, etc. to play with.&lt;/p&gt;

&lt;p&gt;When doing CI/CD on Kubernetes, you can either leave the runner to be hosted by your service provider (eg. Github/Gitlab hosted runners) or host your own runner on the K8 clusters you want. Either way, you will get the power to scale the runners as much as you need and run multiple pipelines parallelly without blocking others.&lt;/p&gt;

&lt;p&gt;Your runner can take the job of pulling your code or binaries from the version control, building the image out of it, pushing it to the registry and also finally deploy it to the target clusters after all the necessary tests and checks are done.&lt;/p&gt;

&lt;p&gt;Otherwise, the way you would do CI/CD in a cloud native world is similar to that of any other CI/CD pipeline.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I do serverless in Kubernetes?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Well, you always have servers. Serverless according to me is nothing but abstractions which helps you forget about the servers and all the complexities and scalability behind allowing you to focus on just the business logic at hand and Kubernetes allows you to do this as well.&lt;/p&gt;

&lt;p&gt;You can opt for projects like &lt;a href="https://knative.dev/"&gt;KNative&lt;/a&gt;, &lt;a href="https://www.openfaas.com/"&gt;OpenFaas&lt;/a&gt; or &lt;a href="https://kubeless.io/"&gt;Kubeless&lt;/a&gt; all of which allow you to run serverless workloads on Kubernetes. But if you are using cloud providers like GKE, they provide their own solution like &lt;a href="https://cloud.google.com/run"&gt;Cloud Run&lt;/a&gt; which comes closer to hosting your own serverless platform. Ultimately, the containers spin up/down in your cluster depending on the compute they need.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I choose my cloud provider?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is a huge debate to have and can depend on both your use case and a lot of other factors.&lt;/p&gt;

&lt;p&gt;But there are few things to keep in mind while choosing a cloud provider.&lt;/p&gt;

&lt;p&gt;Make sure that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;They provide all the basic services you need to help you with your use case&lt;/li&gt;
&lt;li&gt;They provide the services at an affordable cost, even as you scale up/down&lt;/li&gt;
&lt;li&gt;They have great documentation, support and developer relations team&lt;/li&gt;
&lt;li&gt;The services they provide don't lock you in to their platform&lt;/li&gt;
&lt;li&gt;They provide services in most of the regions you would want to serve your customers in&lt;/li&gt;
&lt;li&gt;They provide a great emphasis on security, performance and usability in all their offerings&lt;/li&gt;
&lt;li&gt;They have an SLA to offer you depending on your needs and also have a good track record on quickly responding to possible incidents&lt;/li&gt;
&lt;li&gt;They satisfy all your compliance requirements and also have the necessary certifications to prove the same &lt;/li&gt;
&lt;li&gt;They have a rapid innovation culture which can support you in your future ventures or as you scale up&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These would just be few of the criteria to start with. But above all, make sure that you give it a try yourself before going for it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Where can I know more about the Cloud Native projects?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The best place to check this all out would be here: &lt;a href="https://www.cncf.io/projects/"&gt;https://www.cncf.io/projects/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While this does not cover all the Cloud Native Projects (since it only hosts projects within the CNCF foundation), this would be a great start for you depending on the domain you want to explore more on.&lt;/p&gt;

&lt;p&gt;But if you want to explore other projects, you can also have a look at the Cloud Native Landscape here: &lt;a href="https://landscape.cncf.io/"&gt;https://landscape.cncf.io/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While there are a lot of projects in that list, do note that all of them are in different stages of maturity levels ranging from Sandbox to Graduated. So, please be mindful of that when you are choosing something since it might undergo significant changes over time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are there some case studies which can actually help me in the implementation?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes, and there are lots. For a start, you can go through the Kubernetes specific case studies &lt;a href="https://kubernetes.io/case-studies/"&gt;here&lt;/a&gt; and case studies from other CNCF projects &lt;a href="https://www.cncf.io/case-studies/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you want to know more about how a specific organization uses Kubernetes, its highly likely that its already out in Youtube. Just give it a search and you can find tons of them. Or if you want to explore more, all you have to do is head over to the CloudNativecon | Kubecon and you will find a lot of speakers talking about their experience in using Kubernetes and all the tools available out there.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I contribute back to the Kubernetes and Cloud Native community?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every bit of contribution really matters. And there are a lot of ways in which you can help.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kubernetes.io/docs/contribute/"&gt;Contribute to the K8 Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/kubernetes/community/tree/master/contributors/guide"&gt;Contribute to K8&lt;/a&gt; with bug fixes, enhancements, failing tests, feedback and so on&lt;/li&gt;
&lt;li&gt;Help the community by joining the various channels within the &lt;a href="https://slack.k8s.io/"&gt;Kubernetes Slack&lt;/a&gt; community&lt;/li&gt;
&lt;li&gt;Contribute to all the &lt;a href="https://www.cncf.io/projects/"&gt;CNCF projects&lt;/a&gt; or projects from the &lt;a href="https://landscape.cncf.io/"&gt;Cloud Native landscape&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Write blogs like these, host meetups, speak in conferences about your experience and evangelize your best way possible&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.cncf.io/about/join/"&gt;Join&lt;/a&gt; the CNCF foundation and support the projects directly/indirectly&lt;/li&gt;
&lt;li&gt;Find a problem not addressed by anyone in the community? Propose and develop your own solution and contribute back to the community&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are a lot of small ways in which you can give back. Small or big does not matter. Every contribution counts.&lt;/p&gt;

&lt;p&gt;Hope this was informative. Do you have any question which I have not covered in this list or are you looking for some help or engineering advisory/consultancy? Let me know by reaching out to me &lt;a href="https://twitter.com/techahoy"&gt;@techahoy&lt;/a&gt;. I will be using this blog like a living document and will be updating it with more useful Q&amp;amp;As when I find time.&lt;/p&gt;

&lt;p&gt;If this helped, do share this across with your friends, do hang around and follow us for more like this every week. See you all soon.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>cloud</category>
      <category>devops</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Infrastructure Engineering - The Kubernetes Way</title>
      <dc:creator>t.v.vignesh</dc:creator>
      <pubDate>Fri, 01 Jan 2021 13:42:25 +0000</pubDate>
      <link>https://dev.to/timecampus/infrastructure-engineering-the-kubernetes-way-o8j</link>
      <guid>https://dev.to/timecampus/infrastructure-engineering-the-kubernetes-way-o8j</guid>
      <description>&lt;p&gt;&lt;em&gt;This blog is a part of a series on Kubernetes and its ecosystem where we will dive deep into the infrastructure one piece at a time&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the previous post, we discussed "The First Principles of Infrastructure Engineering" setting the context to this series discussing all our visions and goals when working with incrementally scalable and adaptable cloud native infrastructure to cater to the most important demands of today. With that settled, let us start our journey in this direction and see how various tools and platforms make that all happen to realize our goals.&lt;/p&gt;

&lt;p&gt;While we will talk about infrastructure, the first parallel we can draw is Kubernetes and its ecosystem itself given it addresses a major spectrum it covers and also the thriving ecosystem, community and enterprise backing around it. And that is what we are going to talk about in this blog post. On how Kubernetes addresses the various pressing challenges in the infrastructure as a whole.&lt;/p&gt;

&lt;p&gt;You may ask, is Kubernetes the only player which does this?&lt;/p&gt;

&lt;p&gt;Well, the answer is NO, and there are definitely other players like CoreOS and OpenStack. While you should choose what is best for you, there is a great future for Kubernetes and its ecosystem especially because of the huge community backing which is more evident if you take a look at the thriving landscape &lt;a href="https://landscape.cncf.io/" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;. And most of the times K8s should be a great fit for most of the use cases. &lt;/p&gt;

&lt;p&gt;But this does not stop you from using them together with CoreOS and Openstack. For instance, you can run &lt;a href="https://www.openstack.org/use-cases/containers/leveraging-containers-and-openstack/" rel="noopener noreferrer"&gt;Kubernetes on Openstack&lt;/a&gt; or &lt;a href="https://coreos.com/openstack/" rel="noopener noreferrer"&gt;Openstack on Kubernetes&lt;/a&gt; if you wish.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What does the Cloud Native Stack look like?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Just getting your application running within a Virtual Machine on a cloud provider does not make you cloud native. But as Pivotal said, &lt;em&gt;Cloud native is an approach to building and running applications that fully exploit the advantages of the cloud computing model&lt;/em&gt; which means that we need a completely different thought process on how we look at infrastructure.&lt;/p&gt;

&lt;p&gt;These are some of the important parts of the cloud native stack as mentioned by Mr.Janakiram MSV in The New Stack.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwcmlq3j3nlv1m9yzrlrj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwcmlq3j3nlv1m9yzrlrj.png" alt="The Cloud Native Stack"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And each block you see in this image is a completely separate problem to be solved when working with applications at any scale. Let us see how Kubernetes and the various tools takes up this difficult job abstracting a lot of the complex details required during onboarding and maintenance of infrastructure.&lt;/p&gt;

&lt;p&gt;(You can go through the book from The New Stack on The State of Kubernetes and its ecosystem here: &lt;a href="https://thenewstack.io/ebooks/kubernetes/state-of-kubernetes-ecosystem-second-edition-2020/" rel="noopener noreferrer"&gt;https://thenewstack.io/ebooks/kubernetes/state-of-kubernetes-ecosystem-second-edition-2020/&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compute&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every application requires some degree of computing power depending on the business logic and the demand and the infrastructure should allow for incrementally scale up or down compute as needed depending on the ever changing requirements. &lt;/p&gt;

&lt;p&gt;Kubernetes (which is essentially a project conceptualized from &lt;a href="https://kubernetes.io/blog/2015/04/borg-predecessor-to-kubernetes/" rel="noopener noreferrer"&gt;Borg&lt;/a&gt; at Google) allows for managing compute efficiently and scale it up/down as needed. &lt;/p&gt;

&lt;p&gt;The compute available for the application depends on various factors. The type of node in which you run the containers (the number of CPU cores available to the node, the processors attached, the RAM available and other accessories like GPUs in some cases which are compute intensive), the constraints you have set manually including the &lt;a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/" rel="noopener noreferrer"&gt;cpu, memory limits&lt;/a&gt;, pod affinity/anti-affinity and so on.&lt;/p&gt;

&lt;p&gt;And the best part about it is that all this compute is shared within the cluster or a specific namespace thereby allowing you to effectively manage the resources you have. And if you are not sure about the change in the computing needs, all you need to do is setup an autoscaler (&lt;a href="https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/" rel="noopener noreferrer"&gt;HPA&lt;/a&gt;, &lt;a href="https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler" rel="noopener noreferrer"&gt;VPA&lt;/a&gt;, &lt;a href="https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler" rel="noopener noreferrer"&gt;CA&lt;/a&gt;) and that will scale your compute up/down depending on the constraints you set.&lt;/p&gt;

&lt;p&gt;Now, what if you want to do serverless? Its easy when especially when you work with the Kubernetes ecosystem that you have projects like &lt;a href="https://knative.dev/" rel="noopener noreferrer"&gt;KNative&lt;/a&gt;, &lt;a href="https://www.openfaas.com/" rel="noopener noreferrer"&gt;OpenFaas&lt;/a&gt;, etc. doing exactly this (Ultimately, serverless is nothing but abstracting everything for the developers and offering the elasticity in compute as needed)&lt;/p&gt;

&lt;p&gt;Or if you are someone holding a legacy infrastructure and cannot afford to run all your compute on containers, you can go for projects like &lt;a href="https://kubevirt.io/" rel="noopener noreferrer"&gt;Kubevirt&lt;/a&gt; which allows for exactly that running containers and virtual machines side by side in your cluster.&lt;/p&gt;

&lt;p&gt;Having all these choices makes Kubernetes a great choice for managing compute at any scale.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Storage&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Managing state is difficult for a reason. Managing your storage improperly may lead to bottlenecks in your application as you scale. Every disk is limited by its IOPS (Input/Output Operations Per Second) and as you scale, the storage layer might cause quite a few problems and may often become the bottleneck.&lt;/p&gt;

&lt;p&gt;This might require clustering your storage possibly with multiple replicas and to add to this, you would also need to maintain periodic backups and handle seamless failovers. Now, while Kubernetes does have its way of managing storage using Persistent Volumes, Claims and Storage Classes it does not handle every problem with respect to storage and rather leaves it to the storage provider.&lt;/p&gt;

&lt;p&gt;Its has been possible to &lt;a href="https://kubernetes.io/docs/concepts/storage/storage-classes/#provisioner" rel="noopener noreferrer"&gt;plug in many storage provisioners to Kubernetes&lt;/a&gt; and add &lt;a href="https://kubernetes.io/docs/concepts/storage/volumes/" rel="noopener noreferrer"&gt;many volume plugins&lt;/a&gt; but the future aligns itself towards &lt;a href="https://kubernetes.io/blog/2019/01/15/container-storage-interface-ga/" rel="noopener noreferrer"&gt;CSI&lt;/a&gt; and is therefore promising for compatibility with any storage provider of your choosing.&lt;/p&gt;

&lt;p&gt;For eg. if you would like to bring in file systems like Ceph onto Kubernetes, you do have a &lt;a href="https://github.com/ceph/ceph-csi" rel="noopener noreferrer"&gt;Ceph-CSI driver&lt;/a&gt; or if you would like to reduce friction while maintaining Ceph, you can even go for something like &lt;a href="https://rook.io/docs/rook/v1.5/ceph-csi-drivers.html" rel="noopener noreferrer"&gt;Rook with Ceph CSI&lt;/a&gt;. There are many players in this space and you can read about how they perform and differ &lt;a href="https://vitobotta.com/2019/08/06/kubernetes-storage-openebs-rook-longhorn-storageos-robin-portworx/" rel="noopener noreferrer"&gt;here&lt;/a&gt; each providing different set of options including File, Block, NFS and more.&lt;/p&gt;

&lt;p&gt;If you would like to get more idea on the various storage options available, I would recommend you to watch this talk by Saad Ali from Google:&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/uSxlgK1bCuA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Network&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Networking is critical for any application since it essentially is the data path for all your requests, responses and internal communications. This becomes even more important in the Kubernetes world since your cluster is going to be composed of various pods across same or multiple namespaces each fulfilling specific responsibilities, and having the ability to communicate with each other is critical to the application's working.&lt;/p&gt;

&lt;p&gt;This is made possible with the inbuilt service discovery mechanisms from Kubernetes like &lt;a href="https://github.com/coredns/coredns" rel="noopener noreferrer"&gt;CoreDNS&lt;/a&gt; (Kubedns being its predecessor) with some help from &lt;a href="https://kubernetes.io/docs/reference/command-line-tools-reference/kube-proxy/" rel="noopener noreferrer"&gt;Kube-proxy&lt;/a&gt; and also the basic Kubernetes constructs like Services and Ingress ranging from &lt;a href="https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types" rel="noopener noreferrer"&gt;various types&lt;/a&gt; including ClusterIP, NodePort, LoadBalancer and more. &lt;/p&gt;

&lt;p&gt;Having constructs like these makes it very easier to establish communication via labels rather than having to hardcode the IP addresses or do complex routing all of which is handled by the DNS server if given the proper &lt;a href="https://kubernetes.io/docs/concepts/services-networking/dns-pod-service/#pod-s-hostname-and-subdomain-fields" rel="noopener noreferrer"&gt;FQDN&lt;/a&gt; (Fully Qualified Domain Name)&lt;/p&gt;

&lt;p&gt;Networking becomes more interesting especially with introduction to &lt;a href="https://github.com/containernetworking/plugins" rel="noopener noreferrer"&gt;CNI&lt;/a&gt; (Container Networking Interface) which has actually become the standard for all the networking abstractions (similar to what CSI does for storage). This allows users to use any CNI plugin underneath amongst the large number of &lt;a href="https://github.com/containernetworking/plugins" rel="noopener noreferrer"&gt;in-tree&lt;/a&gt; and third party plugins available like &lt;a href="https://www.projectcalico.org/" rel="noopener noreferrer"&gt;Calico&lt;/a&gt;, &lt;a href="https://www.weave.works/docs/net/latest/overview/" rel="noopener noreferrer"&gt;Weavenet&lt;/a&gt;, &lt;a href="https://coreos.com/flannel/docs/latest/" rel="noopener noreferrer"&gt;Flannel&lt;/a&gt;, etc. and you can look at a comparison of some of them &lt;a href="https://rancher.com/blog/2019/2019-03-21-comparing-kubernetes-cni-providers-flannel-calico-canal-and-weave/" rel="noopener noreferrer"&gt;here&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;CNI even empowers service mesh implementations to leverage its power. For instance, LinkerD has &lt;a href="https://linkerd.io/2/features/cni/" rel="noopener noreferrer"&gt;its own CNI plugin&lt;/a&gt; which takes care of managing the IP Table rules for every pod in the service mesh and &lt;a href="https://istio.io/latest/docs/setup/additional-setup/cni/" rel="noopener noreferrer"&gt;Istio has something similar&lt;/a&gt; too.&lt;/p&gt;

&lt;p&gt;Having all of these as Kubernetes constructs also allows us to moderate traffic using &lt;a href="https://kubernetes.io/docs/concepts/services-networking/network-policies/" rel="noopener noreferrer"&gt;Pod Network Policies&lt;/a&gt; and the possibilities are endless.&lt;/p&gt;

&lt;p&gt;All of this makes Kubernetes a great fit for networking as well. And if you would like to know more about the networking stack, I would recommend you to watch this talk by Bowei Du and Tim Hockin from Google: &lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/tq9ng_Nz9j8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Or this talk from Michael Rubin from Google: &lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/0Omvgd7Hg1I"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Container-Optimized OS&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With more and more virtualization and isolation in place, it calls for trimming down the operating system, kernel and all the packages used so that the resources can be used efficiently and there are less bugs to fix or patch. This is why a container optimized OS came into place. For instance there are distributions like &lt;a href="https://www.flatcar-linux.org/" rel="noopener noreferrer"&gt;Flatcar&lt;/a&gt; from Kinvolk, &lt;a href="https://rancher.com/docs/os/v1.x/en/" rel="noopener noreferrer"&gt;RancherOS&lt;/a&gt; from Rancher and cloud providers even maintain their own versions of COS like &lt;a href="https://cloud.google.com/container-optimized-os" rel="noopener noreferrer"&gt;this&lt;/a&gt;, &lt;a href="https://aws.amazon.com/about-aws/whats-new/2020/03/announcing-bottlerocket-a-new-open-source-linux-based-operating-system-optimized-to-run-containers/" rel="noopener noreferrer"&gt;this&lt;/a&gt; and &lt;a href="https://github.com/Azure/azure-container-networking/blob/master/docs/cni.md" rel="noopener noreferrer"&gt;this&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you would like to know on why a container optimized OS is really needed, I would recommend you to watch this talk: &lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/XT8Lt4JJEQc"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Container Runtime&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Docker initially started out as a pioneer for containers (even though cgroups and containers were used even before Docker in production) and this brought about a lot of people using Docker as the container runtime when it all started. But Kubernetes looked at it in a different way with the basic unit being a Pod. While Kubernetes initially came out with support for Docker using Shims and has been maintaining it, it recently announced that it is &lt;a href="https://kubernetes.io/blog/2020/12/02/dont-panic-kubernetes-and-docker/" rel="noopener noreferrer"&gt;deprecating Docker as the container runtime&lt;/a&gt; in favor of &lt;a href="https://kubernetes.io/blog/2016/12/container-runtime-interface-cri-in-kubernetes/" rel="noopener noreferrer"&gt;CRI&lt;/a&gt; (Container Runtime Interface), a standard which can provide way for standardization for various container runtimes including Docker, &lt;a href="https://containerd.io/" rel="noopener noreferrer"&gt;Containerd&lt;/a&gt;, &lt;a href="https://github.com/opencontainers/runc" rel="noopener noreferrer"&gt;runc&lt;/a&gt; and other runtimes to come like &lt;a href="https://cri-o.io/" rel="noopener noreferrer"&gt;CRI-O&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you would like to have a look at how they differ, &lt;a href="https://www.inovex.de/blog/containers-docker-containerd-nabla-kata-firecracker/" rel="noopener noreferrer"&gt;this&lt;/a&gt; should give a better idea and if you would like to explore more, you can also watch this talk by Phil Estes from IBM: &lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/RyXL1zOa8Bw"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Service Mesh&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Service Mesh is meant to provide you a platform to incrementally scale networking without chaos, maintain control in the communication between services and also offload a lot of operations like authentication, authorization, encryption, tracing, canary testing and more away from the application thereby reducing the complexity as your application scales. But remember, service mesh might be an overkill for small projects and those that don't work with microservices but can definitely benefit as you have scale up your application.&lt;/p&gt;

&lt;p&gt;Tools like Istio, Linkerd and Consul are known for empowering users with their great service mesh offerings each running a sidecar along side the actual container. While setting up service mesh was initially complicated, things are gradually coming to a point where there are CLIs and charts which can set up everything for you in one shot.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://smi-spec.io/" rel="noopener noreferrer"&gt;Service Mesh Interface&lt;/a&gt; (SMI) also paves way to a lot of future developments in this space bringing in a lot of standardization and interoperability without having to change the way your application works. If you would like to know more about what service mesh is and whether you really need a service mesh, you can go through &lt;a href="https://buoyant.io/service-mesh-manifesto/" rel="noopener noreferrer"&gt;this&lt;/a&gt; blog post from William Morgan, creator of Linkerd or you can also watch this talk by Brendan Burns from Microsoft: &lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/izVWk7rYqWI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Security &amp;amp; Hardening&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Security as people rightly say must be a first class citizen for everything we do. While Kubernetes is intentionally not secure by default, it provides you a lot of options and ways to secure the infrastructure and all the workloads you run on top. This can include anything from controlling access to your cluster, the namespace, controlling inter-pod traffic, preventing rootful access, scanning images for vulnerabilities and more and each needs a different approach to be used in order to reach the goal of Zero Trust Security (eg. &lt;a href="https://cloud.google.com/beyondcorp" rel="noopener noreferrer"&gt;Beyondcorp&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;There are a lot of steps to security in Kubernetes. For instance, you can use &lt;a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/" rel="noopener noreferrer"&gt;RBAC&lt;/a&gt; for authorization, encrypt the etcd store, scan the image registry using something like &lt;a href="https://github.com/quay/clair" rel="noopener noreferrer"&gt;Clair&lt;/a&gt;, adding sidecars or libraries with &lt;a href="https://www.openpolicyagent.org/" rel="noopener noreferrer"&gt;Open Policy Agent&lt;/a&gt; (OPA) to allow for defining policies as per your need, adding the appropriate &lt;a href="https://kubernetes.io/docs/tasks/configure-pod-container/security-context/" rel="noopener noreferrer"&gt;Security Contexts&lt;/a&gt; and &lt;a href="https://kubernetes.io/docs/concepts/policy/pod-security-policy/" rel="noopener noreferrer"&gt;Pod Security Policies&lt;/a&gt; to control the permissions your containers has and a lot more like configuring &lt;a href="https://linkerd.io/2/features/automatic-mtls/" rel="noopener noreferrer"&gt;MTLS&lt;/a&gt; to encrypting traffic within your mesh and so on each of which brings you one step closer to your journey with Zero Trust Security.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Container Orchestration Engine&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that we have all our major part of the underlying infrastructure in place and all the workloads we need to run on top, it is important to have an orchestration layer to manage all the infrastructure we have. This is where a project like Kubernetes falls into place. But as we discussed already, Kubernetes is not the only option out there (though its definitely the leader in this area). There are other options available like &lt;a href="https://github.com/quay/clair" rel="noopener noreferrer"&gt;OKD&lt;/a&gt; which powers Openshift, &lt;a href="https://github.com/rancher/rke" rel="noopener noreferrer"&gt;Rancher Kubernetes Engine&lt;/a&gt; (RKE) and more.&lt;/p&gt;

&lt;p&gt;And even if you go for Kubernetes, you will find various distributions depending on the cloud provider you go for or the environment you would like to run your clusters in. For instance, you could use &lt;a href="https://kubeedge.io/" rel="noopener noreferrer"&gt;Kubeedge&lt;/a&gt; if you would like to work with IOTs allowing you to run the cluster offline, optimized to run on smaller hardware with support for different processor architectures.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Build Management&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once you have your applications ready and have checked in the latest code to your version control, the next important step is to actually produce the artifacts you need in order to push the relevant images to the registry and then pull it to run in the cluster. This can be preceded by a lot of steps including scanning for vulnerabilities, running automated tests and so on all of which are typically automated in the DevSecOps flow.&lt;/p&gt;

&lt;p&gt;Some of the pioneers in this area does include &lt;a href="https://docs.gitlab.com/ee/ci/" rel="noopener noreferrer"&gt;Gitlab CI&lt;/a&gt;, &lt;a href="https://jenkins-x.io/" rel="noopener noreferrer"&gt;Jenkins-X&lt;/a&gt;, &lt;a href="https://github.com/features/actions" rel="noopener noreferrer"&gt;Github Actions&lt;/a&gt; and more which can be combined with tools like &lt;a href="https://skaffold.dev/" rel="noopener noreferrer"&gt;Skaffold&lt;/a&gt;, &lt;a href="https://github.com/containers/skopeo" rel="noopener noreferrer"&gt;Skopeo&lt;/a&gt; and the likes of it to bring about a complete pipeline to manage the builds. &lt;/p&gt;

&lt;p&gt;There are a lot of tools you can use to build your OCI compatible images. This can include going for a container builder like Docker, &lt;a href="https://github.com/moby/buildkit" rel="noopener noreferrer"&gt;Buildkit&lt;/a&gt; (again from Docker/Moby), &lt;a href="https://buildah.io/" rel="noopener noreferrer"&gt;Buildah&lt;/a&gt; and more as shared &lt;a href="https://blog.alexellis.io/building-containers-without-docker/" rel="noopener noreferrer"&gt;here&lt;/a&gt;. It all boils down to what you would like to optimize for. If you would like to know how they compare, you can have a look at the presentation by Akhiro Suda from NTT &lt;a href="https://static.sched.com/hosted_files/kccnceu19/12/Building%20images%20%20efficiently%20and%20securely%20on%20Kubernetes%20with%20BuildKit.pdf" rel="noopener noreferrer"&gt;here&lt;/a&gt; on the various builders and how they differ.&lt;/p&gt;

&lt;p&gt;If you are interested in knowing more on how to setup your CI/CD pipelines, I did write a small tutorial on configuring Skaffold with Gitlab CI/CD connecting to a GKE Cluster pushing/pulling images to/from a GCR registry &lt;a href="https://skaffold.dev/docs/tutorials/ci_cd/" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Release Management&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once the application has been tested, built, scanned and pushed the final step in the pipeline is to actually release the application to multiple environments as needed. This is where release management plays a major role. Irrespective of the tool being used, the final asset to be applied to Kubernetes is nothing but a YAML or JSON manifest providing all the details of the various resources.&lt;/p&gt;

&lt;p&gt;This is the same case even if package managers like &lt;a href="https://helm.sh/" rel="noopener noreferrer"&gt;Helm&lt;/a&gt; is used since it does nothing but template the YAML files as available with various values as supplied by the users which can later be pushed to an OCI compliant registry for versioning and sharing as releases. The &lt;a href="https://cd.foundation/" rel="noopener noreferrer"&gt;CD Foundation&lt;/a&gt; also hosts a number of projects under its umbrella meant to address exactly the same problem. &lt;/p&gt;

&lt;p&gt;If you would like to go through Continuous delivery with Kubernetes in detail, I would recommend going through &lt;a href="https://cloud.google.com/solutions/addressing-continuous-delivery-challenges-in-a-kubernetes-world" rel="noopener noreferrer"&gt;this&lt;/a&gt; from Google.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Container Registry&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As we discussed in Build Management, the artifacts generated (be it container images, helm charts, etc. ) are typically pushed to an OCI compliant registry which can then be used as the single source of truth when deploying to the Kubernetes clusters.&lt;/p&gt;

&lt;p&gt;While it all started with &lt;a href="https://hub.docker.com/" rel="noopener noreferrer"&gt;Docker Hub&lt;/a&gt; leading the way, you have other options like &lt;a href="https://quay.io/" rel="noopener noreferrer"&gt;Quay&lt;/a&gt;, &lt;a href="https://cloud.google.com/container-registry" rel="noopener noreferrer"&gt;GCR&lt;/a&gt;, &lt;a href="https://aws.amazon.com/ecr/" rel="noopener noreferrer"&gt;ECR&lt;/a&gt;, &lt;a href="https://azure.microsoft.com/en-in/services/container-registry/" rel="noopener noreferrer"&gt;ACR&lt;/a&gt; providing Image registry as a SAAS service, and if that doesn't work for you, you can even host your own private registry using something like &lt;a href="https://goharbor.io/" rel="noopener noreferrer"&gt;Harbor&lt;/a&gt; making the possibilities endless.&lt;/p&gt;

&lt;p&gt;These registries often come with features like user account management and authorization allowing you to share the same registry with multiple users and clients as needed with appropriate tokens or credentials.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Observability&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that we have a huge stack already in place, the next important thing to keep in mind is the fact that all of these have to be monitored proactively for anomalous behavior indicating possible issues, failures or changes in behavior of the entire system. This becomes really important with scale because it is very difficult to drill down on any problem with a microservices architecture in place with multiple tools and services working together unless an observability stack is in place.&lt;/p&gt;

&lt;p&gt;This is one of the places where the Kubernetes ecosystem really shines. You can go for an &lt;a href="https://www.elastic.co/what-is/elk-stack" rel="noopener noreferrer"&gt;ELK&lt;/a&gt; (Elastic, Logstash, Kibana) stack, &lt;a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-an-elasticsearch-fluentd-and-kibana-efk-logging-stack-on-kubernetes" rel="noopener noreferrer"&gt;EFK&lt;/a&gt; (Elastic, FluentD, Kibana) stack, use &lt;a href="https://prometheus.io/" rel="noopener noreferrer"&gt;Prometheus&lt;/a&gt; for metrics, &lt;a href="https://grafana.com/" rel="noopener noreferrer"&gt;Grafana&lt;/a&gt; for your dashboards, &lt;a href="https://www.jaegertracing.io/" rel="noopener noreferrer"&gt;Jaeger&lt;/a&gt; for Distributed Tracing, and so on with new players coming in like &lt;a href="https://grafana.com/oss/loki/" rel="noopener noreferrer"&gt;Loki&lt;/a&gt;, &lt;a href="https://grafana.com/oss/tempo/" rel="noopener noreferrer"&gt;Tempo&lt;/a&gt;, etc. making this space really interesting. Or if you don't want to bother maintaining this stack, you can also go for Saas providers like &lt;a href="https://www.datadoghq.com/" rel="noopener noreferrer"&gt;Datadog&lt;/a&gt;, &lt;a href="https://cloud.google.com/products/operations" rel="noopener noreferrer"&gt;GCloud Operations&lt;/a&gt; (formerly stackdriver), etc. after setting up instrumentation in the applications where applicable.&lt;/p&gt;

&lt;p&gt;Now, this becomes even more interesting if you have service mesh in your equation. You can observe and visualize a lot of application level metrics without changing the code since any sidecar like Linkerd or Envoy exposes its own set of metrics to be collected for visualization.&lt;/p&gt;

&lt;p&gt;But what about the agents which expose all the data and metrics? Things are more interesting than ever with the &lt;a href="https://medium.com/opentracing/merging-opentracing-and-opencensus-f0fe9c7ca6f0" rel="noopener noreferrer"&gt;merger between Open Tracing and Open Census&lt;/a&gt; creating &lt;a href="https://opentelemetry.io/" rel="noopener noreferrer"&gt;Open Telemetry&lt;/a&gt; which is a standard to look forward to for all observability in the future.&lt;/p&gt;

&lt;p&gt;If you would like to get a more comprehensive idea on the future (or should I say present) of observability, I would recommend going through this talk by Tom and Fredric: &lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/MkSdvPdS1oA"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Developer Experience&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This has been an area of friction so far for all the Kubernetes users since it takes quite a lot of time to get the instant feedback for the changes they do because of all the complexity with Kubernetes comes with. You have to write code, build it, push it to the registry, run it in the cluster and if you want to debug, you are left with not so great ways to do it.&lt;/p&gt;

&lt;p&gt;In other words, The Inner Dev Loop has not been that good so far with Kubernetes until recently since there has been an emergence of a huge number of tools to address this problem. Though there are a lot of tools which tries to address DevEx (Developer experience) with Kubernetes, they don't cater to every scenario out there, so you might want to choose the right tool which works for you depending on whether you use Local Clusters, Remote Clusters or Hybrid Clusters for development.&lt;/p&gt;

&lt;p&gt;Some of the tools would be &lt;a href="https://skaffold.dev/" rel="noopener noreferrer"&gt;Skaffold&lt;/a&gt; with &lt;a href="https://cloud.google.com/code" rel="noopener noreferrer"&gt;Cloud Code&lt;/a&gt;, &lt;a href="https://tilt.dev/" rel="noopener noreferrer"&gt;Tilt&lt;/a&gt;, &lt;a href="https://github.com/microsoft/mindaro" rel="noopener noreferrer"&gt;Bridge for Kubernetes&lt;/a&gt;, &lt;a href="https://okteto.com/" rel="noopener noreferrer"&gt;Okteto&lt;/a&gt;, &lt;a href="https://www.getambassador.io/docs/latest/topics/using/edgectl/" rel="noopener noreferrer"&gt;Service Preview&lt;/a&gt; with &lt;a href="https://www.telepresence.io/" rel="noopener noreferrer"&gt;Telepresence&lt;/a&gt;, &lt;a href="https://garden.io/" rel="noopener noreferrer"&gt;Garden&lt;/a&gt; and so on each addressing the similar problem differently. While they have made the job a lot easier, there is still some more way to go, since according to me, Kubernetes should essentially fade away behind the scenes allowing developers to focus just on the logic at hand but I am very sure that we are in the right path towards it.&lt;/p&gt;

&lt;p&gt;So, with this, I hope you got an idea on what the typical "Cloud Native" stack looks like and how we manage our infrastructure "The Kubernetes Way". There is a lot more we can talk about, but I will save it for the future blog posts where we will dive more deep into each part of the stack we talked about in this blog.&lt;/p&gt;

&lt;p&gt;I would just like to conclude here saying that making your application "Cloud Native" is a continuous journey since you always have room to improve in one place or another and this should be done incrementally in different phases without getting overwhelmed. Trust me, I have done it and I know how it feels, but if you start small and scale gradually, then it should be an interesting journey.&lt;/p&gt;

&lt;p&gt;Any questions? Looking for help? Feel free to reach out to me &lt;a href="https://www.twitter.com/techahoy" rel="noopener noreferrer"&gt;@techahoy&lt;/a&gt;. And if this helped, do share this across with your friends, do hang around and follow us for more like this every week. See you all soon.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>cloud</category>
      <category>microservices</category>
    </item>
    <item>
      <title>Infrastructure Engineering - The first principles</title>
      <dc:creator>t.v.vignesh</dc:creator>
      <pubDate>Sat, 19 Dec 2020 11:25:08 +0000</pubDate>
      <link>https://dev.to/timecampus/infrastructure-engineering-the-first-principles-o70</link>
      <guid>https://dev.to/timecampus/infrastructure-engineering-the-first-principles-o70</guid>
      <description>&lt;p&gt;&lt;em&gt;This blog is a part of a series on Kubernetes and its ecosystem where we will dive deep into the infrastructure one piece at a time&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There are 4 main steps typically to solving any problem out there in the world.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understanding or identifying the problem&lt;/li&gt;
&lt;li&gt;Researching or thinking of possible ways to solve the problem&lt;/li&gt;
&lt;li&gt;Working on the actual solution&lt;/li&gt;
&lt;li&gt;Publish or release your solution to your target audience for feedback&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And iterate on this entire cycle continuously. And this is typically the workflow we tend to follow for any problem irrespective of the domain.&lt;/p&gt;

&lt;p&gt;Now, if you notice this in context with Infrastructure, OPS and Software Engineering, the infrastructure itself has been taking a huge toll on the process creating a lot of friction in the workflow while it is supposed to be just a facilitator to solve the main problem at hand (unless the problem you are trying to solve is related to the infrastructure itself).&lt;/p&gt;

&lt;p&gt;But things are taking a positive direction today with the advent of various standards, platforms and tools today with Kubernetes, Docker, Terraform and various other tools leading the way sharing a path to a positive future. &lt;/p&gt;

&lt;p&gt;While I am in my journey towards building &lt;a href="https://twitter.com/timecampus"&gt;Timecampus&lt;/a&gt;, I was researching for a standard to adopt something along the lines of the &lt;a href="https://12factor.net/"&gt;Twelve Factor App&lt;/a&gt; for SAAS apps, &lt;a href="https://agilemanifesto.org/"&gt;Agile Manifesto&lt;/a&gt; for Agile development,  &lt;a href="https://principledgraphql.com/"&gt;Principled GraphQL&lt;/a&gt; for Data Graph architectures with GraphQL and so on but for the infrastructure and to my surprise noticed that there was none that I could find.&lt;/p&gt;

&lt;p&gt;So, before I start off addressing the problems Kubernetes and its ecosystem solves (or can potentially solve in the future) for infrastructure in this series, I feel that it is very important to lay down the first principles around which we should visualize infrastructure and that is what we are going to discuss in this blog post.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; These principles are from my own experience and also the knowledge I have gathered going through many case studies over time. So, feel free to interpret this in your own way or dismiss any of this if it is not a fit for your use case.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Standards, Abstractions and Encapsulation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In reality, infrastructure is composed of various components each fulfilling a specific responsibility as part of the complete stack with responsibilities ranging from networking, compute, storage and more over time with a lot of peripherals now available to use. While it is definitely healthy to have a freedom of choice and competition, it is very important to note that this should not be presented as a challenge, but be seen as an empowering force for the users.&lt;/p&gt;

&lt;p&gt;And this can only happen only if there are sensible standards and abstractions around all of these disparate components thus abstracting all the complexity away from the end users but at the same time, allowing them to modify it wherever needed. &lt;/p&gt;

&lt;p&gt;Infrastructure should be seen as nothing but a "&lt;strong&gt;Black Box&lt;/strong&gt;" which is decomposable into multiple different black boxes as needed with each black box fulfilling a separate responsibility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Automate Everything&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As discussed before, infrastructure should act as an enabler and not a bottleneck with your valuable time better spent on working on the actual problem rather than the infrastructure itself. Keeping this in mind, every operation with the infrastructure should be automated to the best extent possible. &lt;/p&gt;

&lt;p&gt;And this can be anything which is part of the process including healing, recovery, failover, deployments, migrations, upgrades, log shipping and more. If you find yourself doing something repeatedly, then consider automating since it can save countless hours of time in the future and can also prevent possible human errors in doing things manually.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Extendibility&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While it is important to abstract and encapsulate the various infrastructure components, it should also be extendible by anyone as needed via something like APIs which allows users to build on top of these components as specific to their use case.&lt;/p&gt;

&lt;p&gt;This is important cause not every use case in the world can be natively addressed and adding them all to the core would most often seem nonsensical. Keeping this in mind, a plugin driven approach is often empowering to the entire ecosystem in general.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Environmental Consistency&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While infrastructure can typically vary between different environments be it development, staging or production, across multiple different deployments be it on-premise, private and public clouds or even different cloud or on-premise providers, the experience of the user should be consistent across all these different environments abstracting the various differences between them typically as adapters.&lt;/p&gt;

&lt;p&gt;So, while users interact with the same APIs in the same way consistently across different environments, the way the APIs are handled across different environments should live as adapters or sandboxes thus acting as a compatibility layer on top of the possibly different Infrastructure APIs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Packaging and Release&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Environmental consistency also requires a consistent way in which you would typically package and release your application or the infrastructure itself. A consistent packaging and release mechanism would create no surprises when working across different environments and also help to reproduce any inconsistencies or failure events which may occur in a different environment without any issues. This also helps to properly version control various releases over time and allow users to gradually update or upgrade portions of the infrastructure as they see fit after appropriate review of the changes without forcing something onto them.&lt;/p&gt;

&lt;p&gt;This mandates the need for all components in the infrastructure to maintain its own versioned packaging and release mechanism allowing a consistent and clear upgrade path for every component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Modularity, Single Responsibility &amp;amp; Incremental Scalability&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every piece of the infrastructure as discussed before should be a black box by itself and thereby modular with its own set of APIs each fulfilling a single responsibility which are then orchestrated together to fulfill the complete use case. This not only reduces the possibility of errors creeping in with each module handling its own release cycle, but it also allows for things like incremental adoption and scalability from small to large projects just using the modules which they really need to satisfy their use case.&lt;/p&gt;

&lt;p&gt;This also allows for scalability at the module level depending on your use case.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Administration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While Infrastructure works underneath as loosely coupled modules, they should be easy to administer for end users wherever needed. It is ideally visualized as a honeycomb with each cell working on fulfilling its own responsibility.&lt;/p&gt;

&lt;p&gt;Users must be able to easily monitor and administer any of these components as needed optionally abstracting the complexity of what happens underneath offering a way to respond quickly in the advent of issues which can typically crop up in any part of the infrastructure and also allow for use cases like cost optimization where infrastructure can be effectively utilized where possible and security where the path of communication between all components is better visible for the administrator to enable them to secure it properly as needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Declarative and Self-Documenting Infrastructure as Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As we discussed above infrastructure is made of a lot of components and one thing that is common over time is "&lt;strong&gt;change&lt;/strong&gt;". We should try to architect for change and this is where Infrastructure as code really helps us to well document and orchestrate all the different states of the infrastructure over time declaratively, version control them and do it all in such a way that there is also a path to roll back to a previous state where needed.&lt;/p&gt;

&lt;p&gt;This also paves way for collaboration, reviews, automation and testing where the changes between 2 different states can be well tested in different environments and then consistently rolled out to multiple environments as needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sensible Management of State&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The problem is not in the state, but in managing it properly. Avoiding state is often difficult especially given the dynamic nature of applications today.&lt;/p&gt;

&lt;p&gt;Maintaining state improperly can cause a lot of issues in scaling your applications and the infrastructure that goes with it. So, rather than spreading the state everywhere, it is often sensible to manage the state properly and in isolation so that the rest of the application can work and scale independently of the stateful services while the stateful services can follow their own path to scalability decoupling both worlds from each other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Faster Inner Dev Loop and Agility&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While you may maintain a complex infrastructure and a rollout process for your use case, the same complexity should not be exposed during the development phase. Rather the development experience should be such a way that the infrastructure completely fades behind the scenes, and the developers just focus on getting quick feedback for all the changes they make. &lt;/p&gt;

&lt;p&gt;This can involve a lot of techniques like using sync instead of rebuilds, allowing hybrid development allowing developers to just host a portion of the infrastructure they work on locally leaving the rest in the target environment, custom network proxying, better IDE integration and more all done to speed up the inner dev loop and agility of development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;No single point of failure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For an infrastructure to be reliable, there should typically be no single point of failure, otherwise called highly available systems. This calls for decentralization of responsibilities and also to have things like redundancies and failovers where needed. But it is also important to consider that a 99.99% uptime might not be the call for every use case and hence different use cases call for different levels of redundancies and failover mechanisms making this decision completely dependent on the use case. &lt;/p&gt;

&lt;p&gt;Having said that, it is always better to design simple systems at start and incrementally scalable systems over time as the need arises. So, building highly scalable systems are a journey and not the destination by itself since more decentralization creates more complexity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Support for Seamless Collaboration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Products are often built with the effort of multiple members of a team and the same goes for infrastructure and the applications running on it as well. &lt;/p&gt;

&lt;p&gt;Keeping this in mind, it is important to support seamless ways to collaborate while working on the infrastructure facilitating parallel changes from multiple people, allowing the ability to research and experiment with any part of the infrastructure in an isolated context or sandbox without affecting the others and also the ability to share or package portions of infrastructure as needed facilitating seamless collaboration between different members and this should be done so keeping security in mind allowing only authorized personnel to make changes as needed but do so in a way without creating friction amongst users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Zero Trust Security&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As experts rightly say, security shouldn't be an afterthought but should start as the core principles when building or working with the infrastructure. It is often naïve to say that "&lt;strong&gt;This cannot be compromised&lt;/strong&gt;" since we all know what happens. Rather the thinking should be along the lines of "&lt;strong&gt;If this gets compromised, this is what will happen and this is how I will respond&lt;/strong&gt;" and this is where Zero Trust Security really plays a major role where you never trust anything or anyone at anytime (while in real life you should).&lt;/p&gt;

&lt;p&gt;This gives a first look on all the ways your infrastructure can be compromised and helps you take preventative measures and be ready for anything before the bad stuff actually does happen. This can involve anything from reviewing the access policies, reviewing the network paths, encrypting data or other PII, separating data into multiple tenants, scanning the images, reviewing the underlying infrastructure for security concerns, separating the boundary of attacks or anything similar which can either prevent or reduce the impact of the attack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Infrastructure should be dumb&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While this might sound crazy, the true fact is that the more dumb the infrastructure is the way better it is for stability and maintainability. As we mentioned above, every module should have a single responsibility and this should be in such a way that there is always a cause to a change in the infrastructure.&lt;/p&gt;

&lt;p&gt;For instance, if your infrastructure has to auto scale, it is often better to do it without introducing too much complexity to the infrastructure or its controllers itself. Rather, try to dumb it down as much as possible and use some sensible criteria either from experience or from the historical data to take decisions on the scale either manually or automatically depending on how often such changes are needed. Asking your infrastructure to do too much for you will just raise the complexity. Or if you are indeed looking to create a smart infrastructure system, try to spread the complexity rather than keeping it locked into a single component.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Discoverability&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As we discussed, there are various components to an infrastructure. Considering this, it is very important to have discoverability in mind when designing these systems since they might often need to work together to complete a specific task which can happen only if they are discoverable as and when needed.&lt;/p&gt;

&lt;p&gt;While the mechanism of discoverability itself boils down to your use case, the one thing to keep in mind is that it is better to distribute discoverability since we don't want a single point of failure and also the fact that it should be easy to understand the various calls and the network traffic well without introducing too much complexity even as the number of components and services increase over time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Eventual consistency&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Distributed systems and infrastructure are always eventually consistent considering the various factors like network latencies, bandwidth, throughput, I/O speeds and so on. So, rather than avoiding this fact, designing a system to support eventual consistency is always better since it will help you to better handle failures or data lags whenever it occurs.&lt;/p&gt;

&lt;p&gt;While there are mechanisms like distributed transactions in place to handle this problem, even such solutions are nothing but eventual consistencies with abstractions on top. Keeping this in mind, infrastructure and applications are better designed for such scenarios rather than expecting everything to be consistent every time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testability&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Testability becomes a really important part especially when you want a high degree of stability and automation in place with the constant influx of change you might have in the future. Every part of the infrastructure should be testable in isolation and also as a group to bring about a greater degree of confidence the users would have on the underlying infrastructure.&lt;/p&gt;

&lt;p&gt;This can be anything from testing the various integration points between the infrastructure to testing the logic within giving a complete picture of what went or can go wrong.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sensible defaults&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While we discuss all of these principles, effort must also be made to provide sensible defaults wherever possible allowing the users to incrementally adopt, change or scale as needed. Sensible defaults includes making every piece of infrastructure secure by default, allow basic functionalities like monitoring, logging, backups, failover, etc. without having to manually configure it to work.&lt;/p&gt;

&lt;p&gt;This can prevent a lot of issues which just happen due to the lack of knowledge users might have while working on a part of infrastructure, dumb it down for new comers and also help users to start any project as quickly as possible without going through too much of configuration to start working on something.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Seamless upgrades, updates, maintenance and failovers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While cloud providers do offer an SLA for the deployments when paid, this should not be a feature but rather the default. Upgrades, updates, failovers and maintenance should happen seamlessly without affecting the workloads running on the infrastructure. And even in case of failures, there should be a way to still serve sensible traffic to customers as and when needed avoiding possible downtime. &lt;/p&gt;

&lt;p&gt;All this can happen only if a possible failure is detected as early as possible and effort is made to switch over to healthy traffic and deployment wherever available. To the same effect, proper health checks should be in place to identify and handle failures if any in any part of the infrastructure and even handle upgrades seamlessly as they occur.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fail Quickly and Respond Sensibly&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It is not practically possible to have a 100% uptime for every portion of your infrastructure. Rather, the components should fail quickly whenever there are issues and respond sensibly whenever possible. It is often better to let failures to happen rather than suppressing them which might create a catastrophe at a future point of time.&lt;/p&gt;

&lt;p&gt;And these according to me are the most important principles to keep in mind especially when working with scalable infrastructure.&lt;/p&gt;

&lt;p&gt;Do let us know if we have missed out on something important here since I would like to treat this as a living document updating it as the need arises based on feedback from the community.&lt;/p&gt;

&lt;p&gt;Hope this has shed some light into the various things to keep in mind while working with infrastructure. But as complex as these may sound (and they are indeed complex), there are a lot of tools in the community today and a huge ecosystem which can help us do all of these (at least for the most part). &lt;/p&gt;

&lt;p&gt;As I was writing this blog post, I got a small idea of making the first principles across all the domains available for everyone at one place. &lt;br&gt;
With that aim in mind, I would like to announce the launch of a new site to do just that &lt;strong&gt;&lt;a href="https://thefirstprinciples.dev"&gt;https://thefirstprinciples.dev&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;From the next blog in this series, we will start exploring how the various tools in the ecosystem fit right in to address these various principles and solve the difficult challenges lying ahead in front of us.&lt;/p&gt;

&lt;p&gt;Any questions? Looking for help? Feel free to reach out to me &lt;a href="https://twitter.com/techahoy"&gt;@techahoy&lt;/a&gt;. And if this helped, do share this across with your friends, do hang around and follow us for more like this every week. See you all soon.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>devops</category>
      <category>docker</category>
      <category>cloud</category>
    </item>
    <item>
      <title>GraphQL - The Workflow</title>
      <dc:creator>t.v.vignesh</dc:creator>
      <pubDate>Fri, 11 Dec 2020 03:33:44 +0000</pubDate>
      <link>https://dev.to/timecampus/graphql-the-workflow-2hbn</link>
      <guid>https://dev.to/timecampus/graphql-the-workflow-2hbn</guid>
      <description>&lt;p&gt;&lt;em&gt;This blog is a part of a series on GraphQL where we will dive deep into GraphQL and its ecosystem one piece at a time&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;What an interesting journey has it been so far! We explored some of the amazing libraries, tools and frameworks which really empowers GraphQL to be what it is today with almost everything being open source created with love from the community. But, I do understand that, this can actually be overwhelming for some of you who are just starting off this journey with GraphQL and may have some trouble putting it all together to work for you.&lt;/p&gt;

&lt;p&gt;To address this, we will be talking about the workflow with GraphQL and the tools we have looked at so far and the process of taking it from development to production in this blog. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; While these steps have been ordered serially, that is just to give you a sense of understanding of the workflow. Some of these can also be deferred for later or parallelly done if working with multiple teams. So, with that in mind, let's start.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Evaluation and Research&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As we have discussed before in &lt;a href="https://dev.to/timecampus/graphql-usecase-and-architecture-422p"&gt;this blog post&lt;/a&gt;, GraphQL may not be the solution to every problem. And even if it does satisfy your use case well, this would be the first thing you would need to do. Understand why you want to use GraphQL, how you would like to use it and the ecosystem of tools you need to solve your problem. This can be done only if you introspect your use case and really get to the basics answering few obvious questions around GraphQL and your use case.&lt;/p&gt;

&lt;p&gt;Also, you have to remember that not every organization is operating at the scale of Google, Microsoft or Facebook and what works for them need not work for you. So, while you should definitely be informed on how people do things, do remember that you need to focus on what works for you and what you really need.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Get a boilerplate stack ready&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GraphQL can get overwhelming if you are re-inventing the wheel every time. From putting together your schema, resolvers, server, to the various tools you would typically use with it like linting, codegen and so on. Now, doing this every time you work on a new service is not a good use of your time.&lt;/p&gt;

&lt;p&gt;The best way to avoid this is to put together a boilerplate with all that you would typically want to use and this can become a starting point of all the services you may develop in the future. This would also involve things like setting up your GraphQL Gateway (incase you are using something like Federation or Stitching) since the gateway becomes the single point of contact for all your requests from the clients.&lt;/p&gt;

&lt;p&gt;Now if you are using something like Typescript/Javascript, the tooling you might want to start off with this stage would typically be a GraphQL server like Express GraphQL, Apollo, Helix, Mercurius or anything else which might work for you, putting together something like GraphQL Modules if you are looking to split your resolvers into multiple modules, devising a mechanism to merge together multiple GraphQL schema as the need arises with something like GraphQL Tools, setting up GraphQL Config to help all the tools work in tandem with your schema, getting Codegen and its extensions/presets setup so that you can re-use the types as generated from your schema, getting ESLint setup with your own validation rules, having something like GraphQL Inspector ready so that you can do various operations with your schema like validation, mocking and everything you would typically want as part of your tooling and even having your editor/IDE setup with appropriate extensions and tools to help you with the development process.&lt;/p&gt;

&lt;p&gt;While you can definitely iterate with this as you go along, having the barebones when you start can definitely take a lot of effort away and save a lot of time in the future.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Putting together the data graph and documentation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;All that you do with GraphQL for your use case mainly revolves around your schema and its types since that becomes the base of everything you would develop on top. Getting your data graph ready would typically be the next important step and the way you do it does not matter. You can either go the SDL-first or code-first route depending on what works well for you.&lt;/p&gt;

&lt;p&gt;You might also want to write appropriate documentation parallelly as you work on your schema, especially since GraphQL is self-documenting and it is always good to do it when you have a context of what you are doing rather than as an after-thought.&lt;/p&gt;

&lt;p&gt;Now, if you are working on a microservices architecture and you are looking to split the data graph into multiple parts to be composed or stitched from multiple services, using something like Federation or Stitching, you would also need to understand the clear boundaries of the microservices and how all of them relate to each other through the data graph.&lt;/p&gt;

&lt;p&gt;These boundaries will also decide which service hosts your resolvers/logic to go along with resolving the various fields in the schema and performing the business logic as needed in isolation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Deploying it all as per the need&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that you have your boilerplate and data graph ready, the next step you would typically do before working on your resolvers or any of your business logic is to actually deploy it all wherever you want to, and the way you are looking to do it. Be it public cloud, private cloud or on-premise as containers, VMs or bare metal.&lt;/p&gt;

&lt;p&gt;Doing this will help you proceed forward as per your architecture be it single/multi-tenant and help you resolve the major questions you might have regarding the end-end flow of data considering all the compliance policies and laws you might want to cater to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Mocking and Testing Client Consumption&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that you have everything deployed and ready, the next step you would typically do is testing it all together. Now, you might wonder how this will even work without any resolvers, or a backend to serve the data with.&lt;/p&gt;

&lt;p&gt;While you can definitely spend your time writing the resolvers, business logic or connecting your backend, you first might want to test out the end-end data flow so that you get a validation on how clients would typically interact with your GraphQL API. To do this, you can either mock your schema or hard code the data initially in your resolvers and then serve the schema and test it all end-end.&lt;/p&gt;

&lt;p&gt;This will establish a confidence about your development workflow, give you a clear idea about the data path, how your GraphQL operations (Mutations and Queries would look like), an insight into how you can consume the data and also presents you with opportunities doing things like end-end type checking, code generation and so on with your clients.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Getting the resolvers and backend setup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As you might already know, with GraphQL, your clients don't have to worry about the data source, your backend logic and the various complexities that go with it since they are all abstracted away and this helps you scale the backend and frontend independently of each other. &lt;/p&gt;

&lt;p&gt;To do this, try treating your resolvers as just entities which do an operation and respond back with data given a set of inputs (similar to what you would typically do with a REST API). So, try setting up your backend/datasources from which you would want to serve the data (be it a database like &lt;a href="https://www.postgresql.org/"&gt;Postgres&lt;/a&gt; or &lt;a href="https://www.mongodb.com/"&gt;Mongo&lt;/a&gt; with or without an ORM like &lt;a href="http://prisma.io/"&gt;Prisma&lt;/a&gt;, &lt;a href="http://knexjs.org/"&gt;Knex&lt;/a&gt; or &lt;a href="https://sequelize.org/"&gt;Sequelize&lt;/a&gt;, or even an underlying resource like a REST API maybe with something like &lt;a href="https://graphql-mesh.com/"&gt;GraphQL Mesh&lt;/a&gt; or Graph databases like &lt;a href="https://dgraph.io/"&gt;Dgraph&lt;/a&gt;) and also your resolvers to process the data as you see fit, adding your business logic on top and return back the fields as needed by the resolvers. This is the point where you replace the mocked data with data from the backend.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7: Optimizing the data path&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that you have connected your data sources and added your business logic with all the resolvers you need, the next step would typically be to optimize the data path to make sure that you are not doing repeated calls to the database increasing the load and bandwidth usage and reduce the roundtrips and processing needed as much as possible and also provide faster response times as the clients ask for data.&lt;/p&gt;

&lt;p&gt;This is where you setup things like batching and also solve N+1 problems with something like a &lt;a href="https://github.com/graphql/dataloader"&gt;dataloader&lt;/a&gt;, setup caching with something like &lt;a href="https://redis.io/"&gt;Redis&lt;/a&gt; or even an &lt;a href="https://www.npmjs.com/package/lru-cache"&gt;LRU cache&lt;/a&gt; to act as a proxy for the frequently accessed data whenever and wherever possible, optimizing the network chatter by using something like persisted queries, optimize your resolvers by retrieving as much data as possible from the parent resolvers, setting up pagination to limit the results returned, setting up things like query complexity to control the level of nesting and computation performed, rate-limiting in the gateway to avoid things like &lt;a href="https://www.cloudflare.com/learning/ddos/what-is-a-ddos-attack/"&gt;DDOS&lt;/a&gt; and so on.&lt;/p&gt;

&lt;p&gt;This is really important cause, while GraphQL might provide your clients with a high degree of flexibility, it also comes with its own set of risks if not used right. So, try to keep even the worst case scenarios in mind and design for failures. Do remember that sometimes, it is better to make your application fail and crash rather than having to make it do the wrong thing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8: Controlling and Securing the data path&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;GraphQL provides all its clients with access to any data as they request it and while this might sound empowering (and it is), it is not without its own set of risks. You have to make sure that only the authorized clients have access to the data and only the data which they are allowed to have, only when they need it providing a proper context and purpose to the operation.&lt;/p&gt;

&lt;p&gt;To do this, all the clients need to be authenticated properly whenever and however needed, authorization rules needs to be setup for all the fields either via directives, resolvers or any other mechanism which works well for you, have an encryption/decryption mechanism for confidential data like PII, ability to blacklist specific clients whenever needed and so on thereby controlling and securing the data as much as possible from your end considering that security must be a first-class citizen and not an after thought.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 9: Testing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Testing plays a major role especially when building scalable systems which have to be reliable even with a huge stream of changes which might affect it over time. And this is no exception when you work with GraphQL as well. You can setup automated tests, integration tests and so on as you normally would to improve the confidence people have on the system. And there are lot of libraries which facilitate the same as well like &lt;a href="https://mochajs.org/"&gt;Mocha&lt;/a&gt;, &lt;a href="https://jestjs.io/"&gt;Jest&lt;/a&gt;, &lt;a href="https://github.com/avajs/ava"&gt;AVA&lt;/a&gt; and so on taking a lot of the burden away from you.&lt;/p&gt;

&lt;p&gt;You can test your resolvers, your GraphQL endpoint, your schema and so on. Testing can not just improve the reliability of your code, but can also act as a secondary source of documentation for people who are looking to understand what every function is doing and how to use it as part of their workflow. So, doing this as you go along can help.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 10: Automating or Scripting the repeatable parts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you work on GraphQL or anything else for that matter, there is often a set of operations which you repeatedly do again and again. And over time, the cost of doing it would exponentially grow up. &lt;/p&gt;

&lt;p&gt;For eg. you might push your schema to a registry if you use something like federation for all the changes you do, validate/lint your schema, do code generation as you change the SDL or anything else which is specific to your use case. This is where automation and scripting plays a major role and I can definitely say that I have saved countless hours of my valuable time by just scripting out things which I do repeatedly as part of my workflow.&lt;/p&gt;

&lt;p&gt;Automation, especially with CI/CD becomes even more impactful when you are working with teams. There are a lot of interesting things you can do in your CI/CD pipeline like linting your schema and validating it, getting the list of breaking changes, pushing it to the registry, running automated tests, sending notifications to relevant people in your team as needed and so on saving a lot of time and also providing a high degree of reliability and confidence to what you ship to production.&lt;/p&gt;

&lt;p&gt;This summarizes the most important steps you need to perform as part of your workflow with GraphQL and there are somethings which have been purposefully avoided in this list like setting up your infrastructure for file uploads, enabling real-time data exchange with subscriptions/live queries and so on since it all depends on your use case at hand but if you are interested in those, do have a look at our previous blog posts where we discuss about various tools and libraries which can help you with it.&lt;/p&gt;

&lt;p&gt;While all of this may seem overwhelming, you need not boil yourself doing it all when you start but rather do it incrementally as you go along.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But, I am not using JavaScript/Typescript&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While this series addresses most of the questions with examples from Javascript and Typescript, you must take into note that Javascript / Typescript is not the only language which GraphQL is compatible with since it is language independent. And you can always draw parallels in other languages as well. If you find yourself working in other languages, &lt;a href="https://graphql.org/code/"&gt;&lt;strong&gt;this&lt;/strong&gt;&lt;/a&gt; might help or if you are looking for tutorials, there is a good catalog &lt;a href="https://www.howtographql.com/"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt; and as we discussed before, the ecosystem is too huge and growing with more like this cropping up everyday.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Concluding...&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As all good things come to an end, this blog would be the last of this GraphQL series. But if you are looking for something specific which we have not addressed in this series, do let us know and maybe we can do a follow up blog post or even add it to this series if it makes sense. The reason we conclude here is that we intend to keep this series as a guide rather than a tutorial series since there is a lot of information already out there regarding the various tools, libraries and frameworks we talked about in this series.&lt;/p&gt;

&lt;p&gt;But rest assured, we will definitely have a lot of blogs like these in the future as we work with GraphQL more and more and we also intend to provide you with a case study on how we do all of this at &lt;a href="https://twitter.com/timecampus"&gt;Timecampus&lt;/a&gt; sometime down the line. Do stick around for that. But in the meantime, there are a lot of other blog posts like &lt;a href="https://graphql.org/community/"&gt;these&lt;/a&gt; with blogs, videos and books from the community which is really worth checking out.&lt;/p&gt;

&lt;p&gt;Also, I intend to keep the blog posts in this series as living documents rather than one-off blog posts. Hence, you might find us updating the information shared if needed over time.&lt;/p&gt;

&lt;p&gt;If you are working your way through GraphQL and if this series really did help you in your path, we would love to know your story. GraphQL is where it is today because of people like you, the community, and I am very positive about its present and future especially in a data driven world and the journey towards bringing about a &lt;a href="https://en.wikipedia.org/wiki/Semantic_Web"&gt;semantic web&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you have any questions or are looking for help, feel free to reach out to me &lt;a href="https://twitter.com/techahoy"&gt;@techahoy&lt;/a&gt; anytime.&lt;/p&gt;

&lt;p&gt;And if this helped, do share this across with your friends, do hang around and follow us for more like this every week. See you all soon.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>GraphQL - The Stack #3</title>
      <dc:creator>t.v.vignesh</dc:creator>
      <pubDate>Sun, 06 Dec 2020 02:19:07 +0000</pubDate>
      <link>https://dev.to/timecampus/the-stack-3-2b7m</link>
      <guid>https://dev.to/timecampus/the-stack-3-2b7m</guid>
      <description>&lt;p&gt;&lt;em&gt;This blog is a part of a series on GraphQL where we will dive deep into GraphQL and its ecosystem one piece at a time&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In this series, we had looked at some of the interesting parts of the GraphQL stack so far with a range of tools, libraries and frameworks from the community.&lt;br&gt;
Let us continue the journey in this blog looking at more such tools and services which have created a great impact in the GraphQL ecosystem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/graphql/graphiql"&gt;GraphiQL&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The evolution of GraphQL clients have been really amazing and I would say, this is one of the great things about GraphQL given its powerful introspection capabilities,&lt;br&gt;
being self documenting and also providing ability to extend everything with extensions.&lt;/p&gt;

&lt;p&gt;It all started with GraphiQL demonstrating all these back in the day, but then came Playground (&lt;a href="https://foundation.graphql.org/news/2020/04/03/web-based-graphql-ides-for-the-win-how-why-playground-graphiql-are-joining-forces/"&gt;which had recently merged with the GraphiQL team&lt;/a&gt; to make things even more interesting),&lt;br&gt;
&lt;a href="https://github.com/imolorhe/altair"&gt;Altair&lt;/a&gt; and even desktop/web/editor based clients like &lt;a href="https://insomnia.rest/"&gt;Insomnia&lt;/a&gt;, &lt;a href="https://www.postman.com/graphql/"&gt;Postman&lt;/a&gt;, &lt;a href="https://hoppscotch.io/"&gt;Hoppscotch&lt;/a&gt;, &lt;a href="https://marketplace.visualstudio.com/items?itemName=humao.rest-client"&gt;VSCode Rest Client&lt;/a&gt; and the list&lt;br&gt;
goes on all proving that the developer experience with GraphQL can be made really better with just some sugar on top.&lt;/p&gt;

&lt;p&gt;But, some of the reasons why thinking about the future of GraphiQL feels really great is cause of the &lt;a href="https://github.com/graphql/graphiql/issues/1445"&gt;upcoming support for Monaco mode&lt;/a&gt; ,&lt;br&gt;
&lt;a href="https://github.com/graphql/graphiql/issues/983"&gt;support for plugins&lt;/a&gt; and a lot of amazing features from Playground to now become as part of GraphiQL as part of the transition according to the blog linked above.&lt;/p&gt;

&lt;p&gt;Also, embedding a GraphiQL editor is as simple as importing the HTML and related assets as specified in their &lt;a href="https://github.com/graphql/graphiql/blob/main/packages/graphiql/README.md"&gt;README&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And while the user experience is made as simple as possible, there are a huge number of components which make it all happen behind the scenes as mentioned in the README and you can have a look at&lt;br&gt;
all of them in the monorepo &lt;a href="https://github.com/graphql/graphiql/tree/main/packages"&gt;here&lt;/a&gt; and &lt;a href="https://github.com/graphql/graphql-js/tree/master/src"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--455BmQfm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8gvxby0ngpau3s8e5jll.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--455BmQfm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8gvxby0ngpau3s8e5jll.jpg" alt="GraphiQL"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source: GraphiQL&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/graphql/graphiql/tree/main/packages/codemirror-graphql"&gt;Codemirror&lt;/a&gt; used to be the interface which used to provide the editor support for GraphiQL,&lt;br&gt;
Playground, Insomnia and other editors in the ecosystem in &lt;code&gt;1.x&lt;/code&gt; which is now being succeeded by the &lt;a href="https://github.com/graphql/graphiql/tree/main/packages/graphql-language-service"&gt;language service&lt;/a&gt;&lt;br&gt;
which takes care of providing a web/desktop IDE experience if you are using editors like VSCode, &lt;a href="https://github.com/graphql/graphiql/tree/main/packages/graphql-language-service-parser"&gt;Language Parser&lt;/a&gt; which takes care of parsing the GraphQL SDL and operations you write and convert them to GraphQL AST (If you are curious about how the AST looks, like, you can try going to &lt;a href="https://astexplorer.net/"&gt;ASTExplorer&lt;/a&gt;&lt;br&gt;
select GraphQL, enter your operation and have a look at the AST which is what the final representation will look like) and so on becoming a platform for not just GraphiQL&lt;br&gt;
but the entire editor ecosystem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/OneGraph/graphiql-explorer"&gt;GraphiQL Explorer&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Starting with GraphQL or GraphiQL may actually have a learning curve for beginners since it takes a different approach to dealing with data. And even after people settle down with GraphQL, some people do feel like life was better for them when they were using something as simple as REST or GRPC.&lt;/p&gt;

&lt;p&gt;This is where tools like GraphiQL Explorer play a major role where all their queries and mutations can be constructed automatically just by checking all the fields you need from the schema.&lt;/p&gt;

&lt;p&gt;This workflow feels intuitive since it is as simple as checking all the fields you need in your client. You can read about how Onegraph solves this problem &lt;a href="https://www.onegraph.com/blog/post/2/how-onegraph-onboards-users-who-are-new-to-graphql"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is just a React component which you include with your GraphiQL instance and the rest is history.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rmXfmFeG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zkgezl8utsvmxmlk5hca.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rmXfmFeG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zkgezl8utsvmxmlk5hca.gif" alt="GraphiQL Explorer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/APIs-guru/graphql-voyager"&gt;GraphQL Voyager&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The next beautiful tool I would talk about here is the GraphQL Voyager. Infact, this is the first tool I used when I was new to GraphQL few years back and it drove me nuts seeing the potential of&lt;br&gt;
what GraphQL can do.&lt;/p&gt;

&lt;p&gt;The reason this is great is because, this leverages the complete power of introspection from GraphQL. You get to see all the entities and how they are related,&lt;br&gt;
search through the schema and also browse the docs&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jGnb-h0w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i3q0giapn7hk9hrbiy8d.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jGnb-h0w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/i3q0giapn7hk9hrbiy8d.gif" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source: GraphQL Voyager&lt;/p&gt;

&lt;p&gt;And today, &lt;a href="https://github.com/graphql-editor/graphql-editor"&gt;GraphQL Editor&lt;/a&gt; takes this one step further allowing you to view, edit, browse all the entities and&lt;br&gt;
hierarchy making it really a great tool for anyone who wants to quickly work through the schema.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/jaydenseric/graphql-upload"&gt;GraphQL Upload&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One important thing which GraphQL Spec did not discuss about is a way to transmit files over the wire when using GraphQL. This is where GraphQL Upload comes in.&lt;br&gt;
While not an official spec from GraphQL foundation, Jayden had done a great job to put together a &lt;a href="https://github.com/jaydenseric/graphql-multipart-request-spec"&gt;multi part spec&lt;/a&gt;&lt;br&gt;
to address exactly this problem.&lt;/p&gt;

&lt;p&gt;GraphQL Upload is the library which provides a great implementation of this spec with an ability to work with various frameworks. One thing to remember is that,&lt;br&gt;
while GraphQL Upload definitely does the job and works well over a significant scale, you might want to stick to HTTP for higher production workloads&lt;br&gt;
because of the &lt;a href="https://www.apollographql.com/blog/apollo-server-file-upload-best-practices-1e7f24cdc050/"&gt;reasons outlined in this blog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And if you are using something like a GraphQL Gateway with either federation or stitching, you might want to make sure that you don't overload the gateway transmitting files&lt;br&gt;
creating probable bottlenecks which can affect the rest of your requests. So, try striking a balance since GraphQL need not be a solution for every problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/enisdenjo/graphql-ws"&gt;GraphQL WS&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Subscriptions are a powerful part of GraphQL allowing you to track all the operations happening with the data in near-real time but this mandates the use of a protocol like&lt;br&gt;
websockets or use something like Server Sent Events (SSE).&lt;/p&gt;

&lt;p&gt;While &lt;a href="https://github.com/apollographql/subscriptions-transport-ws"&gt;subscription-transport-ws&lt;/a&gt; from Apollo initially started off this journey, &lt;a href="https://the-guild.dev/blog/graphql-over-websockets"&gt;it is not actively maintained&lt;/a&gt;&lt;br&gt;
and GraphQL WS by Denis definitely is a great replacement to that having no external dependencies and having the ability to work across many frameworks.&lt;/p&gt;

&lt;p&gt;But do remember that, websocket might loose its lead in the future especially with the introduction of HTTP/2 and HTTP/3 &lt;a href="https://wundergraph.com/blog/deprecate_graphql_subscriptions_over_websockets"&gt;as mentioned here&lt;/a&gt; while definitely here to stay. But this wouldn't affect GraphQL in any way since its transport independent.&lt;/p&gt;

&lt;p&gt;Also note that subscriptions are not the only way to do real time communications in GraphQL. There are also things like Live Queries with &lt;a href="https://github.com/n1ru4l/graphql-live-query"&gt;great libraries like this&lt;/a&gt; from Laurin which you can use&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.apollographql.com/docs/federation/"&gt;Apollo Federation&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While Schema Stitching was initially advocated by Apollo with introduction of many helper functions in GraphQL Tools, their &lt;a href="https://www.apollographql.com/docs/federation/migrating-from-stitching/"&gt;direction did change soon&lt;/a&gt; after hearing a lot of feedback from their customers and took their call to introduce Apollo Federation. You can read their reasoning in &lt;a href="https://www.apollographql.com/blog/apollo-federation-f260cf525d21/"&gt;this blog&lt;/a&gt; but this does not mean that &lt;a href="https://github.com/ardatan/graphql-tools/issues/1286"&gt;stitching has lost its relevance&lt;/a&gt; especially with the introduction of Type Merging.&lt;/p&gt;

&lt;p&gt;Apollo Federation does a great job especially when you use it with the rest of the ecosystem from Apollo like the &lt;a href="https://www.apollographql.com/docs/studio/"&gt;Apollo Studio&lt;/a&gt;. Apollo Stack does offer &lt;a href="https://www.apollographql.com/pricing"&gt;a lot of features&lt;/a&gt; which might be relevant to working with a data graph in an organization starting from providing a registry where you can upload parts of the combined schema from all services, version control the changes to your schema validating breaking changes, providing metrics regarding all the clients consuming the schema, tracing of all operations, multiple variants to manage multiple environments, alerting across multiple channels, and a CLI to work with all of these.&lt;/p&gt;

&lt;p&gt;And this can definitely help teams who want to maintain their own part of the schema.&lt;/p&gt;

&lt;p&gt;Federation comes with its &lt;a href="https://www.apollographql.com/docs/federation/federation-spec/#federation-schema-specification"&gt;own specification and directives&lt;/a&gt; as part of it which helps people to define all of the relations between multiple GraphQL entities so that the &lt;a href="https://github.com/apollographql/federation/tree/main/gateway-js"&gt;Apollo Gateway&lt;/a&gt; can combine them all together without having to modify the GraphQL gateway and also functions like &lt;code&gt;__resolveReference&lt;/code&gt; which helps in resolving an entity with its reference as specified by the directives.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/apollographql/apollo-tooling"&gt;The Apollo CLI&lt;/a&gt; when combined with Federation does come with a lot of helpers to take care of things like pushing the schema, listing the services in the studio, doing codegen and so on though I am not currently sure why they are &lt;a href="https://github.com/apollographql/rover"&gt;rewriting it again to Rust&lt;/a&gt; apart from the reasons as suggested &lt;a href="https://jakedawkins.com/2020-03-12-learning-rust/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let's quickly look at how Apollo Studio lets you manage the schema&lt;/p&gt;

&lt;p&gt;This is how you maintain multiple Data graphs in your organization across environments&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--32auUuFt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kzulzxejlvsb5ds8jm93.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--32auUuFt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kzulzxejlvsb5ds8jm93.PNG" alt="View Datagraph"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Browse through the schema, its types, documentation and so on&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wGdpjBeI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/td4htfka20pg0n7m54sa.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wGdpjBeI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/td4htfka20pg0n7m54sa.PNG" alt="Browse Schema"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Track the changelog of your schema over time&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qv8FW8KJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/adh95joe4mwwbat36j1h.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qv8FW8KJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/adh95joe4mwwbat36j1h.PNG" alt="Schema changelog"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Browse through the SDL of your schema&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nxHDBmHh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mljfhnlwd9tw0ydlcuv1.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nxHDBmHh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/mljfhnlwd9tw0ydlcuv1.PNG" alt="Browse SDL"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Execute GraphQL operations against your schema&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---2pPKrHZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jgq8254jkcitmbsiruqq.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---2pPKrHZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jgq8254jkcitmbsiruqq.PNG" alt="Run GraphQL Operations"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and does offer a lot more especially when you are a paying customer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; &lt;a href="https://github.com/apollographql/apollo-server/issues/2360"&gt;Federation with Apollo Server does not support subscriptions yet&lt;/a&gt; and you might want to stick with stitching if you are looking for subscriptions support or switch to some other server like Mercurius &lt;a href="https://github.com/mercurius-js/mercurius/issues/268"&gt;since it does allow subscriptions over federation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.gatsbyjs.com/"&gt;Gatsby&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Gatsby is a static site generator powered by React, GraphQL and a lot of plugins contributed by the community which helps you sites simply by pooling in data from multiple different sources in multiple different ways and it really popularized the idea of doing this all via GraphQL. If you want to know why and how Gatsby uses GraphQL, you can &lt;a href="https://www.gatsbyjs.com/docs/why-gatsby-uses-graphql/"&gt;give this a read&lt;/a&gt;. And while Gatsby does offer both &lt;a href="https://www.gatsbyjs.com/docs/glossary/server-side-rendering/"&gt;Server Side Rendering&lt;/a&gt; and &lt;a href="https://www.gatsbyjs.com/docs/glossary/static-site-generator/"&gt;Static Site Generation&lt;/a&gt;, I would say it all boils down to your &lt;a href="https://frontarm.com/james-k-nelson/static-vs-server-rendering/"&gt;usecase&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;While Gatsby did popularize the idea of using GraphQL for static sites, there are a lot of other static site generators out there like &lt;a href="https://www.11ty.dev/"&gt;Eleventy&lt;/a&gt;, &lt;a href="https://github.com/jekyll/jekyll"&gt;Jekyll&lt;/a&gt;, &lt;a href="https://gohugo.io/"&gt;Hugo&lt;/a&gt;, etc. and I find myself personally aligning towards Eleventy because of quite a few reasons which may not be right for this blog. But if you are curious, you can read blogs like &lt;a href="https://mtm.dev/static"&gt;this&lt;/a&gt; and &lt;a href="https://snipcart.com/blog/choose-best-static-site-generator"&gt;this&lt;/a&gt; which gives a comparison.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-instrumentation-graphql"&gt;Opentelemetry - GraphQL&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Opentelemetry is the new standard for instrumentation (especially after &lt;a href="https://medium.com/opentracing/a-roadmap-to-convergence-b074e5815289"&gt;Open Tracing and Open Census merging&lt;/a&gt; together) and this makes things really amazing for people since there were quite a few overlap before in between them which can now be avoided to bring about a powerful tracing standard.&lt;/p&gt;

&lt;p&gt;Opentelemetry is not specific to any language or implementation and you can find all the amazing projects from Open Telemetry hosted &lt;a href="https://github.com/open-telemetry"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, the exciting thing is that there is now a reference implementation to the same using GraphQL which you can find &lt;a href="https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-instrumentation-graphql"&gt;here&lt;/a&gt; and also an example to help you out with the same &lt;a href="https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/examples/graphql"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This when used with &lt;a href="https://www.jaegertracing.io/"&gt;Jaeger&lt;/a&gt;, &lt;a href="https://zipkin.io/"&gt;Zipkin&lt;/a&gt; or &lt;a href="https://grafana.com/oss/tempo/"&gt;Tempo&lt;/a&gt; can provide you with Traces for your GraphQL operations which you can track across your resolvers. Do note that it is not advisable to be turned on for everything since it has a performance overhead.&lt;/p&gt;

&lt;p&gt;This can give you a context on how your data and context flow irrespective of your architecture in your resolvers and functions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/APIs-guru/graphql-faker"&gt;GraphQL Faker&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/Marak/faker.js"&gt;Faker.js&lt;/a&gt; has been a great project to quickly generate mock or sample data providing various types of entities inbuilt. For eg. you can generate random addresses, images, URLs and so on, helping you to quickly test out your application without relying on the server or the backend to hold data.&lt;/p&gt;

&lt;p&gt;This has become even more amazing with GraphQL Faker since it allows you to use all the great things which Faker provides you with directives. Just define what data you want a specific field to generate by specifying the relevant directives and GraphQL Faker can actually generate all the data for you using &lt;code&gt;Faker.js&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KvpGsWnk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/szzqo51pgj3szqjck51c.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KvpGsWnk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/szzqo51pgj3szqjck51c.gif" alt="GraphQL Faker"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source: GraphQL Faker&lt;/p&gt;

&lt;p&gt;If you are using &lt;code&gt;@graphql-tools&lt;/code&gt; you can also use &lt;code&gt;faker.js&lt;/code&gt; directly and combine it with &lt;a href="https://www.graphql-tools.com/docs/mocking/"&gt;Mocking&lt;/a&gt; to get similar results, but without the need to change your SDL.&lt;/p&gt;

&lt;p&gt;While there are a lot of other tools we can discuss, the GraphQL ecosystem is huge and this pretty much has no end. But I do presume that these are all the tools you mainly need to start your GraphQL journey and leverage the ecosystem in the best way possible.&lt;/p&gt;

&lt;p&gt;But with this the GraphQL journey is still not over. We will continue the next blog discussing a few more interesting things as part of the GraphQL series.&lt;/p&gt;

&lt;p&gt;Is there anything you would like to see me address in this series? Do let me know and we can probably do that in an another post.&lt;/p&gt;

&lt;p&gt;If you have any questions or are looking for help, feel free to reach out to me &lt;a href="https://twitter.com/techahoy"&gt;@techahoy&lt;/a&gt; anytime.&lt;/p&gt;

&lt;p&gt;And if this helped, do share this across with your friends, do hang around and follow us for more like this every week. See you all soon.&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>typescript</category>
      <category>node</category>
      <category>tooling</category>
    </item>
    <item>
      <title>GraphQL - The Stack #2</title>
      <dc:creator>t.v.vignesh</dc:creator>
      <pubDate>Sun, 06 Dec 2020 02:13:27 +0000</pubDate>
      <link>https://dev.to/timecampus/the-stack-2-30me</link>
      <guid>https://dev.to/timecampus/the-stack-2-30me</guid>
      <description>&lt;p&gt;&lt;em&gt;This blog is a part of a series on GraphQL where we will dive deep into GraphQL and its ecosystem one piece at a time&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the &lt;a href="https://dev.to/timecampus/the-stack-1-1920"&gt;previous blog&lt;/a&gt;, we had started going through "The GraphQL Stack" that we use at &lt;a href="https://twitter.com/timecampus"&gt;Timecampus&lt;/a&gt; going through various libraries and tools like &lt;a href="https://code.visualstudio.com/"&gt;VSCode&lt;/a&gt;, &lt;a href="https://graphql-config.com/"&gt;GraphQL Config&lt;/a&gt;, &lt;a href="https://github.com/graphql/vscode-graphql"&gt;VSCode GraphQL&lt;/a&gt;, &lt;a href="https://github.com/dotansimha/graphql-eslint"&gt;GraphQL ESLint&lt;/a&gt;, &lt;a href="https://graphql-inspector.com/"&gt;GraphQL Inspector&lt;/a&gt;, &lt;a href="https://www.typescriptlang.org/"&gt;Typescript&lt;/a&gt;, &lt;a href="https://github.com/contrawork/graphql-helix"&gt;GraphQL Helix&lt;/a&gt; and &lt;a href="https://graphql-code-generator.com/"&gt;GraphQL Codegen&lt;/a&gt;. In this blog, we will continue our journey exploring from where we left off.&lt;/p&gt;

&lt;p&gt;Before we continue, one thing I have to say is that the GraphQL ecosystem is so huge and growing that it is not feasible to look at everything available out there in this GraphQL series, but one thing we are sure of is that, this can indeed put you a few steps ahead in your journey with GraphQL and its ecosystem. With that disclaimer, let's start.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://graphql-modules.com/"&gt;GraphQL Modules&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As we have discussed before, GraphQL does act as a single entry point for all your data giving a unified data graph which can be consumed by any client which is really powerful. But this does not mean that you have to mix up all your code in one place making it really difficult to manage.&lt;/p&gt;

&lt;p&gt;As people have already found, both &lt;a href="https://microservices.io/patterns/microservices.html"&gt;Microservices&lt;/a&gt; and &lt;a href="https://microservices.io/patterns/monolithic.html"&gt;Monolithic&lt;/a&gt; architectures comes with its own set of advantages and challenges and what you go for completely depends on your use case, the scale you need, your team and talent pool.&lt;/p&gt;

&lt;p&gt;But this does not mean that you should not keep your application non-modular irrespective of the architecture you go for. Having clear responsibilities, separation of concerns and decomposing your application into modules gives you great flexibility, power and makes your application less error prone because you just do one thing, but you do it well.&lt;/p&gt;

&lt;p&gt;Now, this is where GraphQL Modules really comes in. Yes, you can have your own way of organizing the code, your own way to pull in the schemas, your own set of tools and so on, but you don't have to reinvent every wheel there is.&lt;/p&gt;

&lt;p&gt;It helps you decompose your schema, resolvers, types and context into smaller modules with each module being completely isolated from each other, yet being able to talk to each other. And this becomes even more powerful as you scale since it comes with concepts like Dependency Injection allowing you to specify your own providers, tokens, scope and so on.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; GraphQL Modules overrides the execute call from &lt;code&gt;graphql-js&lt;/code&gt; to do all its work. So, make sure that the GraphQL server you use allows you to override it.&lt;/p&gt;

&lt;p&gt;At Timecampus, we use a microservices architecture, and every microservice is essentially a monorepo (&lt;a href="https://pnpm.js.org/en/workspaces"&gt;PNPM Workspaces&lt;/a&gt;) by itself covering a specific Domain. For instance, this is how portion of my directory structure looks like. If you notice, I am able to split every Microservice into multiple modules like this which allows me to manage the code better.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6hFdekw2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1rk9cqi0t8o0tdl774al.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6hFdekw2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1rk9cqi0t8o0tdl774al.png" alt="GraphQL Modules Directory Structure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And this is how a simple provider looks like. If you notice, this makes it very simple to comprehend. The convention I use is that, I try to group CRUD operations into a single module but it need not call for a separate microservice all by itself.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--v_t2QreJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ijjz7vlqqlyunlwgjbmt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--v_t2QreJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ijjz7vlqqlyunlwgjbmt.png" alt="Sample GraphQL Provider"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And your Mutations become as simple as this, calling the injector, doing the operations and returning the results:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KR6v6XUN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5yolw44gqcr55zz6hxjw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KR6v6XUN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5yolw44gqcr55zz6hxjw.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And finally all you have to do is compose the schema and resolvers from all the modules in your server giving a unified GraphQL endpoint you can use.&lt;/p&gt;

&lt;p&gt;Now, this becomes even more powerful if you use the &lt;a href="https://graphql-code-generator.com/docs/presets/graphql-modules"&gt;&lt;strong&gt;GraphQL Modules Preset&lt;/strong&gt;&lt;/a&gt; with Codegen since it essentially also splits your types and generates types for each GraphQL Module making things even more organized and isolated.&lt;/p&gt;

&lt;p&gt;There is a lot more that we can explore, but I will leave it at this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://graphql-mesh.com/"&gt;GraphQL Mesh&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;What if you can use GraphQL to do all your operations even when your backend systems, datasources and the services do not understand GraphQL natively and without spending time converting them to GraphQL endpoints? And what if you can aggregate and mesh all of them together with GraphQL? This is where GraphQL Mesh really comes into picture.&lt;/p&gt;

&lt;p&gt;GraphQL Mesh acts as an abstraction layer which can interface with multiple different types of backends like REST, SOAP, GraphQL, GRPC, OData, Thrift and even databases like MySQL, Neo4j and so on as documented &lt;a href="https://graphql-mesh.com/docs/handlers/available-handlers/"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;All you need to do is provide a config file &lt;code&gt;.meshrc.yaml&lt;/code&gt; and it will generate everything for you and the execution engine will take care of converting your GraphQL queries to native backend specific queries.&lt;/p&gt;

&lt;p&gt;Think of GraphQL Mesh like a universal ORM not limited to just databases but any data source or service which produces data and has an execution layer for performing operations on them.&lt;/p&gt;

&lt;p&gt;For eg. you can pass in your OpenAPI spec, and GraphQL Mesh will generate all the necessary things for you to provide a GraphQL schema which you can use.&lt;/p&gt;

&lt;p&gt;At first, I had to think a bit to see whether GraphQL Mesh is relevant to me, cause my stack completely uses GraphQL natively anyways (including my data source &lt;a href="http://dgraph.io/"&gt;Dgraph&lt;/a&gt; which supports GraphQL Natively) and hence was not sure if it suited my use case.&lt;/p&gt;

&lt;p&gt;But the more I thought about it, I started seeing GraphQL Mesh as an abstraction layer which will make my stack future-proof irrespective of all the data sources or backends I may add in the future. And the beauty of it is, there are a lot of ways in which you can use the Mesh (as a separate service, as a SDK with your service or as a gateway).&lt;/p&gt;

&lt;p&gt;I personally use GraphQL Mesh as a SDK with my services to access the backend data sources running GraphQL thereby avoiding any bottlenecks if any. And the added advantage you get here is that it makes all the operations you do fully typed.&lt;/p&gt;

&lt;p&gt;Since I am just in the initial phases of development, this is how my my &lt;code&gt;.meshrc&lt;/code&gt; file looks like where I interface with Dgraph with GraphQL Mesh&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VYIy0urF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ej0pgh1mdcsl8tuaixko.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VYIy0urF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ej0pgh1mdcsl8tuaixko.png" alt="GraphQL Meshrc file"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And when I have the SDK generated with GraphQL Mesh, all I have to do is just use the methods the SDK providers me (based on the GraphQL Mutations and Queries I have provided to it as inputs) like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IR9npNtz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9z17aim9aezlnbei9yb4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IR9npNtz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9z17aim9aezlnbei9yb4.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which makes it really powerful to use without worrying about what happens underneath. While there is a lot we can talk about GraphQL Mesh as well, I will leave it at this for now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://graphql-tools.com/"&gt;GraphQL Tools&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you talk about GraphQL, one simply cannot forget GraphQL Tools irrespective of the architecture or stack you use. Initially developed by &lt;a href="https://apollographql.com/"&gt;Apollo&lt;/a&gt; and then taken over by &lt;a href="https://the-guild.dev/"&gt;The Guild&lt;/a&gt;, GraphQL Tools provides you a very powerful set of utility functions to work with GraphQL which you can use in your services irrespective of whethere you are using something like &lt;a href="https://www.apollographql.com/docs/federation/"&gt;Apollo Federation&lt;/a&gt; or &lt;a href="https://www.graphql-tools.com/docs/stitch-combining-schemas"&gt;Schema Stitching&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It provides you a lot of utility functions which can help you do things like loading a remote GraphQL schema, merge schemas, mock schema with test data, stitch schemas together with either Type Merging or Schema extensions, enables you to write GraphQL schema directives and the list goes on.&lt;/p&gt;

&lt;p&gt;And since it is available as scoped packages &lt;code&gt;@graphql-tools&lt;/code&gt; you can just import only the modules you want and use it without adding any bloat.&lt;/p&gt;

&lt;p&gt;The reason GraphQL Tools shines is because, it stops you from reinventing the wheel, helping you focus on the other things which really matter the most in your journey with GraphQL. For eg. if you see below, I use the functions from GraphQL Tools extensively when I do operations with my schema like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fFxgVMvj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h186vwkl183o3bo0q4b0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fFxgVMvj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/h186vwkl183o3bo0q4b0.png" alt="GraphQL Tools operations"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And it also helps me write my own directives like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oSkMbSbZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lcp6n0sepmnhpvatq3vn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oSkMbSbZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lcp6n0sepmnhpvatq3vn.png" alt="GraphQL Directives"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And since I have recently moved from Federation to Stitching, I am also starting to use &lt;a href="https://www.graphql-tools.com/docs/stitch-type-merging"&gt;&lt;strong&gt;Typemerging&lt;/strong&gt;&lt;/a&gt; from GraphQL Tools to have my GraphQL Gateway setup as well like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F1ZliSjg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/36qx4gaotewptx4dmhj0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F1ZliSjg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/36qx4gaotewptx4dmhj0.png" alt="GraphQL Gateway"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are new to schema stitching with Typemerging, I would recommend you check out &lt;a href="https://github.com/gmac/schema-stitching-demos/"&gt;&lt;strong&gt;this repository&lt;/strong&gt;&lt;/a&gt; from Greg where he does a great job of explaining all the concepts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/dotansimha/graphql-typed-document-node"&gt;Typed Document Node&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Typed Document Node holds a special place in my heart cause it was only after coming across this project that I started understanding the power of marrying GraphQL and Typescript together (I had ignored Codegen and all the related tooling before coming across this since I did not understand the importance of it back then).&lt;/p&gt;

&lt;p&gt;Typed Document Node does a simple job of converting your GraphQL documents to Typescript DocumentNode objects irrespective of whether it is a query, mutation, subscription or fragment. You can have Codegen generate all the Typed Document Node types for you when you work.&lt;/p&gt;

&lt;p&gt;And the reason it is really good is cause, it works well with other libraries like &lt;code&gt;@apollo/client&lt;/code&gt; where you can pass a TypedDocumentNode object generated from your GraphQL operations and the results will also be fully typed, thus helping you to stop worrying about manually typing your GraphQL requests.&lt;/p&gt;

&lt;p&gt;For eg. this is how I use TypedDocumentNode to have all my GraphQL operations typed when calling &lt;code&gt;@apollo/client/core&lt;/code&gt; in my app.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SEMIXKg6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jcv6jep54fc8wiz6sn91.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SEMIXKg6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jcv6jep54fc8wiz6sn91.png" alt="Typed Document Node Example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All I had to do is pass the document which was generated and if you notice, even my response is fully typed.&lt;/p&gt;

&lt;p&gt;And this is how the generated Document Nodes look like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--36kgfRG4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fxsjj8e0dzdndjsvtsqt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--36kgfRG4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fxsjj8e0dzdndjsvtsqt.png" alt="Typed Document Node"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Initially I had it running on both the server and the client side but then removed it from the server side since the SDK from GraphQL Mesh was already doing this job for me.&lt;/p&gt;

&lt;p&gt;There are also plugins like &lt;a href="https://graphql-code-generator.com/docs/plugins/typescript-graphql-request"&gt;&lt;strong&gt;TypeScript GraphQL-Request&lt;/strong&gt;&lt;/a&gt; available when using Codegen which generates a SDK out of GraphQL operations. While I haven't tried it, I did not opt for it cause I did not want to get coupled to the &lt;code&gt;graphql-request&lt;/code&gt; library, and also this was fitting my use case pretty well.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://dgraph.io/"&gt;Dgraph&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;(Watch from 25:43 for my talk on Dgraph)&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/wqG9B7kx2rI"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;While Dgraph is not necessarily relevant to anyone and everyone and definitely not for legacy systems, it is of real relevance and significance for us as we work on &lt;a href="https://twitter.com/timecampus"&gt;Timecampus&lt;/a&gt;. Dgraph is a scalable and distributed Graph database written in &lt;a href="https://golang.org/"&gt;&lt;strong&gt;Golang&lt;/strong&gt;&lt;/a&gt; which understands &lt;strong&gt;GraphQL&lt;/strong&gt; natively (while it also has its own query language as well called &lt;a href="https://dgraph.io/docs/dql/"&gt;&lt;strong&gt;DQL&lt;/strong&gt;&lt;/a&gt; which is a modification of the GraphQL spec to support database specific optimizations).&lt;/p&gt;

&lt;p&gt;As I was building the product, I started off with &lt;a href="https://www.postgresql.org/"&gt;&lt;strong&gt;Postgres&lt;/strong&gt;&lt;/a&gt; with &lt;a href="https://www.prisma.io/"&gt;&lt;strong&gt;Prisma&lt;/strong&gt;&lt;/a&gt; as my ORM. But as I thought more and more and was writing code, I started noticing a few things.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All the entities were increasingly getting connected to each other to various kinds of relationships&lt;/li&gt;
&lt;li&gt;Initially I was paranoid and I had a single Postgres database instance for every microservice following the microservices architecture conventions and thus I was left with isolated pools of datasets which led me to manually do a lot of cross-service calls to get data from the other databases incase I wanted to relate them&lt;/li&gt;
&lt;li&gt;I had to clearly know which database instance had a respective schema before even making the call from a service. Hence, things were no longer an implementation detail&lt;/li&gt;
&lt;li&gt;Since I was using Prisma with Postgres (and believe me, Prisma was really amazing to work with), I also had to manage things like &lt;a href="https://www.prisma.io/docs/concepts/components/prisma-migrate"&gt;&lt;strong&gt;Migrations&lt;/strong&gt;&lt;/a&gt;, rolling them back and forth and also do this in the CI/CD pipelines which was adding more complexity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, there were a lot of other challenges I was facing other than this, but a few things I quickly realized is that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Almost all the data is connected in some way or the other (or at least the majority was)&lt;/li&gt;
&lt;li&gt;Splitting databases to multiple isolated instances per microservice was just adding more and more complexity and the effort was not worth according to me&lt;/li&gt;
&lt;li&gt;A database like Postgres (or even other like MySQL, MSSQL) was not originally designed for a microservices-like architecture (while it definitely works well with it). This makes things like horizontal scaling across multiple nodes difficult to do (while definitely possible with hacks)&lt;/li&gt;
&lt;li&gt;Also, since I ran my entire stack on Kubernetes, I was also looking for a database with Cloud Native support&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While I was aware of Graph databases before, a lot of the Graph databases are meant just for storing the edges and vertices (i.e. the relationships between various nodes) and traversing through them but does not have support for storing the data in itself for which I have to opt in for another database to read/write the data. This adds a lot of complexity to everything and you have to keep both in sync as well which makes it really hard to do.&lt;/p&gt;

&lt;p&gt;Now, Dgraph solves all these problems (and the awesome part as I already told you is that it supports GraphQL natively which gives me the ability to use all the GraphQL tools with it) .&lt;/p&gt;

&lt;p&gt;While they also offer a hosted solution called &lt;a href="https://dgraph.io/slash-graphql"&gt;&lt;strong&gt;Slash GraphQL&lt;/strong&gt;&lt;/a&gt;, I opted in for hosting Dgraph Open Source on my own since I wanted to support any environment be it hybrid cloud or on premise, wanted to have the data as close to me as possible to offer compliance.&lt;/p&gt;

&lt;p&gt;Since it exposes a GraphQL endpoint, I also run the Mesh SDK/Codegen on it and it gives me completely typed database operations with the SDK as I mentioned above.&lt;/p&gt;

&lt;p&gt;And the only tool I need to interact with it is a GraphQL client like Insomnia or VSCode Rest Client (While it does expose its own client called &lt;strong&gt;Ratel&lt;/strong&gt; for doing DQL operations and managing the database). Moreover, the database schema is nothing but a GraphQL schema. So, I had no learning curve as well.&lt;/p&gt;

&lt;p&gt;And another beautiful thing I liked about it is that, I need not worry about scalability anymore since it can be horizontally distributed, across multiple nodes or containers in my Kubernetes Cluster and scaled up/down and it can handle everything exposing a single GraphQL endpoint without me having to setup a single database per microservice.&lt;/p&gt;

&lt;p&gt;A single Graph Database instance per microservice did not make sense for me since it will effectively split the Graph into multiple pieces and the whole point of having a completely connected database graph would be lost.&lt;/p&gt;

&lt;p&gt;Also, the &lt;a href="https://dgraph.io/compare-features"&gt;feature set was quite promising&lt;/a&gt; when comparing other graph databases and the &lt;a href="https://dgraph.io/blog/post/benchmark-neo4j/"&gt;benchmarks were also quite promising&lt;/a&gt; when comparing the likes of Neo4j, but there is definitely a &lt;a href="https://github.com/neo4j/neo4j/issues/8684#issuecomment-274762913"&gt;counter argument for that&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;But the reason I find Dgraph appealing more is cause the underlying store is &lt;a href="https://github.com/dgraph-io/badger"&gt;Badger&lt;/a&gt; which is made using Golang and hence does come with its own set of advantages and performance gains. On top of this, &lt;a href="https://dgraph.io/docs/badger/projects-using-badger/"&gt;Dgraph is not the only store which uses badger&lt;/a&gt; which makes it even more exciting to use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclaimer:&lt;/strong&gt; I don't have experience running Dgraph in production (since we are on our way to launch), but there are &lt;a href="https://dgraph.io/case-studies"&gt;definitely others who have done it&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Now the reason, I added Dgraph to this stack was that Dgraph offers a great GraphQL native solution for databases. But if you are looking to go for Neo4j, it does offer a &lt;a href="https://neo4j.com/labs/grandstack-graphql/"&gt;GraphQL adapter&lt;/a&gt; too.&lt;/p&gt;

&lt;p&gt;Well, the discussion doesn't end here and there is a lot more we can talk about with respect to GraphQL and its ecosystem. We will continue in the next blog post. Hope this was insightful.&lt;/p&gt;

&lt;p&gt;If you have any questions or are looking for help, feel free to reach out to me &lt;a href="https://twitter.com/techahoy"&gt;@techahoy&lt;/a&gt; anytime.&lt;/p&gt;

&lt;p&gt;And if this helped, do share this across with your friends, do hang around and follow us for more like this every week. See you all soon.&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>typescript</category>
      <category>node</category>
      <category>tooling</category>
    </item>
    <item>
      <title>GraphQL - The Stack #1</title>
      <dc:creator>t.v.vignesh</dc:creator>
      <pubDate>Sun, 06 Dec 2020 02:04:17 +0000</pubDate>
      <link>https://dev.to/timecampus/the-stack-1-1920</link>
      <guid>https://dev.to/timecampus/the-stack-1-1920</guid>
      <description>&lt;p&gt;&lt;em&gt;This blog is a part of a series on GraphQL where we will dive deep into GraphQL and its ecosystem one piece at a time&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now that we have discussed about GraphQL, and also about some of the architectural considerations when starting off, let’s look at the next important step in the puzzle — choosing the right tech stack for your usecase and building the development workflow which suits you best in this blog.&lt;/p&gt;

&lt;p&gt;Technology changes and evolves constantly as we have already seen it happening all these days. So, rather than worrying too much about the technology you choose, it is better to choose a tool, library or platform which allows for incremental changes without lockin. Using the list in the &lt;a href="https://dev.to/timecampus/graphql-usecase-and-architecture-422p"&gt;&lt;strong&gt;previous blog post&lt;/strong&gt;&lt;/a&gt; might actually help in your decision making process.&lt;/p&gt;

&lt;p&gt;But, today I am going to assume a tech stack (the GraphQL Tech Stack that I work with everyday to build &lt;a href="https://www.twitter.com/timecampus"&gt;Timecampus&lt;/a&gt;) and walk you through. The reason I say &lt;strong&gt;“GraphQL” Tech Stack&lt;/strong&gt; is because, this is just a part of the complete stack I use and there is more to it which we will discuss sometime down the line in a different blog.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; While these work great for me, this is an area of continuous exploration for me and I don’t mind replacing X with Y as long as the effort is really worth it from a future perspective (we will explore more on what they are and why we use these as we go along). With that, let’s start.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://code.visualstudio.com/"&gt;&lt;strong&gt;VSCode&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There is no doubt that VSCode has become the defacto editor which developers user these days. And it definitely deserves the recognition and credit it gets. VSCode comes with amazing extensions and tooling for GraphQL and its ecosystem built by the community and if you work with GraphQL and Typescript, I would say it is pretty much a standard editor which you would definitely want to use.&lt;/p&gt;

&lt;p&gt;For instance, just do a search for “GraphQL” in the marketplace, and this is what you get:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZRL07bsl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/s5k5honjlal2gh16zbxg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZRL07bsl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/s5k5honjlal2gh16zbxg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;and the ecosystem is growing even more everyday and this makes VSCode indispensable for our stack.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://graphql-config.com/"&gt;&lt;strong&gt;GraphQL Config&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GraphQL Config acts as a single configuration point for all that we do with GraphQL. This is important because when working on projects, it is important to have little to no repetition (DRY principle) and having a separate config file for every tool will start getting overwhelming and messy over time since we will have multiple places to maintain.&lt;/p&gt;

&lt;p&gt;We can specify all that we want regarding GraphQL in a single &lt;code&gt;.graphqlrc&lt;/code&gt; file as mentioned in the docs starting from the location to the schema, the GraphQL documents (queries and mutations), and also the configuration for extensions which we use with it.&lt;/p&gt;

&lt;p&gt;Not just this, a single &lt;code&gt;.graphqlrc&lt;/code&gt; file can be used to specify all the configuration you need for multiple projects that you use in your workspace.&lt;/p&gt;

&lt;p&gt;For eg. it can integrate with our VSCode GraphQL extension to provide autocompletion, intellisense and so on, provide all the config needed to do code generation with GraphQL codegen, linting with GraphQL ESLint and can also pave way to all the other tools we may integrate in the future.&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;.graphqlrc.yml&lt;/code&gt; file may look something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P1T4fpW1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/92zj64h5kxe26nf149h8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P1T4fpW1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/92zj64h5kxe26nf149h8.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GraphQL Config Snippet&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/graphql/vscode-graphql"&gt;&lt;strong&gt;VSCode GraphQL&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next thing which comes to mind is a VSCode extension which can provide the support for all the things you need to do with GraphQL. Originally developed by the amazing people at &lt;a href="https://www.prisma.io/"&gt;&lt;strong&gt;Prisma&lt;/strong&gt;&lt;/a&gt; this extension was later donated to the &lt;a href="https://foundation.graphql.org/"&gt;&lt;strong&gt;GraphQL Foundation&lt;/strong&gt;&lt;/a&gt; and the reason this extension is really promising is because, it provides everything you need to work with GraphQL including syntax highlighting, autocompletion, validation, SDL navigation, execute, operations, support for tagged template literals and all of this with support for GraphQL Config and it works great.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; If you are using the Apollo Stack (like Federation), I would recommend you to go with &lt;a href="https://www.apollographql.com/docs/devtools/editor-plugins/"&gt;&lt;strong&gt;Apollo VSCode&lt;/strong&gt;&lt;/a&gt; instead since it provides support for things like &lt;code&gt;apollo.config.js&lt;/code&gt; (which integrates with the schema registry), federation directives and so on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/dotansimha/graphql-eslint"&gt;&lt;strong&gt;GraphQL ESLint&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The next thing which is important when you work with GraphQL as a team is following a set of standards so that everyone is on the same page. This is where using a linter like GraphQL ESLint would really help. The beauty is that it integrates seamlessly with GraphQL Config, supports ESLint natively and also provides some &lt;a href="https://github.com/dotansimha/graphql-eslint/blob/master/docs/README.md"&gt;&lt;strong&gt;inbuilt rules&lt;/strong&gt;&lt;/a&gt; which is a great start to work with like consistent case, making naming of operations mandatory, forcing a deprecation reason and so on which can be of great use as you scale up with GraphQL.&lt;/p&gt;

&lt;p&gt;A sample &lt;code&gt;.eslintrc&lt;/code&gt; file to be used for GraphQL ESLint would look something like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--afBgtmch--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/k9g8ilodbabai0rrlkd3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--afBgtmch--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/k9g8ilodbabai0rrlkd3.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GraphQL ESLint snippet&lt;/p&gt;

&lt;p&gt;&lt;a href="https://graphql-inspector.com/"&gt;&lt;strong&gt;GraphQL Inspector&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;How do you make collaborating with GraphQL very easy? And how do you do this in such a way that you have all the information you need to take a specific action? What if there are breaking changes to your schema? Errors and issues may creep in anywhere and at anytime.&lt;/p&gt;

&lt;p&gt;This is where GraphQL inspector comes in. It provides a platform with various functionalities like schema validation, coverage, finding similar operations, inspecting the difference between different versions of the schema, mock your schema with test data and also a Github application to do all this for you when you raise a pull request.&lt;/p&gt;

&lt;p&gt;For eg. this is how finding the coverage of your operations against the schema looks like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uw4OmG20--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sj06b4nuvz5ufdn0e6cy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uw4OmG20--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/sj06b4nuvz5ufdn0e6cy.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GraphQL Coverage&lt;/p&gt;

&lt;p&gt;And if you want to find similar fields/types within your schema, this is how it will look like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--owVorOnG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/29xnkze9vwbbzlftcvmw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--owVorOnG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/29xnkze9vwbbzlftcvmw.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GraphQL Similarity&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.typescriptlang.org/"&gt;&lt;strong&gt;Typescript&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When I initially started off with Typescript few years ago, I was not sure of the advantages it would provide me over time for the effort I am putting in to make the code I write completely typed. To be honest, it takes a lot of effort and sometimes can be painful. But, this perception changed over time especially when I started working with GraphQL and Typescript.&lt;/p&gt;

&lt;p&gt;The reason GraphQL works great with Typescript is mainly because of a lot of similarities between them with both being strongly typed, providing a clear path to documentation, offering great validations and also a great ecosystem built both on top of Typescript and GraphQL.&lt;/p&gt;

&lt;p&gt;This will become more evident as we go through this blog. But, writing the types manually for each and every field in the schema or for every operation and keeping them updated can be a huge task. This is where a lot of amazing tools come in like GraphQL Codegen, Typed Document Node, Typegraphql and so on.&lt;/p&gt;

&lt;p&gt;And on top of this, the beauty is that, with GraphQL and Typescript, we can actually make the end-end stack fully typed (which is what we do at &lt;a href="https://www.twitter.com/timecampus"&gt;Timecampus&lt;/a&gt;). And after seeing all this happening, even &lt;code&gt;graphql-js&lt;/code&gt; is on its &lt;a href="https://github.com/graphql/graphql-js/issues/2104"&gt;path to migration with Typescript&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/contrawork/graphql-helix"&gt;&lt;strong&gt;Graphql Helix&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are a lot of GraphQL servers out there. And we even spoke about some of those in our &lt;a href="https://dev.to/blog/graphql-deep-dive-1"&gt;&lt;strong&gt;first blog post&lt;/strong&gt;&lt;/a&gt;. While it is not necessary to pick an out of the box GraphQL server since you can build your own using &lt;code&gt;graphql-js&lt;/code&gt; , it may not be a smart choice since you might not want to reinvent the wheel.&lt;/p&gt;

&lt;p&gt;This is where I use GraphQL Helix which provides me a GraphQL server and also the option to selectively replace any module that I need to work for your usecase. This is very evident from the &lt;a href="https://github.com/contrawork/graphql-helix/tree/master/examples"&gt;&lt;strong&gt;examples folder&lt;/strong&gt;&lt;/a&gt; of the repository demonstrating various usecases like subscriptions, csp, graphql-modules, persisted-queries and so on and also with various frameworks like express, fastify, koa.&lt;/p&gt;

&lt;p&gt;And since there are no outside dependencies except for &lt;code&gt;graphql-js&lt;/code&gt; there is also no bloat to the same unlike other graphql servers. If you want to see how other GraphQL servers perform, you might want to have a look at &lt;a href="https://github.com/benawad/node-graphql-benchmarks"&gt;this&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://graphql-code-generator.com/"&gt;&lt;strong&gt;GraphQL Codegen&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We did discuss how Typescript and GraphQL works seamlessly well with each other. But what if we can generate all that we can from our SDL which provides majority of the information that one needs including name of the schema, fields, types, and so on.&lt;/p&gt;

&lt;p&gt;And this is where GraphQL Codegen plays a major role. You can generate all the types, interfaces and so on and it also comes with a lot of &lt;a href="https://graphql-code-generator.com/docs/plugins/index"&gt;&lt;strong&gt;plugins&lt;/strong&gt;&lt;/a&gt; and &lt;a href="https://graphql-code-generator.com/docs/presets/presets-index"&gt;&lt;strong&gt;presets&lt;/strong&gt;&lt;/a&gt; to help you work with not just Typescript, but also other languages and tooling. All we have to do is import the type we need and just use it making it really simple. And every time we change the schema, we can just regenerate the types. Also, it integrates seamlessly with GraphQL Config making it really easy to maintain.&lt;/p&gt;

&lt;p&gt;For eg. this is how the generated types look like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jn7mPgpc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ehgt078somf9ts6ye6pp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jn7mPgpc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ehgt078somf9ts6ye6pp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are more tools, libraries and platforms we have to talk about as part of our GraphQL Stack and we will be continuing our discussion in the next blog post. Hope this was insightful.&lt;/p&gt;

&lt;p&gt;If you have any questions or are looking for help, feel free to reach out to me &lt;a href="https://twitter.com/techahoy"&gt;@techahoy&lt;/a&gt; anytime.&lt;/p&gt;

&lt;p&gt;And if this helped, do share this across with your friends, do hang around and follow us for more like this every week. See you all soon.&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>typescript</category>
      <category>node</category>
      <category>tooling</category>
    </item>
    <item>
      <title>GraphQL - Usecase and Architecture</title>
      <dc:creator>t.v.vignesh</dc:creator>
      <pubDate>Sun, 06 Dec 2020 01:56:14 +0000</pubDate>
      <link>https://dev.to/timecampus/graphql-usecase-and-architecture-422p</link>
      <guid>https://dev.to/timecampus/graphql-usecase-and-architecture-422p</guid>
      <description>&lt;p&gt;&lt;em&gt;This blog is a part of a series on GraphQL where we will dive deep into GraphQL and its ecosystem one piece at a time&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In the &lt;a href="https://dev.to/timecampus/graphql-diving-deep-4hnm"&gt;&lt;strong&gt;last blog post&lt;/strong&gt;&lt;/a&gt;, we explored the various questions one might have when starting off or working with the GraphQL ecosystem and answered them. Now that justice has been done to clear the clouded thoughts you might have, let’s dive into the next important step in this blog.&lt;/p&gt;

&lt;p&gt;In this blog, we will start looking at how your architecture can look like when working with GraphQL and its ecosystem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Architecture&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Your architecture hugely revolves around your usecase and you have to be very careful in getting it right and take proper consultation if needed from experts. While it is very important to get it right before you start, mistakes can happen, and with a lot of research happening these days, you can often find any revolution happen any day which can make your old way of thinking obsolete.&lt;/p&gt;

&lt;p&gt;That is why, I would highly recommend you to &lt;strong&gt;Architect for Change&lt;/strong&gt; and make your architecture as &lt;strong&gt;Modular&lt;/strong&gt; as possible so that you have the flexibility to do incremental changes in the future if needed. Let’s just talk about architecture in context with GraphQL here. We will explore more deeper into the rest of the architecture in an another blog post.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Basics&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are some things you would have to think of before starting your journey.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Am I building a monolith or am I working on microservices?
Remember that monoliths still have a huge place in today’s world given the complexity which comes with Microservices as long as your project is small.&lt;/li&gt;
&lt;li&gt;What does my deployment target going to look like? VM, Containers or Bare Metal?&lt;/li&gt;
&lt;li&gt;What is going to be my orchestration layer? Kubernetes, Mesos, Swarm or OpenStack?&lt;/li&gt;
&lt;li&gt;What are my scaling needs?&lt;/li&gt;
&lt;li&gt;What is the performance that I expect?&lt;/li&gt;
&lt;li&gt;Do I need Offline support?&lt;/li&gt;
&lt;li&gt;Cloud or On-Premise?&lt;/li&gt;
&lt;li&gt;What is the programming language which makes sense for my usecase?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This list is incomplete. There are more questions like these which you might want to answer yourself and answering this can give you a lot of clarity as you start building your architecture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Ingress / Load Balancer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the first layer that any client would typically hit before making requests to your GraphQL service. This acts as the single entry point for all traffic (it can be regional as well depending on your usecase).&lt;/p&gt;

&lt;p&gt;This would be the first thing you would have to setup before getting started and this is also the layer which handles things like SSL termination, caching (in case you have a CDN setup) and so on.&lt;/p&gt;

&lt;p&gt;If you are in the Kubernetes world, you also have a lot of ingress controllers like &lt;a href="https://kubernetes.github.io/ingress-nginx/"&gt;&lt;strong&gt;Nginx Ingress&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://www.getambassador.io/"&gt;&lt;strong&gt;Ambassador&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://konghq.com/"&gt;&lt;strong&gt;Kong&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://projectcontour.io/"&gt;&lt;strong&gt;Contour&lt;/strong&gt;&lt;/a&gt; and so on which can help.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The API Gateway&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first thing would be the entry point of all your GraphQL requests. Since GraphQL exposes a single endpoint eg. &lt;code&gt;/graphql&lt;/code&gt; this becomes the single entry point for all your operations.&lt;/p&gt;

&lt;p&gt;But, I highly wouldn’t recommend directly exposing your service to client since it can be unsecure, difficult to manage things like rate-limiting, load balancing and so on.&lt;/p&gt;

&lt;p&gt;Rather, it is always recommended to expose it via an API Gateway of your choice. Be it Ambassador, Kong, WSO2, Apigee or anything else for that matter. This can also act as sort of a kill switch or can also be used for things like filtering and moderating traffic whenever needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The GraphQL Gateway&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As you evolve, you might end up having multiple services or might even move to the microservices world to enable scale. Now, this means multiple services with its own GraphQL schema, logic and so on.&lt;/p&gt;

&lt;p&gt;But unlike REST, GraphQL exposes a single endpoint irrespective of the underlying services. This is where a Gateway plays a major role and comes in at the next layer of our architecture. The role of orchestrating or composing (both are different) multiple services and schemas together, delegating queries and mutations to the respective microservices and all of this without the client having to worry about the complexity underneath.&lt;/p&gt;

&lt;p&gt;While you may choose to go for different architectures like &lt;a href="https://graphql-tools.com/docs/schema-stitching"&gt;&lt;strong&gt;Schema Stitching&lt;/strong&gt;&lt;/a&gt; or &lt;a href="https://www.apollographql.com/docs/federation/"&gt;&lt;strong&gt;Federation&lt;/strong&gt;&lt;/a&gt; depending on your usecase, do remember that sometimes, this may be an overkill. You might not even need a GraphQL Gateway to start with if you are building something small and this can reduce a lot of complexity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The GraphQL Service&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The next thing to think of would be the GraphQL service itself (be it a monolith or microservice). Each service would be responsible for a part of the complete data graph as seen in &lt;a href="https://principledgraphql.com/integrity#2-federated-implementation"&gt;&lt;strong&gt;Federated Implementation&lt;/strong&gt;&lt;/a&gt; and this will make things easier to scale. Note that the way you implement it can be different as discussed (Schema Stitching or Federation).&lt;/p&gt;

&lt;p&gt;You might also want to modularize your project structure and code within the service and this is applicable irrespective of whether you use a monolith or microservice to maintain clear separation of concerns, make everything composable and modular as possible.&lt;/p&gt;

&lt;p&gt;While you can end up discovering your own way to do it (I initially went down this path), but what is the use of re-inventing the wheel when you have something like &lt;a href="https://graphql-modules.com/"&gt;&lt;strong&gt;GraphQL Modules&lt;/strong&gt;&lt;/a&gt; which can help you with this.&lt;/p&gt;

&lt;p&gt;You might also want to get your tooling right to reduce as much work you do as possible. Be it linting and validation, code generation, testing, and so on so that you automate most of your workflow and you stay productive while working on any part of the service.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Mode of Communication&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now that you have thought about the service(s), you might also want to think about the mode of communication in between them which is essential to pass data to and fro, synchronously and asynchronously. This also presents some questions which you might want to answer first before starting.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;https (&lt;a href="https://tools.ietf.org/html/rfc2616"&gt;&lt;strong&gt;1.1&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://tools.ietf.org/html/rfc7540"&gt;&lt;strong&gt;2&lt;/strong&gt;&lt;/a&gt; or &lt;a href="https://tools.ietf.org/html/draft-ietf-quic-http-32"&gt;&lt;strong&gt;3&lt;/strong&gt;&lt;/a&gt;) or &lt;a href="https://grpc.io/"&gt;&lt;strong&gt;grpc&lt;/strong&gt;&lt;/a&gt; (over http/2) or &lt;a href="https://thrift.apache.org/"&gt;&lt;strong&gt;Thrift&lt;/strong&gt;&lt;/a&gt; or &lt;a href="https://tools.ietf.org/html/rfc6455"&gt;&lt;strong&gt;Websockets&lt;/strong&gt;&lt;/a&gt;?&lt;/li&gt;
&lt;li&gt;Do you need a &lt;a href="https://smi-spec.io/"&gt;&lt;strong&gt;Service Mesh&lt;/strong&gt;&lt;/a&gt;?&lt;/li&gt;
&lt;li&gt;Is GraphQL going to be used for communicating between services?&lt;/li&gt;
&lt;li&gt;Do I need something like &lt;a href="https://linkerd.io/2/features/automatic-mtls/"&gt;&lt;strong&gt;MTLS&lt;/strong&gt;&lt;/a&gt; for securing inter-service communication?&lt;/li&gt;
&lt;li&gt;How do I do asynchronous communication? Do I use event queues like &lt;a href="https://kafka.apache.org/"&gt;&lt;strong&gt;Kafka&lt;/strong&gt;&lt;/a&gt;, &lt;a href="https://www.rabbitmq.com/"&gt;&lt;strong&gt;RabbitMQ&lt;/strong&gt;&lt;/a&gt; or &lt;a href="https://nats.io/"&gt;&lt;strong&gt;NATS&lt;/strong&gt;&lt;/a&gt; ?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Again, all of these depend on your usecase and hence, there is no definite answer to this. But, try to go for a protocol which offers you less latency, great compatibility with built in support for things like compression, encryption and so on.&lt;/p&gt;

&lt;p&gt;This matters cause while all the clients would communicate with the GraphQL endpoint you expose, you still would have to have some sort of efficient way to do inter-service communication.&lt;/p&gt;

&lt;p&gt;Even if you are going to communicate between your service with GraphQL (which is what I do), you still have to decide how you transmit the GraphQL queries and mutations in between them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Authentication &amp;amp; Control&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Like we discussed in the &lt;a href="https://dev.to/timecampus/graphql-diving-deep-4hnm"&gt;&lt;strong&gt;previous blog post&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; there are various ways to do authentication and authorization. You might want to consider them as well while architecting cause this will decide how chatty your services will be when doing operations, how secure will it be, and so on. There are various ways as we spoke about, both stateful and stateless. While stateless would be better for scalability, you might want to choose what works best for you.&lt;/p&gt;

&lt;p&gt;Depending on your usecase, you might also want to decide if you need something like persisted queries or not. This can prevent clients from sending queries which are not authorized, prevent huge amounts of GraphQL data from being passed over the wire, and so on.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Backend&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And then comes the backend which you are going to use to store/retrieve data from. There are a huge number of options out there and to be honest, there is no one database which fits all usecases. And they even come with different variants — SQL, NoSQL, Search, Time Series and even Graph Databases. You can refer &lt;a href="https://db-engines.com/en/ranking"&gt;&lt;strong&gt;DBEngines&lt;/strong&gt;&lt;/a&gt; for a complete list.&lt;/p&gt;

&lt;p&gt;And you can even put a GraphQL layer or ORM on top of all of them if you want and take the complexity away from the services (eg. with &lt;a href="https://www.prisma.io/"&gt;&lt;strong&gt;Prisma 2&lt;/strong&gt;&lt;/a&gt; or &lt;a href="https://graphql-mesh.com/"&gt;&lt;strong&gt;GraphQL Mesh&lt;/strong&gt;&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;You might also want to look at how you minimize the amount of calls you make to the main database. Do you need caching and have it setup? Have you addressed the N+1 problem with &lt;a href="https://github.com/graphql/dataloader"&gt;&lt;strong&gt;Dataloader&lt;/strong&gt;&lt;/a&gt;?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;More Exploration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, there are a lot of other things you might want to have in your architecture like Hybrid Cloud support, CI/CD pipelines, caching and so on. We will probably explore them in future blog posts as we go along.&lt;/p&gt;

&lt;p&gt;Remember to keep your stack as simple as possible and you can incrementally have them setup as you go along.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some Tips&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When architecting applications, I try to use the &lt;a href="https://medium.com/timecampus/the-power-of-black-box-a7d8a320e557"&gt;&lt;strong&gt;Black Box model&lt;/strong&gt;&lt;/a&gt; as much as possible. This simplifies a lot of things for me.&lt;/li&gt;
&lt;li&gt;I try to go for the Zero Trust Security Model when building my architecture popularized by &lt;a href="https://cloud.google.com/beyondcorp"&gt;&lt;strong&gt;Beyondcorp&lt;/strong&gt;&lt;/a&gt; from Google and while this will create a lot of friction at start, this makes life a lot better for you in the future.&lt;/li&gt;
&lt;li&gt;There are some questions I ask based on the principles like &lt;a href="https://en.wikipedia.org/wiki/You_aren't_gonna_need_it"&gt;&lt;strong&gt;YAGNI&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; &lt;a href="https://en.wikipedia.org/wiki/Don't_repeat_yourself"&gt;&lt;strong&gt;DRY&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; &lt;a href="https://en.wikipedia.org/wiki/KISS_principle"&gt;&lt;strong&gt;KISS&lt;/strong&gt;&lt;/a&gt; and they play a huge role in making sure that you don’t overwhelm yourself with things you don’t want to do right now and prioritize things right.&lt;/li&gt;
&lt;li&gt;I try to refer case studies and see how others are already solving the same problem and this can help me save a lot of my time. Avoiding to re-invent the wheel. For GraphQL, you may find them &lt;a href="https://www.graphql.com/case-studies/"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Deciding the “Right” Stack for “You”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before I pick any tool or technology as part of my tech stack, I do ask a set of questions which help me better judge and make an informed decision on what I want. Probably it might help you too. This applies not just to the GraphQL ecosystem, but anything you choose for that matter.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does this tool/library solve my problem well?&lt;/li&gt;
&lt;li&gt;What is the Licensing model? Is it Open Source? If so, is it MIT/Apache/BSD/GPL&lt;/li&gt;
&lt;li&gt;Does it have community support or backed by a Foundation/Enterprise? When was the last commit? How many contributors? Does it have a clear path to becoming contributors?&lt;/li&gt;
&lt;li&gt;How many people use it in production? What are their experiences? At what scale are they using it?&lt;/li&gt;
&lt;li&gt;What does the stats look like? Stars, Forks, Downloads?&lt;/li&gt;
&lt;li&gt;Is it bloated? Or does it do just one thing well?&lt;/li&gt;
&lt;li&gt;Does it have a clear roadmap for the future? If so, what are the milestones?&lt;/li&gt;
&lt;li&gt;What are the other alternatives? How does it compare to them?&lt;/li&gt;
&lt;li&gt;How is the documentation? Does it have tests? Does it have examples which I can refer to?&lt;/li&gt;
&lt;li&gt;Does it follow standards and is free of Vendor Lockin?&lt;/li&gt;
&lt;li&gt;Are there any security concerns which this tool or library might create?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While not all of these questions might have been addressed by the library or tool well, what I see is atleast the intent to address them in near-time.&lt;/p&gt;

&lt;p&gt;While most of the things in this blog may not be related to GraphQL itself, these are some things which you need to keep in mind before starting your journey with GraphQL. In the next blog, I will show you how my GraphQL Tech Stack looks like as I use it to build &lt;a href="https://www.twitter.com/timecampus"&gt;Timecampus&lt;/a&gt; and we will dive deeper into each layer of the stack, one piece at a time.&lt;/p&gt;

&lt;p&gt;Hope this was informative. Do let us know how you prefer to architect with GraphQL in the comments below and we will be happy to know more about it.&lt;/p&gt;

&lt;p&gt;If you have any questions or are looking for help, feel free to reach out to me &lt;a href="https://twitter.com/techahoy"&gt;@techahoy&lt;/a&gt; anytime.&lt;/p&gt;

&lt;p&gt;And if this helped, do share this across with your friends, do hang around and follow us for more like this every week. See you all soon.&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>architecture</category>
      <category>typescript</category>
      <category>node</category>
    </item>
    <item>
      <title>GraphQL - Diving Deep</title>
      <dc:creator>t.v.vignesh</dc:creator>
      <pubDate>Sun, 06 Dec 2020 01:50:56 +0000</pubDate>
      <link>https://dev.to/timecampus/graphql-diving-deep-4hnm</link>
      <guid>https://dev.to/timecampus/graphql-diving-deep-4hnm</guid>
      <description>&lt;p&gt;&lt;em&gt;This blog is a part of a series on GraphQL where we will dive deep into GraphQL and its ecosystem one piece at a time&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The GraphQL specification was open sourced in 2015 by Facebook along with some basic implementations with a completely unique approach on how to structure, consume, transmit and process data and data graphs.&lt;/p&gt;

&lt;p&gt;Today, the GraphQL spec and its implementations have been donated by Facebook to the GraphQL Foundation with open license for development and governance from the community and it has been great so far.&lt;br&gt;
And today, the GraphQL foundation comprises not just of companies like Facebook but other organizational members as well.&lt;/p&gt;

&lt;p&gt;It was a moment when a lot of people were convinced by its power, utility and promise that the rest became history.&lt;/p&gt;

&lt;p&gt;And today, there is a &lt;a href="https://foundation.graphql.org/" rel="noopener noreferrer"&gt;&lt;strong&gt;GraphQL foundation&lt;/strong&gt;&lt;/a&gt; which tries to ensure that GraphQL and the ecosystem thrives over time, &lt;a href="https://github.com/graphql/graphql-landscape" rel="noopener noreferrer"&gt;&lt;strong&gt;a huge landscape of projects&lt;/strong&gt;&lt;/a&gt;, a huge set of tools like &lt;a href="https://graphql.org/code/" rel="noopener noreferrer"&gt;&lt;strong&gt;this&lt;/strong&gt;&lt;/a&gt; and &lt;a href="https://github.com/chentsulin/awesome-graphql" rel="noopener noreferrer"&gt;&lt;strong&gt;this&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
and these can just be few of the examples on how big the ecosystem has grown with a lot of languages, frameworks, tools supporting it as a first class citizen, so much so that even some of the &lt;a href="https://graphql.org/users/" rel="noopener noreferrer"&gt;&lt;strong&gt;huge enterprises&lt;/strong&gt;&lt;/a&gt; are using it today as part of their stack.&lt;/p&gt;

&lt;p&gt;GraphQL is at our heart at &lt;a href="https://www.twitter.com/timecampus" rel="noopener noreferrer"&gt;Timecampus&lt;/a&gt;, the heart of everything we do and we wanted to share the love we have for GraphQL and the ecosystem and also the hard lessons we learnt along the way. And its not just GraphQL, we will be diving deep into a lot of Open Source Tools, Libraries, Frameworks, Software and Practices as we go along.&lt;/p&gt;

&lt;p&gt;I am pretty sure that we have a lot to talk about as we go along. So, why not start the series with an FAQ? That’s what we are going to do here. I have put together a set of questions and answered them as well below.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you are new to GraphQL, I would recommend you to start with these links before jumping into this blog post:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://graphql.org/learn/" rel="noopener noreferrer"&gt;Introduction to GraphQL - Learn about GraphQL, how it works, and how to use it&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.howtographql.com/" rel="noopener noreferrer"&gt;How to GraphQL - The Fullstack Tutorial for GraphQLThe free and open-source tutorial to learn all around GraphQL to go from zero to production&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.graphql.com/tutorials/" rel="noopener noreferrer"&gt;Explore GraphQL - This is your GraphQL study guide. Learn the fundamentals of schemas and queries, then implement some apps&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://hasura.io/learn/graphql/intro-graphql/introduction/" rel="noopener noreferrer"&gt;GraphQL Tutorial - GraphQL is becoming the new way to use APIs in modern web and mobile apps. However, learning new things always takes&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.apollographql.com/blog/the-concepts-of-graphql-bc68bd819be3/" rel="noopener noreferrer"&gt;GraphQL Concepts Visualized - GraphQL is often explained as a "unified interface to access data from different sources"&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And if you are keen to dig deep into the GraphQL Spec, it is hosted &lt;a href="http://spec.graphql.org/" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, assuming you already know the basics of GraphQL, let’s jump right in.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why should I move away from REST to GraphQL? What are the benefits?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I would start by saying that GraphQL does not make REST or any other channel of communication obsolete. It all boils down to your usecase. For small projects, the simplicity of REST might overweigh the advantages provided by GraphQL but as you have more teams, an evolving product, complex lifecycles and a data schema which gets bigger and bigger by the day, that’s when you will truly realize the value that GraphQL has to offer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frsm2wi7lj1lczjmd56zb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Frsm2wi7lj1lczjmd56zb.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Credits: &lt;a href="https://www.howtographql.com/" rel="noopener noreferrer"&gt;howtographql&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In REST we try to structure different set of endpoints for different data paths, and if you see the &lt;a href="https://www.w3.org/2001/sw/wiki/REST" rel="noopener noreferrer"&gt;REST Specification&lt;/a&gt; it does not offer a way to select only the data you want leading to over-fetching/under-fetching, does not offer type checking, no way to do introspection (unless you build an OpenAPI based documentation yourself) and this can also quickly become chatty since you have to end up calling different endpoints from the client to get different sets of data needed by the application. GraphQL solves all of these like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdymv1wnferoes8gytv13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdymv1wnferoes8gytv13.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Credits: &lt;a href="https://www.howtographql.com/" rel="noopener noreferrer"&gt;howtographql&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And this is the beauty of it. It has a strong Type system, you can select just what you want avoiding over-fetching/under-fetching, you just have to talk to a single endpoint, the spec clearly defines about the execution of the queries (serial or parallel resolvers), its protocol independent unlike REST which relies on &lt;strong&gt;HTTP&lt;/strong&gt; to do everything whereas you can even transmit your GQL queries through http, GRPC, Websockets — you name it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the difference between HTTP, GRPC, GraphQL and others?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In summary, all of them are different. HTTP is a protocol by itself and does not define about the structure of the data transmitted via HTTP itself (The latest version is http 3) , &lt;a href="https://grpc.io/" rel="noopener noreferrer"&gt;GRPC &lt;/a&gt;uses protocol buffers to sends packets using http 2 as the protocol (and in the future can extend to use http 3 as well) and is often used for inter-service communications and GraphQL has nothing to do with the transport layer at all. It is just a specification for structuring and transmitting data to and fro different locations and it does not even matter even if you compress, encrypt or do anything with the queries and mutations as long as you have a logic to decompress or decrypt them on the server side. So, in summary they serve different purposes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I version my GraphQL endpoints like I do in REST?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While there is nothing stopping you from having different versions to the GraphQL endpoints like &lt;code&gt;/v1/graphql&lt;/code&gt; &lt;code&gt;/v2/graphql&lt;/code&gt; or something along the same lines, GraphQL recommends you to have a continuously evolving version of your data graph. So, you can deprecate fields you no longer use, removing them at a later point of time, add new fields as and when you need without affecting the rest of the schema avoiding any conflicts which may occur otherwise.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the recommended way to define my schema?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Over time, people have developed a lot of abstractions on top of GraphQL that suddenly there seems like there are a lot of ways to define the schema.&lt;/p&gt;

&lt;p&gt;Some ways including&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Writing the SDL directly as &lt;code&gt;.gql&lt;/code&gt; or &lt;code&gt;.graphql&lt;/code&gt; files and then loading and parsing them&lt;/li&gt;
&lt;li&gt;Using a library like &lt;a href="https://typegraphql.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Typegraphql&lt;/strong&gt;&lt;/a&gt; to write your schema as code&lt;/li&gt;
&lt;li&gt;Define them directly as JS/TS objects as defined &lt;a href="https://graphql.org/graphql-js/type/" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and there are more and more can evolve over time.&lt;/p&gt;

&lt;p&gt;One thing to understand is that, if you are using Node.js &lt;a href="https://github.com/graphql/graphql-js" rel="noopener noreferrer"&gt;graphql-js&lt;/a&gt; would typically be the underlying implementation of all libraries and ultimately everything would get converted to JS/TS objects typically an &lt;a href="https://graphql.org/graphql-js/language/" rel="noopener noreferrer"&gt;AST&lt;/a&gt; ultimately making all these as abstractions on top of the existing way to define schemas. Note that the implementation can differ a bit in other languages or even within Node.js if you are using other ways of implementation like &lt;a href="https://github.com/zalando-incubator/graphql-jit" rel="noopener noreferrer"&gt;graphql-jit&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are some of the GraphQL servers available and how do they differ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you are using Node.js there are a lot of implementations of GraphQL servers with a few being &lt;a href="https://github.com/graphql/express-graphql" rel="noopener noreferrer"&gt;express-graphql&lt;/a&gt;, &lt;a href="https://github.com/apollographql/apollo-server" rel="noopener noreferrer"&gt;apollo-server&lt;/a&gt;, &lt;a href="https://github.com/mercurius-js/mercurius" rel="noopener noreferrer"&gt;mercurius&lt;/a&gt;, &lt;a href="https://github.com/contrawork/graphql-helix" rel="noopener noreferrer"&gt;graphql-helix&lt;/a&gt; and more. And if you are using other languages, you can see a great list &lt;a href="https://graphql.org/code/" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, talking in context with Node.js it all varies depending on your usecase.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Are you dependent on &lt;a href="https://www.apollographql.com/" rel="noopener noreferrer"&gt;Apollo&lt;/a&gt; or its ecosystem like federation? Go for apollo-server&lt;/li&gt;
&lt;li&gt;Do you use &lt;a href="https://github.com/expressjs/express" rel="noopener noreferrer"&gt;express&lt;/a&gt; as your framework? Use express-graphql&lt;/li&gt;
&lt;li&gt;Are you using fastify or are looking for a performant graphql library with comprehensive support? Go for mercurius&lt;/li&gt;
&lt;li&gt;Are you looking for making things as modular as possible, reduce bloat, and progressively extend functionality as you go along? Go for graphql-helix&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Well, there are lot of things that I have not mentioned but this is just a start to decide which suggests some of the factors to keep into account.&lt;/p&gt;

&lt;p&gt;And infact, if you are keen on understanding how every graphql-server performs, I would recommend checking out &lt;a href="https://github.com/benawad/node-graphql-benchmarks" rel="noopener noreferrer"&gt;this&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the best way to leverage GraphQL with Typescript?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Considering both GraphQL and Typescript are strongly typed, we can actually combine them together to give us an amazing experience with the help of some tooling. This will help us to make the end-end request-response lifecycle strongly typed.&lt;/p&gt;

&lt;p&gt;For instance, there are some amazing projects from &lt;a href="https://the-guild.dev/" rel="noopener noreferrer"&gt;&lt;strong&gt;The Guild&lt;/strong&gt;&lt;/a&gt; like &lt;a href="https://graphql-code-generator.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;GraphQL Codegen&lt;/strong&gt;&lt;/a&gt; which we can use for generating types based on our local/remote schema with great Typescript integration, and you have a lot of plugins/recepies you can use along with it as well.&lt;/p&gt;

&lt;p&gt;Want to generate Typescript objects based on GQL documents? You can try out &lt;a href="https://github.com/dotansimha/graphql-typed-document-node" rel="noopener noreferrer"&gt;&lt;strong&gt;Typed Document Node&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Or do you want to directly code the schema in Typescript and maintain strict types? Try &lt;a href="https://typegraphql.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Typegraphql&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Well, there are more examples like these and this is just a start.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I setup my Dev environment to work on GraphQL?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While this needs a separate blog post all by itself, here are some examples.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you are using &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;VSCode&lt;/a&gt; and are looking to enable syntax highlighting, validation, autocomplete, code-completion and so on, you can try using either &lt;a href="https://marketplace.visualstudio.com/items?itemName=GraphQL.vscode-graphql" rel="noopener noreferrer"&gt;VSCode GraphQL&lt;/a&gt; or &lt;a href="https://marketplace.visualstudio.com/items?itemName=apollographql.vscode-apollo" rel="noopener noreferrer"&gt;Apollo GraphQL&lt;/a&gt; depending on which suits you better.&lt;/li&gt;
&lt;li&gt;If you are working with &lt;a href="https://www.typescriptlang.org/" rel="noopener noreferrer"&gt;Typescript&lt;/a&gt; it would be better to have codegen setup as part of your workflow.&lt;/li&gt;
&lt;li&gt;If you want to validate your schema as and when you push to Version control to maintain sanity, setup something like &lt;a href="https://github.com/kamilkisiela/graphql-inspector" rel="noopener noreferrer"&gt;GraphQL Inspector&lt;/a&gt; locally and in your CI/CD pipelines to maintain your sanity. If you use the Apollo ecosystem, it comes inbuilt in the Apollo Studio or the CLI tools which it gives you.&lt;/li&gt;
&lt;li&gt;Want to have ESLint support to enforce standards and maintain sanity across your team, try something like &lt;a href="https://github.com/dotansimha/graphql-eslint" rel="noopener noreferrer"&gt;GraphQL ESLint&lt;/a&gt; and set it up with your preferred conventions.&lt;/li&gt;
&lt;li&gt;Setup a &lt;a href="https://graphql-config.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;graphql-config&lt;/strong&gt;&lt;/a&gt; and this will interface with other tooling like the codegen, VSCode GraphQL extension, GraphQL ESLint and more. This will help a lot since you have one config to manage all the interfacing tools. If you are using the Apollo Stack, you might need an &lt;a href="https://www.apollographql.com/docs/devtools/editor-plugins/#setting-up-an-apollo-config" rel="noopener noreferrer"&gt;&lt;strong&gt;apollo-config&lt;/strong&gt;&lt;/a&gt; as well&lt;/li&gt;
&lt;li&gt;If you want to keep your GraphQL code as modular as possible with support for things like dependency injection, try something like &lt;a href="https://graphql-modules.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;GraphQL Modules&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Want to interface with multiple different data sources and integrations each with their own format but still have the experience of GraphQL when developing on top of them? Try something like &lt;a href="https://graphql-mesh.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;GraphQL Mesh&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Want to use a tool to test GraphQL endpoints? You might need something like &lt;a href="https://insomnia.rest/" rel="noopener noreferrer"&gt;&lt;strong&gt;Insomnia&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; &lt;a href="https://www.postman.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Postman&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; &lt;a href="https://hoppscotch.io/" rel="noopener noreferrer"&gt;&lt;strong&gt;Hoppscotch&lt;/strong&gt;&lt;/a&gt; &lt;strong&gt;or&lt;/strong&gt; &lt;a href="https://marketplace.visualstudio.com/items?itemName=humao.rest-client" rel="noopener noreferrer"&gt;&lt;strong&gt;VSCode REST Client&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And while I can talk more about this, it will never end cause the ecosystem is too huge and thriving.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I use REACT/Angular /Vue/Web Components. How do I integrate GraphQL with my components?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Again, the front end ecosystem is huge as well with its own set of tooling and libraries.&lt;/p&gt;

&lt;p&gt;In my case, I typically try to work on the frontend without any framework (I use &lt;a href="https://lit-element.polymer-project.org/" rel="noopener noreferrer"&gt;Lit Elements&lt;/a&gt; in my case and we will have a separate blog on that soon), the tool you use completely depends on your requirements here.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Apollo Client does have a good integration with these frameworks including &lt;a href="https://www.apollographql.com/docs/react/" rel="noopener noreferrer"&gt;React&lt;/a&gt;, &lt;a href="https://www.apollographql.com/docs/ios/" rel="noopener noreferrer"&gt;iOS&lt;/a&gt; and &lt;a href="https://www.apollographql.com/docs/android/" rel="noopener noreferrer"&gt;&lt;strong&gt;Android&lt;/strong&gt;&lt;/a&gt; — so, you might want to check that out&lt;/li&gt;
&lt;li&gt;Using React? &lt;a href="https://relay.dev/" rel="noopener noreferrer"&gt;Relay&lt;/a&gt; can be a &lt;a href="https://blog.bitsrc.io/apollo-and-relay-side-by-side-adb5e3844935" rel="noopener noreferrer"&gt;great choice&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Using Vue? You can try &lt;a href="https://apollo.vuejs.org/guide/" rel="noopener noreferrer"&gt;&lt;strong&gt;Vue Apollo&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Using web components with Apollo Stack for GQL? You might want to check out &lt;a href="https://github.com/apollo-elements/apollo-elements" rel="noopener noreferrer"&gt;&lt;strong&gt;Apollo Elements&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Using vanilla JS or TS or using web components and want to have a framework-independent way of doing things? You can stick to the GraphQL codegen itself since it takes care of almost everything underneath. Or if you want, you can also use Apollo Client’s vanilla version &lt;code&gt;@apollo/client/core&lt;/code&gt;.
&lt;a href="https://github.com/apollo-elements/apollo-elements" rel="noopener noreferrer"&gt;&lt;strong&gt;Apollo Elements&lt;/strong&gt;&lt;/a&gt; does come with support for a lot of webcomponent libraries like &lt;a href="https://lit-element.polymer-project.org/" rel="noopener noreferrer"&gt;Lit&lt;/a&gt;, &lt;a href="https://www.fast.design/" rel="noopener noreferrer"&gt;Fast&lt;/a&gt; and &lt;a href="https://github.com/ruphin/gluonjs" rel="noopener noreferrer"&gt;Gluon&lt;/a&gt; or even without any of it and hence is quite flexible.&lt;/li&gt;
&lt;li&gt;Or if you are just looking for a lightweight, performant and extensible GraphQL client, &lt;a href="https://formidable.com/open-source/urql/" rel="noopener noreferrer"&gt;URQL&lt;/a&gt; can be great as well.&lt;/li&gt;
&lt;li&gt;Or if you are looking for a minimal client which runs both in the Browser and Node, you can try &lt;a href="https://github.com/prisma-labs/graphql-request" rel="noopener noreferrer"&gt;GraphQL Request&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Well, there are lot of other ways we haven’t talked about and this is just a start.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are some of the ways in which I can maintain performance while using GraphQL?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While GraphQL is really promising and helpful, you have to understand that like any technology or framework, it does come with its own set of problems, most of which have already been addressed. For instance you might have heard about the N+1 problem, lack of caching, Query cost and complexity and so on and these have been addressed by some projects like the &lt;a href="https://github.com/graphql/dataloader" rel="noopener noreferrer"&gt;Dataloader&lt;/a&gt;, &lt;a href="https://www.apollographql.com/docs/apollo-server/performance/apq/" rel="noopener noreferrer"&gt;Persisted Queries&lt;/a&gt;, &lt;a href="https://www.apollographql.com/docs/apollo-server/performance/caching/" rel="noopener noreferrer"&gt;Caching&lt;/a&gt; and more which you can setup depending on your needs.&lt;/p&gt;

&lt;p&gt;Ultimately it depends on the degree of the flexibility you want to offer. The more the flexibility, the more the cost. And it is your decision to decide it based on your usecase.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are some of the principles or standards to be followed when trying to build my datagraph architecture?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Some amazing people have already answered this &lt;a href="https://principledgraphql.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt; and I highly recommend you to go through it before starting off your journey with GraphQL.&lt;/p&gt;

&lt;p&gt;And if you are looking for some help with the rules and implementation details with respect to GraphQL, you can find a great doc on this &lt;a href="https://graphql-rules.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;While all of these are principles trying to guide you in the right direction, choose what is best for your usecase and work with it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I use GraphQL to interact with multiple sources of data?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One of the great examples of real-world implementation of this would be &lt;a href="https://www.gatsbyjs.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Gatsby&lt;/strong&gt;&lt;/a&gt; where irrespective of the source of data, everything ultimately gets converted to GraphQL with plugins which can then be used in your workflow.&lt;/p&gt;

&lt;p&gt;If you are to build it in the server side, either you can use an out of the box solution like &lt;a href="https://graphql-mesh.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;GraphQL Mesh&lt;/strong&gt;&lt;/a&gt; or you can build it on your own since GraphQL just acts as an abstraction on top.&lt;/p&gt;

&lt;p&gt;Or if you are on the apollo stack and want to connect to multiple data sources, you can have a look at &lt;a href="https://www.apollographql.com/docs/tutorial/data-source/" rel="noopener noreferrer"&gt;&lt;strong&gt;apollo-datasource&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Or you want to have a single ORM which closely resembles GraphQL like &lt;a href="https://www.prisma.io/" rel="noopener noreferrer"&gt;Prisma&lt;/a&gt; to integrate with multiple databases underneath&lt;/p&gt;

&lt;p&gt;Ultimately it all boils down to how you structure your resolvers.&lt;/p&gt;

&lt;p&gt;But, it does not stop here. Some databases also support GraphQL either via adapters or natively as well.&lt;/p&gt;

&lt;p&gt;For eg.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://dgraph.io/" rel="noopener noreferrer"&gt;&lt;strong&gt;Dgraph&lt;/strong&gt;&lt;/a&gt; has a native &lt;a href="https://dgraph.io/graphql" rel="noopener noreferrer"&gt;GraphQL&lt;/a&gt; implementation&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://neo4j.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;Neo4j&lt;/strong&gt;&lt;/a&gt; has a &lt;a href="https://neo4j.com/developer/graphql/" rel="noopener noreferrer"&gt;GraphQL&lt;/a&gt; adapter&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://hasura.io/" rel="noopener noreferrer"&gt;&lt;strong&gt;Hasura&lt;/strong&gt;&lt;/a&gt; provides a GraphQL abstraction on top of your datasources&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.graphile.org/postgraphile/" rel="noopener noreferrer"&gt;&lt;strong&gt;Postgraphile&lt;/strong&gt;&lt;/a&gt; can help if you use Postgres&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Well, these are just some of the tools and services. There are more like this which can help.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The GraphQL spec is missing some of the types like DateTime, GeoLocation and more. How do I implement that?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes, this can be painful. But, it is by design to keep GraphQL as lean and lightweight as possible.&lt;/p&gt;

&lt;p&gt;This is where &lt;a href="https://graphql.org/learn/schema/#scalar-types" rel="noopener noreferrer"&gt;GraphQL Scalars&lt;/a&gt; really help. You can define your own types and use them across your schema if they are not supported out of the box.&lt;/p&gt;

&lt;p&gt;But, this can be tedious to implement and using a package like &lt;a href="https://github.com/Urigo/graphql-scalars" rel="noopener noreferrer"&gt;&lt;strong&gt;graphql-scalars&lt;/strong&gt;&lt;/a&gt; can actually help since it comes inbuilt with some of the commonly used scalars which you can import and use.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;There are some fields which I find myself repeating between various queries and mutations. How do I avoid doing this?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As the &lt;a href="https://en.wikipedia.org/wiki/Don't_repeat_yourself" rel="noopener noreferrer"&gt;DRY principle&lt;/a&gt; goes, we can also make our operations modular with the help of &lt;a href="https://graphql.org/learn/queries/#fragments" rel="noopener noreferrer"&gt;GraphQL Fragments&lt;/a&gt; and then use those fragments as applicable anywhere.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Can’t I convert my Database schema directly to a GraphQL schema or generate a GraphQL schema?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While technically, it is possible and this is what database providers who offer a GraphQL layer on top use like Hasura or Graphcool — It is highly &lt;strong&gt;not recommended&lt;/strong&gt; for client consumption and I would also recommend you to read &lt;a href="https://graphql.org/learn/thinking-in-graphs/" rel="noopener noreferrer"&gt;this&lt;/a&gt; to get more idea.&lt;/p&gt;

&lt;p&gt;The main reason to this according to me is that GraphQL is meant to describe the Data Graph which revolves around the business/domain terminologies without involving the underlying technical complexity or details. For instance, one should not care about which table a specific field comes from, how to join, and so on.&lt;/p&gt;

&lt;p&gt;It should just be about the business implementation for the end users so even a product manager who does not know about the underlying technical implementation can use it.&lt;/p&gt;

&lt;p&gt;So, while you may use GraphQL as sort of an ORM for your databases or other data sources, exposing that directly to the clients is not a good option. Rather, there should be one more layer on top just to have it make sense for any end user and reduce the complexity for clients.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are there some helpers libraries I can use to work with my GraphQL schemas?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes. &lt;a href="https://www.graphql-tools.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;GraphQL Tools&lt;/strong&gt;&lt;/a&gt; (which was initially from Apollo and then taken over by the Guild) is one of those libraries which I highly recommend. You can do a lot of operations on your SDL or schema like merging multiple schemas, mocking your schemas with test data, building custom directives, loading remote schemas and so on which you can add as part of your stack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the best strategy to distribute your schema? What if I am using Microservices with GraphQL?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While GraphQL is meant to be a single endpoint or provide a single unified view of the data for the clients, it is often not possible to do it all at one place since it can create a lot of bottlenecks. This is why &lt;a href="https://www.graphql-tools.com/docs/stitch-combining-schemas/" rel="noopener noreferrer"&gt;&lt;strong&gt;Schema stitching&lt;/strong&gt;&lt;/a&gt; or &lt;a href="https://www.apollographql.com/docs/federation/" rel="noopener noreferrer"&gt;&lt;strong&gt;Apollo Federation&lt;/strong&gt;&lt;/a&gt; came into place where multiple subschemas can contribute to the unified data graph.&lt;/p&gt;

&lt;p&gt;While we can have a separate blog on Schema Stitching versus Federation sometime down the line, each have its own set of merits and demerits which you can understand only if you give both a try.&lt;/p&gt;

&lt;p&gt;These videos can help get some basics (but a lot has changed since these videos were released especially with GraphQL Tools introducing &lt;a href="https://www.graphql-tools.com/docs/stitch-type-merging/" rel="noopener noreferrer"&gt;&lt;strong&gt;Type Merging&lt;/strong&gt;&lt;/a&gt;):&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/Vq0ajno-zgw"&gt;
&lt;/iframe&gt;
&lt;/p&gt;



&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/LKQKn1oFXJU"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;If you are still confused on what to go for, you can also read &lt;a href="https://product.voxmedia.com/2020/11/2/21494865/to-federate-or-stitch-a-graphql-gateway-revisited" rel="noopener noreferrer"&gt;&lt;strong&gt;this&lt;/strong&gt;&lt;/a&gt; blog about stitching and federation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What are some of the GraphQL events/conferences to watch out for?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since GraphQL was released, it garnered a huge interest in the community that a lot of conferences, events and meetups are held around the world keeping GraphQL as the main theme. Some of them are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://summit.graphql.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;The GraphQL Summit&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://graphqlconf.org/" rel="noopener noreferrer"&gt;&lt;strong&gt;GraphQL Conf&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hasura.io/enterprisegraphql/" rel="noopener noreferrer"&gt;&lt;strong&gt;Enterprise GraphQL&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://graphql.asia/" rel="noopener noreferrer"&gt;&lt;strong&gt;GraphQL Asia&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://graphqlgalaxy.com/" rel="noopener noreferrer"&gt;&lt;strong&gt;GraphQL Galaxy&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and there are more including meetups like &lt;a href="https://www.meetup.com/topics/graphql/" rel="noopener noreferrer"&gt;&lt;strong&gt;these&lt;/strong&gt;&lt;/a&gt; and &lt;a href="https://graphql.org/community/upcoming-events/" rel="noopener noreferrer"&gt;&lt;strong&gt;these&lt;/strong&gt;&lt;/a&gt;. You can find most of the previous sessions recorded on Youtube if you search for it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How can I contribute to GraphQL and its ecosystem?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every bit of help really counts since GraphQL foundation is run by a set of volunteers and its all open source. You can&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write blogs like this to spread knowledge amongst the community&lt;/li&gt;
&lt;li&gt;Host meetups, speak in conferences about your experience and evangelize your best way possible.&lt;/li&gt;
&lt;li&gt;Contribute to the &lt;a href="https://github.com/graphql/graphql-spec" rel="noopener noreferrer"&gt;&lt;strong&gt;GraphQL spec&lt;/strong&gt;&lt;/a&gt; with your suggestions (Some suggestions may take years to implement even if it is good, so you may need to have a lot of patience for this)&lt;/li&gt;
&lt;li&gt;Contribute to the ecosystem of tools leveraging GraphQL be it with documentation, tests, features, bug fixes, feedback and what not. It will definitely help.&lt;/li&gt;
&lt;li&gt;Facing a challenge with GraphQL which has not been solved before? Build your own tooling and contribute it to the community&lt;/li&gt;
&lt;li&gt;Create failing tests and reproducible projects&lt;/li&gt;
&lt;li&gt;Answer and help others on Github Issues, Discord, Stack Overflow, Twitter, Reddit. There are a lot of amazing GraphQL communities out there.&lt;/li&gt;
&lt;li&gt;Or if you want to take it to the next level and want to align your entire organization to help the GraphQL foundation, &lt;a href="https://foundation.graphql.org/join/" rel="noopener noreferrer"&gt;become its member&lt;/a&gt; and contribute.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are a lot of small ways in which you can give back. Small or big does not matter. Every contribution counts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are there some case studies which can actually help me in the implementation?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sure. While I can’t list them all here, here are some:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://netflixtechblog.com/how-netflix-scales-its-api-with-graphql-federation-part-1-ae3557c187e2" rel="noopener noreferrer"&gt;Netflix and GraphQL&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/airbnb-engineering/how-airbnb-is-moving-10x-faster-at-scale-with-graphql-and-apollo-aa4ec92d69e2" rel="noopener noreferrer"&gt;Airbnb and GraphQL&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.graphql.com/articles/graphql-at-github" rel="noopener noreferrer"&gt;Github and GraphQL&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://about.sourcegraph.com/graphql/graphql-at-twitter/" rel="noopener noreferrer"&gt;Twitter and GraphQL&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;and you can find more &lt;a href="https://www.graphql.com/case-studies/" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are there any publicly available GraphQL APIs which I can play around with?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Yes. While most of them would require you to authenticate, they are available for you to use. Some examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.github.com/v4/explorer/" rel="noopener noreferrer"&gt;Github GraphQL Explorer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gitlab.com/-/graphql-explorer" rel="noopener noreferrer"&gt;Gitlab GraphQL Explorer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.yelp.com/developers/graphiql" rel="noopener noreferrer"&gt;Yelp GraphQL Explorer&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can have a look at more like these &lt;a href="https://github.com/APIs-guru/graphql-apis" rel="noopener noreferrer"&gt;here&lt;/a&gt; and play around with it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I have a legacy architecture/stack as part of my organization. How do I incrementally migrate to GraphQL?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is one of the places where GraphQL really shines. You need not move everything over at one piece. Here are some steps which might help.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;First, build a Datagraph for your entire business without worrying about the underlying logic/implementation. But don’t worry too much since you can always evolve this over time.&lt;/li&gt;
&lt;li&gt;Next, implement resolvers for every part of the schema in such a way that at phase 1, you just wrap your existing infrastructure with GraphQL. For instance, if your services use SOAP, you can add a GraphQL layer on top of it and calling that can all the SOAP service underneath and the client need not worry about it. You can use something like &lt;a href="https://graphql-mesh.com/" rel="noopener noreferrer"&gt;GraphQL Mesh&lt;/a&gt; or &lt;a href="https://sofa-api.com/" rel="noopener noreferrer"&gt;SOFA&lt;/a&gt; which can help in abstracting these. There is a good blog post on how to migrate from REST to GraphQL &lt;a href="https://the-guild.dev/blog/migrating-from-rest" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Change the client implementation one by one to call the GraphQL gateway instead of the legacy service.&lt;/li&gt;
&lt;li&gt;Now that you have GraphQL working in your ecosystem, you can incrementally move away from legacy implementations like SOAP without having to worry about how it will affect the clients progressively, one component at a time to use a native GraphQL implementation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;While this is one possible approach, this is not the only approach. There are lot of other ways in which you can take this one step at a time without worrying about the legacy code you have.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I secure my GraphQL endpoint?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While the GraphQL spec itself does not recommend any specific way to do this and leaves it to the person implementing it, you can either use &lt;a href="https://jwt.io/" rel="noopener noreferrer"&gt;&lt;strong&gt;JWT&lt;/strong&gt;&lt;/a&gt;&lt;strong&gt;,&lt;/strong&gt; Cookies, Sessions and so on like you normally would when authenticating through other mechanisms.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I enable authorization to my GraphQL fields or schema?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is very powerful in GraphQL since you can do a authorization at a very fine grained level be it at the type level or at the field level. You can read &lt;a href="https://www.apollographql.com/blog/authorization-in-graphql-452b1c402a9/" rel="noopener noreferrer"&gt;this&lt;/a&gt; blog which suggests various ways in which you can do authorization.&lt;/p&gt;

&lt;p&gt;You can also use libraries like &lt;a href="https://github.com/maticzav/graphql-shield" rel="noopener noreferrer"&gt;&lt;strong&gt;GraphQL Shield&lt;/strong&gt;&lt;/a&gt; which offers powerful middlewares to do this. But remember that authorization does come with attached cost since you are running a specific logic in/before your resolvers for all the fields which you want to authorize.&lt;/p&gt;

&lt;p&gt;One often overlooked way is the use of &lt;a href="https://www.graphql-tools.com/docs/schema-directives/" rel="noopener noreferrer"&gt;&lt;strong&gt;directives&lt;/strong&gt;&lt;/a&gt; to do authorization, one example of which is mentioned in &lt;a href="https://blog.grandstack.io/authorization-in-graphql-using-custom-schema-directives-eafa6f5b4658" rel="noopener noreferrer"&gt;this&lt;/a&gt; blog and this is very powerful and declarative. This way, you can specify the scope and add the directive to the respective fields in your SDL and it can do the job for you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I enable real-time applications like Chat, auto-updates and so on in my application with GraphQL?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are some options currently to do this.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first would be to use &lt;a href="https://www.howtographql.com/graphql-js/7-subscriptions/" rel="noopener noreferrer"&gt;GraphQL Subscriptions&lt;/a&gt; which is part of the spec. You have to register the subscriptions upfront and also have support for Websockets if you want to do this.&lt;/li&gt;
&lt;li&gt;Another way is to do periodic long-time polling which can work at a small scale keeping your application stateless.&lt;/li&gt;
&lt;li&gt;An another way is to use &lt;a href="https://medium.com/open-graphql/graphql-subscriptions-vs-live-queries-e38302c7ab8e" rel="noopener noreferrer"&gt;live queries&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each option comes up with its own set of advantages and disadvantages again. Just remember that it is not often possible to keep your application stateless if you want something like Subscriptions. So, make sure you manage the state well and plan for failures and scaling your app.&lt;/p&gt;

&lt;p&gt;And if you are new to subscriptions, you can probably &lt;a href="https://www.youtube.com/watch?v=Wi7P39sF2nw&amp;amp;feature=youtu.be" rel="noopener noreferrer"&gt;watch this&lt;/a&gt; to get an idea about the basics of how subscription works.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What can I even do with introspection?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://graphql.org/learn/introspection/" rel="noopener noreferrer"&gt;&lt;strong&gt;Introspection&lt;/strong&gt;&lt;/a&gt; is typically used by the tooling to understand your GraphQL types and schema. For instance, tools like &lt;a href="https://apis.guru/graphql-voyager/" rel="noopener noreferrer"&gt;&lt;strong&gt;GraphQL Voyager&lt;/strong&gt;&lt;/a&gt; can introspect your schema and build amazing graphs, and almost all extensions built around GraphQL leverage this power to understand your schema, types and everything around it.&lt;/p&gt;

&lt;p&gt;Note that, it is recommended by experts to have introspection disabled in production due to security and performance reasons.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I do tracing of all operations in GraphQL?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are various ways in which you can do this.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you want to do this on your own, you can send traces or contexts from within the resolvers using the &lt;a href="https://www.jaegertracing.io/" rel="noopener noreferrer"&gt;&lt;strong&gt;Jaeger&lt;/strong&gt;&lt;/a&gt;/&lt;a href="https://opentelemetry.io/" rel="noopener noreferrer"&gt;&lt;strong&gt;Opentelemetry&lt;/strong&gt;&lt;/a&gt; SDKs and send all the information manually for tracing.&lt;/li&gt;
&lt;li&gt;Opentelemetry has recently made support for GraphQL available. You can find it &lt;a href="https://github.com/open-telemetry/opentelemetry-js-contrib/tree/master/plugins/node/opentelemetry-instrumentation-graphql" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;But if you find yourself using the Apollo Stack, Apollo comes with its own tracing options like Apollo Tracing and you can read about it &lt;a href="https://www.apollographql.com/blog/exposing-trace-data-for-your-graphql-server-with-apollo-tracing-97c5dd391385/" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Just remember that Tracing will cause a lot of performance overhead and it is highly recommended to have it off unless otherwise needed or probably use it only for specific layers of concern.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I handle errors gracefully?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Again, there are a lot of ways to do this.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you use the Apollo stack, you can use the apollo-errors package as documented &lt;a href="https://www.apollographql.com/docs/apollo-server/data/errors/" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;If you use express-graphql or want to use graphql-js natively, they expose error functions as well based on &lt;a href="https://github.com/graphql/express-graphql#additional-validation-rules" rel="noopener noreferrer"&gt;&lt;strong&gt;GraphQLError&lt;/strong&gt;&lt;/a&gt; and can also use GraphQL extensions to augment with custom payload like error codes and so on which what you typically do when using servers like graphql-helix.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, this is the case since GraphQL does not have any dependence on the transport layer and thus status codes like 200, 400 or 500 may not make sense unless they are part of the response and the spec does not prescribe a specific way to do this as well.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is GraphQL related to Graph databases in some way?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While GraphQL encourages you to think of your entire data as graphs of connected information since that would give a better insight into how to structure your schema leading to a unified data graph, it has no relation with Graph databases by itself since Graph databases act as a way to represent and store data in underlying storage systems to allow for fast traversal, walking and retrieval.&lt;/p&gt;

&lt;p&gt;But, that being said, GraphQL and Graph Databases do have a lot of synergy between them. You can read about that &lt;a href="https://dgraph.io/blog/post/graphdb-for-your-next-app/" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt; and &lt;a href="https://datalanguage.com/blog/graphql-and-graph-databases" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt; since its all about establishing the data schema and its relationships.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When exposing REST APIs to end users, I used to bill users based on API calls made. How do I do this for GraphQL?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This can be a challenging problem cause in GraphQL, its the clients which decide what to query/mutate and the server might not know that upfront unless you are using something like persisted queries.&lt;/p&gt;

&lt;p&gt;And here, the CPU consumed can depend on the level of nesting of the queries, the operations which your resolvers do and so on making it difficult to estimate the costs upfront. You can find a detailed blog about this &lt;a href="https://medium.com/dev-genius/a-principled-approach-to-graphql-query-cost-analysis-8c7243de42c1" rel="noopener noreferrer"&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One way to handle this only allow persisted queries and approve them and assign costs to them upfront, but this can get tricky to manage over the long run as number of queries and mutations increase.&lt;/li&gt;
&lt;li&gt;Another way is to use custom cost directives as in &lt;a href="https://github.com/pa-bru/graphql-cost-analysis" rel="noopener noreferrer"&gt;this package&lt;/a&gt; manually specifying the complexity and cost and using that to bill your APIs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is relatively a new area and still under exploration. For instance, Dgraph bills for Slash GraphQL based on the nodes accessed as mentioned &lt;a href="https://dgraph.io/pricing" rel="noopener noreferrer"&gt;here&lt;/a&gt; which can be valid for databases using GraphQL but not necessarily for GraphQL api by itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here are some other resources which hosts FAQs on GraphQL as well&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.apollographql.com/docs/resources/faq/" rel="noopener noreferrer"&gt;Apollo GraphQL FAQ&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://graphql.org/faq/" rel="noopener noreferrer"&gt;GraphQL Org FAQ&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.howtographql.com/advanced/5-common-questions/" rel="noopener noreferrer"&gt;Howtographql FAQ&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And there are more. Just google for it.&lt;/p&gt;

&lt;p&gt;Hope this was informative. Do you have any question which I have not covered in this list or are you looking for some help? Let me know by reaching out to me &lt;a href="https://twitter.com/techahoy" rel="noopener noreferrer"&gt;@techahoy&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And if this helped, do share this across with your friends, do hang around and follow us for more like this every week. See you all soon.&lt;/p&gt;

</description>
      <category>graphql</category>
      <category>architecture</category>
      <category>typescript</category>
      <category>node</category>
    </item>
  </channel>
</rss>
