Skip to content

Commit

Permalink
Merge pull request #69 from naseemkullah/labels-helper
Browse files Browse the repository at this point in the history
[stable/gcloud-sqlproxy] Labels helper
  • Loading branch information
rimusz authored Dec 25, 2019
2 parents 6a0bf39 + 577a9e1 commit 7c82de4
Show file tree
Hide file tree
Showing 13 changed files with 42 additions and 48 deletions.
4 changes: 3 additions & 1 deletion stable/gcloud-sqlproxy/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ keywords:
maintainers:
- email: rmocius@gmail.com
name: rimusz
- email: naseemkullah@gmail.com
name: naseemkullah
name: gcloud-sqlproxy
sources:
- https://github.com/rimusz/charts
version: 0.19.2
version: 0.19.3
1 change: 1 addition & 0 deletions stable/gcloud-sqlproxy/OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ approvers:
- rimusz
reviewers:
- rimusz
- naseemkullah
22 changes: 21 additions & 1 deletion stable/gcloud-sqlproxy/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,26 @@ Create chart name and version as used by the chart label.
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "gcloud-sqlproxy.labels" -}}
helm.sh/chart: {{ include "gcloud-sqlproxy.chart" . }}
{{ include "gcloud-sqlproxy.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Selector labels
*/}}
{{- define "gcloud-sqlproxy.selectorLabels" -}}
app.kubernetes.io/name: {{ include "gcloud-sqlproxy.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end -}}

{{/*
Generate gcp service account name
*/}}
Expand All @@ -57,4 +77,4 @@ Check if any type of credentials are defined
*/}}
{{- define "gcloud-sqlproxy.hasCredentials" -}}
{{ or .Values.serviceAccountKey ( or .Values.existingSecret .Values.usingGCPController ) -}}
{{- end -}}
{{- end -}}
11 changes: 5 additions & 6 deletions stable/gcloud-sqlproxy/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ kind: Deployment
metadata:
name: {{ include "gcloud-sqlproxy.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "gcloud-sqlproxy.name" . }}
helm.sh/chart: {{ include "gcloud-sqlproxy.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "gcloud-sqlproxy.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicasCount }}
selector:
matchLabels:
{{- include "gcloud-sqlproxy.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "gcloud-sqlproxy.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "gcloud-sqlproxy.selectorLabels" . | nindent 8 }}
annotations:
{{ toYaml .Values.podAnnotations | indent 8 }}
spec:
Expand Down
7 changes: 2 additions & 5 deletions stable/gcloud-sqlproxy/templates/gcpserviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: GcpServiceAccount
metadata:
labels:
controller-tools.k8s.io: "1.0"
app.kubernetes.io/name: {{ include "gcloud-sqlproxy.fullname" . }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "gcloud-sqlproxy.labels" . | nindent 4 }}
name: {{ include "gcloud-sqlproxy.fullname" . }}
spec:
serviceAccountIdentifier: {{ include "gcloud-sqlproxy.serviceAccountName" . }}
Expand All @@ -19,4 +16,4 @@ spec:
roles:
- roles/cloudsql.client
{{ end }}
{{ end }}
{{ end }}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
labels:
app.kubernetes.io/name: {{ include "gcloud-sqlproxy.name" . }}
helm.sh/chart: {{ include "gcloud-sqlproxy.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "gcloud-sqlproxy.labels" . | nindent 4 }}
name: {{ include "gcloud-sqlproxy.fullname" . }}
spec:
scaleTargetRef:
Expand Down
5 changes: 1 addition & 4 deletions stable/gcloud-sqlproxy/templates/networkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ apiVersion: networking.k8s.io/v1
metadata:
name: "{{ include "gcloud-sqlproxy.fullname" . }}"
labels:
app.kubernetes.io/name: {{ include "gcloud-sqlproxy.name" . }}
helm.sh/chart: {{ include "gcloud-sqlproxy.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "gcloud-sqlproxy.labels" . | nindent 4 }}
spec:
podSelector:
matchLabels:
Expand Down
5 changes: 1 addition & 4 deletions stable/gcloud-sqlproxy/templates/pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
labels:
app.kubernetes.io/name: {{ include "gcloud-sqlproxy.name" . }}
helm.sh/chart: {{ include "gcloud-sqlproxy.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "gcloud-sqlproxy.labels" . | nindent 4 }}
name: {{ include "gcloud-sqlproxy.fullname" . }}
spec:
selector:
Expand Down
5 changes: 1 addition & 4 deletions stable/gcloud-sqlproxy/templates/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: Role
metadata:
namespace: {{ .Values.namespace }}
labels:
app.kubernetes.io/name: {{ include "gcloud-sqlproxy.name" . }}
helm.sh/chart: {{ include "gcloud-sqlproxy.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "gcloud-sqlproxy.labels" . | nindent 4 }}
name: {{ include "gcloud-sqlproxy.fullname" . }}
rules:
- apiGroups: [""]
Expand Down
5 changes: 1 addition & 4 deletions stable/gcloud-sqlproxy/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ kind: RoleBinding
metadata:
namespace: {{ .Values.namespace }}
labels:
app.kubernetes.io/name: {{ include "gcloud-sqlproxy.name" . }}
helm.sh/chart: {{ include "gcloud-sqlproxy.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "gcloud-sqlproxy.labels" . | nindent 4 }}
name: {{ .Release.Name }}
roleRef:
apiGroup: rbac.authorization.k8s.io
Expand Down
7 changes: 2 additions & 5 deletions stable/gcloud-sqlproxy/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ kind: Secret
metadata:
name: {{ include "gcloud-sqlproxy.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "gcloud-sqlproxy.name" . }}
helm.sh/chart: {{ include "gcloud-sqlproxy.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "gcloud-sqlproxy.labels" . | nindent 4 }}
type: Opaque
data:
credentials.json: |-
{{ .Values.serviceAccountKey }}
{{- end -}}
{{- end -}}
{{- end -}}
5 changes: 1 addition & 4 deletions stable/gcloud-sqlproxy/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ kind: ServiceAccount
metadata:
namespace: {{ .Values.namespace }}
labels:
app.kubernetes.io/name: {{ include "gcloud-sqlproxy.name" . }}
helm.sh/chart: {{ include "gcloud-sqlproxy.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "gcloud-sqlproxy.labels" . | nindent 4 }}
name: {{ include "gcloud-sqlproxy.fullname" . }}
{{- end }}
8 changes: 2 additions & 6 deletions stable/gcloud-sqlproxy/templates/svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ metadata:
cloud.google.com/load-balancer-type: "Internal"
{{- end }}
labels:
app.kubernetes.io/name: {{ include "gcloud-sqlproxy.name" . }}
helm.sh/chart: {{ include "gcloud-sqlproxy.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "gcloud-sqlproxy.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
Expand All @@ -21,5 +18,4 @@ spec:
targetPort: {{ .instanceShortName | default (.instance | trunc 15) }}
{{- end }}
selector:
app.kubernetes.io/name: {{ include "gcloud-sqlproxy.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "gcloud-sqlproxy.selectorLabels" . | nindent 4 }}

0 comments on commit 7c82de4

Please sign in to comment.