Creating OSBA Namespaced Service Instances

A TypeScript function to provision namespaced Service Instances with Service Catalog and the Open Service Broker for Azure.

This particular example provisions a Blob Storage named foobar in the Kubernetes namespace named default (ServiceBroker must already exist in this namespace) and in the Azure resource group named testing (Azure will create if not present) in westus2 data-center.

const provision = (
  name: string,
  namespace: string,
  location: string,
  resourceGroup: string
) =>
  fetch(
    `http://localhost:8001/apis/servicecatalog.k8s.io/v1beta1/namespaces/${namespace}/serviceinstances`,
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json"
      },
      body: JSON.stringify({
        apiVersion: "servicecatalog.k8s.io/v1beta1",
        kind: "ServiceInstance",
        metadata: {
          name
        },
        spec: {
          serviceClassExternalName: "azure-storage",
          servicePlanExternalName: "blob-container",
          parameters: {
            location,
            resourceGroup
          }
        }
      })
    }
  );

provision("foobar", "default", "westus2", "testing");

Evan Louie

Evan is software developer who likes to eat, drink, and code. When he's not at the gym or just being lazy, he's usally coding something stupid in an attempt to either break the internet or just make it a little less broken. Evan is currently working as a Open Source Software Engineer at Microsoft on the Open Source West team.

evanlouie evanlouie


Published