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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #6 : Add Namespace and Probes Configuration to Kubernetes Manifests #7

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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
47 changes: 35 additions & 12 deletions demo-extended/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.name }}
namespace: {{ .Values.namespace }}
labels:
app: {{ .Values.name }}
spec:
replicas: {{ (.Values.scaling).replicas | default 1 }}
replicas: {{ .Values.scaling.replicas }}
selector:
matchLabels:
app: {{ .Values.name }}
Expand All @@ -17,12 +18,14 @@ spec:
containers:
- name: {{ .Values.name }}
image: "{{ .Values.general.image }}:{{ .Values.general.version }}"
{{- if ((.Values.networking).expose) }}

{{- if .Values.networking.expose }}
ports:
- name: http
containerPort: {{ .Values.networking.port | default 80 }}
containerPort: {{ .Values.networking.port }}
protocol: TCP
{{- end }}

env:
{{- if ((.Values.general).environment) }}
{{- range $key, $value := (.Values.general).environment }}
Expand All @@ -31,18 +34,38 @@ spec:
{{- end }}
{{- end }}
{{- if or ((.Values.scaling).resources).memory ((.Values.scaling).resources).cpu }}

resources:
{{- if ((.Values.scaling).resources).memory }}
{{- if .Values.scaling.resources.memory }}
limits:
memory: {{ ((.Values.scaling).resources).memory }}Gi
memory: "{{ .Values.scaling.resources.memory }}Gi"
{{- end }}
{{- if or ((.Values.scaling).resources).memory ((.Values.scaling).resources).cpu }}
{{- if .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 }}Gi
{{- end }}
cpu: "{{ .Values.scaling.resources.cpu }}"
{{- end }}

{{- if .Values.probes.enabled }}
readinessProbe:
httpGet:
path: {{ .Values.probes.readiness.path }}
port: http
initialDelaySeconds: {{ .Values.probes.readiness.initialDelaySeconds }}
periodSeconds: {{ .Values.probes.readiness.periodSeconds }}
failureThreshold: {{ .Values.probes.readiness.failureThreshold }}

livenessProbe:
httpGet:
path: {{ .Values.probes.liveness.path }}
port: http
initialDelaySeconds: {{ .Values.probes.liveness.initialDelaySeconds }}
periodSeconds: {{ .Values.probes.liveness.periodSeconds }}

startupProbe:
httpGet:
path: {{ .Values.probes.startup.path }}
port: http
initialDelaySeconds: {{ .Values.probes.startup.initialDelaySeconds }}
periodSeconds: {{ .Values.probes.startup.periodSeconds }}
failureThreshold: {{ .Values.probes.startup.failureThreshold }}
{{- end }}
3 changes: 2 additions & 1 deletion demo-extended/templates/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ apiVersion: v1
kind: Service
metadata:
name: {{ .Values.name }}
namespace: {{ .Values.namespace }}
labels:
app: {{ .Values.name }}
spec:
Expand All @@ -14,4 +15,4 @@ spec:
name: http
selector:
app: {{ .Values.name }}
{{- end }}
{{- end }}
107 changes: 107 additions & 0 deletions demo-extended/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"title": "Name",
"description": "Application name"
},
"namespace": {
"type": "string",
"title": "Namespace",
"description": "Namespace for Application"
},
"general": {
"type": "object",
"title": "General",
Expand Down Expand Up @@ -74,6 +79,106 @@
"resources"
]
},
"probes": {
"type": "object",
"title": "Probes",
"description": "Configuration for container probes",
"properties": {
"enabled": {
"title": "Enabled",
"type": "boolean",
"default": true,
"description": "Toggle to enable or disable all probes"
},
"startup": {
RohanRusta21 marked this conversation as resolved.
Show resolved Hide resolved
"title": "Startup Probe",
"type": "object",
"description": "Configuration for the startup probe",
"properties": {
RohanRusta21 marked this conversation as resolved.
Show resolved Hide resolved
"path": {
"title": "Path for probe",
"type": "string",
"description": "The endpoint to probe for startup readiness"
},
"initialDelaySeconds": {
"title": "Initial Delay Seconds",
"type": "integer",
"description": "The number of seconds to wait before performing the first probe"
},
"periodSeconds": {
"title": "Period Seconds",
"type": "integer",
"description": "The number of seconds between each probe"
},
"failureThreshold": {
"title": "Failure Threshold",
"type": "integer",
"description": "The number of consecutive failures required to consider the probe as failed"
}
}
},
"liveness": {
"title": "Liveness Probe",
"type": "object",
"description": "Configuration for the liveness probe",
"properties": {
"path": {
"title": "Path for probe",
"type": "string",
"description": "The endpoint to probe for liveness"
},
"initialDelaySeconds": {
"title": "Initial Delay Seconds",
"type": "integer",
"description": "The number of seconds to wait before performing the first probe"
},
"periodSeconds": {
"title": "Period Seconds",
"type": "integer",
"description": "The number of seconds between each probe"
},
"failureThreshold": {
"title": "Failure Threshold",
"type": "integer",
"description": "The number of consecutive failures required to consider the probe as failed"
}
}
},
"readiness": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add order: ["path", "initialDelaySeconds"...]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @petar-cvit , Yup its done now. Please Review it :)

"title": "Readiness Probe",
"type": "object",
"description": "Configuration for the readiness probe",
"properties": {
"path": {
"title": "Path for probe",
"type": "string",
"description": "The endpoint to probe for readiness"
},
"initialDelaySeconds": {
"title": "Initial Delay Seconds",
"type": "integer",
"description": "The number of seconds to wait before performing the first probe"
},
"periodSeconds": {
"title": "Period Seconds",
"type": "integer",
"description": "The number of seconds between each probe"
},
"failureThreshold": {
"title": "Failure Threshold",
"type": "integer",
"description": "The number of consecutive failures required to consider the probe as failed"
}
}
}
},
"order": [
"enabled",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add enabled to each probe separately? Also can you make it disabled by default in values.yaml

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @petar-cvit , actually initially I tried to have separate toggle for each probe. But it was not working fine. Maybe will try it again.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do. You can paste the error here if you want and we can try to figure it out

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain me this error.
image

UI changes performed :
image

"startup",
"liveness",
"readiness"
]
},
"networking": {
"type": "object",
"title": "Networking",
Expand All @@ -100,8 +205,10 @@
],
"order": [
"name",
"namespace",
"general",
"scaling",
"probes",
"networking"
],
"title": "Values",
Expand Down
23 changes: 22 additions & 1 deletion demo-extended/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: my-app

namespace: default
general:
image: nginx
version: 1.14.2
Expand All @@ -8,6 +8,27 @@ general:

scaling:
replicas: 3
resources:
cpu: 1
memory: 512

probes:
enabled: true
startup:
path: "/"
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3
liveness:
path: "/"
initialDelaySeconds: 10
periodSeconds: 20
failureThreshold: 3
readiness:
path: "/"
initialDelaySeconds: 5
periodSeconds: 10
failureThreshold: 3

networking:
expose: true
Expand Down