Skip to content

Instantly share code, notes, and snippets.

@RodEsp
Last active January 14, 2022 15:04
Show Gist options
  • Save RodEsp/84b0e3d6fa9371cce7eb77ba08ecc1fa to your computer and use it in GitHub Desktop.
Save RodEsp/84b0e3d6fa9371cce7eb77ba08ecc1fa to your computer and use it in GitHub Desktop.

Please credit this guide if you use its instructions elsewhere.

Installing Spinnaker on a local Kubernetes cluster for local Spinnaker development

All the commands in this document are meant to be run from your computer’s terminal, unless stated otherwise. This guide has only been tested on macOS Catalina.

Install Docker and Kubernetes

  1. Download and install Docker Desktop from: https://www.docker.com/products/docker-desktop
  2. Enable Kubernetes:
    1. Launch Docker
    2. Click the Docker icon on your taskbar and then click Preferences.
    3. Go to the Resources section and set the following:
      1. CPUs: 8
      2. Memory: 16.00 GB
      3. Swap: 2 GB
      4. Disk image size: 64 GB
    4. Go to the Kubernetes section.
      1. Check Enable Kubernetes.
      2. Check Deploy Docker Stacks to Kubernetes by default.
      3. Select Show system containers (advanced).
    5. Click Apply & Restart (this will take a few minutes).
    6. In a terminal, execute kubectl version to validate install.
      1. You should see something like the following
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.5", GitCommit:"20c265fef0741dd71a66480e35bd69f18351daea", GitTreeState:"clean", BuildDate:"2019-10-15T19:16:51Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.5", GitCommit:"20c265fef0741dd71a66480e35bd69f18351daea", GitTreeState:"clean", BuildDate:"2019-10-15T19:07:57Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}

Install Halyard on Docker

  1. Install Halyard on Docker following Spinnaker's Instructions.
  2. Stop the Halyard container.
    1. docker stop halyard

Setting up a local Storage Service

We will be using Minio running in Kubernetes as a Storage Service for Spinnaker.

You will need Helm 3+ installed for this section. If you do not have it follow these instructions. Then run

helm repo add stable https://kubernetes-charts.storage.googleapis.com/

helm repo update

SETUP PERSISTENT STORAGE

  1. Create a PersistentVolume (PV) in Kubernetes, run:

    1.  echo "apiVersion: v1
       kind: PersistentVolume
       metadata:
         name: minio-pv
         labels:
           type: local
       spec:
         storageClassName: manual
         capacity:
           storage: 2Gi
         accessModes:
           - ReadWriteOnce
         hostPath:
           path: "/mnt/data"" | kubectl apply -f -
      
  2. Create a PersistentVolumeClaim (PVC) in Kubernetes.

    1. First, create the spinnaker namespace.
      1. kubectl create namespace spinnaker
    2. Then create the PVC, run:
    3.  echo "apiVersion: v1
       kind: PersistentVolumeClaim
       metadata:
         name: minio-pvc
         namespace: spinnaker
       spec:
         accessModes:
           - ReadWriteOnce
         resources:
           requests:
             storage: 2Gi" | kubectl apply -f -
      

SETUP MINIO

  1. Deploy Minio to Kubernetes. (reference)
    1. helm install minio stable/minio --namespace spinnaker --set accessKey=minioadmin --set secretKey=minioadmin --set persistence.existingClaim=minio-pvc
  2. Create this file on your computer (reference): ~/.hal/default/profiles/front50-local.yml
    1. Write this into the file and save it: spinnaker.s3.versioning: false
  3. Run the Halyard docker container.
    1. docker run --name halyard --rm -v ~/.hal:/home/spinnaker/.hal -v ~/.kube:/home/spinnaker/.kube -it gcr.io/spinnaker-marketplace/halyard:stable
  4. In another terminal, exec into the running Halyard container.
    1. docker exec -it halyard bash
    2. In the Halyard container, run: (reference)
      1. echo "minioadmin" | hal config storage s3 edit --endpoint http://minio.spinnaker.svc.cluster.local:9000 --access-key-id minioadmin --secret-access-key
      2. hal config storage edit --type s3
      3. hal config storage s3 edit --path-style-access true

Configuring a Cloud Provider

Make sure your Halyard docker container is running, from step 3 of SETUP MINIO and you are exec’d into it, step 4i. of the same section.

  1. In the Halyard container:
    1. Make sure your kubectl context is set to docker-desktop.
      1. kubectl config use-context docker-desktop
    2. Configure Kubernetes as your Cloud Provider using these instructions.
      1. Make sure you enable artifact support.
    3. Configure Halyard to install Spinnaker on Kubernetes (reference):
      1. hal config deploy edit --type distributed --account-name my-k8s-account

Install and run Spinnaker on Kubernetes

Make sure your Halyard docker container is running, from step 3 of SETUP MINIO and you are exec’d into it, step 4i. of the same section.

(Reference)

  1. In the Halyard container:
    1. hal config version edit --version VERSION - But change VERSION to the version number you need.
    2. hal deploy apply
      1. This is the command that actually deploys Spinnaker to K8s.
  2. It will take a little while for Spinnaker to start up in your Kubernetes cluster. You can monitor its progress by running kubectl get all -n spinnaker on your computer's terminal.
    1. If you have watch (mac/linux) installed run watch -n 1 "kubectl get all -n spinnaker" for live updates.
    2. You can also get live updates on just the pods by running kubectl get pods -n spinnaker --watch.
  3. Once all the pods are up and running, continue to the next section.

Run Deck locally against Spinnaker on your K8s cluster

Note that for this section Deck is being used as an example but you should be able to do basically the same thing for any of Spinnaker's microservices. This section assumes you have cloned the Spinnaker/Deck repository on your computer.

  1. Port-forward the Spinnaker Gate service so it can be accessed from your computer. (Deck, Spinnaker’s GUI, needs to be able to reach Gate, Spinnaker’s API.)
    1. kubectl -n spinnaker port-forward service/spin-gate 8084:8084
  2. Start the Spinnaker Deck service in development mode on your computer.
    1. Navigate to wherever you cloned the Spinnaker/Deck repository and run
      1. AUTH_ENABLED=false API_HOST=http://localhost:8084 yarn start
  3. On your browser, navigate to http://localhost:9000/, you should now see the Spinnaker UI (Deck) show up!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment