Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scope helper names, add resource label helpers #11

Merged
merged 2 commits into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions stable/spinnaker/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,33 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "name" -}}
{{- define "spinnaker.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 24 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create a default fully qualified app name.
We truncate at 24 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
*/}}
{{- define "fullname" -}}
{{- define "spinnaker.fullname" -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- printf "%s-%s" .Release.Name $name | trunc 24 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels for metadata.
*/}}
{{- define "spinnaker.standard-labels" -}}
app: {{ include "spinnaker.fullname" . | quote }}
heritage: {{ .Release.Service | quote }}
release: {{ .Release.Name | quote }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
{{- end -}}

{{/*
A set of common selector labels for resources.
*/}}
{{- define "spinnaker.standard-selector-labels" -}}
app: {{ include "spinnaker.fullname" . | quote }}
release: {{ .Release.Name | quote }}
{{- end -}}
8 changes: 4 additions & 4 deletions stable/spinnaker/templates/configmap/halyard-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ template "fullname" . }}-halyard-config
name: {{ template "spinnaker.fullname" . }}-halyard-config
labels:
app: {{ template "fullname" . }}
{{ include "spinnaker.standard-labels" . | indent 4 }}
data:
install.sh: |
# Wait for the Hal daemon to be ready
export DAEMON_ENDPOINT=http://{{ template "fullname" . }}-halyard:8064
export DAEMON_ENDPOINT=http://{{ template "spinnaker.fullname" . }}-halyard:8064
export HAL_COMMAND="hal --daemon-endpoint $DAEMON_ENDPOINT"
until $HAL_COMMAND --ready; do sleep 10 ; done

Expand All @@ -19,7 +19,7 @@ data:

