Hello! Here you'll find a way to quickly (~30min) setup a local Spinnaker instance (with examples) to play with. This repo was made as a takeaway from my DevOps Toronto Meetup talk 'An Overview of Spinnaker' of April 2019.
TL;DR: Run every code block in a terminal (with Homebrew installed) and go to http://localhost:9000
This will guide you to:
- Setup a local lightweight Kubernetes, using:
- Installing Spinnaker (via the stable/spinnaker Helm chart)
And optionally:
- Installing Spinnaker Tools:
- Setup an example Application and Pipelines
- Cleaning up
brew cask install multipass
If you're not using Homebrew, see multipass
readme for alternative installation methods
# Spinnaker spins up a few microservices so good cpu/memory/disk helps.
multipass launch --name k3s-spin --cpus 4 --mem 8G --disk 20G
Hint: Monitor processes and resources of your VM with htop
: multipass exec k3s-spin -- sh -c "sudo snap install htop"
then (in a new shell) multipass exec k3s-spin -- sh -c "htop"
multipass exec k3s-spin -- sh -c "curl -sfL https://get.k3s.io/ | sh -"
brew install jq kubernetes-cli
If you're not using Homebrew, see jq
, kubectl
for alternative installation methods
# Copy kubeconfig from VM
multipass copy-files k3s-spin:/etc/rancher/k3s/k3s.yaml $HOME/.kube/k3s-spin.yaml
# Get VM IP
K3S_IP=$(multipass info k3s-spin --format json | jq -r '.info."k3s-spin".ipv4[0]')
# Replace 'localhost' in kubeconfig with VM IP
sed -i "s/127.0.0.1/${K3S_IP}/g" $HOME/.kube/k3s-spin.yaml
# Tell kubectl to use the k3s kubeconfig by default
export KUBECONFIG=$HOME/.kube/k3s-spin.yaml
One last step, tell Kubernetes to use local storage (disk) — You don't need to know what any of this does for this playground, but see Rancher's Local Path Provisioner if you're curious.
# Get Local Path Provisioner (local-path)
curl -LO https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml
# Install
kubectl apply -f local-path-storage.yaml
# Make local-path default storage class
kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
# Cleanup
rm local-path-storage.yaml
Hint: Test your Kubernetes connection with kubectl get all --all-namespaces
(you should get a list of Kubernetes resources).
# The Kubernetes namespace we'll use throughout
export SPIN_NAMESPACE='spin-playground'
# Create namespace
kubectl create ns ${SPIN_NAMESPACE}
NB: Even though it exits right away, THE FOLLOWING STEP TAKES A WHILE!
# Install Spinnaker via k3s' HelmChart resource
cat <<EOF | kubectl create -f -
apiVersion: helm.cattle.io/v1
kind: HelmChart
metadata:
name: spinnaker
namespace: kube-system
spec:
chart: stable/spinnaker
targetNamespace: ${SPIN_NAMESPACE}
EOF
Hint: Monitor the progression of the installation:
- Using
htop
installed earlier (memory usage and cpu usage will creep up), and; - Using
kubectl
:kubectl get all --namespace $SPIN_NAMESPACE
(until all deployments are ready);kubectl logs <resource> -f --namespace $SPIN_NAMESPACE
(to check logs) or;kubectl describe <resource> --namespace $SPIN_NAMESPACE
(to check states)
Hint: The helm chart will create, in order:
- A Job (
job.batch/spinnaker-install-using-ha
) to bootstrap the rest of the installation; - Services:
service/spinnaker-minio
,service/spinnaker-redis-master
,service/spinnaker-spinnaker-halyard
, respectively: an AWS S3-compatible block storage (for storing config), a cache server (for caching infrastructure), and the Spinaker configuration tool; - After some time: all of the Spinnaker microservices components as Services, i.e. Clouddriver, Orca, Deck, Igor, Gate, Echo, Font50, Rosco.. These take some time to all report as Ready too as many depend on others.
Caveat / Help / My Spinnaker install dies:
This is a very low-resource install of Spinnaker. Running it is fine, but installing it first does take a toll that can result in some timeouts.
-
Sometimes Minio and Redis Services will die and go away, if this happens, delete the helm chart resource and add it again:
kubectl delete helmcharts/spinnaker --namespace kube-system
Then re-run the last step above.
-
Some Spinnaker microservices might
CrashLoopBackOff
(same reason as above): It should fix itself with time. There's a lot going on and most component depends on others, but the Kubernetes scheduler decides the order with which to create them. -
Upon inspecting their logs, some Spinnaker microservices might be stuck in error loops (especially after most other components are up): kill the pod (after looking it up using
kubectl get all --namespace $SPIN_NAMESPACE
. The deployment will replace it. e.g.:kubectl delete pod/spin-gate-6778864f66-qjqlt --namespace $SPIN_NAMESPACE
NB: Only proceed once kubectl get all --namespace $SPIN_NAMESPACE
shows all deployments in Ready state!
In a new terminal window, port-forward the Spinnaker UI (Deck, port 9000).
export KUBECONFIG=$HOME/.kube/k3s-spin.yaml
export SPIN_NAMESPACE='spin-playground'
export DECK_POD=$(kubectl get pods --namespace ${SPIN_NAMESPACE} -l "cluster=spin-deck" -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward --namespace ${SPIN_NAMESPACE} $DECK_POD 9000
Head to http://localhost:9000. It's up! 🎉
In a new terminal window, port-forward the Spinnaker API (Gate, port 8084).
export KUBECONFIG=$HOME/.kube/k3s-spin.yaml
export SPIN_NAMESPACE='spin-playground'
export GATE_POD=$(kubectl get pods --namespace ${SPIN_NAMESPACE} -l "cluster=spin-gate" -o jsonpath="{.items[0].metadata.name}")
kubectl port-forward --namespace ${SPIN_NAMESPACE} $GATE_POD 8084
Hint: You only need to do this if you plan to use the hal
or spin
CLIs.
Follow the official instructions (Docker method recommended).
hal
is the CLI tool used to configure and managing Spinnaker, for example:
- Updating Spinnaker;
- Connecting to a CI engine like Jenkins or Travis;
- Adding a private Docker registry;
- Connecting Spinnaker to a cloud provider such as AWS;
- Backing up and restoring configuration;
- ... and much more: command reference.
NB: This is optional. The installation used in this playground is self-contained and already adds the current Kubernetes instance as a provider.
Hint: For more advanced installation on Kubernetes, use helm chart values overrides. Providers and more can be configured directly on install.
Hint: Once you're in the halyard container, any command (e.g. hal config list
) will let you know your hal
is working correctly by providing a successful response.
Follow the official instructions (installation and usage).
NB: No need to configure spin
here. By default, spin
will look for the Spinnaker API at http://localhost:8084, which is what we have set up.
spin
is the CLI tool used to manage:
- Applications
- Pipelines
- Pipeline Templates
spin application save --file examples/application/my-devopsto-app.json
Hint: Applications can also be created by:
- Passing attributes directly the attributes to
spin application save
- In the UI, Applications > Actions > Create Application
spin pipeline save --file examples/application/wait_pipeline.json
To remove any trace of Spinnaker from k3s, just delete the namespace it was installed in and the HelmChart resource it was installed with. This can take a while as Kubernetes does a clean removal.
export SPIN_NAMESPACE='spin-playground'
kubectl delete ns ${SPIN_NAMESPACE}
kubectl delete helmchart spinnaker --namespace kube-system
multipass delete k3s-spin
multipass purge
docker rm halyard # hal
rm <path to spin> # spin
https://medium.com/@zhimin.wen/running-k3s-with-multipass-on-mac-fbd559966f7c
https://medium.com/@zhimin.wen/deploy-jenkins-helm-chart-on-k3s-running-on-macbook-484bb7ba588f
The MIT License (MIT) Copyright © 2019 Pierre Nicolas Durette