Skip to content

Commit d588eb3

Browse files
wip: updated the chart/template
Signed-off-by: Rahul Vishwakarma <[email protected]>
1 parent 23aa9b4 commit d588eb3

13 files changed

+301
-112
lines changed

chart/templates/cert-manager.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# for running this you need to have cert-manager install on your cluster
2+
# Installation: https://cert-manager.io/docs/installation/
3+
---
4+
apiVersion: cert-manager.io/v1
5+
kind: Issuer
6+
metadata:
7+
name: selfsigned
8+
namespace: {{ .Values.image.namespace }}
9+
spec:
10+
selfSigned: {}
11+
---
12+
apiVersion: cert-manager.io/v1
13+
kind: Certificate
14+
metadata:
15+
name: webhook1-certificate
16+
namespace: {{ .Values.image.namespace }}
17+
spec:
18+
secretName: "{{ .Chart.Name }}-tls" # Secret mounted in deployment
19+
dnsNames:
20+
- "{{ include "chart.fullname" . }}.{{ .Values.image.namespace }}.svc"
21+
- "{{ include "chart.fullname" . }}.{{ .Values.image.namespace }}.svc.cluster.local"
22+
issuerRef:
23+
name: selfsigned
24+
---

chart/templates/clusterrole.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,16 @@ metadata:
55
rules:
66
- apiGroups: ["apps"]
77
resources: ["deployments"]
8-
verbs: ["get", "list", "watch"]
8+
verbs: [ "get", "list", "watch", "create", "update", "patch" ]
99
- apiGroups: [""]
1010
resources: ["services"]
1111
verbs: ["get", "list", "watch", "create", "update"]
1212
- apiGroups: ["networking.k8s.io"]
1313
resources: ["ingresses"]
1414
verbs: ["get", "list", "watch", "create", "update"]
15+
- apiGroups: [ "admissionregistration.k8s.io" ]
16+
resources: [ "validatingwebhookconfigurations" ]
17+
verbs: [ "get", "list", "watch", "create", "update", "patch" ]
18+
- apiGroups: [ "" ]
19+
resources: [ "secrets" ]
20+
verbs: [ "get", "list", "watch", "create", "update", "patch" ]

chart/templates/clusterrolebinding.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ metadata:
44
name: {{ include "chart.fullname" . }}
55
subjects:
66
- kind: ServiceAccount
7-
name: {{ include "chart.serviceAccountName" . }}
8-
namespace: {{ .Release.Namespace }}
7+
name: default
8+
namespace: {{ .Values.image.namespace }}
99
roleRef:
1010
kind: ClusterRole
1111
name: {{ include "chart.fullname" . }}
12-
apiGroup: rbac.authorization.k8s.io
12+
apiGroup: rbac.authorization.k8s.io

chart/templates/deployment.yaml

Lines changed: 16 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,72 +2,32 @@ apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: {{ include "chart.fullname" . }}
5-
labels:
6-
{{- include "chart.labels" . | nindent 4 }}
5+
namespace: {{ .Values.image.namespace }}
76
spec:
8-
{{- if not .Values.autoscaling.enabled }}
9-
replicas: {{ .Values.replicaCount }}
10-
{{- end }}
7+
replicas: 1
118
selector:
129
matchLabels:
13-
{{- include "chart.selectorLabels" . | nindent 6 }}
10+
k8s.custom.controller: k8s-custom-controller
1411
template:
1512
metadata:
16-
{{- with .Values.podAnnotations }}
17-
annotations:
18-
{{- toYaml . | nindent 8 }}
19-
{{- end }}
2013
labels:
21-
{{- include "chart.labels" . | nindent 8 }}
22-
{{- with .Values.podLabels }}
23-
{{- toYaml . | nindent 8 }}
24-
{{- end }}
14+
k8s.custom.controller: k8s-custom-controller
2515
spec:
26-
{{- with .Values.imagePullSecrets }}
27-
imagePullSecrets:
28-
{{- toYaml . | nindent 8 }}
29-
{{- end }}
30-
serviceAccountName: {{ include "chart.serviceAccountName" . }}
31-
{{- with .Values.podSecurityContext }}
32-
securityContext:
33-
{{- toYaml . | nindent 8 }}
34-
{{- end }}
3516
containers:
3617
- name: {{ .Chart.Name }}
37-
{{- with .Values.securityContext }}
38-
securityContext:
39-
{{- toYaml . | nindent 12 }}
40-
{{- end }}
4118
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
19+
volumeMounts:
20+
- name: {{ .Values.webhook.volumeMounts }}
21+
mountPath: /certs
22+
readOnly: true
4223
env:
24+
- name: TLS_CERT_FILE
25+
value: "/certs/tls.crt"
26+
- name: TLS_KEY_FILE
27+
value: "/certs/tls.key"
4328
- name: CONTEXT
44-
value: {{ .Values.context | quote }}
45-
imagePullPolicy: {{ .Values.image.pullPolicy }}
46-
ports:
47-
- name: http
48-
containerPort: {{ .Values.service.port }}
49-
protocol: TCP
50-
{{- with .Values.resources }}
51-
resources:
52-
{{- toYaml . | nindent 12 }}
53-
{{- end }}
54-
{{- with .Values.volumeMounts }}
55-
volumeMounts:
56-
{{- toYaml . | nindent 12 }}
57-
{{- end }}
58-
{{- with .Values.volumes }}
29+
value: "kind-practice"
5930
volumes:
60-
{{- toYaml . | nindent 8 }}
61-
{{- end }}
62-
{{- with .Values.nodeSelector }}
63-
nodeSelector:
64-
{{- toYaml . | nindent 8 }}
65-
{{- end }}
66-
{{- with .Values.affinity }}
67-
affinity:
68-
{{- toYaml . | nindent 8 }}
69-
{{- end }}
70-
{{- with .Values.tolerations }}
71-
tolerations:
72-
{{- toYaml . | nindent 8 }}
73-
{{- end }}
31+
- name: {{ .Values.webhook.volumeMounts }}
32+
secret:
33+
secretName: "{{ .Chart.Name }}-tls"

