<?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 Berndt Jung on Medium]]></title>
        <description><![CDATA[Stories by Berndt Jung on Medium]]></description>
        <link>https://medium.com/@berndtjung?source=rss-a73f10339b0f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TGblFJiC62aFvxIXD2FKhw.jpeg</url>
            <title>Stories by Berndt Jung on Medium</title>
            <link>https://medium.com/@berndtjung?source=rss-a73f10339b0f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 15:59:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@berndtjung/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[Dispatch + Services]]></title>
            <link>https://medium.com/dispatchframework/dispatch-services-a501e69613eb?source=rss-a73f10339b0f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a501e69613eb</guid>
            <category><![CDATA[vmware]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[dispatches]]></category>
            <category><![CDATA[functions-as-a-service]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Berndt Jung]]></dc:creator>
            <pubDate>Wed, 11 Apr 2018 21:22:17 GMT</pubDate>
            <atom:updated>2018-04-11T22:16:30.334Z</atom:updated>
            <content:encoded><![CDATA[<p>Functions are stateless. Applications are not. Functions as a Service (FaaS) depend on external services to provide state and other services in order to build more interesting applications. This blog post highlights the new service management functionality within <a href="https://vmware.github.io/dispatch/">Dispatch</a>. This feature is still experimental. Additionally, we will be demonstrating this feature a the <a href="https://cfna18.sched.com/event/f8ee85557deea94f671bfdf756b8f743">Cloud Foundry Summit</a> later this month.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*-dRzUWQnlqgoLSo8rObdBw.png" /></figure><p>In order to bring services to Dispatch, we are leveraging the <a href="https://www.openservicebrokerapi.org/">Open Services Broker API</a> (OSBAPI). This API defines a contract for listing, provisioning and binding services such as databases. By working against this specification, we can easily integrate with any service which has an open service broker implementation. This includes just about any service designed to work with Cloud Foundry, which immediately gives us a great service catalog.</p><p>This post will be a demonstration of using the new services support in Dispatch. More specifically, we will be provisioning and binding an Azure Postgres database from Dispatch, then making that binding available to Dispatch functions. Now your serverless applications have state!</p><p>As stated earlier, this support is still experimental, so it’s likely that the CLI options as well as installation steps will change.</p><h3>Prerequisites</h3><ol><li>A working kubernetes environment with helm initialized.</li><li>Dispatch CLI (<a href="https://github.com/vmware/dispatch/releases">v.0.1.11 release</a>)</li><li>An Azure account</li></ol><p>For this demo, we are installing Dispatch locally via minikube.</p><h3>Installing</h3><h4>Install Dispatch</h4><p>Install Dispatch and create some base resources. See the <a href="https://vmware.github.io/dispatch/documentation/guides/quickstart">quickstart</a> for more information about configuring and installing Dispatch on Kubernetes.</p><pre>$ dispatch install -f config.yaml<br>...<br>Config file written to: /Users/bjung/.dispatch/config.json<br>$ cd examples/<br>$ dispatch create -f seed.yaml <br>Created BaseImage: nodejs6-base<br>Created BaseImage: python3-base<br>Created BaseImage: powershell-base<br>Created Image: nodejs6<br>Created Image: python3<br>Created Image: powershell<br>Created Function: hello-py<br>Created Function: http-py<br>Created Function: hello-js<br>Created Function: hello-ps1<br>Created Secret: open-sesame</pre><h4>Install the service catalog</h4><p>Dispatch is leveraging the Kubernetes service catalog as a proxy to open service brokers. Installing the service catalog and service brokers is currently a manual step handled outside of Dispatch. This is all likely to change as the service management evolves.</p><pre># Add the svc-cat helm repository<br>$ helm repo add svc-cat \<br>    <a href="https://svc-catalog-charts.storage.googleapis.com/">https://svc-catalog-charts.storage.googleapis.com</a><br>&quot;svc-cat&quot; has been added to your repositories<br>$ helm install svc-cat/catalog \<br>    --name catalog --namespace dispatch --wait</pre><h4>Install the Azure Service Broker</h4><p>You will need an Azure account as well as some <a href="https://github.com/Azure/open-service-broker-azure/blob/master/docs/quickstart-minikube.md#cluster-setup">setup</a>.</p><pre># Add the azure helm <br>$ helm repo add azure \<br>    <a href="https://kubernetescharts.blob.core.windows.net/azure">https://kubernetescharts.blob.core.windows.net/azure</a><br>&quot;azure&quot; has been added to your repositories<br>$ helm install azure/open-service-broker-azure --name osba --namespace dispatch --wait \<br>  --set azure.subscriptionId=$AZURE_SUBSCRIPTION_ID \<br>  --set azure.tenantId=$AZURE_TENANT_ID \<br>  --set azure.clientId=$AZURE_CLIENT_ID \<br>  --set azure.clientSecret=$AZURE_CLIENT_SECRET</pre><p>Be aware, it can take a while for the pods to become ready.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z-qwKhgV_bMprpOAQRX4Rw.png" /><figcaption>All pods up and running</figcaption></figure><h3>Working with Services</h3><p>At this point, your environment should be ready to go. It takes a little while for dispatch to sync with the service catalog, so be patient. Also, don’t be alarmed if you see more or less services and plans. The Azure service broker is under heavy development.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p8uSOYag3CfcQUAW05fZGQ.png" /><figcaption>Listing available service classes</figcaption></figure><p>In this example we are going to provision and bind a Postgres database which we can use from a function. The real trick is understanding what parameters are required to properly create a service instance. In the case of the azure services, the <a href="https://github.com/Azure/open-service-broker-azure/blob/master/docs/modules/postgresql.md">documentation</a> is your friend. The OSBAPI includes optional schemas for provisioning and binding, but the Azure service broker does not include these fields.</p><h4>Create a Postgres service instance</h4><pre>$ dispatch create serviceinstance azure-pg azure-postgresql \<br>    basic50 --params &#39;<br>{<br>    &quot;location&quot;: &quot;westus&quot;,<br>    &quot;resourceGroup&quot;: &quot;demo&quot;,<br>    &quot;firewallRules&quot;: [<br>        {<br>            &quot;startIPAddress&quot;: &quot;0.0.0.0&quot;,<br>            &quot;endIPAddress&quot;: &quot;255.255.255.255&quot;,<br>            &quot;name&quot;: &quot;AllowAll&quot;<br>        }<br>    ]<br>}&#39;<br>Created serviceinstance: azure-pg</pre><p>What the above Dispatch command will do is provision and bind a Postgres database via the OSBAPI. What does this mean? Provisioning means creating a new “Azure Database for PostgreSQL server” as well as creating a new database on the server. There are also ways of re-using existing servers and even existing databases, but that’s outside our scope right now. Binding means creating credentials (username/password) for the database and storing those credentials securely. Now, these credentials can be injected into the function similarly to how secrets are injected.</p><p>Provisioning takes some time ~10 minutes. When completed you should see the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*roNfOcl10gbkgldqaNNVfw.png" /><figcaption>A provisioned and bound postgres database</figcaption></figure><p>We can easily verify exactly what happened. If you log into your Azure console and navigate to the “demo” resource group, you will see an “Azure Database for PostgreSQL server” resource with a UUID for a name. Within Dispatch, this UUID corresponds to both the azure-pg serviceinstance’s ID, and the name of the Dispatch secret which stores the binding information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vxbkuMs3TKGxbfqvV6g_dQ.png" /><figcaption>The secret which stores the binding data</figcaption></figure><h4>Using the service from within a function</h4><p>Of course the whole point of all this is to be able to use services from within functions. We have now deployed a Postgres server, created a database and credentials. Those credentials (binding) are stored as Dispatch secrets and can be made available to functions with a simple flag. First, let’s create an image which contains the Postgres driver dependency:</p><pre>$ cd examples/python3/postgres<br>dispatch create image python3-pg python3-base \<br>    --runtime-deps requirements.txt<br>Created image: python3-pg</pre><p>Then create the function:</p><pre>$ dispatch create function python3-pg pg-example postgres.py \<br>    --service azure-pg --schema-in postgres.schema.json<br>Created function: pg-example</pre><p>By adding the --service azure-pg flag we are telling Dispatch to inject the binding to the function at execution time. Credentials are not hard-coded anywhere.</p><p>The function we created is a very simple function which just creates a table (if it doesn’t exist) and writes a simple row from input. We do input validation via the schema defined with the --schema-in postgres.schema.json flag.</p><p>Finally, executing the function:</p><pre>$ dispatch exec pg-example --wait \<br>    --input &#39;{&quot;num&quot;: 1, &quot;data&quot;: &quot;hello everyone&quot;}&#39;<br>{<br>    &quot;blocking&quot;: true,<br>    &quot;executedTime&quot;: 1523469967,<br>    &quot;faasId&quot;: &quot;e130c396-e6af-49f5-983a-e343299bd170&quot;,<br>    &quot;finishedTime&quot;: 1523469970,<br>    &quot;functionId&quot;: &quot;281c05bb-2400-4573-b4d6-e39886b58b7a&quot;,<br>    &quot;functionName&quot;: &quot;pg-example&quot;,<br>    &quot;input&quot;: {<br>        &quot;data&quot;: &quot;hello everyone&quot;,<br>        &quot;num&quot;: 1<br>    },<br>    &quot;logs&quot;: [<br>        &quot;num: 1, data: hello everyone&quot;<br>    ],<br>    &quot;name&quot;: &quot;9d8ee54d-a17b-4251-b661-d6ad1daac88b&quot;,<br>    &quot;output&quot;: [<br>        {<br>            &quot;data&quot;: &quot;hello everyone&quot;,<br>            &quot;num&quot;: 1<br>        }<br>    ],<br>    &quot;reason&quot;: null,<br>    &quot;secrets&quot;: [],<br>    &quot;services&quot;: null,<br>    &quot;status&quot;: &quot;READY&quot;,<br>    &quot;tags&quot;: []<br>}</pre><p>We can see based on the output field that the data has been written to the database. If we run the same function again (with different input), we can see the function can retrieve the previous data:</p><pre>$ dispatch exec pg-example --wait \<br>    --input &#39;{&quot;num&quot;: 2, &quot;data&quot;: &quot;hello everyone again&quot;}&#39;<br>{<br>    &quot;blocking&quot;: true,<br>    &quot;executedTime&quot;: 1523470034,<br>    &quot;faasId&quot;: &quot;e130c396-e6af-49f5-983a-e343299bd170&quot;,<br>    &quot;finishedTime&quot;: 1523470034,<br>    &quot;functionId&quot;: &quot;281c05bb-2400-4573-b4d6-e39886b58b7a&quot;,<br>    &quot;functionName&quot;: &quot;pg-example&quot;,<br>    &quot;input&quot;: {<br>        &quot;data&quot;: &quot;hello everyone again&quot;,<br>        &quot;num&quot;: 2<br>    },<br>    &quot;logs&quot;: [<br>        &quot;num: 1, data: hello everyone&quot;,<br>        &quot;num: 2, data: hello everyone again&quot;<br>    ],<br>    &quot;name&quot;: &quot;0ef780e8-8451-4146-a306-a1cc0ed621eb&quot;,<br>    &quot;output&quot;: [<br>        {<br>            &quot;data&quot;: &quot;hello everyone&quot;,<br>            &quot;num&quot;: 1<br>        },<br>        {<br>            &quot;data&quot;: &quot;hello everyone again&quot;,<br>            &quot;num&quot;: 2<br>        }<br>    ],<br>    &quot;reason&quot;: null,<br>    &quot;secrets&quot;: [],<br>    &quot;services&quot;: null,<br>    &quot;status&quot;: &quot;READY&quot;,<br>    &quot;tags&quot;: []<br>}</pre><h4>Exposing an API endpoint</h4><p>Now we can take our function and expose an HTTP API endpoint:</p><pre>$ dispatch create api post-pg-example pg-example \<br>    --auth public --https-only --method POST --path /postgres/demo<br>Created api: post-pg-example</pre><p>Use the Dispatch config to determine the host and HTTPS port:</p><pre>$ cat ~/.dispatch/config.json<br>{<br>    &quot;host&quot;: &quot;192.168.64.55&quot;,<br>    &quot;port&quot;: 32312,<br>    &quot;scheme&quot;: &quot;https&quot;,<br>    &quot;organization&quot;: &quot;dispatch&quot;,<br>    &quot;cookie&quot;: &quot;******&quot;,<br>    &quot;insecure&quot;: true,<br>    &quot;api-https-port&quot;: 32191,<br>    &quot;api-http-port&quot;: 32023<br>}</pre><p>And it’s live!</p><pre>$ curl -k <a href="https://192.168.64.55:32191/postgres/demo">https://192.168.64.55:32191/postgres/demo</a> \<br>    -H &#39;Content-type: application/json&#39; \<br>    -d &#39;{&quot;num&quot;: 3, &quot;data&quot;: &quot;hello from API&quot;}&#39;<br>[<br>    {&quot;data&quot;:&quot;hello everyone&quot;,&quot;num&quot;:1},<br>    {&quot;data&quot;:&quot;hello everyone again&quot;,&quot;num&quot;:2},<br>    {&quot;data&quot;:&quot;hello from API&quot;,&quot;num&quot;:3}<br>]</pre><h4>Beyond Azure</h4><p>This post demonstrated bringing Azure services to Dispatch, but because the services integration is based on the OSBAPI, any compatible service can be used. Azure was chosen because it offers a compelling list of services and comes with Kubernetes service catalog binding. In other words, it’s an easy integration. As we evolve this feature, we will make adding any OSBAPI compatible service easy directly via Dispatch.</p><h3>Conclusion</h3><p>The above is a very basic example of how you can now leverage external services which advertise via the OSBAPI. With Dispatch you now have the tools to link functions with stateful services like databases and present them via APIs. This is the basis of most web-services. The services support presented, is still very experimental, but we will continue to develop and refine.</p><p>If you are going to the <a href="https://cfna18.sched.com/event/f8ee85557deea94f671bfdf756b8f743">Cloud Foundry Summit North America 2018</a>, please come hear us talk about this feature in person.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a501e69613eb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dispatchframework/dispatch-services-a501e69613eb">Dispatch + Services</a> was originally published in <a href="https://medium.com/dispatchframework">dispatchframework</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>