<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abdallah Abedraba on Medium]]></title>
        <description><![CDATA[Stories by Abdallah Abedraba on Medium]]></description>
        <link>https://medium.com/@aabedraba?source=rss-973db452be94------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dEHk11hN36R1p8j9L0jpng.jpeg</url>
            <title>Stories by Abdallah Abedraba on Medium</title>
            <link>https://medium.com/@aabedraba?source=rss-973db452be94------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 14:43:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aabedraba/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Zero Downtime migration of API Authentication]]></title>
            <link>https://medium.com/@aabedraba/zero-downtime-migration-of-api-authentication-c062e13f846b?source=rss-973db452be94------2</link>
            <guid isPermaLink="false">https://medium.com/p/c062e13f846b</guid>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[zuplo]]></category>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[migration]]></category>
            <dc:creator><![CDATA[Abdallah Abedraba]]></dc:creator>
            <pubDate>Thu, 20 Jul 2023 22:00:58 GMT</pubDate>
            <atom:updated>2023-07-20T22:02:38.349Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Originally published in Zuplo’s blog, by </em><a href="https://twitter.com/ntotten"><em>Nate Totten</em></a></p><p>One of the biggest benefits of an API Gateway is that it provides an abstraction layer between your clients and your backend (i.e. business logic). This layer allows your backend to be unaware of various API implementations and configurations such as authentication, authorization, and rate limits. This separation of concerns also makes it possible to swap out specific implementations in a single place - your gateway - without having to rewrite a large amount of backend code.</p><p>One question we have helped Zuplo customers with is how to migrate to a new authorization provider (say AWS Cognito to Auth0) or even to an entirely new type of authorization system (say JWT to API Keys). Normally, this type of migration would mean code changes to your API implementation - in the simple case where you have a single service this might be fairly straightforward, but what we have seen in practice is that customers end up with many services that each need to implement the same authentication service. In either case though, an API gateway can dramatically simplify the migration.</p><h3>Separation of Concerns<a href="https://zuplo.com/blog#separation-of-concerns">​</a></h3><p>When migrating authorization providers, the first step is to ensure a clean separation of concerns. This means that only the API gateway should handle client-facing authorization. By cleanly separating the layers, future changes will be much easier to make.</p><p>A pattern we often recommend to customers who are migrating to an API gateway is to pass authorization information to the backend via an HTTP header. This model means that your backend trusts the API gateway to have already authenticated the client - this is referred to as a trusted subsystem design.</p><p>What this means is that instead of the backend service receiving say the Authorization header directly from the client, it would receive something like a custom-user-id header that would contain the user’s ID (or sub, etc.). Your service would be setup to trust that the request from the gateway is pre-authorized. Of course this requires the establishment of a trusted relationship between the gateway and your service. Setting that up is beyond the scope of this article, but you can see <a href="https://zuplo.com/docs/articles/securing-your-backend">options supported with Zuplo in our documentation</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BluWDw7kHh3WEEnS7a8E_w.png" /></figure><h3>Authorization at the Gateway<a href="https://zuplo.com/blog#authorization-at-the-gateway">​</a></h3><p>With the backend service setup to trust the user information from the gateway, the next step is to actually perform the authorization for your current authorization provider. With Zuplo this is typically done using one of our built-in policies like <a href="http://localhost:3002/docs/policies/auth0-jwt-auth-inbound">Auth0</a> or <a href="http://localhost:3002/docs/policies/cognito-jwt-auth-inbound">AWS Cognito</a> JWT authentication.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qS4Jsyebj4wdGMbFDLypmg.png" /></figure><p>With authorization handled, the gateway next needs to be configured to pass the user information to the backend. In Zuplo this can be done by adding a <a href="https://zuplo.com/docs/policies/custom-code-inbound">Custom Code Inbound</a> policy. This policy is configured to take the user.sub value that was extracted from the JWT token and add it to the custom-user-id header. The policy&#39;s code is shown below.</p><pre>import { ZuploContext, ZuploRequest } from &quot;@zuplo/runtime&quot;;<br><br>export default async function (request: ZuploRequest, context: ZuploContext) {<br>  const headers = new Headers(request.headers);<br>  headers.set(&quot;custom-user-id&quot;, request.user.sub);<br>  return new ZuploRequest(request, { headers });<br>}</pre><p>With these steps in place the current authentication provider is now running on the gateway and the backend receives the authorization information via headers.</p><h3>Multiple Authorization Providers<a href="https://zuplo.com/blog#multiple-authorization-providers">​</a></h3><p>In order to migrate clients to the new authentication provider with zero downtime, it is necessary to support multiple authentication providers for a period of time. With Zuplo this is extremely easy. By default, the authorization policies in Zuplo are configured to return unauthorized responses if the request doesn’t contain valid authorization credentials (i.e. a JWT on the Authorization header). However, each provider can be configured to allow unauthenticated requests, thus allowing multiple providers to attempt to authenticate the request.</p><p>To change the first authentication policy set the the allowUnauthenticatedRequests property on the policy to true.</p><pre>{<br>  &quot;name&quot;: &quot;my-cognito-jwt-auth-inbound-policy&quot;,<br>  &quot;policyType&quot;: &quot;cognito-jwt-auth-inbound&quot;,<br>  &quot;handler&quot;: {<br>    &quot;export&quot;: &quot;CognitoJwtInboundPolicy&quot;,<br>    &quot;module&quot;: &quot;$import(@zuplo/runtime)&quot;,<br>    &quot;options&quot;: {<br>      &quot;allowUnauthenticatedRequests&quot;: true,<br>      &quot;region&quot;: &quot;$env(AWS_REGION)&quot;,<br>      &quot;userPoolId&quot;: &quot;$env(AWS_COGNITO_USER_POOL_ID)&quot;<br>    }<br>  }<br>}</pre><p>Next, add a second authentication policy. This policy will also have the allowUnathenticatedRequests property set to true.</p><pre>{<br>  &quot;name&quot;: &quot;my-auth0-jwt-auth-inbound-policy&quot;,<br>  &quot;policyType&quot;: &quot;auth0-jwt-auth-inbound&quot;,<br>  &quot;handler&quot;: {<br>    &quot;export&quot;: &quot;Auth0JwtInboundPolicy&quot;,<br>    &quot;module&quot;: &quot;$import(@zuplo/runtime)&quot;,<br>    &quot;options&quot;: {<br>      &quot;allowUnauthenticatedRequests&quot;: true,<br>      &quot;auth0Domain&quot;: &quot;$env(AUTH0_DOMAIN)&quot;,<br>      &quot;audience&quot;: &quot;$env(AUTH0_AUDIENCE)&quot;<br>    }<br>  }<br>}</pre><p>Now with both of these policies set to allow unauthenticated requests, the API is left unsecured - both policies will allow requests even if the user is not authenticated. In order to require that each request is authenticated, we need to add a third policy that runs after both of these policies that enforces authentication. This can be done with a second <a href="https://zuplo.com/docs/policies/custom-code-inbound">Custom Code Inbound</a> policy. The below example custom policy checks if the user sub is set, if it isn’t it means neither auth policy succeeded so we return unauthorized.</p><pre>import { ZuploRequest, HttpProblems } from &quot;@zuplo/runtime&quot;;<br><br>export default async function (request: ZuploRequest, context: ZuploContext) {<br>  if (!request.user.sub) {<br>    return HttpProblems.unauthorized(request, context);<br>  }<br>  return request;<br>}</pre><blockquote>For more information about the HttpProblems helper see <a href="https://zuplo.com/docs/articles/http-problems">documentation</a>.</blockquote><h3>Migrating Clients + Cleanup<a href="https://zuplo.com/blog#migrating-clients--cleanup">​</a></h3><p>With your API gateway now supporting both authentication providers, clients can be migrated to use the new provider. Once all the clients are migrated, the old provider can be removed. You can also remove the custom authorization policy and set the one authentication policy’s property allowUnauthenticatedRequests to false.</p><p>If you need to encourage your clients to migrate to the new authentication policy see our <a href="https://zuplo.com/blog/2022/05/25/how-to-get-clients-to-move-off-old-version-of-api">post on versioning an API for some helpful tips</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c062e13f846b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flux + Testkube: GitOps Testing is here]]></title>
            <link>https://medium.com/kubeshop-i/flux-testkube-gitops-testing-is-here-7c69ea60409c?source=rss-973db452be94------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c69ea60409c</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[gitops]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[continuous-delivery]]></category>
            <dc:creator><![CDATA[Abdallah Abedraba]]></dc:creator>
            <pubDate>Thu, 13 Apr 2023 11:29:02 GMT</pubDate>
            <atom:updated>2023-04-13T11:29:02.934Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*As5gDKhoR0i0tAVEkzFf8Q.png" /><figcaption>Testkube + Flux!</figcaption></figure><h3>Introduction: Challenges to GitOps Cloud Native Testing</h3><p>One of the major trends in contemporary cloud native application development is the adoption of GitOps; managing the state of your Kubernetes cluster(s) in Git — with all the bells and whistles provided by modern Git platforms like GitHub and GitLab in regard to workflows, auditing, security, tooling, etc. Tools like ArgoCD or Flux are used to do the heavy lifting of keeping your Kubernetes cluster in sync with your Git repository; as soon as difference is detected between Git and your cluster it is deployed to ensure that your repository is the source-of-truth for your runtime environment.</p><p>Don’t you agree that it’s time to move testing and related activities into this paradigm also? Exactly! We at Kubeshop are working hard to provide you with the first GitOps-friendly Cloud-native test orchestration/execution framework — Testkube — to ensure that your QA efforts align with this new and shiny approach to application configuration and cluster configuration management. Combined with the GitOps approach described above, Testkube will include your test artifacts and application configuration in the state of your cluster and make git the source of truth for these test artifacts. And it’s Open-Source too. For more on Testkube, check out the introduction blog, <a href="https://kubeshop.io/blog/hello-testkube-power-to-testers-on-k8s">“Hello Testkube”</a>.</p><p>Benefits of the GitOps approach:</p><ol><li>Since your tests are included in the state of your cluster you are always able to validate that your application components/services work as required.</li><li>Since tests are executed from inside your cluster there is no need to expose services under test externally purely for the purpose of being able to test them.</li><li>Tests in your cluster are always in sync with the external tooling used for authoring</li><li>Test execution is not strictly tied to CI but can also be triggered manually for ad-hoc validations or via internal triggers (Kubernetes events)</li><li>You can leverage all your existing test automation assets from Postman, or Cypress (even for end-to-end testing), or … through executor plugins.</li></ol><p>Conceptually, this can be illustrated as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*-ftlQ3EbFZvYnW3z.png" /></figure><h3>‍<br>GitOps Tutorial</h3><p>Let’s see this in action — here comes a step-by-step walkthrough to get this in place for the automated application deployment and execution of Postman collections in a local Kind cluster to test.</p><p>Let’s start with setting things up for our GitOps-powered testing machine!</p><h3>Installations for GitOps Testing</h3><h4>1. <a href="https://github.com/kubeshop/testkube-flux/fork">Fork the example repository</a> and clone it locally</h4><pre>git clone https://github.com/$GITHUB_USER/testkube-flux.git</pre><h4>2. Start a Kubernetes cluster</h4><p>You can use Minikube, Kind or any managed cluster with a cloud provider (EKS, GKE, etc). In this example we’re using <a href="https://kind.sigs.k8s.io/">Kind</a>.</p><pre>kind create cluster</pre><h4>3. Create a Github Classic Token:</h4><p>Must be of type <a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#creating-a-personal-access-token-classic"><strong>Classic</strong></a> (i.e. starts with ghp_)</p><pre>GITHUB_TOKEN=&lt;ghp_&gt;<br>GITHUB_USER=&lt;username&gt;</pre><p>And export the environment variables in your terminal.</p><h4>4. Install Flux in the cluster and connect it to the repository</h4><p>Install the <a href="https://fluxcd.io/flux/installation/">Flux CLI</a> and run:</p><pre>flux bootstrap github \<br>--owner=$GITHUB_USER \<br>--repository=testkube-flux \<br>--path=cluster \<br>--personal</pre><h4>5. Create a Flux Source and a Kusktomize Controller</h4><p>The following command will create Flux source to tell Flux to apply changes that are created in your repository:</p><pre>flux create source git testkube-tests \<br>--url=https://github.com/$GITHUB_USER/testkube-flux \<br>--branch=main \<br>--interval=30s \<br>--export &gt; ./cluster/flux-system/sources/testkube-tests/test-source.yaml</pre><p>And now create a Flux Kustomize Controller to apply the Testkube Test CRDs in the cluser using <a href="https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/">Kustomize</a>:</p><pre>flux create kustomization testkube-test \<br>--target-namespace=testkube \<br>--source=testkube-tests \<br>--path=&quot;cluster/testkube&quot; \<br>--prune=true \<br>--interval=30s \<br>--export &gt; ./cluster/flux-system/sources/testkube-tests/testkube-kustomization.yaml</pre><h4>6. Install Testkube in the cluster</h4><p>Install the Testkube CLI from <a href="https://kubeshop.github.io/testkube/installing">https://kubeshop.github.io/testkube/installing</a></p><p>And run the following command to install Testkube and its components in the cluster:</p><pre>testkube install</pre><h4>7. Create a Test CRD with testkube CLI</h4><p>In this example the test being used is a Postman test, which you can find in /img/server/tests/postman-collection.json.</p><p>To create a Kubernetes CRD for the test, run:</p><pre>testkube generate tests-crds img/server/tests/postman-collection.json &gt; cluster/testkube/server-postman-test.yaml</pre><p>Note: You can <a href="https://kubeshop.github.io/testkube/integrations/testkube-automation">run Testkube from your CI/CD pipeline </a>in case you want to automate the creation of the Test CRDs.</p><h4>8. Add the generated test to the Kustomize file:</h4><p>The name of the test file created in the previous step is server-postman-test.yaml, add that to the Kustomize file located in <a href="https://testkube.io/blog/cluster/testkube/kustomization.yaml">cluster/testkube/kustomization.yaml</a>:</p><pre>apiVersion: kustomize.config.k8s.io/v1beta1<br>kind: Kustomization<br>resources:<br>+ - server-postman-test.yaml</pre><h4>9. Push all the changes to your repository</h4><pre>git pull origin main<br>git add -A &amp;&amp; git commit -m &quot;Configure Testkube tests&quot;<br>git push</pre><h4>10. Your tests should be applied in the cluster</h4><p>To see if Flux detected your changes run:</p><pre>flux get kustomizations --watch</pre><p>And to ensure that the test has been created run:</p><pre>testkube get test<br>NAME | TYPE | CREATED | LABELS |<br>--------------------------+--------------------+-------------------------------+---------------------------------------------------+<br>postman-collection-test | postman/collection | 2023-01-30 18:04:13 +0000 UTC | kustomize.toolkit.fluxcd.io/name=testkube-test, |<br>| | | kustomize.toolkit.fluxcd.io/namespace=flux-system |</pre><h4>11. Run your tests</h4><p>Now that you have deployed your tests in a GitOps fashion to the cluster, you can use Testkube to run the tests for you through multiple ways:</p><ul><li>Using the Testkube CLI</li><li>Using the Testkube Dashboard</li><li>Running Testkube CLI from a CI/CD pipeline</li></ul><p>We’ll use the Testkube CLI for brevity. Run the following command to run the recently created test:</p><pre>testkube run test postman-collection-test</pre><p>And see the test result with:</p><pre>testkube get execution postman-collection-test-1</pre><pre>Test execution completed with success in 13.345s</pre><h3>GitOps Takeaways</h3><p>Once fully realized — using GitOps for testing of Kubernetes applications as described above provides a powerful alternative to a more traditional approach where orchestration is tied to your current CI/CD tooling and not closely aligned with the lifecycle of Kubernetes applications.</p><p>This tutorial uses Postman collections for testing an API, but you can bring your a whole suite of tests with you to Testkube. <a href="https://kubeshop.github.io/testkube/category/test-types">Check the documentation for the available test types</a>.</p><p>Would love to get your thoughts on the above approach — over-engineering done right? Waste of time? Let us know!</p><p>Check Testkube on GitHub — and let us know if you’re missing something we should be adding to make your k8s resource testing easier.</p><ul><li><a href="https://github.com/kubeshop/testkube/releases">Download the latest release</a> on GitHub</li><li>Check out the <a href="https://kubeshop.github.io/testkube/">documentation</a></li><li>Get in touch with us on our <a href="https://discord.gg/uNuhy6GDyn">Discord server</a></li></ul><p>Thank you!‍</p><p><em>Originally published at </em><a href="https://testkube.io/blog/flux-testkube-gitops-testing-is-here"><em>https://testkube.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c69ea60409c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kubeshop-i/flux-testkube-gitops-testing-is-here-7c69ea60409c">Flux + Testkube: GitOps Testing is here</a> was originally published in <a href="https://medium.com/kubeshop-i">Testkube</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tips for using Prisma in your team]]></title>
            <link>https://medium.com/@aabedraba/tips-for-using-prisma-in-your-team-42fd936bba1f?source=rss-973db452be94------2</link>
            <guid isPermaLink="false">https://medium.com/p/42fd936bba1f</guid>
            <category><![CDATA[prisma]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[orm]]></category>
            <dc:creator><![CDATA[Abdallah Abedraba]]></dc:creator>
            <pubDate>Fri, 06 Jan 2023 09:35:10 GMT</pubDate>
            <atom:updated>2023-01-06T09:35:10.897Z</atom:updated>
            <content:encoded><![CDATA[<p>Prisma is a powerful ORM in the Node.js ecosystem, with its goals to make better database abstractions for developers and to be thoroughly type-safe. But good practices in team development are essential to getting the most out of this powerful tool. Wrongly managed migrations can lead to downtime, out-of-sync schema versions; and dangerous production migrations could lead to deleting your whole database. Here is a list of tips I developed while working (and sometimes failing to work) with Prisma over the last two years.</p><h3>Deploying to production</h3><p>If you try to deploy by adding a column, migrating after deploying can lead to failed requests in the new deployment. And it’s the other way around when you try to delete a column: migrating before the new deployment will lead to some requests from the older deployment to fail.</p><p>On both occasions you might be running into the error that looks like the following The column `db.Tweet.likeCount` does not exist in the current database.</p><p>It’s important to ensure that you are running the migrations as one of the very last steps before the production deployment is done, as close to the start of the service as possible, ideally in your CI/CD pipeline.</p><p>If you do not want to run your migrations in CI/CD pipeline, consider following these rules when adding deleting a column so you can avoid downtimes:</p><ul><li>When adding a column, migrate first and then deploy</li><li>When deleting a column, deploy first and then migrate</li></ul><h3>Zero downtime migrations</h3><p>When renaming a field in the same release, you will run into failed database requests while the renaming of the fields is happening.</p><p>To avoid the downtime, you will need to roll the new migration progressively by breaking the migration into smaller non-breaking migrations.</p><p>For example, if you want to rename column from text to content, follow these steps in different releases:</p><ol><li>Create column content and mark it as optional and write to it at the same time you&#39;re writing to the text column</li><li>Copy the already existing data from text to content</li><li>Add the <a href="https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#ignore">@ignore</a> tag to text column and make it optional. Mark content as non-optional. Remove references to text in your code.</li><li>Delete the text column and mark content as non-optional</li></ol><h3>Custom migrations</h3><p>Consider you want to add a specific type of index to your column than the one Prisma suggests. Applying the migration directly to the database, will make your prisma.schema and migrations folder to be out-of-sync from your version control repository.</p><p>To avoid out-of-sync schemas, follow these steps:</p><ol><li>Add the index to your column in prisma.schema</li><li>Run npx prisma migrate dev --create-only so it just creates the sql file, but not apply it</li><li>Change the created sql file to contain the custom index you need and apply the migration with npx prisma migrate dev</li><li>Commit the new change to your version control repository</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42fd936bba1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Three Steps of Building Design-First APIs in Kubernetes]]></title>
            <link>https://medium.com/kubeshop-i/the-three-steps-of-building-design-first-apis-in-kubernetes-8810c04304d1?source=rss-973db452be94------2</link>
            <guid isPermaLink="false">https://medium.com/p/8810c04304d1</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[design-first]]></category>
            <category><![CDATA[api-workflow]]></category>
            <dc:creator><![CDATA[Abdallah Abedraba]]></dc:creator>
            <pubDate>Tue, 13 Dec 2022 05:19:15 GMT</pubDate>
            <atom:updated>2022-12-13T05:19:15.299Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EBWYLwS6CNpVuiQc.png" /></figure><p>Every time your organization needs to create a new API from scratch on Kubernetes, you’re faced with a decision: Are we going to create and follow a process to get this job done, or are we just going to stumble our way into a deployment that we hope gets the job done?</p><p>If your organization <em>is</em> mature enough to follow a process, which is a great first step, you also need to decide which route to go. There are a few popular approaches to API design and development, but we’re going to hone in on the <a href="https://kusk.io/blog/from-design-first-to-automated-deployment-with-openapi">design-first approach</a> because it means you’re generating the API’s specifications from the <em>design of your API</em>, not your code. It’s the best way to create APIs that are developer-friendly, go to market faster, and solve everyone’s problems the right way, the first time.</p><p>There are three big steps to get the job done.‍</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WlekBvQAMDAdQfcC.png" /></figure><h3>1. Determine what business problem you’re trying to solve</h3><p>You start by getting the people from technical and business units in the same room (or Zoom call) together to discuss and iterate on how the API should work and validate the design decisions you’re making <em>before</em> anyone even opens up an IDE.</p><p>You’ll ask questions like:</p><ul><li>What do we need to get buy-in from customers, leadership, developers, QA testers, and IT operation?</li><li>What kinds of naming conventions or code quality guides should we enforce?</li><li>Which security, authentication, and authorization standards do we need?</li></ul><h3>2. Codify your API in a human- and machine-readable document</h3><p>Once you know exactly what your team is trying to accomplish, you can start translating the business requirements and goals into an API definition using <a href="https://www.openapis.org/">OpenAPI</a>, which is the most broadly adopted specification for new APIs. The YAML syntax makes it approachable for technical and business folks alike.</p><p>Your goal in this step is to convert your agreed-upon design into an OpenAPI definition, a single document that details exactly how the API works, like the path(s) it responds to, what structure and type those responses should be, what security schemes the API will need, what kind of validation is required, and more.</p><p>In the end, this definition becomes your API contract: A single source of truth for how your API works on the frontend, backend, and from the end user’s perspective.</p><h3>3. Convert the API design into code, tests, and other artifacts using generators… like Kusk!</h3><p>With your OpenAPI definition in Git, your teams can start writing client- and server-side code that meets those requirements. Or you can use other tools that convert your API into other valuable resources or knowledge:</p><ul><li>With <a href="https://openapi-generator.tech/">openapi-generator</a>, you can generate client- and server-side code in a variety of languages.</li><li>Tools like <a href="https://github.com/apideck-libraries/portman">portman</a> automatically create tests from your OpenAPI definition</li><li>Complete, up-to-date, and exhaustive documentation that can be generated with <a href="https://stoplight.io/open-source/elements">Stoplight Elements</a></li><li>Security verification against known vulnerabilities and remediation advice using tools like <a href="https://42crunch.com/">42Crunch</a></li></ul><p>And when it comes to taking an OpenAPI definition to a live Kubernetes deployment, there’s <a href="https://kusk.io/">Kusk</a>, an API Gateway that helps you validate, deploy, and monitor your APIs using the open-source and much-loved <a href="https://www.envoyproxy.io/">Envoy Proxy</a>.</p><p>With Kusk, developers can annotate existing OpenAPI definitions to add any gateway-related configurations, like CORS rules, cache controls, rate limiting, and much more. Kusk automatically turns that under the hood into an Envoy Proxy configuration, plus the rest of the OpenAPI definition, into a functional gateway that can validate requests and consolidate your error handling.</p><p>There’s more — once you’re using Kusk, your frontend developers can use gateway-level mocking to start building the end-user experience while their peers in the backend team work on implementing the API, getting your API to production way faster.</p><p>Ready to build your next API with a design-first strategy? <a href="https://docs.kusk.io/getting-started/install-kusk-cli/">Install Kusk</a> and get involved on <a href="https://bit.ly/kubeshop-discord">Discord</a> to learn from others at this exciting intersection between OpenAPI and Kubernetes. The power of the API community awaits…!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8810c04304d1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kubeshop-i/the-three-steps-of-building-design-first-apis-in-kubernetes-8810c04304d1">The Three Steps of Building Design-First APIs in Kubernetes</a> was originally published in <a href="https://medium.com/kubeshop-i">Testkube</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy NextJS App in Kubernetes]]></title>
            <link>https://medium.com/kubeshop-i/deploy-nextjs-app-in-kubernetes-915ba034dcb0?source=rss-973db452be94------2</link>
            <guid isPermaLink="false">https://medium.com/p/915ba034dcb0</guid>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[frontend]]></category>
            <dc:creator><![CDATA[Abdallah Abedraba]]></dc:creator>
            <pubDate>Thu, 08 Dec 2022 21:35:06 GMT</pubDate>
            <atom:updated>2022-12-08T21:35:06.247Z</atom:updated>
            <content:encoded><![CDATA[<p>Deploying your NextJS application (or any web application for that matter) to Kubernetes should be a seamless experience. Containerize your NextJS app, create a Kubernetes Deployment and… done?</p><p>Actually, that’s not all. You still need to expose the application to the public, connect it to your domain, and probably do some fancy stuff like adding an OAuth login to your application. So, is that something you need to code yourself?</p><h3>Use an API Gateway to deploy your web applications</h3><p>Most of these issues that we describe in the process of deploying your web application in Kubernetes are actually solved by an API Gateway.</p><p>An API Gateway (or in Kubernetes terms, an Ingress Controller) is responsible for exposing your applications and microservices to the public, so people from outside the cluster can visit your application through your domain.</p><p>The API Gateway usually helps you connect your domain to your Kubernetes application, add authentication rules like OAuth, protect your application against DDoS attacks, add CORS rules, and load balance the traffic that is incoming. All of these without the need to write a single line of code yourself.</p><h3>Deploy your NextJS application in Kubernetes with Kusk Gateway</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wpQx4cTAxOLF9H00.png" /></figure><p><a href="https://kusk.io/">Kusk Gateway</a> is fully open-source API Gateway for Kubernetes that focuses on providing APIs with an amazing developer experience and simplicity of use, with the power of OpenAPI; but it also helps frontend developers deploy their applications easily in Kubernetes.</p><p>Let’s show an example of how to deploy your NextJS application with Kusk Gateway in Kubernetes. These instructions actually apply to any web application written in any language.</p><h3>1. Containerize your NextJS app</h3><p>We will first need to create a container of the web application and upload it to a container registry like Dockerhub.</p><p>To containerize your NextJS application follow the instruction from the NextJS team <a href="https://nextjs.org/docs/deployment#docker-image">here</a>. And once you’ve containerized it, don’t forget to push it to your Dockerhub registry.</p><pre>docker push -t $DOCKER_USERNAME/web-application .</pre><h3>2. Create a Kubernetes cluster</h3><p>There are many options to create a Kubernetes cluster, locally or using a cloud provider. The Title team <a href="https://docs.tilt.dev/choosing_clusters.html">has documented well</a> which clusters work best for your use cases.</p><p>For this tutorial, it’s best if you can use a cloud provider cluster. There are very cheap options like <a href="https://www.civo.com/">Civo cloud</a> from 5$/month. But you can also use a local cluster with Minikube or Kind.</p><h3>3. Install Kusk Gateway in your cluster</h3><p>Once you’ve connected to a Kubernetes cluster, install the Kusk CLI which will help you install and manage Kusk Gateway in your cluster:</p><pre># MacOS<br>brew install kubeshop/kusk/kusk<br><br># Linux<br>curl -sSLf https://get.kusk.io | bash<br># Windows<br><br>choco source add --name=kubeshop_repo --source=https://chocolatey.kubeshop.io/chocolatey<br>choco install kusk -y</pre><p>Once you’ve installed the CLI, run the following command which will install Kusk Gateway in your Kubernetes cluster:</p><pre>kusk cluster install</pre><h3>4. Deploy your application to the cluster</h3><p>We’ll take the containerized application from step 1 and deploy it to the cluster. Make sure to update the $DOCKER_USERNAME field and the name of the container if you’ve changed it, in this case we’re using the container name web-application.</p><pre>kubectl create deployment web-app --image=$DOCKER_USERNAME/web-application<br>kubectl expose deployment web-app --name web-app-svc --port=3000</pre><h3>5. Expose your web application to the public with Kusk Gateway</h3><p>To expose your application with Kusk Gateway, you will need to create a Kusk StaticRoute. Here’s an example of one you can use for your application:</p><pre>apiVersion: gateway.kusk.io/v1alpha1<br>kind: StaticRoute<br>metadata:<br>  name: web-app-static-route<br>spec:<br>  fleet:<br>    name: kusk-gateway-envoy-fleet<br>    namespace: kusk-system<br>  upstream:<br>    service:<br>      name: web-app-svc<br>      namespace: default<br>      port: 3000</pre><p>Create a static-route.yaml file with the above content and apply it to the cluster with:</p><pre>kubectl apply -f static-route.yaml</pre><p>And your application is now exposed to the world!</p><h3>6. Test your application in the browser</h3><p>To test your application you’ll need to get the IP address of the gateway. Run the following command to obtain it:</p><pre>kusk ip<br><br>&gt; output: 12.34.56.78</pre><p>Now test this in your browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/0*3Pf7mwcw_ZM3fKSl.png" /></figure><h3>Next steps</h3><p>As a next step, you can try to connect your domain to the IP address of the application, you can follow an example the Kusk team has prepared <a href="https://github.com/kubeshop/kusk-examples/tree/main/with-cert-manager">here</a>. Or you can add OAuth to your frontend application, <a href="https://docs.kusk.io/guides/authentication/oauth2">the guides</a> are already created for you!</p><p>Kusk also helps your API/backend team be very productive with the use of OpenAPI. It enables some neat GitOps workflows while providing all the features of a resilient gateway to the APIs. Give it a try and spread the word!</p><p>If you have any questions or ideas please feel free to join our <a href="https://discord.gg/uNuhy6GDyn">Discord server</a> and get in touch. Kusk is fully open source, so you can always help us by <a href="https://github.com/kubeshop/kusk-gateway/">starring the project on GitHub</a>, opening issues, or a PR!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=915ba034dcb0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kubeshop-i/deploy-nextjs-app-in-kubernetes-915ba034dcb0">Deploy NextJS App in Kubernetes</a> was originally published in <a href="https://medium.com/kubeshop-i">Testkube</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What It Means to Be OpenAPI-First in Kubernetes]]></title>
            <link>https://medium.com/kubeshop-i/what-it-means-to-be-openapi-first-in-kubernetes-a8f5e784e9a5?source=rss-973db452be94------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8f5e784e9a5</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[open-api]]></category>
            <category><![CDATA[api-gateway]]></category>
            <dc:creator><![CDATA[Abdallah Abedraba]]></dc:creator>
            <pubDate>Tue, 06 Dec 2022 16:26:40 GMT</pubDate>
            <atom:updated>2022-12-06T16:26:40.370Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9DhIfaQyxFvL9Cz-.png" /></figure><p><a href="https://www.openapis.org/">OpenAPI</a> (previously known as Swagger) is a specification that initially provided developers the ability to document their REST APIs so users can easily understand what they offer and how to consume them. But because it is also a machine-readable specification, it has allowed for a boom of tooling around the specification and, as a result, around REST APIs.</p><h3>OpenAPI Is Not Just About API Documentation</h3><p>When developers are starting with their OpenAPI journey, they usually don’t realize that it can entail much more than just generating the documentation of the API. OpenAPI offers a modern way to build an API altogether that allows teams to acquire a lot of productivity and have a better development experience.</p><p>Let’s look at what these modern development workflows are and what they achieve.</p><h3>Design-First Approach</h3><p>Design-first is the process of designing and agreeing on an OpenAPI definition, and only after that each team can start working on writing the code to match the designed OpenAPI definition that now serves as an API contract.</p><p>Following this workflow will allow teams to have a more thoughtful discussion on what the API is going to look like (after all, we should think before we code, right?) and it allows different teams from the organization to be involved, such as consumer teams, legal, marketing, etc.</p><p>Tools like <a href="https://openapi-generator.tech/">openapi-generator</a> fit really well with the design-first approach, as API producers and consumers alike can generate boilerplate code from their OpenAPI definition for both servers and clients. There are also <a href="https://openapi.tools/#testing">myriad testing tools</a> that can use OpenAPI definitions to generate test skeletons to be used as a basis for testing functionality, performance and security.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*so--wv7zTCQr8uPfXjENMw.png" /></figure><p>Mocking tools can take an OpenAPI definition and generate mocked responses for the API automagically. With a design-first approach and mocking, frontend teams, for example, can start working on using the designed API without having to wait on the backend team, <a href="https://kubeshop.io/blog/rapidly-prototype-your-apis-on-kubernetes-with-kusk-gateway">a great improvement in developer productivity</a>.</p><h3>Declarative Configurations for API Deployment</h3><p>Eventually, an API will need to be deployed on infrastructure to make it available to consumers. In an environment that uses declarative configuration, developers define a configuration file that describes what the expected behavior of the system should be, and then some tools will reconcile the configuration with the system to match the expected behavior.</p><p>The Kubernetes project, and also tools like Terraform or Puppet, have vastly propelled the use of more and more declarative configurations through the use of YAML files. That’s because they’ve solved the issue of reconciling declarative configurations, which is a sophisticated solution in and of itself. So now developers can use these systems to deploy their applications and configure their environments.</p><p>This development pattern has allowed for methodologies like GitOps to rise: putting a declarative configuration in your GitHub repository and then using all the bells and whistles GitHub offers to deploy your application in a continuous way.</p><p>Ideally, you would be able to “<a href="https://thenewstack.io/can-you-gitops-your-apis">GitOps your APIs</a>,” but so far there hasn’t been an easy way to achieve that. The OpenAPI specification already offers a standard way to define APIs, but the Kubernetes ecosystem didn’t have first-class support for it. At least not yet.</p><h3>Enter Kusk, an OpenAPI-first Gateway for Kubernetes</h3><p>When the <a href="https://kusk.io/">Kusk</a> team at Kubeshop set out to bridge the gap between Kubernetes and OpenAPI, we thought of beginning to solve the problem from the entry point of APIs in Kubernetes: the gateway. Gateways or ingress controllers are what direct the traffic to different microservices depending on the request. For example, if a user makes a GET /cart request, the gateway should direct the request to the microservice that handles that specific path.</p><p>Having a gateway that can support OpenAPI was the first step to unlocking the power of the specification in the Kubernetes realm, but we didn’t find tools that really addressed it fully.</p><h3>How Did Existing Gateways Support OpenAPI?</h3><p>We wanted to look at how the popular gateways solved this issue. For instance, Kong’s support of OpenAPI is extremely cumbersome. To be able to configure Kong using OpenAPI, you need to convert the OpenAPI definition to a Kong-specific YAML definition by the use of <a href="https://github.com/Kong/insomnia">Insomnia’s CLI</a> and then use <a href="https://github.com/Kong/deck">decK</a> to convert that YAML definition to API calls that configured Kong through the Admin API. It was clear to us that OpenAPI was an afterthought in that case.</p><p>Other projects like <a href="https://www.krakend.io/">KrakenD</a> support some importing of OpenAPI, but developers still need to learn a specific configuration language to use KrakenD. Finally, Google’s Gateway had limited support for OpenAPI, and most of the configuration could only be done through Google Cloud’s GUI, REST API or Terraform.</p><p>Unfortunately for developers out there, none of the aforementioned gateways allow for a fluid and iterative development and deployment workflow for teams that have embraced an OpenAPI-first approach to building their APIs.</p><h3>How Kusk Uses OpenAPI to Deploy Your APIs</h3><p><a href="https://kusk.kubeshop.io/">Kusk</a> is an open source OpenAPI-driven gateway for Kubernetes built by the team at Kubeshop. We wanted to take the benefits of the OpenAPI ecosystem and apply them to the Kubernetes world, and we were lucky to have Ole Lensmar, chairman of the OpenAPI specification for some years, to lead us.</p><p>When it came to using a gateway, we didn’t want to reinvent the wheel, as it is a very critical piece of software. We also wanted to have an open source solution and use open source all we could. We ended up choosing <a href="https://www.envoyproxy.io/">Envoy</a> to power the gateway we were looking for. Envoy is a well-tested piece of software that has been <a href="https://www.envoyproxy.io/community">used by many big projects in the Kubernetes world</a>, although we knew we needed to simplify its configuration for developers.</p><p>With Kusk, the gateway is totally configured through OpenAPI. We use an x-kusk annotation to extend the OpenAPI definition so developers can add the gateway-related configurations in a very simple way, like CORS rules, cache-control, rate-limit, OAuth and more directly to the OpenAPI definition. We then translate these annotations to Envoy-specific configuration, so we can abstract Envoy completely and let developers focus on the API only.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UqlW7wfbogogjXgJ8J96fA.png" /></figure><p>We didn’t want to be yet another gateway. We wanted developers to need only OpenAPI to configure all the aspects of the API, from the functional to the operational ones like configuring said gateway.</p><p>Because Kusk uses OpenAPI to configure Envoy, there are important features that can be unlocked from the gateway level, like <a href="https://kubeshop.io/blog/automatic-request-validation-with-openapi">automatically validating the requests</a> with the fields defined in the OpenAPI definition, or even enabling gateway-level mocking of the APIs, and much more.</p><h3>OpenAPI in Kubernetes, Finally</h3><p>With Kusk, we wanted to tap into the power of the OpenAPI ecosystem fully. We expect developers not just to use the gateway itself, but to be able to use other tools from the OpenAPI ecosystem like documentation, code-generators, mocking and all the available tools and the ones to come from the power of the OpenAPI community.</p><p>Give <a href="https://kusk.kubeshop.io/">Kusk</a> a try and let us know what you think. The team is available to answer any questions on <a href="https://bit.ly/kubeshop-discord">Discord</a> and we are always welcoming and excited about <a href="https://github.com/kubeshop/kusk-gateway">pull requests</a> from the community.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8f5e784e9a5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kubeshop-i/what-it-means-to-be-openapi-first-in-kubernetes-a8f5e784e9a5">What It Means to Be OpenAPI-First in Kubernetes</a> was originally published in <a href="https://medium.com/kubeshop-i">Testkube</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kusk-gateway 1.4: OpenAPI code-first support]]></title>
            <link>https://medium.com/kubeshop-i/kusk-gateway-1-4-openapi-code-first-support-498306ffcee?source=rss-973db452be94------2</link>
            <guid isPermaLink="false">https://medium.com/p/498306ffcee</guid>
            <category><![CDATA[code-first]]></category>
            <category><![CDATA[openapi-overlays]]></category>
            <category><![CDATA[api-gateway]]></category>
            <dc:creator><![CDATA[Abdallah Abedraba]]></dc:creator>
            <pubDate>Tue, 06 Dec 2022 07:50:28 GMT</pubDate>
            <atom:updated>2022-12-06T07:50:28.465Z</atom:updated>
            <content:encoded><![CDATA[<p>This 1.4.0 release adds support for code-first OpenAPI generation, support to install Kusk CLI using apt and choco and scalable authorization with Cloudentity.</p><h3>Code-first support with OpenAPI Overlays</h3><p>Until now, Kusk Gateway fitted really well with design-first approaches when working with OpenAPI, meaning teams would create the OpenAPI definition before starting to write code. This is helpful when your team uses code generation tools, Kusk mocking feature, and more.</p><p>Kusk now supports code-first approaches, i.e. OpenAPI generated from code annotations, by use of OpenAPI Overlays.</p><p><a href="https://github.com/OAI/Overlay-Specification">OpenAPI Overlays</a> is a new specification that allows you to have an OpenAPI file without any Kusk extensions, and an overlay file containing the extenions you would want to add to your OpenAPI definition. After merging the overlay with the OpenAPI file, the resulting file is an OpenAPI definition with all the metadata added to it, ready to be deployed by Kusk.</p><p>This way, teams can generate their OpenAPI from code, and then add the gateway deployment metadata later.</p><p><a href="https://docs.kusk.io/guides/overlays">Check out the documentation</a> for examples of how to use OpenAPI Overlays with Kusk.</p><h3>Simplified frontend deployment</h3><p>We have simplified how you deploy frontend web applications with Kusk and improved the developer experience. It’s now extremely simple to deploy a web application written in any language and framework to Kubernetes with Kusk Gateway.</p><p>Check out <a href="https://github.com/kubeshop/kusk-examples">our example</a> on deploying a front-end web application on Kubernetes using Kusk Gateway.</p><h3>Scalable authorization with Cloudentity</h3><p>Earlier this month we <a href="https://kusk.io/blog/kusk-and-cloudentity">announced our partnership with Cloudentity</a>, an authorization management platform, which will allow Kusk users to have an authorization platform that scales at the same pace as their APIs, while using all the benefits of Kusk Gateway and OpenAPI.</p><p><a href="https://docs.kusk.io/guides/authentication/cloudentity">Check out our guides</a> on how to use Cloudentity with Kusk Gateway and start your API authorization journey now!</p><h3>… and more!</h3><p>We keep adding little but important features for Kusk users, this release includes:</p><ul><li>Support for apt and choco installation methods of Kusk CLI for Debian and Windows users</li><li>Added kusk validate command to validate and report errors on your OpenAPI definition before applying it</li><li>Added support for OpenAPI External References for Kusk Gateway</li></ul><h3>Try it out!</h3><p>Try and download the new version of Kusk <a href="https://kusk.io/blog/docs.kusk.io/getting-started">here</a>! If you have any questions or ideas please feel free to join our <a href="https://discord.gg/uNuhy6GDyn">Discord server</a> and get in touch. Kusk is fully open source, so you can always help us by starring the <a href="https://github.com/kubeshop/kusk-gateway/">project on github</a>, opening issues or a PR!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=498306ffcee" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kubeshop-i/kusk-gateway-1-4-openapi-code-first-support-498306ffcee">Kusk-gateway 1.4: OpenAPI code-first support</a> was originally published in <a href="https://medium.com/kubeshop-i">Testkube</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Choosing a database solution and ORM for Node.js]]></title>
            <link>https://medium.com/@aabedraba/choosing-a-database-solution-and-orm-for-node-js-6c256ced72ff?source=rss-973db452be94------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c256ced72ff</guid>
            <category><![CDATA[prism]]></category>
            <category><![CDATA[orm]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Abdallah Abedraba]]></dc:creator>
            <pubDate>Tue, 25 Oct 2022 17:36:39 GMT</pubDate>
            <atom:updated>2022-10-25T17:36:39.547Z</atom:updated>
            <content:encoded><![CDATA[<p>In my last project we set out to build our infrastructure from ground up. We knew we wanted to do everything in React and Node.js, as having a single programming language for the frontend and backend helps when it comes to hiring, allows developers to tap in with less friction in both stacks, and improves the speed of product development and iterations, which is crucial in a startup.</p><p>But with great power speed of development, comes great responsibility. To protect ourselves from runtime errors (cannot read property of undefined anyone?), increase robustness and improve the developer experience, we chose TypeScript, a statically typed superset of Javascript. We had a lot of love in our team for TypeScript and once we tried it we couldn’t go back to plain ole Javascript!</p><p>Another decision we had to make is with regards to the type database we needed. We have all appreciated at some point NoSQL solutions like DynamoDB, or Google’s Firebase. But with rapidly increasing data relations and in the spirit of robustness, developer experience and consistency that we found in TypeScript, we ended up choosing SQL for great part of our solutions, which is <a href="https://blog.couchbase.com/unreasonable-effectiveness-of-sql/">unreasonably effective</a>.</p><p>Finally with the same spirit (read <a href="https://vimeo.com/230142234"><em>values</em></a>), we start our journey to find the right ORM in the Node.js ecosystem. There are many options out there, but the most popular ones were <a href="https://knexjs.org/">KnexJs</a>, <a href="https://typeorm.io/">TypeORM</a>, <a href="https://sequelize.org/">Sequelize</a> and the growing <a href="https://prisma.io/">Prisma</a>.</p><h3>Typescript support</h3><p>It wouldn’t make sense to use an ORM that does not support types when working with Typescript. So we really are looking for first class support of Typescript. KnexJs and Sequelize both mention that TypeScript really doesn’t make much of a difference [<a href="https://knexjs.org/#typescript-support">1</a>][<a href="https://sequelize.org/v7/manual/typescript.html">2</a>]. Also, looking at their respective Github projects, both projects are entirely written in Javascript, with later added types definitions.</p><p>In contrast, TypeORM and Prisma are almost fully written in TypeScript and both support TypeScript at their core. Although I found that TypeORM does lack vigorous type support, for example the ILIKE operator allows for any type to be passed in, and it doesn&#39;t have a nested relation type support.</p><h3>Migrations</h3><p>Support for migrations was essential as we wanted a tool that could help us with:</p><ul><li>versioning our migrations, e.g. using git</li><li>database rollbacks</li><li>the inevitable editing of fields</li><li>zero downtime migration</li></ul><p>Really all the ORMs that we are comparing in this article have support for the first three, although it’s worth noting that TypeORM did not have official support for seeding data into the database.</p><p>The last point though, I could not really find a lot of documentation in Knex, TypeORM and Sequelize with regards to no-downtime migrations. Prisma did have an edge over the others with its documented support for <a href="https://www.prisma.io/docs/guides/database/developing-with-prisma-migrate/customizing-migrations#renaming-a-field"><em>Expand and Contract</em> pattern</a>.</p><h3>Testing</h3><p>All four options have support for testing, although I found that Sequelize did not have trivial mocking of the library, like Knex’s mock-knex or Prisma&#39;s and TypeORM&#39;s deep mock solutions.</p><h3>Documentation</h3><p>Last but not least, documentation is a very important decision factor when it comes to choosing a library.</p><p>TypeORM and Sequelize both have a very well documented library, full of examples. Knex’s documentation I found just very esoteric and with poor presentation. But the surprise came with Prisma’s docs which are just delightful!</p><h3>Decision!</h3><p>So, all in all, the comparison looks like this table below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5EaLCc4dhqbc9YhywWMFzQ.png" /></figure><p>Needless to say we did end up choosing Prisma as it really have excelled in every category we were looking for.</p><h3>Experience and conclusion</h3><p>I personally really enjoyed working with Prisma, and so have my teammates! Prisma really have bridged the gap to become a fullstack developer, being able to tap in the backend with no fear of facing SQL for the most part.</p><p>The main issues we did have was that <strong>the library has been changing rapidly</strong>. And this is really a praise disguised in a complaint. At the time we adopted Prisma it was still in 1.0 and the website did mention that it wasn’t ready for production. So when 2.0 came, and subsequently its readiness for production, we did have to do quite the migration. But the docs really helped us with this.</p><p>Another issue that we ran into was that the library from one version to the other stopped having support for our unit testing methodology, so at some points instead of dealing with it, we had to halt the upgrade until we found a solution.</p><p>Finally we ran into issues related to the serverless environments that we were using, and the prisma team and its very involved community <a href="https://github.com/prisma/prisma/issues/10353">helped us a lot</a> closing these problems.</p><p>After two years of experience and looking forward, Prisma looks like it’s stabilizing quite a lot while the production of features keeps a great pace. I definitely will continue using it for new projects!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c256ced72ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kusk + Cloudentity — Fine-Grained Authorization for your APIs]]></title>
            <link>https://medium.com/kubeshop-i/kusk-cloudentity-fine-grained-authorization-for-your-apis-34d60b1968ba?source=rss-973db452be94------2</link>
            <guid isPermaLink="false">https://medium.com/p/34d60b1968ba</guid>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[open-api]]></category>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[api-gateway]]></category>
            <dc:creator><![CDATA[Abdallah Abedraba]]></dc:creator>
            <pubDate>Tue, 18 Oct 2022 04:43:56 GMT</pubDate>
            <atom:updated>2022-10-18T04:49:38.119Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kusk + Cloudentity — Fine-Grained Authorization for your APIs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Qxgi5jSWy6YeJwAXkC3dg.png" /></figure><p>The Kusk team is glad to announce it has partnered with <a href="https://cloudentity.com/">Cloudentity</a>, an authorization-as-a-service platform, to enable users to leverage Cloudentity’s robust centralized policy management and distributed Authorizer frameworks in combination with <a href="https://kusk.io/">Kusk’s</a> OpenAPI extensions.</p><p>Security and infrastructure teams at organizations across the world rely on Cloudentity to keep their applications safe and secure. We’re excited to join their team of trusted partners like Okta, Amazon Web Services (AWS), Azure, Google, and Axway.</p><p>This is part of our main effort in helping companies create better and more resilient APIs.</p><h3>OpenAPI for Open Standards</h3><p>Cloudentity embraces open standards and open-source in its journey to enable developers to implement scalable security from day one. Cloudentity users achieve security compliance faster and with less effort in ecosystems like Open Banking, which heavily rely on standards like OpenAPI.</p><p>Kusk allows users to extend their OpenAPI definitions to include API gateway configuration rules so developers can have less complexity in their path to production. The configuration of the API gateway by use of OpenAPI enables developers to include features like response mocking and request body validation, among many others, out-of-the-box from day one.</p><h3>Control the Authorization of APIs</h3><p>Kusk allows users to create their own authorization logic with <a href="https://docs.kusk.io/guides/authentication/custom-auth-upstream">Custom Auth Upstreams</a>. But dealing with authorization rules is complicated and doesn’t easily scale.</p><p>With Cloudentity added as an authorizer to Kusk Gateway, API requests are now protected with rules that developers can create using Cloudentity’s <a href="https://cloudentity.com/developers/howtos/access_policies/creating-cloudentity-policies-using-visual-editor/">Visual Policy Editor</a> or <a href="https://cloudentity.com/developers/howtos/access_policies/protecting-apps-using-open-policy-agent/">REGO policies</a> built on Open Policy Agent. These rules are then orchestrated in Cloudentity allowing developers to tailor the authorization of their APIs easily and scale it at the same time their API grows.</p><p>This is a great step for developers that use Kusk Gateway with their APIs, enabling more out-the-box working API self-service solutions, while still maintaining flexibility and control over the gateway in their Kubernetes clusters.</p><h3>How does this integration work?</h3><p>To use Cloudentity as the authorizer of your API requests with Kusk Gateway, you need to add the auth extension to your OpenAPI spec:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/856cd6e3430f00c34c6c5e212283f004/href">https://medium.com/media/856cd6e3430f00c34c6c5e212283f004/href</a></iframe><p>Kusk then configures the gateway to use a Cloudentity Authorizer that will filter requests using Cloudentity’s powerful and highly customizable authorization rules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3qVmlPqybcw06Zbe.jpg" /></figure><p>You can see the full instructions on how to use Cloudentity with Kusk in our <a href="https://docs.kusk.io/guides/authentication/cloudentity">guides</a>.</p><h3>Try it out now!</h3><p>We are very excited to add more integrations that enable our users to build great APIs. Check on how to use Cloudentity with Kusk in our <a href="https://docs.kusk.io/guides/authentication/cloudentity">guides</a>. If you have any issues or questions about Kusk Gateway with Cloudentity, reach out to the team on the <a href="https://discord.gg/6zupCZFQbe">Discord channel</a> or open an issue in the GitHub <a href="http://github.com/kubeshop/kusk-gateway">repository</a>).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34d60b1968ba" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kubeshop-i/kusk-cloudentity-fine-grained-authorization-for-your-apis-34d60b1968ba">Kusk + Cloudentity — Fine-Grained Authorization for your APIs</a> was originally published in <a href="https://medium.com/kubeshop-i">Testkube</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup Ingress Controller with CORS configuration]]></title>
            <link>https://medium.com/kubeshop-i/setup-ingress-controller-with-cors-configuration-51c04cee6729?source=rss-973db452be94------2</link>
            <guid isPermaLink="false">https://medium.com/p/51c04cee6729</guid>
            <category><![CDATA[ingress]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[open-api]]></category>
            <category><![CDATA[cors]]></category>
            <dc:creator><![CDATA[Abdallah Abedraba]]></dc:creator>
            <pubDate>Tue, 04 Oct 2022 16:46:34 GMT</pubDate>
            <atom:updated>2022-10-04T17:18:21.739Z</atom:updated>
            <content:encoded><![CDATA[<p>Configuring CORS in Kubernetes is not easy, let alone debugging issues with it. In a microservices architecture, leaving CORS to be managed by each backend could lead to non-standardized CORS rules throughout your APIs. So how can we solve these issues?</p><h3>First things first, what is CORS?</h3><p>CORS is a mechanism implemented by browsers to ensure that requests are not sent to the server when the request is made by a domain the server does not expect to receive a request from (for example, malicious.com).</p><p>It’s a security feature implemented for browsers mainly because when using CORS acts on the Origin header of a request (which an attacker can easily set if they’re running the request outside of the browser), it’s no good for the server to protect against these types of requests. But, if the request is made through a browser, the Origin header cannot be overridden by an attacker because the browser controls this header. So CORS becomes a browser’s responsibility as it’s the browser that should block the malicious requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*yQgYrHEYDW-vswvN.png" /></figure><h3>How to configure your Ingress Controller for CORS?</h3><p>For this example, we will be using <a href="https://kusk.io/">Kusk Gateway</a>, an open-source OpenAPI-driven Ingress Controller. The reasons we want to use Kusk Gateway is that firstly it simplifies the configuration of Envoy, a very sophisticated proxy, and it allows users to configure it using an <a href="https://www.openapis.org/">OpenAPI definition</a>, so the developers don’t need to learn yet another Kubernetes annotations (the case with Nginx Ingress for example), and they can <a href="https://thenewstack.io/what-it-means-to-be-openapi-first-in-kubernetes/">leverage the OpenAPI ecosystem</a> for code-generation, API mocking, testing, <a href="https://openapi.tools/">and more</a>.</p><p>Let’s see how that looks in practice. We will deploy a simple hello-world example.</p><h3>1- Install Kusk in your Kubernetes cluster</h3><p>First, let’s install the Kusk CLI:</p><pre># MacOS<br>brew install kubeshop/kusk/kusk</pre><pre># Linux<br>curl -sSLf https://raw.githubusercontent.com/kubeshop/kusk-gateway/main/cmd/kusk/scripts/install.sh | bash</pre><pre># Windows (go binary needed)<br>go install -x github.com/kubeshop/kusk-gateway/cmd/kusk@latest</pre><p>Once the CLI is installed, proceed to install Kusk in your cluster:</p><pre>kusk cluster install</pre><h3>2- Deploy a sample application to your cluster</h3><p>You can deploy this example application:</p><pre>kubectl create deployment hello-world --image=kubeshop/kusk-hello-world:v1.0.0</pre><p>And we now wrap it in a service:</p><pre>kubectl expose deployment hello-world --type=ClusterIP --port=8080</pre><h3>3- Configure your OpenAPI definition for Kusk</h3><p>Create a file openapi.yaml with the following content:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97dacb3bb29bf3f8676ac3f0feb45eb1/href">https://medium.com/media/97dacb3bb29bf3f8676ac3f0feb45eb1/href</a></iframe><p>As you can see this is a standard OpenAPI definition. This API exposes a single /hello path.</p><p>We also have the x-kusk extension, this is a standard way to make annotations in OpenAPI, we’ve added there the CORS rules for our API and also the upstream details of the application we deployed in the first step.</p><h3>4- Apply the changes to the cluster</h3><p>The following command will configure Kusk Gateway with the new rules:</p><pre>kusk deploy -i openapi.yaml</pre><h3>5- Connect to Kusk Gateway</h3><p>One way of testing CORS rules is by trying to access the website from the browser through a different domain than the one we have defined in CORS. The other way of testing it is through the CLI with curl. Let’s explore both.</p><p>But first, let’s get the External IP of our Ingress Controller:</p><pre>kusk ip</pre><h3>6- How to test CORS?</h3><p>As you’ve seen in the step earlier, we have configured CORS to expect requests from example.com and we will now make our requests from example.org to test that the requests are blocked.</p><p>Open <a href="https://example.org/">https://example.org</a> in your browser, and access the developer console, then run the following Javascript snippet (make sure your change the EXTERNAL-IP):</p><pre>(function() {<br>  fetch(&quot;http://EXTERNAL-IP/hello&quot;)<br>    .then(res =&gt; console.log(res))<br>})()</pre><p>Given that our CORS configuration expects requests from example.com and not example.org, the browser should fail the request with the following error:</p><pre>Access to fetch at &#39;http://localhost:8080/hello&#39; from origin &#39;https://example.org&#39; has been blocked by CORS policy: No &#39;Access-Control-Allow-Origin&#39; header is present on the requested resource.</pre><p>What is happening under the hood is that the browser makes a <a href="https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request">preflight request</a> (a request before the actual request is made) which essentially asks the server for the origins that it expects to be called from. This happens by making an HTTP request using the <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS">OPTIONS</a> method.</p><p>The server checks the origin header that the browser has set and it then can decide between either adding the `Access-Control-Allow-Origin: <a href="https://example.com`/">https://example.com`</a> or not adding it. In case it’s not added (meaning the server does not recognize the origin it’s being called from), the browser blocks the actual request.</p><h3>CORS through your Ingress Controller made easy</h3><p>With Kusk, it’s really easy to configure CORS in your APIs from a single place and using a standard like OpenAPI, which is essential for any modern REST API developer.</p><p>Check out how to configure CORS, rate-limiting and authentication in your Ingress Controller in our <a href="http://docs.kusk.io/">guides</a> and let us know about your experience in our <a href="https://discord.gg/uNuhy6GDyn">Discord channel</a>, and we are more than happy to see issues raised and PRs opened in our <a href="https://github.com/kubeshop/kusk-gateway">Github repository</a> :)</p><p>Thank you for reading!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51c04cee6729" width="1" height="1" alt=""><hr><p><a href="https://medium.com/kubeshop-i/setup-ingress-controller-with-cors-configuration-51c04cee6729">Setup Ingress Controller with CORS configuration</a> was originally published in <a href="https://medium.com/kubeshop-i">Testkube</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>