📄
Spinnaker
  • Home
  • Introduction
    • Spinnaker
    • Kubernetes Concept
    • First deployment
  • Pipeline
    • Basics
    • Configuration
    • Highlander deployment
  • Blue/Green Deployment
    • Concepts
    • Built-in Strategy
    • Rollback pipeline
    • Merge pipelines
Powered by GitBook
On this page

Was this helpful?

  1. Pipeline

Basics

Setup a basic pipeline in order to deploy a simple frontend application

PreviousFirst deploymentNextConfiguration

Last updated 5 years ago

Was this helpful?

Through the next few exercises, we'll setup the deployment on development environment of an application which display a wonderful page.

Create the Pipeline

Head to the "Pipeline" tab:

  • click "configure a new pipeline"

  • enter the pipeline name "deploy-dev"

  • click the "Create" button

You created an empty pipeline named "deploy-dev".

This page is the configuration stage of the pipeline: every pipeline start with this stage. We will get back to the configuration stage later, for now let's add a new stage.

Service stage

Add a new stage:

  • click the "Add stage" grey button

  • select the "Deploy (Manifest)" type

  • select the Kubernetes account Spinnaker will use in order to deploy the manifest (only one choice should be available)

  • paste the following YAML file in the "Manifest" section

  • replace ${account} with your actual account name (provided at the beginning of this lab: ie "batman", "superman", and so on...)

  • name the stage "Deploy Service"

  • save your changes (bottom right corner)

apiVersion: v1
kind: Service
metadata:
  # Name of the service
  name: wonderfulapp-service
  namespace: ${account}
spec:
  # Route traffic to any Pods matching these labels
  selector:
    app: wonderfulapp
    environment: dev
  ports:
    # publish TCP port 80, and expect pods to be listening on the same port
    - protocol: TCP
      port: 80

Ingress stage

Now, we need to add a new step in order to deploy the application's Ingress rule:

  • click the "Add stage" grey button

  • select the "Deploy (Manifest)" type

  • select the Kubernetes account spinnaker will use in order to deploy the manifest (only one choice should be available)

  • paste the following YAML file in the "Manifest" section

  • replace ${account} with your actual account name

  • name the stage "Deploy Ingress"

  • save your changes (bottom right corner)

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  # Name of the Ingress rule
  name: wonderfulapp-ingress
  namespace: ${account}
  annotations:
    # Rewrite URL 'mydomain/matchingPath/anything' to 'backendService/anything'
    nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
  rules:
    - http:
        paths:
          # will match path '/${account}/wonderfulapp/anything' capturing separately (/) and (anything)
          - path: /${account}/wonderfulapp(/|$)(.*)
            backend:
              # Use service named 'wonderfulapp-service' as backend on port 80
              serviceName: wonderfulapp-service
              servicePort: 80

ReplicaSet stage

Finally, we need to add a last step in order to deploy the application's pods:

  • click the "Add stage" grey button

  • select the "Deploy (Manifest)" type

  • select the Kubernetes account spinnaker will use in order to deploy the manifest (only one choice should be available)

  • paste the following YAML file in the "Manifest" section

  • replace ${account} with your actual account name

  • name the stage "Deploy ReplicaSet"

  • save your changes (bottom right corner)

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  # Name of this replicaSet
  name: wonderfulapp-replica
  namespace: ${account}
spec:
  # Number of pods to keep up and running (exceeding pods will be terminated)
  replicas: 1
  # labels used to find pods managed by this replicaSet
  selector:
    matchLabels:
      app: wonderfulapp
      environment: dev
  # pods template
  template:
    metadata:
      # labels set to pods created by this replicaSet
      labels:
        app: wonderfulapp
        environment: dev
    spec:
      containers:
      - name: wonderfulapp
        image: jcalderan/wonderfulapp:grey
        # pod will expose port 80
        # the containerised application is expected to be listening on this port
        ports:
        - containerPort: 80

Run the Pipeline

You should now have a pipeline resembling this:

Save your changes and go back to the Pipeline tab: you should see your pipeline named "deploy-dev". Click the button "Start manual execution".

After a few seconds, your pipeline execution completes.

Take a moment to click on each step and play with the pipeline results output.

Go to the "Infrastructure" tab : a new Cluster Group has been created, as well as a new Load Balancer (in Spinnaker terms, not Kubernetes).

Go to the Load Balancers tab (just below "Infrastructure"). You can see both the Ingress rule and the Service:

You can find the URL of your cluster here:

  • click on the Ingress

  • the right menu appears

  • copy the address displayed under the label "Ingress": this is the publicly accessible URL of your cluster.

You should be able to access the application at http://${clusterURL}/${account}/wonderfulapp.

Summary

Our Pipeline ensure new pods won't be deployed if an error occurs during the Ingress/Service stage: using Pipelines, we are able to coordinate deployment stages which depends on each other completion status.

This manifest configures a which allows other applications to access the wonderfulapp's pods. The following diagram, from the Kubernetes documentation on the , shows how the service select the pods which will receive traffics according to their labels.

This manifest describes an used by the cluster's in order to route incoming traffic to the right Service, which in turn will route traffic to the right pods.

We defined a in order to manage our pods, thus all operations on pods (scaling up/down, updating, etc...) will be handled by this manifest.

Kubernetes Service
CoreOS website
Ingress rule
Ingress Controller
Kubernetes ReplicaSet