From 86304daff7eaca6f71155a58097446fdecf4e477 Mon Sep 17 00:00:00 2001 From: na Date: Thu, 12 Sep 2024 11:06:57 +0200 Subject: [PATCH] init: Add Helm charts for oc-mongo, oc-mongo-express, and oc-catalog --- arch/diagrams/src/oc-deploy.puml | 53 +++++++++ arch/diagrams/src/oc-mongo.puml | 40 +++++++ oc-deploy/.helmignore | 23 ++++ oc-deploy/Chart.lock | 12 ++ oc-deploy/Chart.yaml | 14 +++ oc-deploy/charts/oc-catalog-0.1.0.tgz | Bin 0 -> 841 bytes oc-deploy/charts/oc-catalog/Chart.yaml | 5 + .../charts/oc-catalog/templates/service.yml | 12 ++ .../oc-catalog/templates/statefulset.yml | 33 ++++++ oc-deploy/charts/oc-catalog/values.yaml | 19 ++++ oc-deploy/charts/oc-mongo-0.1.0.tgz | Bin 0 -> 968 bytes oc-deploy/charts/oc-mongo-express-0.1.0.tgz | Bin 0 -> 847 bytes oc-deploy/charts/oc-mongo-express/Chart.yaml | 5 + .../oc-mongo-express/templates/service.yaml | 12 ++ .../templates/statefulset.yaml | 39 +++++++ oc-deploy/charts/oc-mongo-express/values.yaml | 18 +++ oc-deploy/charts/oc-mongo/Chart.yaml | 5 + oc-deploy/charts/oc-mongo/templates/pvc.yaml | 10 ++ .../charts/oc-mongo/templates/secret.yaml | 8 ++ .../charts/oc-mongo/templates/service.yaml | 11 ++ .../oc-mongo/templates/statefulset.yaml | 31 +++++ oc-deploy/charts/oc-mongo/values.yaml | 19 ++++ oc-deploy/values.yaml | 48 ++++++++ oc-grafana-helm/Chart.yaml | 5 + .../templates/grafana-deployment.yaml | 21 ++++ .../templates/grafana-service.yaml | 11 ++ oc-grafana-helm/values.yaml | 18 +++ oc-mongo-express-helm/Chart.yaml | 5 + .../templates/deployment.yaml | 34 ++++++ oc-mongo-express-helm/templates/service.yaml | 12 ++ oc-mongo-express-helm/values.yaml | 19 ++++ oc-mongo-helm/Chart.yaml | 5 + oc-mongo-helm/templates/pvc.yaml | 16 +++ oc-mongo-helm/templates/secret.yaml | 11 ++ oc-mongo-helm/templates/service.yaml | 13 +++ oc-mongo-helm/templates/statefulset.yaml | 31 +++++ oc-mongo-helm/values.yaml | 24 ++++ occhart/.helmignore | 23 ++++ occhart/Chart.yaml | 24 ++++ occhart/charts/dex/dex-deployment.yaml | 32 ++++++ occhart/charts/dex/dex-service.yaml | 11 ++ .../charts/grafana/grafana-deployment.yaml | 21 ++++ occhart/charts/grafana/grafana-service.yaml | 11 ++ occhart/charts/ldap/ldap-deployment.yaml | 21 ++++ occhart/charts/ldap/ldap-service.yaml | 11 ++ occhart/charts/loki/loki-deployment.yaml | 21 ++++ occhart/charts/loki/loki-service.yaml | 11 ++ occhart/charts/mongo/mongo-deployment.yaml | 21 ++++ occhart/charts/mongo/mongo-service.yaml | 11 ++ occhart/charts/nats/nats-deployment.yaml | 21 ++++ occhart/charts/nats/nats-service.yaml | 11 ++ .../charts/traefik/traefik-deployment.yaml | 37 ++++++ occhart/charts/traefik/traefik-ingress.yaml | 81 +++++++++++++ occhart/charts/traefik/traefik-service.yaml | 17 +++ occhart/charts/zinc/zinc-deployment.yaml | 21 ++++ occhart/charts/zinc/zinc-service.yaml | 11 ++ occhart/templates/NOTES.txt | 22 ++++ occhart/templates/_helpers.tpl | 62 ++++++++++ occhart/templates/deployment.yaml | 68 +++++++++++ occhart/templates/hpa.yaml | 32 ++++++ occhart/templates/ingress.yaml | 61 ++++++++++ occhart/templates/service.yaml | 15 +++ occhart/templates/serviceaccount.yaml | 13 +++ occhart/templates/tests/test-connection.yaml | 15 +++ occhart/values.yaml | 107 ++++++++++++++++++ 65 files changed, 1454 insertions(+) create mode 100644 arch/diagrams/src/oc-deploy.puml create mode 100644 arch/diagrams/src/oc-mongo.puml create mode 100644 oc-deploy/.helmignore create mode 100644 oc-deploy/Chart.lock create mode 100644 oc-deploy/Chart.yaml create mode 100644 oc-deploy/charts/oc-catalog-0.1.0.tgz create mode 100644 oc-deploy/charts/oc-catalog/Chart.yaml create mode 100644 oc-deploy/charts/oc-catalog/templates/service.yml create mode 100644 oc-deploy/charts/oc-catalog/templates/statefulset.yml create mode 100644 oc-deploy/charts/oc-catalog/values.yaml create mode 100644 oc-deploy/charts/oc-mongo-0.1.0.tgz create mode 100644 oc-deploy/charts/oc-mongo-express-0.1.0.tgz create mode 100644 oc-deploy/charts/oc-mongo-express/Chart.yaml create mode 100644 oc-deploy/charts/oc-mongo-express/templates/service.yaml create mode 100644 oc-deploy/charts/oc-mongo-express/templates/statefulset.yaml create mode 100644 oc-deploy/charts/oc-mongo-express/values.yaml create mode 100644 oc-deploy/charts/oc-mongo/Chart.yaml create mode 100644 oc-deploy/charts/oc-mongo/templates/pvc.yaml create mode 100644 oc-deploy/charts/oc-mongo/templates/secret.yaml create mode 100644 oc-deploy/charts/oc-mongo/templates/service.yaml create mode 100644 oc-deploy/charts/oc-mongo/templates/statefulset.yaml create mode 100644 oc-deploy/charts/oc-mongo/values.yaml create mode 100644 oc-deploy/values.yaml create mode 100644 oc-grafana-helm/Chart.yaml create mode 100644 oc-grafana-helm/templates/grafana-deployment.yaml create mode 100644 oc-grafana-helm/templates/grafana-service.yaml create mode 100644 oc-grafana-helm/values.yaml create mode 100644 oc-mongo-express-helm/Chart.yaml create mode 100644 oc-mongo-express-helm/templates/deployment.yaml create mode 100644 oc-mongo-express-helm/templates/service.yaml create mode 100644 oc-mongo-express-helm/values.yaml create mode 100644 oc-mongo-helm/Chart.yaml create mode 100644 oc-mongo-helm/templates/pvc.yaml create mode 100644 oc-mongo-helm/templates/secret.yaml create mode 100644 oc-mongo-helm/templates/service.yaml create mode 100644 oc-mongo-helm/templates/statefulset.yaml create mode 100644 oc-mongo-helm/values.yaml create mode 100644 occhart/.helmignore create mode 100644 occhart/Chart.yaml create mode 100644 occhart/charts/dex/dex-deployment.yaml create mode 100644 occhart/charts/dex/dex-service.yaml create mode 100644 occhart/charts/grafana/grafana-deployment.yaml create mode 100644 occhart/charts/grafana/grafana-service.yaml create mode 100644 occhart/charts/ldap/ldap-deployment.yaml create mode 100644 occhart/charts/ldap/ldap-service.yaml create mode 100644 occhart/charts/loki/loki-deployment.yaml create mode 100644 occhart/charts/loki/loki-service.yaml create mode 100644 occhart/charts/mongo/mongo-deployment.yaml create mode 100644 occhart/charts/mongo/mongo-service.yaml create mode 100644 occhart/charts/nats/nats-deployment.yaml create mode 100644 occhart/charts/nats/nats-service.yaml create mode 100644 occhart/charts/traefik/traefik-deployment.yaml create mode 100644 occhart/charts/traefik/traefik-ingress.yaml create mode 100644 occhart/charts/traefik/traefik-service.yaml create mode 100644 occhart/charts/zinc/zinc-deployment.yaml create mode 100644 occhart/charts/zinc/zinc-service.yaml create mode 100644 occhart/templates/NOTES.txt create mode 100644 occhart/templates/_helpers.tpl create mode 100644 occhart/templates/deployment.yaml create mode 100644 occhart/templates/hpa.yaml create mode 100644 occhart/templates/ingress.yaml create mode 100644 occhart/templates/service.yaml create mode 100644 occhart/templates/serviceaccount.yaml create mode 100644 occhart/templates/tests/test-connection.yaml create mode 100644 occhart/values.yaml diff --git a/arch/diagrams/src/oc-deploy.puml b/arch/diagrams/src/oc-deploy.puml new file mode 100644 index 0000000..699c36d --- /dev/null +++ b/arch/diagrams/src/oc-deploy.puml @@ -0,0 +1,53 @@ +@startuml Arch Diagram + +top to bottom direction + +component front as "oc-front" #MistyRose + +component api as "oc-api" #BlueViolet +component auth as "oc-auth" #BlueViolet + +component catalog as "oc-catalog" #MistyRose +component workspace as "oc-workspace" #MistyRose +component workflow as "oc-workflow" #MistyRose +component calendarIn as "oc-calendar-in" #MistyRose +component calendarOut as "oc-calendar-out" #MistyRose +component stat as "oc-status" #MistyRose + +component disco as "oc-discovery" #MistyRose +component agg as "oc-aggregator" #MistyRose + +component scheduler as "oc-scheduler" #LightYellow +component monitor as "oc-monitor" #LightYellow + +database rd as "Nats" #Green +database zn as "Zinc" #Green +database loki as "Loki" #Green +database mongo as "MongoDB" #Green +database nats as "Nats" #Green + +front -- api + +api -- auth : auth user +api -- catalog : local search +api -- workspace : store user data +api -- workflow +api -- calendarIn +api -- calendarOut +api -- stat + +catalog -- disco +catalog -- agg + +scheduler -- monitor +scheduler -- catalog + +rd -- scheduler +loki -- monitor + +catalog -- mongo : store resources available for users +workspace -- mongo : store resources allocated to a workspace +workflow -- mongo : store workflow +calendarOut -- mongo : store booking informations for this dc + +@enduml diff --git a/arch/diagrams/src/oc-mongo.puml b/arch/diagrams/src/oc-mongo.puml new file mode 100644 index 0000000..799859c --- /dev/null +++ b/arch/diagrams/src/oc-mongo.puml @@ -0,0 +1,40 @@ +@startuml +skinparam componentStyle rectangle + +node "Kubernetes Cluster" { + ' MongoDB service and statefulset + + cloud "Service: mongo" as mongo_service { + mongo_service : Type: ClusterIP + mongo_service : Internal Port: 27017 + } + + ' MongoDB StatefulSet with PVC and PV + + node "StatefulSet: MongoDB" as mongo_statefulset { + component " Pod: MongoDB" as mongo_pod{ + component "Container: MongoDB" as mongo_container { + mongo_container : Image: mongo:latest + mongo_container : PullPolicy: IfNotPresent + mongo_container : Exposed Port: 27017 + mongo_container : Volume Mount: /data/db + mongo_container : Volume Mount: /data/configdb + mongo_container : Secret: username, password (base64) + } + } + + storage "PersistentVolumeClaim: mongo-pvc" as mongo_PVC { + mongo_pvc : Access Mode: ReadWriteOnce + mongo_pvc : Size: 1Gi + mongo_pvc : Storage Class: {{ .Values.persistence.storageClass }} + } + } + + storage "PersistentVolume: PV" as mongo_PV { + mongo_pv : Bound to PVC: mongo-pvc + } + mongo_service --> mongo_statefulset : Routes traffic to MongoDB StatefulSet + mongo_pod --> mongo_PVC : Mounted Persistent Volume Claim + mongo_pvc --> mongo_PV : Bound Persistent Volume +} +@enduml \ No newline at end of file diff --git a/oc-deploy/.helmignore b/oc-deploy/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/oc-deploy/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/oc-deploy/Chart.lock b/oc-deploy/Chart.lock new file mode 100644 index 0000000..a994431 --- /dev/null +++ b/oc-deploy/Chart.lock @@ -0,0 +1,12 @@ +dependencies: +- name: oc-mongo + repository: file://../oc-mongo + version: 0.1.0 +- name: oc-mongo-express + repository: file://../oc-mongo-express + version: 0.1.0 +- name: oc-catalog + repository: file://../oc-catalog + version: 0.1.0 +digest: sha256:036af8acf7fe0a73f039776d13f63aeb7530e7a8b0febb49fd5e8415ac6672c6 +generated: "2024-08-27T14:34:41.6038407+02:00" diff --git a/oc-deploy/Chart.yaml b/oc-deploy/Chart.yaml new file mode 100644 index 0000000..40903e8 --- /dev/null +++ b/oc-deploy/Chart.yaml @@ -0,0 +1,14 @@ +apiVersion: v2 +name: oc-deploy +description: A Helm chart to deploy oc-mongo, oc-mongo-express, and oc-catalog together +version: 0.1.0 +dependencies: + - name: oc-mongo + version: 0.1.0 + repository: "file://../oc-mongo" + - name: oc-mongo-express + version: 0.1.0 + repository: "file://../oc-mongo-express" + - name: oc-catalog + version: 0.1.0 + repository: "file://../oc-catalog" diff --git a/oc-deploy/charts/oc-catalog-0.1.0.tgz b/oc-deploy/charts/oc-catalog-0.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..ccb3cc7f4182c24906d0f75a1755f02d0faffd85 GIT binary patch literal 841 zcmV-P1GfAhiwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PI&$Z`(Ey_A`IQ!S9wSOLhvrWzMh_*j%IO`dTp5MG;1c1W6eX z0{{1cqGZdiwrp7Hps2qWCFFfap2+XhS&5n8j!Tu#*H7HIsNtoYye=rEbd{#%+g( zIHFUMp%tdkt{u9CUs0AI{7r#JWgtT>RZ~|;Wdg3XECly7Qt=YmV3O?mC1?~! zl)Uvj_>nQt|BlNV?Kd!hm-L?|^j!bxa&guFC19}C=~~s5V-OQklsrd901Rqn3#UxO zz+hfjXPPL(U1WD660)`qO(d1zk}WBv^MSqr9M2g@?$9~{pld0&N*1DF@cwb5+}5DQ z$`NAG>`Il65>LrR)-5%MzJC&$; z9Vd8E|BL0B{+H=8z3TrGIQjm^TjBkJEt?oMtSr(e2LO`cN*2as4~)@UfN_-D`Nj3;K`K^t}IHC9C+V|4U$~f3CHi zA5EaU1o!CvyAc3L{(#aB3}DnITHS5hjMINkISnm|Z&vJyc!wQK(D$kPl-!A@-v+z+ zdOraD-R~%aay{e;dyEgz*W@8o<#@&S5i9^9UCy%@7Y(=j_0u7 zPY-zpW*SyJ>|)S0^|M&*hM{3|zkk^L^5M(f?WfzHZts6SOarvP3>Zwi{%ZO+%s)Q9 zA0dr)VSS3RUd-e9c?QMfX~l!EqxJhh!>b(sMeK3E{$*B&&rqKSt88@Otu=bZ6<1vG TE$~+W00960Bh9%902TlMHXWp^ literal 0 HcmV?d00001 diff --git a/oc-deploy/charts/oc-catalog/Chart.yaml b/oc-deploy/charts/oc-catalog/Chart.yaml new file mode 100644 index 0000000..490589d --- /dev/null +++ b/oc-deploy/charts/oc-catalog/Chart.yaml @@ -0,0 +1,5 @@ +apiVersion: v2 +name: oc-catalog +description: A Helm chart for deploying the oc-catalog application +version: 0.1.0 +appVersion: "1.0" diff --git a/oc-deploy/charts/oc-catalog/templates/service.yml b/oc-deploy/charts/oc-catalog/templates/service.yml new file mode 100644 index 0000000..4540d6b --- /dev/null +++ b/oc-deploy/charts/oc-catalog/templates/service.yml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: oc-catalog +spec: + selector: + app: {{ .Chart.Name }} + ports: + - protocol: TCP + port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetPort }} + type: {{ .Values.service.type }} diff --git a/oc-deploy/charts/oc-catalog/templates/statefulset.yml b/oc-deploy/charts/oc-catalog/templates/statefulset.yml new file mode 100644 index 0000000..308856c --- /dev/null +++ b/oc-deploy/charts/oc-catalog/templates/statefulset.yml @@ -0,0 +1,33 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ .Release.Name }}-oc-catalog + labels: + app: oc-catalog +spec: + serviceName: "oc-catalog" + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app: oc-catalog + template: + metadata: + labels: + app: oc-catalog + spec: + containers: + - name: oc-catalog + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + ports: + - containerPort: 8080 + env: + - name: MONGO_DATABASE + value: "DC_myDC" + - name: MONGO_URI + value: "mongodb://{{ .Release.Name }}-mongo:27017" + imagePullSecrets: + {{- if .Values.imagePullSecrets }} + {{- range .Values.imagePullSecrets }} + - name: {{ .name }} + {{- end }} + {{- end }} diff --git a/oc-deploy/charts/oc-catalog/values.yaml b/oc-deploy/charts/oc-catalog/values.yaml new file mode 100644 index 0000000..55812e7 --- /dev/null +++ b/oc-deploy/charts/oc-catalog/values.yaml @@ -0,0 +1,19 @@ +replicaCount: 1 + +image: + repository: registry.dev.svc.cluster.local:5000/oc-catalog + tag: latest + pullPolicy: IfNotPresent + +service: + type: NodePort + port: 8087 + targetPort: 8080 + +mongo: + database: DC_myDC + uri: mongodb://oc-deploy-mongo:27017 + +imagePullSecrets: + - name: regcred + diff --git a/oc-deploy/charts/oc-mongo-0.1.0.tgz b/oc-deploy/charts/oc-mongo-0.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..f3f9580b13f343354769a99c09d8a9e03eef0789 GIT binary patch literal 968 zcmV;(12_C1iwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PL90kJ>mC$2t42cw!Gd0SU=~WT}U04&9ZuQ`D|z&&GK`v`*~W z4l7#mzposV5Hhf|+AMUWd@m@m{bHN<`TB?CqfF*&IeFYLZO1#7i9y#2f*_d1arqkr zLHjod=d(c=&t_2+NAoxu1mScZ1p^2=@5vbz#xgw!{`0rmgL@@nDt$(6QkhfOP6<=0 zejJA5U`P@)T&K#GuinA0C^FzKS70SIB&dYkrTH4{2BAtO;4)J($J~;fWk~A+vaNy# z<8U01dyl?X&Ht8(0?q$o0N41BXY&^SQ8*8K{%;|TN~D}U$|AQELPFAvt&tJ{jY^u- zO1-1t;RUd4O+he=#u5Nk2(geNe-uBo_>bdiNC6c!bx_F0M|!$-l=jAUq8!Yn(I z`|TTypZ&VgAbaczVZSFvA*Uz&8uth=y43Pm)3tXVWMrXv)lTD=0*yU90T?T_bE`|? zoH@8a_nzdRSZDb6KH8xLT;qQ_Yw!Ob!iQMZ}|=B+yexVrvFQJep0+MoY# zq6_?&8SoOx5F2^*0A3X>o^Vn^dGA` zuxMPeRK?r!==QWToFYr0@|Lt)}(Xp$^D3BzT+O4oHT-_P?? q_-~QbxkD;#e3-izPv3J;y*GrtdiCmc2mKQO0RR8iNh~4&9smGyJJz-U literal 0 HcmV?d00001 diff --git a/oc-deploy/charts/oc-mongo-express-0.1.0.tgz b/oc-deploy/charts/oc-mongo-express-0.1.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..ceddd766bd471fda297b9432c6585f89ef7beca0 GIT binary patch literal 847 zcmV-V1F-xbiwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PI&^Z~8VA0NuxTkWgE5# z<-1Rg`I7`%s!_F?n)5~#2ft5^89|k*YkS=ztDa38;u4QL31y0j#X*w|ZF3XXbBXiS zn{UuM(Ep0EC8`fKfK&SSy>4CqeZSHFr$C}$aY#pend$&M$B7dfVc-Br6kNrc%Pgpg z8$i=207f+`?Er`+V-wEeFbm*%G3I(AQDLebN162a98#=WQw3l{mtdP zG`bCaQ!_fyzs5uqCws9uyz{N#r2e~pP5%Spkw*WYfy(>eb6(C0=ypy1&bE>Hk zmQ~(*4ek^fQiblACJ1?6d&Mh(q2ViJ7-}xf-vCsILl-fYpzL@DgyfosoCR<{niR3E zXP7k~?OSPkCCvcj`G!_@lOyE)u$^L^<`^*(W<%e~3EtAbrWzMZrtr+~ffM@glK!Bs z|3SCW|EHj=e=3B!*qgxS_-Cm9lMw(g`WG_wssZesqLAOX$lE@dxNUnA)3vCIjLWTz zReIHf5~{=JKT0*dVoO^EY-W|VZon!DUP%G4-JC(lQ%&O( + http: + paths: + - path: /front + pathType: Prefix + backend: + service: + name: front-service + port: + number: 80 + - path: /back1 + pathType: Prefix + backend: + service: + name: back1-service + port: + number: 80 + - path: /back2 + pathType: Prefix + backend: + service: + name: back2-service + port: + number: 80 + - path: /mongo + pathType: Prefix + backend: + service: + name: mongo + port: + number: 27017 + - path: /nats + pathType: Prefix + backend: + service: + name: nats + port: + number: 4222 + - path: /zinc + pathType: Prefix + backend: + service: + name: zinc + port: + number: 4080 + - path: /dex + pathType: Prefix + backend: + service: + name: dex + port: + number: 5556 + - path: /ldap + pathType: Prefix + backend: + service: + name: ldap + port: + number: 389 + - path: /grafana + pathType: Prefix + backend: + service: + name: grafana + port: + number: 3000 + - path: /loki + pathType: Prefix + backend: + service: + name: loki + port: + number: 3100 diff --git a/occhart/charts/traefik/traefik-service.yaml b/occhart/charts/traefik/traefik-service.yaml new file mode 100644 index 0000000..ced00ff --- /dev/null +++ b/occhart/charts/traefik/traefik-service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: traefik + labels: + app: traefik +spec: + type: LoadBalancer + ports: + - port: 80 + name: web + targetPort: 80 + - port: 8080 + name: admin + targetPort: 8080 + selector: + app: traefik diff --git a/occhart/charts/zinc/zinc-deployment.yaml b/occhart/charts/zinc/zinc-deployment.yaml new file mode 100644 index 0000000..1e8ec56 --- /dev/null +++ b/occhart/charts/zinc/zinc-deployment.yaml @@ -0,0 +1,21 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: zinc + labels: + app: zinc +spec: + replicas: 1 + selector: + matchLabels: + app: zinc + template: + metadata: + labels: + app: zinc + spec: + containers: + - name: zinc + image: public.ecr.aws/zinclabs/zinc:latest + ports: + - containerPort: 4080 diff --git a/occhart/charts/zinc/zinc-service.yaml b/occhart/charts/zinc/zinc-service.yaml new file mode 100644 index 0000000..920a6dd --- /dev/null +++ b/occhart/charts/zinc/zinc-service.yaml @@ -0,0 +1,11 @@ +apiVersion: v1 +kind: Service +metadata: + name: zinc + labels: + app: zinc +spec: + ports: + - port: 4080 + selector: + app: zinc diff --git a/occhart/templates/NOTES.txt b/occhart/templates/NOTES.txt new file mode 100644 index 0000000..7eb4fd4 --- /dev/null +++ b/occhart/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "occhart.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "occhart.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "occhart.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "occhart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/occhart/templates/_helpers.tpl b/occhart/templates/_helpers.tpl new file mode 100644 index 0000000..a468e9c --- /dev/null +++ b/occhart/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "occhart.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "occhart.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "occhart.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "occhart.labels" -}} +helm.sh/chart: {{ include "occhart.chart" . }} +{{ include "occhart.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "occhart.selectorLabels" -}} +app.kubernetes.io/name: {{ include "occhart.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "occhart.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "occhart.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/occhart/templates/deployment.yaml b/occhart/templates/deployment.yaml new file mode 100644 index 0000000..b0f577c --- /dev/null +++ b/occhart/templates/deployment.yaml @@ -0,0 +1,68 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "occhart.fullname" . }} + labels: + {{- include "occhart.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "occhart.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "occhart.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "occhart.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + livenessProbe: + {{- toYaml .Values.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.volumeMounts }} + volumeMounts: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.volumes }} + volumes: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/occhart/templates/hpa.yaml b/occhart/templates/hpa.yaml new file mode 100644 index 0000000..5a29738 --- /dev/null +++ b/occhart/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "occhart.fullname" . }} + labels: + {{- include "occhart.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "occhart.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/occhart/templates/ingress.yaml b/occhart/templates/ingress.yaml new file mode 100644 index 0000000..cd4f245 --- /dev/null +++ b/occhart/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "occhart.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "occhart.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/occhart/templates/service.yaml b/occhart/templates/service.yaml new file mode 100644 index 0000000..fb1ca05 --- /dev/null +++ b/occhart/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "occhart.fullname" . }} + labels: + {{- include "occhart.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "occhart.selectorLabels" . | nindent 4 }} diff --git a/occhart/templates/serviceaccount.yaml b/occhart/templates/serviceaccount.yaml new file mode 100644 index 0000000..5960499 --- /dev/null +++ b/occhart/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "occhart.serviceAccountName" . }} + labels: + {{- include "occhart.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/occhart/templates/tests/test-connection.yaml b/occhart/templates/tests/test-connection.yaml new file mode 100644 index 0000000..ca44c9d --- /dev/null +++ b/occhart/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "occhart.fullname" . }}-test-connection" + labels: + {{- include "occhart.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "occhart.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/occhart/values.yaml b/occhart/values.yaml new file mode 100644 index 0000000..43e0286 --- /dev/null +++ b/occhart/values.yaml @@ -0,0 +1,107 @@ +# Default values for occhart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: nginx + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + 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: "" + +podAnnotations: {} +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +livenessProbe: + httpGet: + path: / + port: http +readinessProbe: + httpGet: + path: / + port: http + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {}