Skip to content

Commit

Permalink
extended template
Browse files Browse the repository at this point in the history
  • Loading branch information
petar-cvit committed Apr 8, 2024
1 parent 81bc669 commit 7464fae
Show file tree
Hide file tree
Showing 5 changed files with 223 additions and 0 deletions.
7 changes: 7 additions & 0 deletions demo-extended/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: extended-demo
description: Demo chart with more properties to chose from

type: application

version: 0.1.0
56 changes: 56 additions & 0 deletions demo-extended/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.name }}
{{- if ((.Values.general).labels) }}
labels:
{{- range $key, $value := (.Values.general).labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
spec:
replicas: {{ (.Values.scaling).replicas | default 1 }}
selector:
matchLabels:
app: {{ .Values.name }}
template:
metadata:
{{- if ((.Values.general).labels) }}
labels:
{{- range $key, $value := (.Values.general).labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
spec:
containers:
- name: {{ .Values.name }}
image: "{{ .Values.general.image }}:{{ .Values.general.version }}"
{{- if ((.Values.networking).expose) }}
ports:
- name: http
containerPort: {{ .Values.networking.port | default 80 }}
protocol: TCP
{{- end }}
env:
{{- if ((.Values.general).environment) }}
{{- range $key, $value := (.Values.general).environment }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
{{- if or ((.Values.scaling).resources).memory ((.Values.scaling).resources).cpu }}
resources:
{{- if ((.Values.scaling).resources).memory }}
limits:
memory: {{ ((.Values.scaling).resources).memory }}
{{- end }}
{{- if or ((.Values.scaling).resources).memory ((.Values.scaling).resources).cpu }}
requests:
{{- if ((.Values.scaling).resources).cpu }}
cpu: {{ ((.Values.scaling).resources).cpu }}
{{- end }}
{{- if ((.Values.scaling).resources).memory }}
memory: {{ ((.Values.scaling).resources).memory }}
{{- end }}
{{- end }}
{{- end }}
21 changes: 21 additions & 0 deletions demo-extended/templates/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if ((.Values.networking).expose) }}
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.name }}
{{- if ((.Values.general).labels) }}
labels:
{{- range $key, $value := (.Values.general).labels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
spec:
type: ClusterIP
ports:
- port: {{ (.Values.networking).port }}
targetPort: http
protocol: TCP
name: http
selector:
app: {{ .Values.name }}
{{- end }}
120 changes: 120 additions & 0 deletions demo-extended/values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"general": {
"properties": {
"image": {
"title": "App image",
"type": "string"
},
"version": {
"title": "Image version",
"type": "string"
},
"environment": {
"title": "Environment variables",
"type": "object"
},
"labels": {
"title": "App labels",
"type": "object"
}
},
"required": [
"image"
],
"order": [
"image",
"version",
"environment",
"labels"
]
},
"scaling": {
"type": "object",
"properties": {
"replicas": {
"title": "Replicas",
"type": "integer",
"minimum": 0
},
"resources": {
"properties": {
"cpu": {
"title": "CPUs",
"type": "integer"
},
"memory": {
"title": "Memory",
"description": "Measured in Gi",
"type": "integer"
}
},
"required": [
"cpu",
"memory"
],
"order": [
"cpu",
"memory"
]
}
},
"required": [
"replicas"
],
"order": [
"replicas",
"resources"
]
},
"networking": {
"type": "object",
"properties": {
"expose": {
"title": "Expose",
"type": "boolean"
},
"port": {
"title": "Port",
"type": "integer"
}
},
"order": [
"expose",
"port"
]
},

"replicas": {
"description": "Number of replicas",
"type": "integer"
},
"image": {
"description": "Container Image",
"type": "string"
},
"version": {
"description": "Container image version",
"type": "string"
},
"service": {
"description": "Expose your application",
"type": "boolean"
}
},
"order": [
"name",
"replicas",
"script",
"json",
"image",
"version",
"service"
],
"title": "Values",
"type": "object"
}
19 changes: 19 additions & 0 deletions demo-extended/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: my-app

general:
image: nginx
version: 1.14.2
environment:
ENVIRONMENT: production
labels:
app: my-app
team: my-team
project: northstar

scaling:
replicas: 3
resources:

networking:
expose: true
port: 8080

0 comments on commit 7464fae

Please sign in to comment.