chart/templates/ingress.yaml

Lines changed: 0 additions & 43 deletions
This file was deleted.

chart/templates/namespace.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: {{ .Values.image.namespace }}

chart/templates/service.yaml

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@ apiVersion: v1
22
kind: Service
33
metadata:
44
name: {{ include "chart.fullname" . }}
5-
labels:
6-
{{- include "chart.labels" . | nindent 4 }}
5+
namespace: {{ .Values.image.namespace }}
76
spec:
8-
type: {{ .Values.service.type }}
9-
ports:
10-
- port: {{ .Values.service.port }}
11-
targetPort: 8000 #http
12-
protocol: TCP
13-
name: http
147
selector:
15-
{{- include "chart.selectorLabels" . | nindent 4 }}
8+
k8s.custom.controller: k8s-custom-controller
9+
ports:
10+
- protocol: TCP
11+
port: {{ .Values.service.port }}
12+
targetPort: 8000
13+
type: ClusterIP

chart/templates/trivy-deployment.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ .Values.trivy.name }}
5+
labels:
6+
app: {{ .Values.trivy.name }}
7+
spec:
8+
replicas: 1 # You can adjust the number of replicas for high availability
9+
selector:
10+
matchLabels:
11+
app: {{ .Values.trivy.name }}
12+
template:
13+
metadata:
14+
labels:
15+
app: {{ .Values.trivy.name }}
16+
spec:
17+
containers:
18+
- name: {{ .Values.trivy.name }}
19+
image: "{{ .Values.trivy.image }}:{{ .Values.trivy.tag }}"# aquasec/trivy:latest # Use a specific version instead of latest in production
20+
args: ["server", "--listen", "0.0.0.0:8080"] # Listen on all interfaces
21+
ports:
22+
- containerPort: 8080
23+
name: http
24+
# volumeMounts:
25+
# - name: trivy-cache
26+
# mountPath: /root/.cache/trivy
27+
# volumes:
28+
# - name: trivy-cache
29+
# persistentVolumeClaim:
30+
# claimName: trivy-cache-pvc

chart/templates/trivy-service.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: "{{ .Values.trivy.name }}-service"
5+
labels:
6+
app: {{ .Values.trivy.name }}
7+
spec:
8+
selector:
9+
app: {{ .Values.trivy.name }}
10+
ports:
11+
- protocol: TCP
12+
port: 8080
13+
targetPort: 8080
14+
type: ClusterIP
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: admissionregistration.k8s.io/v1
2+
kind: ValidatingWebhookConfiguration
3+
metadata:
4+
name: {{ .Values.webhook.name }}
5+
annotations:
6+
cert-manager.io/inject-ca-from: "{{ .Values.image.namespace }}/{{ .Values.webhook.name }}-certificate"
7+
webhooks:
8+
- name: "{{ include "chart.fullname" . }}.{{ .Values.image.namespace }}.svc"
9+
admissionReviewVersions:
10+
- v1
11+
sideEffects: None
12+
timeoutSeconds: 30
13+
clientConfig:
14+
service:
15+
name: {{ include "chart.fullname" . }}
16+
namespace: {{ .Values.image.namespace }}
17+
path: /validate
18+
port: {{ .Values.service.port }}
19+
rules:
20+
- apiGroups: [ "apps" ]
21+
apiVersions: [ "v1" ]
22+
operations: [ "CREATE" ]
23+
resources: [ "deployments" ]
24+
failurePolicy: Fail

0 commit comments

Comments
 (0)