$HAL_COMMAND deploy apply
clean.sh: |
export HAL_COMMAND='hal --daemon-endpoint http://{{ template "fullname" . }}-halyard:8064'
export HAL_COMMAND='hal --daemon-endpoint http://{{ template "spinnaker.fullname" . }}-halyard:8064'
$HAL_COMMAND deploy clean -q
config.sh: |
# Spinnaker version
Expand Down
8 changes: 4 additions & 4 deletions stable/spinnaker/templates/hooks/cleanup.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ .Release.Name }}-cleanup-using-hal"
name: "{{ template "spinnaker.fullname" . }}-cleanup-using-hal"
labels:
app: {{ template "fullname" . }}
{{ include "spinnaker.standard-labels" . | indent 4 }}
component: halyard
annotations:
"helm.sh/hook": "pre-delete"
Expand All @@ -12,14 +12,14 @@ spec:
template:
metadata:
labels:
app: {{ template "fullname" . }}
{{ include "spinnaker.standard-labels" . | indent 8 }}
component: halyard
spec:
restartPolicy: OnFailure
volumes:
- name: halyard-config
configMap:
name: {{ template "fullname" . }}-halyard-config
name: {{ template "spinnaker.fullname" . }}-halyard-config
containers:
- name: halyard-install
image: {{ .Values.halyard.image.repository }}:{{ .Values.halyard.image.tag }}
Expand Down
6 changes: 3 additions & 3 deletions stable/spinnaker/templates/hooks/install-using-hal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Job
metadata:
name: "{{ .Release.Name }}-install-using-hal"
labels:
app: {{ template "fullname" . }}
{{ include "spinnaker.standard-labels" . | indent 4 }}
component: halyard
annotations:
"helm.sh/hook": "post-install,post-upgrade"
Expand All @@ -12,7 +12,7 @@ spec:
template:
metadata:
labels:
app: {{ template "fullname" . }}
{{ include "spinnaker.standard-labels" . | indent 8 }}
component: halyard
spec:
{{- if .Values.nodeSelector }}
Expand All @@ -28,7 +28,7 @@ spec:
{{- end }}
- name: halyard-config
configMap:
name: {{ template "fullname" . }}-halyard-config
name: {{ template "spinnaker.fullname" . }}-halyard-config
{{- if .Values.halyard.additionalConfig.enabled }}
- name: additional-config
configMap:
Expand Down
8 changes: 5 additions & 3 deletions stable/spinnaker/templates/ingress/deck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@ metadata:
annotations:
{{ toYaml .Values.deck.ingress.annotations | indent 4 }}
{{- end }}
name: {{ template "fullname" . }}
name: {{ template "spinnaker.fullname" . }}
labels:
{{ include "spinnaker.standard-labels" . | indent 4 }}
spec:
rules:
- host: {{ .Values.deck.host | quote }}
http:
paths:
- path: /
backend:
serviceName: {{ template "fullname" . }}-deck
serviceName: {{ template "spinnaker.fullname" . }}-deck
servicePort: {{ .Values.deck.port }}
{{- if .Values.deck.ingress.tls }}
tls:
{{ toYaml .Values.deck.ingress.tls | indent 4 }}
{{- end -}}
{{- end }}
{{- end }}
18 changes: 11 additions & 7 deletions stable/spinnaker/templates/rbac/halyard-sa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ .Release.Name }}-halyard
name: {{ .Release.Name }}-halyard
labels:
{{ include "spinnaker.standard-labels" . | indent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: edit
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: edit
subjects:
- namespace: {{ .Release.Namespace }}
kind: ServiceAccount
name: {{ template "fullname" . }}-halyard
name: {{ template "spinnaker.fullname" . }}-halyard
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ template "fullname" . }}-halyard
namespace: {{ .Release.Namespace }}
name: {{ template "spinnaker.fullname" . }}-halyard
namespace: {{ .Release.Namespace }}
labels:
{{ include "spinnaker.standard-labels" . | indent 4 }}
12 changes: 7 additions & 5 deletions stable/spinnaker/templates/rbac/spinnaker-sa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Release.Name }}-spinnaker
name: {{ .Release.Name }}-spinnaker
labels:
{{ include "spinnaker.standard-labels" . | indent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- namespace: {{ .Release.Namespace }}
kind: ServiceAccount
name: default
{{ end }}
{{- end }}
4 changes: 2 additions & 2 deletions stable/spinnaker/templates/secrets/gcs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "fullname" . }}-gcs
name: {{ template "spinnaker.fullname" . }}-gcs
labels:
app: {{ template "fullname" . }}
{{ include "spinnaker.standard-labels" . | indent 4 }}
component: halyard
type: Opaque
data:
Expand Down
4 changes: 2 additions & 2 deletions stable/spinnaker/templates/secrets/registry.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ template "fullname" . }}-registry
name: {{ template "spinnaker.fullname" . }}-registry
labels:
app: {{ template "fullname" . }}
{{ include "spinnaker.standard-labels" . | indent 4 }}
component: clouddriver
type: Opaque
data:
Expand Down
22 changes: 13 additions & 9 deletions stable/spinnaker/templates/statefulsets/halyard.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,39 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "fullname" . }}-halyard
name: {{ template "spinnaker.fullname" . }}-halyard
labels:
app: {{ template "fullname" . }}
{{ include "spinnaker.standard-labels" . | indent 4 }}
component: halyard
spec:
ports:
- port: 8064
name: daemon
clusterIP: None
selector:
app: {{ template "fullname" . }}
app: {{ template "spinnaker.fullname" . }}
component: halyard
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ template "fullname" . }}-halyard
name: {{ template "spinnaker.fullname" . }}-halyard
labels:
{{ include "spinnaker.standard-labels" . | indent 4 }}
spec:
serviceName: {{ template "fullname" . }}-halyard
serviceName: {{ template "spinnaker.fullname" . }}-halyard
replicas: 1
selector:
matchLabels:
app: {{ template "fullname" . }}
{{ include "spinnaker.standard-selector-labels" . | indent 6 }}
component: halyard
template:
metadata:
labels:
app: {{ template "fullname" . }}
{{ include "spinnaker.standard-labels" . | indent 8 }}
component: halyard
spec:
serviceAccountName: {{ template "fullname" . }}-halyard
serviceAccountName: {{ template "spinnaker.fullname" . }}-halyard
securityContext:
runAsUser: 1000
fsGroup: 1000
Expand Down Expand Up @@ -64,7 +66,7 @@ spec:
{{- if .Values.gcs.enabled }}
- name: gcs-key
secret:
secretName: {{ template "fullname" . }}-gcs
secretName: {{ template "spinnaker.fullname" . }}-gcs
{{- end }}
- name: halyard-config
emptyDir: {}
Expand All @@ -90,6 +92,8 @@ spec:
volumeClaimTemplates:
- metadata:
name: halyard-home
labels:
{{ include "spinnaker.standard-labels" . | indent 8 }}
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
Expand Down