<?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 Nick Longinow on Medium]]></title>
        <description><![CDATA[Stories by Nick Longinow on Medium]]></description>
        <link>https://medium.com/@nicklonginow?source=rss-16fa583a7d87------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lPg1Ajn1donOa9IjiK7oZA.jpeg</url>
            <title>Stories by Nick Longinow on Medium</title>
            <link>https://medium.com/@nicklonginow?source=rss-16fa583a7d87------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 16:13:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nicklonginow/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[Using Google Kubernetes Engine to host Google Cloud Endpoints]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/@nicklonginow/using-google-kubernetes-engine-to-host-google-cloud-endpoints-6896c008ed98?source=rss-16fa583a7d87------2"><img src="https://cdn-images-1.medium.com/max/638/1*wKS7s48bPBL3-TS9MU-vTA.png" width="638"></a></p><p class="medium-feed-snippet">Endpoints deployed using containers</p><p class="medium-feed-link"><a href="https://medium.com/@nicklonginow/using-google-kubernetes-engine-to-host-google-cloud-endpoints-6896c008ed98?source=rss-16fa583a7d87------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://medium.com/@nicklonginow/using-google-kubernetes-engine-to-host-google-cloud-endpoints-6896c008ed98?source=rss-16fa583a7d87------2</link>
            <guid isPermaLink="false">https://medium.com/p/6896c008ed98</guid>
            <category><![CDATA[endpoints]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Nick Longinow]]></dc:creator>
            <pubDate>Fri, 01 Mar 2019 22:47:39 GMT</pubDate>
            <atom:updated>2019-03-04T14:27:01.433Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Continuous Delivery Pipelines to  Google Kubernetes Engine with Gitlab]]></title>
            <link>https://medium.com/@nicklonginow/continuous-delivery-pipelines-to-google-kubernetes-engine-with-gitlab-d65e04be6c0b?source=rss-16fa583a7d87------2</link>
            <guid isPermaLink="false">https://medium.com/p/d65e04be6c0b</guid>
            <category><![CDATA[continuous-delivery]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[gitlab]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[kubernetes-engine]]></category>
            <dc:creator><![CDATA[Nick Longinow]]></dc:creator>
            <pubDate>Wed, 30 Jan 2019 20:31:25 GMT</pubDate>
            <atom:updated>2019-01-30T20:48:12.944Z</atom:updated>
            <content:encoded><![CDATA[<h3>Continuous Delivery Pipelines to Google Kubernetes Engine with Gitlab</h3><p>In this article we’ll build a continuous integration and deployment pipeline into Kubernetes running on Google Cloud platform. We’ll use (1) gitlab.com for the pipeline, (2) Google Cloud for the Kubernetes, and (3) Spring Boot for the microservices application. This article assumes that you have some familiarity with Google Cloud Platform, Kubernetes, Linux and Spring. Let’s get started!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*prOoSpEQOC4cwM0_z-quCw.png" /></figure><p><strong>Core Setup</strong></p><p>1. Download the code from github at <a href="https://github.com/nlonginow/demo-kubernetes-pipeline.git">this</a> link.</p><p>2. Create a new project on Gitlab.com and connect your local code to it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/485/1*gENjbhZSYQ8qq46LIAIMUw.png" /></figure><p>where &lt;me&gt; and &lt;repo&gt; are replaced with the correct tags for your repository.</p><p>3. Turn on <strong>Auto-Devops</strong>. This will cause Gitlab to run our pipeline on each checkin to the repository. In your Gitlab project, go to Settings — CI/CD and expand out the Auto DevOps section. Check the box as shown.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*oneCv1F5hO5Z-ayaECfKZw.jpeg" /></figure><p>4. Setup Gitlab CI/CD <strong>environment variables</strong>. We’ll need 3 variables to be stored here, (1) a Google Key to enable the pipeline in Gitlab to execute commands against our Kubernetes cluster on our behalf, (2) a password to the Gitlab repository where we store the containers built by our pipeline, and (3) a keyword for use in the smoke test portion of our pipeline. Create a variable called <strong>REGISTRY_PASSWD </strong>and enter your Gitlab account password here. Create another variable called <strong>TEST_ONE_KEYWORD </strong>and enter the value “alive” in the box to the right. Also create a variable called <strong>GOOGLE_KEY</strong>, but don’t enter a value just yet. We need some information from Google Cloud Platform to complete that item, and will do that next.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*EC2wgZ-lNbby6HRJVKcvqw.jpeg" /></figure><p>a. <strong>The Google Key</strong>. This is the key representing a service account in Google Cloud Platform which is authorized to do specific actions relative to the Kubernetes cluster. It represents a <strong><em>Service Account </em></strong>in GCP. For this step, you’ll need a Google Cloud Platform account and project (if you don’t already have one, follow <a href="https://developers.google.com/maps/premium/devconsole-access#creating_a_google_account">these</a> steps to get that in place). First, go to your cloud console for the project you want to use, and select IAM — Admin — Service Account. Click Create Service Account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/1*7Ci8ZsIVFxJC5LydBgYD5Q.jpeg" /></figure><p>Give this account some permissions. We will give it Compute Engine admin, so it can update our cluster as part of the pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*Ehz1WYahHQOlM7nxQVoeWQ.jpeg" /></figure><p>Click Continue and then click Create Key. Select JSON in the next screen, and save the file locally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*4etnDAYaKA8aczkGmT9b4g.jpeg" /></figure><p>That’s it on that. Now we can add it to our Gitlab environment variables. Go back to Gitlab — Settings — CICD — Environment Variables and set the value for the variable GOOGLE_KEY by pasting in the entire contents of the JSON file into the box next to it. Click Save.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*EC2wgZ-lNbby6HRJVKcvqw.jpeg" /></figure><p><strong>The Pipeline</strong></p><p>We now have credentials in place for operating a pipeline of code delivery into Google Cloud Kubernetes Engine. Let’s build the actual pipeline now. A Gitlab pipeline is specified by a .gitlab-ci.yml file which mustbe located in the root of the repository. If Gitlab finds that file, it will kick off the pipeline on each commit to the repository.</p><p>Here is the front of that file. Notice that Gitlab pipelines use docker containers to run each stage, so we need Docker in Docker as our primary service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*x-WO1w7fOAX7B_HRFej-DA.jpeg" /></figure><p>The pipeline has 6 stages, all executed in sequence if the preceding stage was successful. Each one runs in a docker container, using an image we specify for the type of work in that stage.</p><p>The first 2 stages build, package (containerize) and then store the application on Gitlab’s repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*pLlYVGlKSYkCEqs0kU7Cng.jpeg" /></figure><p>Once our code is built and successfully packaged as a Docker container and stored in our repository, we are ready to prepare our test environment. Notice that our pipeline exists entirely to test a code checkin against an integration environment, not just a simple set of jUnit tests. To do this, we spin up a cluster and deploy/test our new code there.</p><p>So, we have a warmup stage. Here, we are scaling up our deployment and testing cluster. Our cluster is always alive, but is kept at 0 nodes when not in use, to save resource cost. In GCP Kubernetes Engine the nodes are actually VMs, and while they are running we incur cost. So, when we are not testing new code, we reduce the nodes to 0, so no VMs are running. The cluster is still alive, it just have far fewer resources allocated.</p><p>This stage will use a Google Cloud console docker image, since we will be executing Google Cloud commands.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*hdGJfG3jWaEOZSfe3KDzNw.jpeg" /></figure><p>Note how we are making use of the environment variable GOOGLE_KEY in order to authorize the pipeline actions. This step may take a few minutes while the nodes spin up.</p><p>Now we have a running cluster with 3 nodes. The next step deploys our microservice Java Spring application container to the cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*TPgGq13nvlVD93HR8lu_Hg.jpeg" /></figure><p>Once this succeeds, we have our microservice container deployed to the pod(s) in our cluster. The definition of those pods is based on deployment files, which we look at in detail below.</p><p>Now we are ready to test the running application. A couple things of note in this step are that we need an IP and port for running a REST test against the application. Instead of hard coding those values into the script (and Java code) we are using a concept of Kubernetes called a Deployment and <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/">ConfigMap</a>to store them. We use standard Google Cloud console linux commands to describe those objects, and then some standard linux tools to parse out the needed information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*7rq22RwVg6DlgnD0xuI-UA.jpeg" /></figure><p>The entire point of the test script is to gather the IP and Port details by inspecting Kubernetes, and then using those values as parameters to a simple smoke test command file. The smoke test executes a curl command against our web application, and looks for a specific string in the output.</p><p>Here is the smokeTest file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*ANExPy1-6gipoZiwK7IqTg.jpeg" /></figure><p>Finally, now that our pipeline has built, containerized, deployed and tested (live) our microservice application, we want to reduce our cluster size to 0 so as to avoid incurring additional costs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*2fdurERKFsIKYDc1C8rB9w.jpeg" /></figure><p>Note that this is only the pipeline for deploying a single service. The code in this example includes a pair of services (and containers) that get built and deployed in their own respective repositories. i.e., we only build the code for a microservice when that particular microservice has changed.</p><p><strong>The Kubernetes Components</strong></p><p>Now, let’s take a look at the Kubernetes objects. There are 3 components to our Kubernetes application, (1) a <strong><em>ConfigMap </em></strong>for storing basic variables, (2) a <strong><em>Service</em></strong>, for enabling ingress to our application from the outside world, and (3) a <strong><em>deployment </em></strong>specifying the number of replicas (pods) that we want to deploy for our microservice. Here are the files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*Rcm0eNgkWqi64ehb7Ys8IA.jpeg" /></figure><p>Note that we used some of this information previously in our pipeline. We will also use in our Java Spring application, so that it is not hardcoded anywhere.</p><p>Next, the Service. We are deploying a <strong>LoadBalancer</strong> type service on port 8081, which will provide us with an externally accessible IP. This is not the least expensive way to access a pod, but for purposes of this demonstration it is the simplest. Look into an <a href="https://kubernetes.io/docs/concepts/services-networking/ingress/">Ingress</a> service for a less expensive approach.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*pMFS8RXQXCjKsfrBc9KGvQ.jpeg" /></figure><p>And, the deployment of the pods themselves. Note that the pod specification includes a reference to the ConfigMap elements defined earlier, which makes that information globally available to the code running in the pod (container). Again, note that the registry details for gitlab are for my own project; your project will have your own details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*5JYo7F5Io9m6983A1Y9xFQ.jpeg" /></figure><p><strong>The Microservices Java Application (Spring)</strong></p><p>All of our work up till now has assumed we have an application to containerize and deploy to Kubernetes. Now, let’s look at the application itself. It’s a standard Spring Boot web application which represents a front-end to a 2-tier application (ie., having a backend container to operate against).</p><p>We’ll just look at the Controller class. The rest of it is quite standard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*4Unm0xN-nri3HDT7CY81Lw.jpeg" /></figure><p>Our application is simple 2 microservices which communicate with each other, the first being one accessed by the outside world (via the LoadBalancer IP), and the second being that which is called into from the first one. We use Kube DNS to discover the second container.</p><p>What we want to especially observe here is that we retrieved our value for the URL related to our backend service via the ConfigMap, and also the port for that service. Thus, no hardcoding in the java files, or copying values in multiple places. The ConfigMap in our deployment file provided these values as global environment variables to any container running in that pod’s deployment.</p><p><strong>Conclusion</strong></p><p>In this article we saw how to build a Gitlab.com pipeline for continuous delivery of a Java Spring microservices application into a Google Cloud Kubernetes engine.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d65e04be6c0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>