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

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

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9f6b9bd
"Added code for Probes & Namespace"
RohanRusta21 Apr 25, 2024
647f337
Update values.yaml
RohanRusta21 Apr 25, 2024
931e99a
Update values.schema.json
RohanRusta21 Apr 25, 2024
d39a512
Update Chart.yaml
RohanRusta21 Apr 25, 2024
d421355
Update deployment.yaml
RohanRusta21 Apr 25, 2024
ab32e68
Update Chart.yaml
RohanRusta21 Apr 26, 2024
b2e54fd
Update values.schema.json
RohanRusta21 May 2, 2024
01d71e2
Update values.schema.json
RohanRusta21 May 2, 2024
bb69782
Update values.yaml
RohanRusta21 May 2, 2024
4ef0a98
Update values.schema.json
RohanRusta21 May 2, 2024
ba98d11
Update values.yaml
RohanRusta21 May 2, 2024
7234332
Update values.yaml
RohanRusta21 May 2, 2024
b9f58e6
Update values.schema.json
RohanRusta21 May 2, 2024
a8df846
Update values.schema.json
RohanRusta21 May 2, 2024
d0364ac
Update deployment.yaml
RohanRusta21 May 2, 2024
d1b7e62
Updated deployment.yaml for env
RohanRusta21 May 5, 2024
4203578
Update values.yaml
RohanRusta21 May 5, 2024
9630037
Update values.schema.json
RohanRusta21 May 5, 2024
c9d7c60
Update values.schema.json
RohanRusta21 May 5, 2024
42a31a4
Update values.schema.json
RohanRusta21 May 5, 2024
91b183c
Update values.schema.json
RohanRusta21 May 5, 2024
9ea3325
Update values.yaml
RohanRusta21 May 5, 2024
bf9ab27
Update values.schema.json
RohanRusta21 May 5, 2024
312d157
Update Chart.yaml
RohanRusta21 May 5, 2024
bfcf826
Update deployment.yaml
RohanRusta21 May 5, 2024
e987067
modified deployment,values.yaml,schema json
RohanRusta21 Jul 22, 2024
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
55 changes: 36 additions & 19 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 }}
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 leave this default?

Copy link
Author

Choose a reason for hiding this comment

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

yes we can

replicas: {{ .Values.scaling.replicas }}
selector:
matchLabels:
app: {{ .Values.name }}
Expand All @@ -17,32 +18,48 @@ spec:
containers:
- name: {{ .Values.name }}
image: "{{ .Values.general.image }}:{{ .Values.general.version }}"
{{- if ((.Values.networking).expose) }}

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you remove all empty lines?

Copy link
Author

Choose a reason for hiding this comment

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

yeah sure

{{- if .Values.networking.expose }}
ports:
- name: http
containerPort: {{ .Values.networking.port | default 80 }}
containerPort: {{ .Values.networking.port }}
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if port is not set? We cant enforce it since exposing is optional

Copy link
Author

Choose a reason for hiding this comment

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

Yeah but this template is meant to expose the port specified by the user.

protocol: TCP
{{- end }}

env:
{{- if ((.Values.general).environment) }}
{{- range $key, $value := (.Values.general).environment }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- if .Values.general.environment }}
{{- toYaml .Values.general.environment | indent 12 }}
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 revert this? With the UI for env variables, the indent doesn't work
Screenshot 2024-05-04 at 22 42 24

{{- end }}
{{- end }}
{{- if or ((.Values.scaling).resources).memory ((.Values.scaling).resources).cpu }}

resources:
{{- if ((.Values.scaling).resources).memory }}
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 rever the resources object since its not format properly and it can cause a null pointer because of deleted brackets

Copy link
Author

Choose a reason for hiding this comment

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

ok

{{- 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 }}
{{- end }}

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 }}
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 }}
80 changes: 80 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,79 @@
"resources"
]
},
"probes": {
"type": "object",
"title": "Probes",
"properties": {
"startup": {
RohanRusta21 marked this conversation as resolved.
Show resolved Hide resolved
"title": "Startup Probe",
"type": "object",
"properties": {
RohanRusta21 marked this conversation as resolved.
Show resolved Hide resolved
"path": {
"title": "Path for probe",
"type": "string"
},
"initialDelaySeconds": {
"title": "Initial Delay Seconds",
"type": "integer"
},
"periodSeconds": {
"title": "Period Seconds",
"type": "integer"
},
"failureThreshold": {
"title": "Failure Threshold",
"type": "integer"
}
}
},
"liveness": {
"title": "Liveness Probe",
"type": "object",
"properties": {
"path": {
"title": "Path for probe",
"type": "string"
},
"initialDelaySeconds": {
"title": "Initial Delay Seconds",
"type": "integer"
},
"periodSeconds": {
"title": "Period Seconds",
"type": "integer"
}
}
},
"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",
"properties": {
"path": {
"title": "Path for probe",
"type": "string"
},
"initialDelaySeconds": {
"title": "Initial Delay Seconds",
"type": "integer"
},
"periodSeconds": {
"title": "Period Seconds",
"type": "integer"
},
"failureThreshold": {
"title": "Failure Threshold",
"type": "integer"
}
}
}
},
"order": [
"startup",
"liveness",
"readiness"
]
},
"networking": {
"type": "object",
"title": "Networking",
Expand All @@ -100,8 +178,10 @@
],
"order": [
"name",
"namespace",
"general",
"scaling",
"probes",
"networking"
],
"title": "Values",
Expand Down
21 changes: 20 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,25 @@ general:

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

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

networking:
expose: true
Expand Down