Gitlab Autodevops Gke

2 minute read

Gitlab Auto DevOps with GKE

Simple Go Service

Go file

Note: Needs to be on port 5000

package main

import (

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		fmt.Fprintf(w, "Hello, you've requested: %s\n", r.URL.Path)

	http.ListenAndServe(":5000", nil)


# build stage
FROM golang:alpine AS build-env
ADD . /src
RUN cd /src && go build -o goapp

# final stage
FROM alpine
COPY --from=build-env /src/goapp /app/

K8 & Gitlab integration

Operations > Kubernetes > create cluster on Google Cloud with your account.

Give it a name.

Environment can be wildcard.

Ideally you would have three envs:

  • Review
  • Stage
  • Prod

For this example you only need 1 node

Once the cluster is up you need to install:

  • Helm Tiller
  • Ingress
  • Prometheus
  • Gitlab runner
  • Knative (see later)

Machine type: n1-standard-1 (1 vCPU, 3.75 GB memory)

Once you have ingress up and running you will have an IP

Use the wildcard DNS service from to give you a domain name and add it to gitlab settings > CI/CD -> Auto DevOps. eg:

Select auto devops pipeline.

Turn off Test, Code Quality, Postgres jobs:

In Settings > General > Environment Variables:


Once the code is pushed the jobs build and production will run and give you an endpoint to test

Gitlab > Environmets.

Here you can launch the endpoint, view the monitor and get a shell to the system.


Should return:

Hello, you've request: /test


GCP > Kubernetes Engine > Clusters

This gives a view of the node pools.


GCP > Compute Engine > VM instances

To view the actual VMs.

Here you can ssh into the VM. Also look at logs in Stack driver logging.


Extends K8 divided into:

  • Serving, request driven compute
  • Build, Source to container orchestration
  • Eventing, managing delivery of events

Abstracts common tasks:

  • Container deployment
  • Routing and managing traffic
  • Autoscale (including to 0)
  • Binding to events


  • Platform agnostic
  • Simplifies operational concerns
  • Focus on writing code

Appears to needs a minimum of 3 nodes.

Lets try with 3 and n1-standard-1

Do not need to install ingress, just install knative and use the IP it gives. For domain use

Production passes but the IP does not work. Missing something perhaps this is side to side access.

Install ingress and change the auto dev ops to point to the ingress IP.

Ok this is better now we get invalid host header (vue application), the dev server in vue isn’t the right one, ought to build it properly.

Had to add vue.config.js to root and add host port settings:

module.exports = {
    devServer: {
        host: '',
        port: '5000',
        public: '',

– and it works.


Leave a comment

Your email address will not be published. Required fields are marked *