Skip to content

Commit

Permalink
create pvc and configmap
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwani-opstree committed Jul 8, 2024
1 parent 5ad7399 commit d274858
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 39 deletions.
11 changes: 11 additions & 0 deletions charts/microservice/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,14 @@ Selector labels
{{- define "microservice.selectorLabels" -}}
app: {{ include "microservice.fullname" . }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "microservice.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "microservice.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/microservice/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "microservice.fullname" $root }}-{{ $cm.name }}-cm
namespace: {{ .Values.global.namespace }}
namespace: {{ $root.Values.global.namespace }}
data:
{{- if $cm.data }}
{{- range $filename, $content := $cm.data }}
Expand Down
7 changes: 6 additions & 1 deletion charts/microservice/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ spec:
labels:
{{- include "microservice.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "microservice.serviceAccountName" . }}
containers:
- name: {{ include "microservice.fullname" . }}
image: "{{ .Values.deployment.image.name }}:{{ .Values.deployment.image.tag }}"
Expand Down Expand Up @@ -66,7 +71,7 @@ spec:
{{- range $conf := .Values.deployment.volumes.configMaps }}
- name: {{ include "microservice.fullname" $root }}-{{ $conf.name }}-cm
configMap:
name: {{ $conf.name }}
name: {{ include "microservice.fullname" $root }}-{{ $conf.name }}-cm
{{- end }}
{{- if .Values.deployment.volumes.pvc.enabled}}
- name: {{ .Values.deployment.volumes.pvc.existing_claim | default .Values.volumes.pvc.name }}-volume
Expand Down
21 changes: 21 additions & 0 deletions charts/microservice/templates/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if .Values.deployment.volumes.pvc.enabled }}
{{- if .Values.deployment.volumes.pvc.existing_claim -}}
{{- else -}}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.deployment.volumes.pvc.name }}
namespace: {{ .Values.global.namespace }}
spec:
{{- if .Values.deployment.volumes.pvc.class }}
storageClassName: {{ .Values.deployment.volumes.pvc.class }}
{{- end }}
accessModes:
{{- range $accessMode := .Values.deployment.volumes.pvc.accessModes }}
- {{ $accessMode }}
{{- end }}
resources:
requests:
storage: {{ .Values.deployment.volumes.pvc.size }}
{{- end }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/microservice/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "microservice.serviceAccountName" . }}-sa
labels:
{{- include "microservice.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}
81 changes: 44 additions & 37 deletions charts/microservice/values.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# -- global variables
global:
namespace: ""
namespace: "default"
replicaCount: 1
nameOverride: "ashwani"
fullnameOverride: "ashwani"
imagePullSecrets: []
environment: {}
# list of key: value
# GLOBAL1: value
Expand Down Expand Up @@ -63,49 +64,45 @@ deployment:

# Additional volumes on the output Deployment definition.
volumes:
enabled: true
pvc:
enabled: false
existing_claim:
name: pvc
mountPath: /pv
size: 1G
class:
accessModes:
- ReadWriteOnce
enabled: false
# pvc:
# enabled: false
# existing_claim: false
# name: pvc
# mountPath: /pv
# size: 1G
# class: "default"
# accessModes:
# - ReadWriteOnce

# configFileCommonHeader: |
# line1
# line2

configMaps:
- name: test
mountPath: /test
data:
test.conf: |
hello
# hello2

# - name: test-from-file
# mountPath: /test2
# files:
# - source: config.conf
# destination: application.conf
# - name: test-mixed
# mountPath: /test3
# data:
# test2.conf: |
# another hello
# files:
# - source: config.conf
# destination: application2.conf

# - name: foo
# secret:
# secretName: mysecret
# optional: false
# configMaps:
# - name: test
# mountPath: /test
# data:
# test.conf: |
# hello
# hello2

# - name: test-from-file
# mountPath: /test2
# files:
# - source: config.conf
# destination: application.conf
# - name: test-mixed
# mountPath: /test3
# data:
# test2.conf: |
# another hello
# files:
# - source: config.conf
# destination: application2.conf

# Additional volumeMounts on the output Deployment definition.

volumeMounts: []
# - name: foo
# mountPath: "/etc/foo"
Expand All @@ -130,3 +127,13 @@ service:
specs:
- port: 80
name: http

serviceAccount:
create: true
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

0 comments on commit d274858

Please sign in to comment.