<?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 Lionel Villard on Medium]]></title>
        <description><![CDATA[Stories by Lionel Villard on Medium]]></description>
        <link>https://medium.com/@lionelvillard?source=rss-7ff780e12236------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*8jLqqoUSeIcUIKOT.jpeg</url>
            <title>Stories by Lionel Villard on Medium</title>
            <link>https://medium.com/@lionelvillard?source=rss-7ff780e12236------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 01:08:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lionelvillard/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[Creating Users in Kind Cluster]]></title>
            <link>https://medium.com/@lionelvillard/creating-users-in-kind-cluster-6c5ee35db3fe?source=rss-7ff780e12236------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c5ee35db3fe</guid>
            <category><![CDATA[multi-tenant]]></category>
            <category><![CDATA[kind]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Lionel Villard]]></dc:creator>
            <pubDate>Fri, 06 May 2022 21:08:36 GMT</pubDate>
            <atom:updated>2023-02-13T21:48:15.513Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*NnHLlB1xyPMnrHtu" /><figcaption>Photo by <a href="https://unsplash.com/@bady?utm_source=medium&amp;utm_medium=referral">bady abbas</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><a href="https://kind.sigs.k8s.io/">Kind</a> is a widely used tool for running Kubernetes locally and in CI/CD environments so it is quite natural to use it for testing scenarios involving multiple isolated users (or tenants). In this article I will go over the few steps you need to follow in order to create new users in kind.</p><h4>Starting Kind and Admin User</h4><p>If you haven’t already a running kind cluster, you can run this command to create one:</p><pre>$ kind create cluster<br>Creating cluster &quot;kind&quot; ...<br> ✓ Ensuring node image (kindest/node:v1.23.4) 🖼<br> ✓ Preparing nodes 📦<br> ✓ Writing configuration 📜<br> ✓ Starting control-plane 🕹️<br> ✓ Installing CNI 🔌<br> ✓ Installing StorageClass 💾<br>Set kubectl context to &quot;kind-kind&quot;<br>You can now use your cluster with:</pre><pre>kubectl cluster-info --context kind-kind</pre><pre>Have a nice day! 👋</pre><p>This command does two things: it starts a Kubernetes cluster in docker and it also creates the certificate, the user key and the Certificate Signing Request (CSR) for accessing it as an admin user.</p><p>The CSR is actually where the information about the admin user is stored. You can decode by using these commands:</p><pre>$ kind get kubeconfig | yq e &#39;.users[0].user.client-certificate-data&#39; - | base64 -D &gt; kind.csr<br>$ openssl x509 -in kind.csr -noout -text<br>Certificate:<br>    Data:<br>        Version: 3 (0x2)<br>        Serial Number: 6690758191217784951 (0x5cda592031923877)<br>    Signature Algorithm: sha256WithRSAEncryption<br>        Issuer: CN=kubernetes<br>        Validity<br>            Not Before: May  6 18:45:36 2022 GMT<br>            Not After : May  6 18:45:39 2023 GMT<br>        Subject: O=system:masters, CN=kubernetes-admin<br>...</pre><blockquote>If you don’t have yq installed, just copy and paste the client-certificate-data value in a file. Make sure to base64 decode the value before running the openssl command</blockquote><p>The important information is the Subject indicating that the user name is kubernetes-admin and that this user belongs to the system:masters group. In Kubernetes you can see users in the system:masters group have admin access:</p><pre>$ kubectl get clusterrolebindings.rbac.authorization.k8s.io cluster-admin -n kube-system -oyaml</pre><pre>apiVersion: rbac.authorization.k8s.io/v1<br>kind: ClusterRoleBinding<br>metadata:<br>  annotations:<br>    rbac.authorization.kubernetes.io/autoupdate: &quot;true&quot;<br>  labels:<br>    kubernetes.io/bootstrapping: rbac-defaults<br>  name: cluster-admin<br>roleRef:<br>  apiGroup: rbac.authorization.k8s.io<br>  kind: ClusterRole<br>  name: cluster-admin<br>subjects:<br>- apiGroup: rbac.authorization.k8s.io<br>  kind: Group<br>  name: system:masters</pre><p>With cluster-admin ClusterRole being:</p><pre>$ kubectl get clusterrole.rbac.authorization.k8s.io cluster-admin -n kube-system -oyaml<br>apiVersion: rbac.authorization.k8s.io/v1<br>kind: ClusterRole<br>metadata:<br>  annotations:<br>    rbac.authorization.kubernetes.io/autoupdate: &quot;true&quot; <br>  labels:<br>    kubernetes.io/bootstrapping: rbac-defaults<br>  name: cluster-admin<br>rules:<br>- apiGroups:<br>  - &#39;*&#39;<br>  resources:<br>  - &#39;*&#39;<br>  verbs:<br>  - &#39;*&#39;<br>- nonResourceURLs:<br>  - &#39;*&#39;<br>  verbs:<br>  - &#39;*&#39;</pre><h4>Creating New Users</h4><p>You first need to get the Kubernetes root certificate and private key to generate the user certificate, user key and CSR. You can copy these files from the container running Kubernetes to the host machine by using the docker cp command:</p><pre>$ docker cp kind-control-plane:/etc/kubernetes/pki/ca.crt .<br>$ docker cp kind-control-plane:/etc/kubernetes/pki/ca.key .</pre><p>where kind-control-plane is the name of the container created by kind.</p><p>First, you can create the user private key with this command:</p><pre>$ openssl genrsa -out user1.key 2048<br>Generating RSA private key, 2048 bit long modulus<br>........+++<br>................................................+++<br>e is 65537 (0x10001)</pre><p>Next, you can create the CSR as follows:</p><pre>$ openssl req -new -key user1.key -out user1.csr -subj “/CN=user1/O=tenant1”</pre><p>As you saw before, the Common Name (CN) is mapped to the Kubernetes subject of kind User and the Organization (O) is mapped to the Kubernetes subject of kind Group.</p><p>Finally, the user certificate is generated by this command:</p><pre>$ openssl x509 -req -in user1.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out user1.crt -days 360<br>Signature ok<br>subject=/CN=user1/O=tenant1<br>Getting CA Private Key</pre><h4>Creating the Kube Config File</h4><p>The last bit is to create a Kube Config file for the new user to get access to the kind cluster. You can create a file named config and copy the following configuration in it:</p><pre>apiVersion: v1<br>kind: Config <br>clusters:<br>- cluster:<br>    certificate-authority-data: &lt;ca.crt base64 encoded&gt;<br>    server: <a href="https://127.0.0.1:51285/">https://127.0.0.1:</a><a href="https://127.0.0.1:56289/">56289</a><br>  name: kind-kind<br>contexts:<br>- context:<br>    cluster: kind-kind<br>    user: user1<br>  name: user1<br>users:<br>- name: user1<br>  user:<br>    client-certificate-data: &lt;user1.crt base64 encoded&gt;  <br>    client-key-data: &lt;user1.key base64 encoded&gt;</pre><p>Don’t forget to replace the placeholders with your actual values you previously generated. You can get the cluster server address with this command:</p><pre>$ kubectl cluster-info<br>Kubernetes control plane is running at <a href="https://127.0.0.1:56289/">https://127.0.0.1:56289</a><br>CoreDNS is running at <a href="https://127.0.0.1:56289/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy">https://127.0.0.1:56289/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy</a></pre><blockquote>Thankfully kubectl provides two flags, --as and--group for user and group impersonating. Below, replace --kubeconfig config by --as user1 for the same effect.</blockquote><p>Then you can <em>try </em>to list all the namespaces in the cluster:</p><pre>$ kubectl get ns --kubeconfig config<br>Error from server (Forbidden): namespaces is forbidden: User &quot;user1&quot; cannot list resource &quot;namespaces&quot; in API group &quot;&quot; at the cluster scope</pre><p>As expected, your new user does not have access to anything because you didn’t create any RBAC rules. To give this user access to viewing namespaces, you can apply these two Kubernetes configuration files:</p><pre>$ cat &lt;&lt;EOF | kubectl apply -f - <br>apiVersion: rbac.authorization.k8s.io/v1<br>kind: ClusterRole<br>metadata:<br>  name: tenant-user<br>rules:<br>- apiGroups: [&quot;&quot;]<br>  resources: [&quot;namespaces&quot;]<br>  verbs: [&quot;get&quot;, &quot;watch&quot;, &quot;list&quot;]<br>EOF</pre><p>And:</p><pre>$ cat &lt;&lt;EOF | kubectl apply -f -<br>apiVersion: rbac.authorization.k8s.io/v1<br>kind: ClusterRoleBinding<br>metadata:<br>  name: tenant-user<br>subjects:<br>- kind: User<br>  name: user1<br>  apiGroup: rbac.authorization.k8s.io<br>roleRef:<br>  kind: ClusterRole<br>  name: tenant-user<br>  apiGroup: rbac.authorization.k8s.io<br>EOF</pre><p>Now user1can see which namespaces exists in the cluster:</p><pre>$ kubectl get ns --kubeconfig config<br>NAME                 STATUS   AGE<br>default              Active   131m<br>kube-node-lease      Active   131m<br>kube-public          Active   131m<br>kube-system          Active   131m<br>local-path-storage   Active   130m</pre><p>Have fun with your multi-tenant test scenarios in Kind!</p><h4>References</h4><ul><li><a href="https://kubernetes.io/docs/reference/access-authn-authz/authentication/">Authentication in Kubernetes</a></li><li><a href="https://kubernetes.io/docs/tasks/administer-cluster/certificates/">Kubernetes Certificates</a></li><li><a href="https://kind.sigs.k8s.io/">Kind</a></li><li><a href="https://www.digitalocean.com/community/tutorials/openssl-essentials-working-with-ssl-certificates-private-keys-and-csrs">OpenSSL tutorial</a></li><li><a href="https://cloudhero.io/creating-users-for-your-kubernetes-cluster">Creating Users for your Kubernetes Cluster</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c5ee35db3fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Express.js apps to OpenWhisk (Part 2)]]></title>
            <link>https://medium.com/openwhisk/deploying-express-js-apps-to-openwhisk-part-2-dd8fc51e8944?source=rss-7ff780e12236------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd8fc51e8944</guid>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[openwhisk]]></category>
            <category><![CDATA[web-hosting]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Lionel Villard]]></dc:creator>
            <pubDate>Wed, 10 May 2017 15:19:36 GMT</pubDate>
            <atom:updated>2017-05-18T13:44:00.517Z</atom:updated>
            <content:encoded><![CDATA[<h4>Generalization</h4><p>The first <a href="https://medium.com/openwhisk/deploying-express-js-apps-to-openwhisk-part-1-9133ba5f262c">installment</a> of this series shows how easy is to deploy a simple Express.js app to <a href="http://openwhisk.org/">Apache OpenWhisk</a>. In this tutorial, I’ll go through the steps of deploying an existing Express.js app. This time I will be using the OpenWhisk Express.js <a href="https://www.npmjs.com/package/openwhisk-expressjs">npm package</a> instead of an ad-hoc action.</p><p>I picked the <a href="https://scotch.io/tutorials/building-and-securing-a-modern-backend-api?ref=mybridge.co">movieanalyst</a> demo application which rank 1 in the<a href="https://medium.mybridge.co/node-js-top-10-articles-for-the-past-month-fdd2f2429622"> August 2016 Node.JS top 10 articles</a>. It is actually composed of <em>three</em> Express apps (two front-end clients, one backed service), secured with <a href="https://auth0.com/">Auth0</a> (o != o). I encourage you to read the original article especially the part describing how to setup Auth0.</p><p>Let’s get started.</p><h4>Step 1: adapting the original application</h4><p>The original application has been put together to demonstrate how to use Auth0 and designed to run locally. Since I want to actually deploy it, I made the following changes:</p><ul><li>in all server.js file, I moved app.listen(...) into bin/www. OpenWhisk listens to HTTP requests, not our application.</li><li>sensitive values, such as <em>client id,</em> <em>client secrets </em>and <em>audience</em>, and backend service endpoints are hard-coded. Instead, let’s put everything in a config file we are going to use during deployment.</li></ul><p>The modified source code is available <a href="https://github.com/lionelvillard/building-and-securing-a-modern-backend-api">here</a>.</p><h4>Interlude: a little trick</h4><p>I recently learn a trick that will be useful in this tutorial: it is possible ❶ to combine public and private actions using <a href="https://github.com/openwhisk/openwhisk/blob/master/docs/actions.md#creating-action-sequences">sequence action</a> and ❷ to add the web annotation on sequence action. The general command is:</p><pre>$ wsk action update private/mywebaction \<br>             /whisk.system/utils/echo,private/action \<br>             --sequence --web yes</pre><p>Secrets can be stored in private/action since the private package does not have to be made public in order to be used by a web action. We will see how to use this feature in Step 3, but first let’s create the private actions.</p><h4>Step 2: creating the private actions</h4><p>Since movieanalyst is composed of three Express.js apps, the best is to create three corresponding actions. They all look identical to this code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d31181ebd70b974fe32eb7dbc4155a11/href">https://medium.com/media/d31181ebd70b974fe32eb7dbc4155a11/href</a></iframe><p>Notice that:</p><ul><li>I implicitly use another nice OpenWhisk feature related to <a href="https://github.com/openwhisk/openwhisk/blob/master/docs/reference.md#statelessness"><em>statelessness</em></a>: the action state <em>might</em> still be available across invocations. In that case, app and redirect might have already been initialized, savings us some CPU cycles.</li><li>The OpenWhisk Express.js action introduced Part 1 has now been made available as a <a href="https://www.npmjs.com/package/openwhisk-expressjs">npm public package</a> called openwhisk-expressjs. This action has also been generalized and now takes an optional object called express_locals which is used to extend app.locals. No more baseurl and staticbaseurl.</li></ul><p>Let’s put this code inside a file called action.js in the root directory. We also need to update all three package.json files by setting &quot;main&quot; to &quot;action.js&quot;.</p><h4>Step 3: Deploying</h4><p>The project is now ready to be deployed. If you haven’t done it already, it’s now time to setup Auth0 as described in this <a href="https://scotch.io/tutorials/building-and-securing-a-modern-backend-api?ref=mybridge.co">article</a>.</p><p>The deployment script for each app looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45d0d119ac9af65767ca6e3c8eea8777/href">https://medium.com/media/45d0d119ac9af65767ca6e3c8eea8777/href</a></iframe><p>This script:</p><ul><li>creates a zip file containing the node js action (line 3). The size of the zip file is around 1MB, well below the 48MB limit. There is still room for growth before having to rely on size optimization techniques such as minimization and code splitting.</li><li>updates the private action called $PACKAGE/express-website (line 6).</li><li>updates the sequence <em>web</em> action by applying the little trick we learned before (line 9). Note in this case I use the <em>raw</em> web annotation telling OpenWhisk not to parse query parameters.</li></ul><p>We also need a master deployment script</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f211db8e068f182509f6cb081ceeff7c/href">https://medium.com/media/f211db8e068f182509f6cb081ceeff7c/href</a></iframe><p>To deploy, first create a JSON configuration file containing the Auth0 secrets:</p><pre>{<br>  &quot;package&quot;: &quot;movieanalyst&quot;,<br>  &quot;client_id&quot;: &quot;&lt;website client id&gt;&quot;,<br>  &quot;client_secret&quot;: &quot;&lt;website secret&gt;&quot;,<br>  &quot;admin_client_id&quot;: &quot;&lt;admin client id&gt;&quot;,<br>  &quot;admin_client_secret&quot;: &quot;&lt;admin secret&gt;&quot;,<br>  &quot;auth0_domain&quot;: &quot;&lt;your Auth0 domain&gt;&quot;,<br>  &quot;auth0_audience&quot;: &quot;&lt;your Auth0 audience&gt;&quot;,<br>  &quot;api_host&quot;: &quot;&lt;API host name&gt;&quot;<br>}</pre><p>and run the master script:</p><pre>$ ./deploy.sh config.&lt;yourenv&gt;.json</pre><p>In my case, I deployed it to Bluemix. The application main <a href="https://openwhisk.ng.bluemix.net/api/v1/web/villard@us.ibm.com_dev/movieanalyst/website">website</a> has access to the movies, reviewers and publications endpoints, while the <a href="https://openwhisk.ng.bluemix.net/api/v1/web/villard@us.ibm.com_dev/movieanalyst/admin">admin</a> app has additionally access to the pending endpoint which returns movie reviews that are not ready to be publicly accessible.</p><p>Try accessing directly the backend API (https://openwhisk.ng.bluemix.net/api/v1/web/villard@us.ibm.com_dev/movieanalyst/api), you get rejected because of the missing Auth0 authorization token. This token is acquired by the main website and the admin app before making calls to the API.</p><p>Try navigating to the pending review page (https://openwhisk.ng.bluemix.net/api/v1/web/villard@us.ibm.com_dev/movieanalyst/website/pending) from the main web site (a route has been created but not made available through the UI). You should get forbidden access as the website client does not have the admin scope applied to it. I refer you to the original article for more details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pI22H6kcslC9q7g-NuZkAg.png" /><figcaption>The main website</figcaption></figure><p>Note that for a real application the access to the admin webpage should be restricted to privileged users, for instance by using OAuth or Auth0. Nothing in OpenWhisk prevents using OAuth, it is just a matter of updating the admin app.</p><h4>Wrapping up</h4><p>This concludes this mini-series on Express.js deployed to Apache OpenWhisk. It shows that OpenWhisk is a viable platform for hosting web site and in particular the ones written using Express.js.</p><p>I hope it inspires you to try it on your own app and please let me know of any issues on <a href="https://github.com/lionelvillard/openwhisk-expressjs">github</a>.</p><p>Thanks for your feedback in advance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd8fc51e8944" width="1" height="1" alt=""><hr><p><a href="https://medium.com/openwhisk/deploying-express-js-apps-to-openwhisk-part-2-dd8fc51e8944">Deploying Express.js apps to OpenWhisk (Part 2)</a> was originally published in <a href="https://medium.com/openwhisk">Apache OpenWhisk</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Express.js apps to OpenWhisk (Part 1)]]></title>
            <link>https://medium.com/openwhisk/deploying-express-js-apps-to-openwhisk-part-1-9133ba5f262c?source=rss-7ff780e12236------2</link>
            <guid isPermaLink="false">https://medium.com/p/9133ba5f262c</guid>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[openwhisk]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[web-hosting]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Lionel Villard]]></dc:creator>
            <pubDate>Wed, 03 May 2017 21:06:20 GMT</pubDate>
            <atom:updated>2017-07-19T13:44:19.639Z</atom:updated>
            <content:encoded><![CDATA[<h4>Ad-hoc approach</h4><p>In this article I will show you how to deploy Express.js applications to <a href="http://openwhisk.org/">OpenWhisk</a>, with minimal modification. The <a href="https://medium.com/@lionelvillard/deploying-express-js-apps-to-openwhisk-part-2-dd8fc51e8944">Part 2</a> generalizes the process described below.</p><h4>Getting started</h4><p>For the purpose on this article, let’s first create a new <a href="http://expressjs.com/">Express</a> 4.x application. If you want to use your own app (be sure it’s using the 4.x api. In particular, app.listen(..) must not be in the main file), just skip this step.</p><pre>$ npm install express-generator -g<br>$ express --view=pug myexpressapp<br>$ cd myexpressapp<br>$ npm install </pre><p>To check it’s working, start the application by typing the command npm start and load <a href="http://localhost:3000/">http://localhost:3000</a> in a browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*_d8fEio9Fr6Y8-aZK-R64A.png" /><figcaption>Auto-generated Express app</figcaption></figure><h4>Paths consideration</h4><p>The generated Express application expects resources to be installed in the domain root folder, but by default OpenWhisk web actions are served from a <a href="https://github.com/openwhisk/openwhisk/blob/master/docs/webactions.md#vanity-url">sub-directory</a>. Luckily only one file needs to be changed, views/layout.pug:</p><pre>doctype html<br>html<br>  head<br>    title= title<br>    <strong>if baseurl</strong><br>     <strong>base(href=baseurl)</strong><br>    link(rel=&#39;stylesheet&#39;, <strong>href=&#39;stylesheets/style.css&#39;</strong>)<br>  body<br>    block content</pre><h4>Installing the OpenWhisk web action</h4><p>The next step is to create the OpenWhisk web action that will invoke the Express app. This is a generic action that can be reused across all Express apps. It is available <a href="https://raw.githubusercontent.com/lionelvillard/openwhisk-webapp-starterkits/master/myexpressapp/main.js">here</a> and self-explanatory. Just copy it into your root directory and add following dependency:</p><p>$ npm install supertest --dev</p><h4>Deploying</h4><p>Our application is now ready to be deployed to OpenWhisk. For this step, I assume you have the <a href="https://github.com/openwhisk/openwhisk/blob/master/docs/README.md#setting-up-the-openwhisk-cli">OpenWhisk CLI</a> installed and set up. If you happen to have a Bluemix account (no credit cards required), the setup is <a href="https://console.ng.bluemix.net/openwhisk/learn/cli">much easier</a>.</p><p>Let’s create a <a href="https://github.com/openwhisk/openwhisk/blob/master/docs/actions.md#packaging-an-action-as-a-nodejs-module">zip action</a> that can then be deployed:</p><pre>$ zip -r app.zip .<br>$ wsk action update express app.zip --kind nodejs:6 --web raw -p baseurl &lt;yourbaseurl&gt;</pre><p>This command says to update an action called express and to put it in the default package. --web raw makes the action <a href="https://github.com/openwhisk/openwhisk/blob/master/docs/webactions.md#web-actions">web</a> accessible with <a href="https://github.com/openwhisk/openwhisk/blob/master/docs/webactions.md#raw-http-handling">raw handling</a> and -p baseurl &lt;yourbaseurl&gt; sets the parameter baseurl to your base url.</p><p>For instance, I use this command on Bluemix:</p><pre>$ wsk action update express app.zip --kind nodejs:6 --web raw -p baseurl https://openwhisk.ng.bluemix.net/api/v1/web/villard@us.ibm.com_dev/default/express/</pre><p>To load this web action, go to <a href="https://openwhisk.ng.bluemix.net/api/v1/web/villard@us.ibm.com_dev/default/express">https://openwhisk.ng.bluemix.net/api/v1/web/villard@us.ibm.com_dev/default/express</a></p><h4>Optional: deploying static assets elsewhere</h4><p>Due to several OpenWhisk <a href="https://github.com/openwhisk/openwhisk/blob/master/docs/reference.md#system-limits">limits</a>, it’s better to host large static assets somewhere else. Here I’ll use <a href="https://surge.sh/">Surge</a> because it’s really easy to use.</p><p>First, install the tool with npm and run the surge command in the directory containing your static assets, in this case public.</p><pre>$ npm install -global surge<br>$ cd public<br>$ surge</pre><p>If this is your first time running, you will need to enter your email and password to register a new account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*c87opZF8cr-TXz-B_VwDIQ.png" /><figcaption>Deploying static assets on Surge</figcaption></figure><p>We then need to tell our Express app to fetch the static assets from Surge. The OpenWhisk web action expects the argument named staticbaseurl so let’s use it in our views/layout.pug template:</p><pre>doctype html<br>html<br>  head<br>    title= title<br>    <strong>base(href=baseurl)</strong><br>    link(rel=&#39;stylesheet&#39;, <br>     <strong>href=`</strong>${staticbaseurl || &#39;&#39;}stylesheets/style.css<strong>&#39;</strong>)<br>  body<br>    block content</pre><p>Let’s redeployed our application, but this time using the static assets hosted on Surge:</p><pre>$ zip -r app.zip . --exclude=public/*<br>$ wsk action update express app.zip --kind nodejs:6 \<br>       --web raw \<br>       -p baseurl <a href="https://openwhisk.ng.bluemix.net/api/v1/web/villard@us.ibm.com_dev/default/express/">https://openwhisk.ng.bluemix.net/api/v1/web/villard@us.ibm.com_dev/default/express/</a> \<br>       -p staticbaseurl https://openwhisk-expressjs-demo.surge.sh/</pre><p>Don’t forget to substitute the baseurl and staticbaseurl values by your own values. Reload the <a href="https://openwhisk.ng.bluemix.net/api/v1/web/villard@us.ibm.com_dev/default/express">action</a>, open the HTML source code to see that the stylesheets being loaded from Surge.</p><h4>Conclusion and teaser</h4><p>With little effort, we created a new Express.js app and deployed it on a serverless cloud platform that automatically and reasonably scales for you.</p><p>In the second part of this post I’ll go through the steps of deploying a <a href="https://scotch.io/tutorials/building-and-securing-a-modern-backend-api?ref=mybridge.co">real express application</a> composed of three separate Express apps secured by <a href="http://auth0.com/">Auth0</a> and <a href="https://jwt.io/">JWT</a>.</p><p>Thanks for your feedback in advance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9133ba5f262c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/openwhisk/deploying-express-js-apps-to-openwhisk-part-1-9133ba5f262c">Deploying Express.js apps to OpenWhisk (Part 1)</a> was originally published in <a href="https://medium.com/openwhisk">Apache OpenWhisk</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Web Starter Kits for OpenWhisk — Ember.js]]></title>
            <link>https://medium.com/openwhisk/introducing-web-starter-kits-for-openwhisk-ember-js-part-1-2e554b2176d6?source=rss-7ff780e12236------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e554b2176d6</guid>
            <category><![CDATA[emberjs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[bluemix]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[openwhisk]]></category>
            <dc:creator><![CDATA[Lionel Villard]]></dc:creator>
            <pubDate>Fri, 07 Apr 2017 18:15:18 GMT</pubDate>
            <atom:updated>2017-05-04T11:58:37.479Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, <a href="http://openwhisk.org/">Apache OpenWhisk</a> added <a href="https://github.com/openwhisk/openwhisk/blob/master/docs/webactions.md">web actions</a> enabling <a href="https://github.com/openwhisk/openwhisk/blob/master/docs/actions.md">actions</a> to be invoked through HTTP requests, as explained <a href="https://medium.com/openwhisk/serverless-http-handlers-with-openwhisk-90a986cc7cdd">here</a>, <a href="https://medium.com/openwhisk/whats-new-web-actions-e0ffeef1bea3">here</a> and <a href="https://www.raymondcamden.com/2017/03/02/designing-an-openwhisk-action-for-web-action-support/">here</a>.</p><p>This opens the door for easy and fast serverless deployment of web applications, including your front-end, back-end or both. You can even do this for <em>free </em>in <a href="https://www.ibm.com/cloud-computing/bluemix/openwhisk">Bluemix</a> thanks to the generous free tier.</p><p>In this article I will describe how to deploy new and existing Web applications developed using <a href="https://emberjs.com/"><strong>Ember.js</strong></a>. In subsequent articles I will cover some other Node.js Web frameworks (<a href="https://angular.io/">Angular</a>, <a href="https://reactstarter.com/">React Starter Kit</a>, <a href="http://expressjs.com/">Express</a>, <a href="https://www.meteor.com/">Meteor</a> or <a href="https://github.com/gatsbyjs/gatsby">Gatsby</a>).</p><p>So let’s get started by first installing the Ember CLI (if not already done)</p><pre>npm install -g ember-cli</pre><p>and create a new web app</p><pre>ember new openwhiskdemo<br>cd openwhiskdemo</pre><p>To make thing a bit interesting, let’s modify the default application to use bootstrap the way it is described <a href="http://www.netosober.io/bootstrap/emberjs/embercli/2015/07/16/emberjs-styling-wtih-bootstrap/">here</a>, but for the purpose of this article let’s just add a navar.</p><p>Edit <em>/app/templates/application.hbs</em> with the following content</p><pre>&lt;nav class=&quot;navbar navbar-default&quot;&gt;<br>  &lt;div class=&quot;container-fluid&quot;&gt;<br>    &lt;div class=&quot;navbar-header&quot;&gt;<br>      &lt;button type=&quot;button&quot; class=&quot;navbar-toggle collapsed&quot;<br>      data-toggle=&quot;collapse&quot; data-target=&quot;#menu-collapse&quot;&gt;<br>        &lt;span class=&quot;sr-only&quot;&gt;Toggle navigation&lt;/span&gt;<br>        &lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;<br>        &lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;<br>        &lt;span class=&quot;icon-bar&quot;&gt;&lt;/span&gt;<br>      &lt;/button&gt;<br>      {{ link-to &#39;Home&#39; &#39;index&#39; class=&quot;navbar-brand&quot; }}<br>    &lt;/div&gt;</pre><pre>    &lt;div class=&quot;collapse navbar-collapse&quot; id=&quot;menu-collapse&quot;&gt;<br>      &lt;ul class=&quot;nav navbar-nav&quot;&gt;<br>        &lt;li&gt;{{ link-to &#39;About&#39; &#39;about&#39; }}&lt;/li&gt;<br>        &lt;li&gt;{{ link-to &#39;Contact&#39; &#39;contact&#39; }}&lt;/li&gt;<br>      &lt;/ul&gt;<br>    &lt;/div&gt;<br>  &lt;/div&gt;<br>&lt;/nav&gt;</pre><pre>&lt;div class=&quot;container&quot;&gt;<br>  {{outlet}}<br>&lt;/div&gt;</pre><p>and add Bootstrap using a CDN in <em>/app/index.html</em></p><pre>&lt;!-- Latest compiled and minified CSS --&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;<a href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css</a>&quot;&gt;</pre><pre>&lt;!-- Optional theme --&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;<a href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css</a>&quot;&gt;</pre><pre>&lt;!-- Latest compiled and minified JavaScript --&gt;<br>    &lt;script src=&quot;<a href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js">https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js</a>&quot;&gt;<br>    &lt;/script&gt;</pre><p>Let’s verify that everything is running as expected</p><pre>ember serve</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/1*y5MFPDyPx6GBsF9FmAcRWg.png" /></figure><p>The next step is to package the generated assets into a OpenWhisk web action. This action is responsible for properly routing HTTP requests to Ember resources: /assets/... serves assets stored in the assets directory, and all other requests must be redirected to /index.html. The full code of this action is available <a href="https://github.com/lionelvillard/openwhisk-webapp-starterkits/tree/master/emberjs">here</a>. Let’s add an Ember add-on to automatically copy these files when building our web app</p><pre>ember g in-repo-addon openwhisk</pre><p>And copy emberjsrouter.js, wsk-package.js and index.js into openwhiskdemo/lib/openwhisk/</p><p>We are almost set to build our production-ready Web application. By default OpenWhisk actions can be invoked using a URL that is structured as follows: https://{APIHOST}/api/v1/web/{QUALIFIED ACTION NAME}.[{EXT}] . The Ember root URL must be updated to reflect this in config/environment.js:</p><pre>if (environment === ‘production’) {<br>  ENV.rootURL = ‘/api/v1//web/villard@us.ibm.com_dev/default/emberdemo’;<br>}</pre><p>default/emberdemo corresponds to the action name emberdemo deployed in the default package. villard@us.ibm.com_devis my organization name and space on Bluemix and must be replaced by your own name. Now we can build our web app</p><pre>ember build --prod --output-path prod</pre><p>and deploy it on OpenWhisk. If you don’t have the wsk installed on your system, please read <a href="https://github.com/openwhisk/openwhisk/blob/master/docs/README.md#setting-up-the-openwhisk-cli">this</a>, or <a href="https://console.ng.bluemix.net/openwhisk/learn/cli">this</a> if you have a Bluemix account.</p><pre>cd prod<br>zip -r ember.zip .<br>wsk action update emberdemo ember.zip --kind nodejs:6 --web yes</pre><p>That’s it! Try it in a browser: <a href="https://openwhisk.ng.bluemix.net/api/v1/web/villard@us.ibm.com_dev/default/emberdemo">https://openwhisk.ng.bluemix.net/api/v1/web/villard@us.ibm.com_dev/default/emberdemo</a></p><p>On a final note, things to consider:</p><ul><li>OpenWhisk adds some <a href="https://github.com/openwhisk/openwhisk/blob/master/docs/reference.md#system-limits">limitations</a>. In particular the maximum payload is 1MB. In this example, the minified gzip vendor.js file weights 200Kb but can grow easily when adding external dependencies. One way to mitigate this growth is to serve common libraries from CDN (like bootstrap) and to store large assets in <a href="https://www.ibm.com/cloud-computing/bluemix/cloud-object-storage">ObjectStore</a>s.</li><li>Looking for a semi-custom domain? Please read <a href="https://medium.com/openwhisk/semi-custom-domains-for-openwhisk-web-apps-1ef1bd5bc437">this</a>.</li><li>emberjsrouter.js is under development. Please submit bugs <a href="https://github.com/lionelvillard/openwhisk-webapp-starterkits/issues">here</a>.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e554b2176d6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/openwhisk/introducing-web-starter-kits-for-openwhisk-ember-js-part-1-2e554b2176d6">Introducing Web Starter Kits for OpenWhisk — Ember.js</a> was originally published in <a href="https://medium.com/openwhisk">Apache OpenWhisk</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>