├── .gitignore ├── Dockerfile ├── Makefile ├── README.md ├── chart └── spin-helm-demo │ ├── .helmignore │ ├── Chart.yaml │ ├── templates │ ├── _helpers.tpl │ ├── deployment.yaml │ └── service.yaml │ └── values.yaml ├── src ├── images │ └── spinnaker-logo-inline.svg ├── index.html └── site.conf └── values ├── dev.yaml └── prod.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | *.tgz 2 | .env -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM nginx:alpine 2 | 3 | ADD src/ /data/www/ 4 | ADD src/site.conf /etc/nginx/conf.d/ -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CHART_NAME=$(shell cat chart/spin-helm-demo/Chart.yaml | yq -r .name) 2 | CHART_VERSION=$(shell cat chart/spin-helm-demo/Chart.yaml | yq -r .version) 3 | 4 | APP_VERSION ?= $(shell cat chart/spin-helm-demo/Chart.yaml | yq -r .appVersion) 5 | 6 | CHART_BUCKET ?= spin-helm-demo-bucket 7 | DOCKER_REPO ?= spin-helm-repo 8 | SPINNAKER_API ?= https://my-spinnaker.io 9 | 10 | docker: 11 | docker build -t $(DOCKER_REPO):$(APP_VERSION) . 12 | docker tag $(DOCKER_REPO):$(APP_VERSION) $(DOCKER_REPO):latest 13 | 14 | dockerpush: docker 15 | docker push $(DOCKER_REPO):$(APP_VERSION) 16 | docker push $(DOCKER_REPO):latest 17 | 18 | compile: 19 | helm package chart/spin-helm-demo 20 | 21 | upload: 22 | aws s3 cp $(CHART_NAME)-$(CHART_VERSION).tgz s3://$(CHART_BUCKET)/packages/ 23 | aws s3 cp values/dev.yaml s3://$(CHART_BUCKET)/packagevalues/$(CHART_NAME)/dev.yaml 24 | aws s3 cp values/prod.yaml s3://$(CHART_BUCKET)/packagevalues/$(CHART_NAME)/prod.yaml 25 | 26 | triggerdocker: 27 | curl -L -vvv -X POST \ 28 | -k \ 29 | -H"Content-Type: application/json" $(SPINNAKER_API)/webhooks/webhook/spinhelmdemo \ 30 | -d '{"artifacts": [{"type": "docker/image", "name": "$(CHART_NAME)", "reference": "$(DOCKER_REPO):$(APP_VERSION)", "kind": "docker"}]}' 31 | 32 | triggerchart: 33 | curl -L -vvv -X POST \ 34 | -k \ 35 | -H"Content-Type: application/json" $(SPINNAKER_API)/webhooks/webhook/spinhelmdemo \ 36 | -d '{"artifacts": [{"type": "s3/object", "name": "s3://$(CHART_BUCKET)/packages/spin-helm-demo-0.1.0.tgz", "reference": "s3://$(CHART_BUCKET)/packages/spin-helm-demo-$(CHART_VERSION).tgz", "kind": "s3"}]}' -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # spin-helm-demo 2 | 3 | This is the sample repository for the post [Deploying Helm Charts with Armory Spinnaker](https://kb.armory.io/kubernetes/using-spinnaker-and-helm/). If you're planning on using Helm charts with Spinnaker, these resources should serve as a good way to get started. 4 | 5 | ## What's included? 6 | 7 | * A simple "application" running inside a Docker container. Located in `src/`. 8 | * A basic Helm chart that includes a `Deployment` and `Service` 9 | * A `Makefile` for automating various pieces of the process. You could take these commands and integrate them into your CI workflows. 10 | 11 | ## Dependencies 12 | 13 | * `docker` 14 | * `make` 15 | * `helm` 16 | * `aws` 17 | * `curl` 18 | 19 | ## Making customizations 20 | 21 | The `Makefile` exposes a few options that can be overridden. To override them, create a file called `.env` with the following contents: 22 | 23 | ``` 24 | export CHART_BUCKET=my-chart-bucket 25 | export DOCKER_REPO=dockerhubusername/spin-helm-demo 26 | export SPINNAKER_API=https://mycoolspinnaker.spinnaker.io 27 | ``` 28 | 29 | Then, run `source .env` to make them all environment variables. `make` will override the default values with these variables. -------------------------------------------------------------------------------- /chart/spin-helm-demo/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | -------------------------------------------------------------------------------- /chart/spin-helm-demo/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | appVersion: "1.1.4" 3 | description: A Helm chart for demoing Helm support in Spinnaker 4 | name: spin-helm-demo 5 | version: 0.1.7 6 | -------------------------------------------------------------------------------- /chart/spin-helm-demo/templates/_helpers.tpl: -------------------------------------------------------------------------------- 1 | {{/* vim: set filetype=mustache: */}} 2 | {{/* 3 | Expand the name of the chart. 4 | */}} 5 | {{- define "spin-helm-demo.name" -}} 6 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} 7 | {{- end -}} 8 | 9 | {{/* 10 | Create a default fully qualified app name. 11 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 12 | If release name contains chart name it will be used as a full name. 13 | */}} 14 | {{- define "spin-helm-demo.fullname" -}} 15 | {{- if .Values.fullnameOverride -}} 16 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} 17 | {{- else -}} 18 | {{- $name := default .Chart.Name .Values.nameOverride -}} 19 | {{- if contains $name .Release.Name -}} 20 | {{- .Release.Name | trunc 63 | trimSuffix "-" -}} 21 | {{- else -}} 22 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} 23 | {{- end -}} 24 | {{- end -}} 25 | {{- end -}} 26 | 27 | {{/* 28 | Create chart name and version as used by the chart label. 29 | */}} 30 | {{- define "spin-helm-demo.chart" -}} 31 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} 32 | {{- end -}} 33 | -------------------------------------------------------------------------------- /chart/spin-helm-demo/templates/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1beta2 2 | kind: Deployment 3 | metadata: 4 | name: {{ template "spin-helm-demo.fullname" . }} 5 | labels: 6 | app: {{ template "spin-helm-demo.name" . }} 7 | chart: {{ template "spin-helm-demo.chart" . }} 8 | release: {{ .Release.Name }} 9 | heritage: {{ .Release.Service }} 10 | environment: {{ .Values.environment }} 11 | demo: "{{ .Values.demo }}" 12 | spec: 13 | replicas: {{ .Values.replicaCount }} 14 | selector: 15 | matchLabels: 16 | app: {{ template "spin-helm-demo.name" . }} 17 | release: {{ .Release.Name }} 18 | template: 19 | metadata: 20 | labels: 21 | app: {{ template "spin-helm-demo.name" . }} 22 | release: {{ .Release.Name }} 23 | environment: {{ .Values.environment }} 24 | spec: 25 | containers: 26 | - name: {{ .Chart.Name }} 27 | image: "{{ .Values.image.name }}" 28 | imagePullPolicy: {{ .Values.image.pullPolicy }} 29 | ports: 30 | - name: http 31 | containerPort: 3000 32 | protocol: TCP 33 | livenessProbe: 34 | httpGet: 35 | path: / 36 | port: http 37 | readinessProbe: 38 | httpGet: 39 | path: / 40 | port: http 41 | resources: 42 | {{ toYaml .Values.resources | indent 12 }} 43 | {{- with .Values.nodeSelector }} 44 | nodeSelector: 45 | {{ toYaml . | indent 8 }} 46 | {{- end }} 47 | {{- with .Values.affinity }} 48 | affinity: 49 | {{ toYaml . | indent 8 }} 50 | {{- end }} 51 | {{- with .Values.tolerations }} 52 | tolerations: 53 | {{ toYaml . | indent 8 }} 54 | {{- end }} 55 | -------------------------------------------------------------------------------- /chart/spin-helm-demo/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ template "spin-helm-demo.fullname" . }} 5 | labels: 6 | app: {{ template "spin-helm-demo.name" . }} 7 | chart: {{ template "spin-helm-demo.chart" . }} 8 | release: {{ .Release.Name }} 9 | heritage: {{ .Release.Service }} 10 | spec: 11 | type: {{ .Values.service.type }} 12 | ports: 13 | - port: {{ .Values.service.port }} 14 | targetPort: http 15 | protocol: TCP 16 | name: http 17 | selector: 18 | app: {{ template "spin-helm-demo.name" . }} 19 | release: {{ .Release.Name }} 20 | -------------------------------------------------------------------------------- /chart/spin-helm-demo/values.yaml: -------------------------------------------------------------------------------- 1 | # Default values for spin-helm-demo. 2 | # This is a YAML-formatted file. 3 | # Declare variables to be passed into your templates. 4 | 5 | replicaCount: 2 6 | environment: dev 7 | demo: false 8 | 9 | image: 10 | name: spin-helm-demo 11 | pullPolicy: IfNotPresent 12 | 13 | service: 14 | type: LoadBalancer 15 | port: 3000 16 | 17 | ingress: 18 | enabled: false 19 | annotations: {} 20 | # kubernetes.io/ingress.class: nginx 21 | # kubernetes.io/tls-acme: "true" 22 | path: / 23 | hosts: 24 | - chart-example.local 25 | tls: [] 26 | # - secretName: chart-example-tls 27 | # hosts: 28 | # - chart-example.local 29 | 30 | resources: {} 31 | # We usually recommend not to specify default resources and to leave this as a conscious 32 | # choice for the user. This also increases chances charts run on environments with little 33 | # resources, such as Minikube. If you do want to specify resources, uncomment the following 34 | # lines, adjust them as necessary, and remove the curly braces after 'resources:'. 35 | # limits: 36 | # cpu: 100m 37 | # memory: 128Mi 38 | # requests: 39 | # cpu: 100m 40 | # memory: 128Mi 41 | 42 | nodeSelector: {} 43 | 44 | tolerations: [] 45 | 46 | affinity: {} 47 | -------------------------------------------------------------------------------- /src/images/spinnaker-logo-inline.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | spinnaker-logo-inline 5 | Created with Sketch. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Spinnaker Helm Demo 7 | 8 | 9 | 10 | 11 | 12 |

Hello Armory Spinnaker Users!

13 | 14 | 15 | -------------------------------------------------------------------------------- /src/site.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 3000; 3 | root /data/www; 4 | } -------------------------------------------------------------------------------- /values/dev.yaml: -------------------------------------------------------------------------------- 1 | replicaCount: 1 2 | environment: dev 3 | demo: true -------------------------------------------------------------------------------- /values/prod.yaml: -------------------------------------------------------------------------------- 1 | replicaCount: 4 2 | environment: prod 3 | demo: false --------------------------------------------------------------------------------