From 9f30e8d212da702dd012d9748921ee30825629da Mon Sep 17 00:00:00 2001 From: Johanne TROTIN Date: Thu, 6 Mar 2025 10:36:51 +0100 Subject: [PATCH] =?UTF-8?q?T=C3=A9l=C3=A9verser=20les=20fichiers=20vers=20?= =?UTF-8?q?"helm-chart"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- helm-chart/Chart.lock | 6 +++ helm-chart/Chart.yaml | 17 +++++++ helm-chart/deployment.yaml | 71 +++++++++++++++++++++++++++ helm-chart/sa-token.yaml | 39 +++++++++++++++ helm-chart/values.yaml | 99 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 232 insertions(+) create mode 100644 helm-chart/Chart.lock create mode 100644 helm-chart/Chart.yaml create mode 100644 helm-chart/deployment.yaml create mode 100644 helm-chart/sa-token.yaml create mode 100644 helm-chart/values.yaml diff --git a/helm-chart/Chart.lock b/helm-chart/Chart.lock new file mode 100644 index 0000000..5bc833f --- /dev/null +++ b/helm-chart/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: postgresql + repository: https://charts.bitnami.com/bitnami + version: 13.2.2 +digest: sha256:7d2611e423ca9850c7a92d3ca4e200be9602d8beb6b0f7c49023b39fc03652bc +generated: "2024-01-11T14:15:33.5910163+01:00" diff --git a/helm-chart/Chart.yaml b/helm-chart/Chart.yaml new file mode 100644 index 0000000..cb32311 --- /dev/null +++ b/helm-chart/Chart.yaml @@ -0,0 +1,17 @@ +apiVersion: v2 +name: cours-nunez +description: A Helm chart for Kubernetes +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.0.0" +dependencies: + - name: postgresql + version: 13.2.2 + repository: https://charts.bitnami.com/bitnami diff --git a/helm-chart/deployment.yaml b/helm-chart/deployment.yaml new file mode 100644 index 0000000..ae7f030 --- /dev/null +++ b/helm-chart/deployment.yaml @@ -0,0 +1,71 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "helm-chart.fullname" . }} + labels: + {{- include "helm-chart.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "helm-chart.selectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + releaseTime: {{ dateInZone "2006-01-02 15:04:05Z" (now) "UTC"| quote }} + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "helm-chart.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "helm-chart.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 }} + env: + - name: DATABASE_URL + value: "postgres://{{ .Values.postgresql.auth.username }}:{{ .Values.postgresql.auth.password }}@{{ .Release.Name }}-postgresql:5432/{{ .Values.postgresql.auth.database }}" + - name: OTREE_ADMIN_PASSWORD + value: "{{ .Values.otree.admin_password }}" + - name: OTREE_AUTH_LEVEL + value: "{{ .Values.otree.auth_level }}" + - name: OTREE_PRODUCTION + value: "{{ .Values.otree.production }}" + ports: + - name: http + containerPort: {{ .Values.service.port }} + protocol: TCP + # livenessProbe: + # httpGet: + # path: / + # port: http + # readinessProbe: + # httpGet: + # path: / + # port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- 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/helm-chart/sa-token.yaml b/helm-chart/sa-token.yaml new file mode 100644 index 0000000..3a67fc1 --- /dev/null +++ b/helm-chart/sa-token.yaml @@ -0,0 +1,39 @@ +apiVersion: v1 +kind: Secret +metadata: + name: default-token + namespace: labeds + annotations: + kubernetes.io/service-account.name: default +type: kubernetes.io/service-account-token +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: labeds-admin + namespace: labeds + labels: + rbac.authorization.k8s.io/aggregate-to-admin: "true" + rbac.authorization.k8s.io/aggregate-to-edit: "true" +rules: +- apiGroups: [""] + resources: ["*"] + verbs: ["get", "list", "watch", "create", "update", "patch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +# This role binding allows "jane" to read pods in the "default" namespace. +# You need to already have a Role named "pod-reader" in that namespace. +kind: RoleBinding +metadata: + name: admin-rolebinding + namespace: labeds +subjects: +# You can specify more than one "subject" +- kind: ServiceAccount + name: default # "name" is case sensitive + namespace: labeds +roleRef: + # "roleRef" specifies the binding to a Role / ClusterRole + kind: Role #this must be Role or ClusterRole + name: labeds-admin # this must match the name of the Role or ClusterRole you wish to bind to + apiGroup: rbac.authorization.k8s.io \ No newline at end of file diff --git a/helm-chart/values.yaml b/helm-chart/values.yaml new file mode 100644 index 0000000..d0dd711 --- /dev/null +++ b/helm-chart/values.yaml @@ -0,0 +1,99 @@ +# Default values for helm-chart. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: code.groupe-genes.fr/labeds/cours_nunez + pullPolicy: Always + # Overrides the image tag whose default is the chart appVersion. + tag: 1.3 + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +serviceAccount: + # Specifies whether a service account should be created + create: 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: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 8000 + +ingress: + enabled: true + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: cours-nunez.lab.groupe-genes.fr + 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: 30000m + memory: 32Gi + requests: + cpu: 500m + memory: 1024Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +otree: + admin_password: admin_mdp123 + auth_level: STUDY + production: 'false' + +postgresql: + auth: + username: otree + password: posEayU2yWKn + database: otree + primary: + persistence: + size: 50Gi + + +