From 6c032b3b1e01b53dd676963f1294634e8af458d2 Mon Sep 17 00:00:00 2001 From: Tristan <74349933+trispera@users.noreply.github.com> Date: Thu, 11 Apr 2024 12:49:48 +0300 Subject: [PATCH] Dc to deploy (#28) * Rstudio. From DeploymentConfig to Deployment DeploymentConfig is deprecated since OKD 4.14: - Switch from DeploymentConfig to Deployment - Add `initContainers` to wait for the build to be completed - Create a `serviceaccount`, `role` and `rolebinding` to be used to read the build status (oc wait) * Matomo. From DeploymentConfig to Deployment DeploymentConfig is deprecated since OKD 4.14: - Switch from DeploymentConfig to Deployment - Add annotations to keep the PVC after uninstalling the Chart - Fix Services * Minio. From DeploymentConfig to Deployment DeploymentConfig is deprecated since OKD 4.14: - Switch from DeploymentConfig to Deployment - Add annotations to keep the PVC after uninstalling the Chart - Update README * Update Charts version * Change to Recreate --- charts/matomo/Chart.yaml | 4 +- ...{deploymentconfig.yaml => deployment.yaml} | 54 +++++++------------ charts/matomo/templates/pvc.yaml | 2 + charts/matomo/templates/service.yaml | 4 +- charts/minio/Chart.yaml | 4 +- charts/minio/README.md | 2 +- ...{deploymentconfig.yaml => deployment.yaml} | 23 ++++---- charts/minio/templates/pvc.yaml | 2 + charts/rstudio/Chart.yaml | 4 +- ...{deploymentconfig.yaml => deployment.yaml} | 36 ++++++------- charts/rstudio/templates/imagestream.yaml | 4 +- charts/rstudio/templates/pvc.yaml | 4 ++ charts/rstudio/templates/role.yaml | 13 +++++ charts/rstudio/templates/rolebinding.yaml | 11 ++++ charts/rstudio/templates/sa.yaml | 4 ++ 15 files changed, 96 insertions(+), 75 deletions(-) rename charts/matomo/templates/{deploymentconfig.yaml => deployment.yaml} (80%) rename charts/minio/templates/{deploymentconfig.yaml => deployment.yaml} (81%) rename charts/rstudio/templates/{deploymentconfig.yaml => deployment.yaml} (68%) create mode 100644 charts/rstudio/templates/role.yaml create mode 100644 charts/rstudio/templates/rolebinding.yaml create mode 100644 charts/rstudio/templates/sa.yaml diff --git a/charts/matomo/Chart.yaml b/charts/matomo/Chart.yaml index b4b7c88..eebd7db 100644 --- a/charts/matomo/Chart.yaml +++ b/charts/matomo/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 -name: matomo-helm +name: matomo description: Matomo Helm Chart for Rahti platform Link to the repo https://github.com/CSCfi/helm-charts -version: 1.1.1 +version: 1.2.1 sources: - https://github.com/CSCfi/helm-charts icon: https://avatars.githubusercontent.com/u/698038?s=280&v=4 diff --git a/charts/matomo/templates/deploymentconfig.yaml b/charts/matomo/templates/deployment.yaml similarity index 80% rename from charts/matomo/templates/deploymentconfig.yaml rename to charts/matomo/templates/deployment.yaml index aafd455..26053ab 100644 --- a/charts/matomo/templates/deploymentconfig.yaml +++ b/charts/matomo/templates/deployment.yaml @@ -1,19 +1,21 @@ -apiVersion: apps.openshift.io/v1 -kind: DeploymentConfig +apiVersion: apps/v1 +kind: Deployment metadata: + labels: + app: {{ .Values.mariadb.name }} annotations: template.alpha.openshift.io/wait-for-ready: "true" - name: mariadb + name: {{ .Values.mariadb.name }} spec: - replicas: 1 selector: - name: mariadb + matchLabels: + app: {{ .Values.mariadb.name }} strategy: type: Recreate template: metadata: labels: - name: mariadb + app: {{ .Values.mariadb.name }} spec: containers: - env: @@ -46,7 +48,7 @@ spec: port: 3306 timeoutSeconds: {{ .Values.mariadb.livenessProbe.timeoutSeconds }} {{- end }} - name: mariadb + name: {{ .Values.mariadb.name }} ports: - containerPort: 3306 {{- if .Values.mariadb.readinessProbe.enabled }} @@ -70,44 +72,24 @@ spec: - name: {{ .Values.mariadb.name }}-data persistentVolumeClaim: claimName: {{ .Values.mariadb.name }} - triggers: - - imageChangeParams: - automatic: true - containerNames: - - mariadb - from: - kind: ImageStreamTag - name: {{ .Values.mariadb.imageStream.name }}:{{ .Values.mariadb.imageStream.tag }} - namespace: {{ .Values.mariadb.imageStream.namespace }} - type: ImageChange - - type: ConfigChange --- -apiVersion: apps.openshift.io/v1 -kind: DeploymentConfig +apiVersion: apps/v1 +kind: Deployment metadata: labels: - app: matomo - name: matomo + app: {{ .Values.matomo.name }} + name: {{ .Values.matomo.name }} spec: - replicas: 1 selector: - app: matomo - deploymentconfig: matomo + matchLabels: + app: {{ .Values.matomo.name }} strategy: - resources: {} - rollingParams: - intervalSeconds: 1 - maxSurge: 25% - maxUnavailable: 25% - timeoutSeconds: 600 - updatePeriodSeconds: 1 - type: Rolling + type: RollingUpdate template: metadata: labels: - app: matomo - deploymentconfig: matomo + app: {{ .Values.matomo.name }} spec: containers: - env: @@ -138,7 +120,7 @@ spec: name: {{ .Values.mariadb.name }} image: {{ .Values.matomo.image }} imagePullPolicy: Always - name: matomo + name: {{ .Values.matomo.name }} ports: - containerPort: 8080 protocol: TCP diff --git a/charts/matomo/templates/pvc.yaml b/charts/matomo/templates/pvc.yaml index c55c2b7..11efbca 100644 --- a/charts/matomo/templates/pvc.yaml +++ b/charts/matomo/templates/pvc.yaml @@ -2,6 +2,8 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: {{ .Values.mariadb.name }} + annotations: + helm.sh/resource-policy: "keep" spec: accessModes: - ReadWriteOnce diff --git a/charts/matomo/templates/service.yaml b/charts/matomo/templates/service.yaml index 8a5f0c3..017e31d 100644 --- a/charts/matomo/templates/service.yaml +++ b/charts/matomo/templates/service.yaml @@ -9,7 +9,7 @@ spec: - name: mariadb port: 3306 selector: - name: {{ .Values.mariadb.name }} + app: {{ .Values.mariadb.name }} type: {{ .Values.mariadb.service.type }} --- @@ -30,5 +30,5 @@ spec: protocol: TCP targetPort: 8443 selector: - deploymentconfig: {{ .Values.matomo.name }} + app: {{ .Values.matomo.name }} type: {{ .Values.matomo.service.type }} diff --git a/charts/minio/Chart.yaml b/charts/minio/Chart.yaml index c280f24..cf72860 100644 --- a/charts/minio/Chart.yaml +++ b/charts/minio/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 -name: minio-helm +name: minio description: Minio Helm Chart for Rahti platform Link to the repo https://github.com/CSCfi/helm-charts -version: 1.1.1 +version: 1.2.1 sources: - https://github.com/CSCfi/helm-charts icon: https://min.io/resources/img/logo.svg diff --git a/charts/minio/README.md b/charts/minio/README.md index 5a4edbc..d12a4be 100644 --- a/charts/minio/README.md +++ b/charts/minio/README.md @@ -5,7 +5,7 @@ helm upgrade --install minio . ``` ## Explanations -This Helm Chart helps you to deploy Minio on CSC Rahti 2 (Openshift 4). +This Helm Chart helps you to deploy Minio on CSC Rahti (Openshift 4). If you want to use it with different values, you can edit `values.yaml` file and then run: ```sh helm upgrade --install minio . -f {custom_values.yaml} diff --git a/charts/minio/templates/deploymentconfig.yaml b/charts/minio/templates/deployment.yaml similarity index 81% rename from charts/minio/templates/deploymentconfig.yaml rename to charts/minio/templates/deployment.yaml index f184784..52d82aa 100644 --- a/charts/minio/templates/deploymentconfig.yaml +++ b/charts/minio/templates/deployment.yaml @@ -1,11 +1,15 @@ -apiVersion: apps.openshift.io/v1 -kind: DeploymentConfig +apiVersion: apps/v1 +kind: Deployment metadata: labels: app: {{ .Values.minio.clusterName }} name: {{ .Values.minio.clusterName }} spec: - replicas: 1 + selector: + matchLabels: + app: {{ .Values.minio.clusterName }} + strategy: + type: Recreate template: metadata: labels: @@ -21,8 +25,9 @@ spec: - mountPath: /mnt/default-config-json/ name: default-config-json containers: - - image: {{ .Values.minio.image }} - name: {{ .Values.minio.clusterName }} + - name: {{ .Values.minio.clusterName }} + imagePullPolicy: IfNotPresent + image: {{ .Values.minio.image }} ports: - containerPort: 9000 protocol: TCP @@ -31,11 +36,11 @@ spec: {{- if .Values.minio.readinessProbe.enabled }} readinessProbe: httpGet: - {{- .Values.minio.readinessProbe.httpGet | toYaml | nindent 12 }} - {{- end }} + {{- .Values.minio.readinessProbe.httpGet | toYaml | nindent 12 }} + {{- end }} volumeMounts: - - mountPath: /data/files - name: minio-vol + - name: minio-vol + mountPath: /data/files command: - minio - server diff --git a/charts/minio/templates/pvc.yaml b/charts/minio/templates/pvc.yaml index c17844c..65dee24 100644 --- a/charts/minio/templates/pvc.yaml +++ b/charts/minio/templates/pvc.yaml @@ -2,6 +2,8 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: {{ .Values.minio.pvc.name }} + annotations: + helm.sh/resource-policy: "keep" labels: app: {{ .Values.minio.clusterName }} spec: diff --git a/charts/rstudio/Chart.yaml b/charts/rstudio/Chart.yaml index e85ef68..3a8d267 100644 --- a/charts/rstudio/Chart.yaml +++ b/charts/rstudio/Chart.yaml @@ -1,8 +1,8 @@ apiVersion: v2 -name: rstudio-helm +name: rstudio description: RStudio Helm Chart for Rahti platform Link to the repo https://github.com/CSCfi/helm-charts -version: 1.0.1 +version: 1.2.1 sources: - https://github.com/CSCfi/helm-charts icon: https://upload.wikimedia.org/wikipedia/commons/0/0e/Eo_circle_light-blue_white_letter-r.svg diff --git a/charts/rstudio/templates/deploymentconfig.yaml b/charts/rstudio/templates/deployment.yaml similarity index 68% rename from charts/rstudio/templates/deploymentconfig.yaml rename to charts/rstudio/templates/deployment.yaml index 3f66e45..f9ee48b 100644 --- a/charts/rstudio/templates/deploymentconfig.yaml +++ b/charts/rstudio/templates/deployment.yaml @@ -1,24 +1,33 @@ -apiVersion: apps.openshift.io/v1 -kind: DeploymentConfig +apiVersion: apps/v1 +kind: Deployment metadata: labels: app: {{ .Values.appName }} name: {{ .Values.appName }} spec: - replicas: 1 selector: + matchLabels: app: {{ .Values.appName }} strategy: - type: Rolling + type: Recreate template: metadata: labels: app: {{ .Values.appName }} spec: + serviceAccount: build-reader + initContainers: + - name: wait-for-build + imagePullPolicy: IfNotPresent + image: quay.io/openshift/origin-cli:4.16 + command: + - sh + - -c + - oc wait --for=jsonpath='{.status.phase}'=Complete build -l buildconfig={{ .Values.appName }} --timeout=900s containers: - - image: {{ .Values.appName }}:latest + - name: {{ .Values.appName }} imagePullPolicy: IfNotPresent - name: {{ .Values.appName }} + image: image-registry.openshift-image-registry.svc:5000/{{ .Release.Namespace }}/{{ .Values.appName }}:latest ports: - containerPort: 3838 protocol: TCP @@ -33,14 +42,11 @@ spec: securityContext: {{- .Values.rstudio.containerSecurityContext | toYaml | nindent 10 }} {{- end }} - {{- if .Values.openshift.enabled }} - dnsPolicy: ClusterFirst restartPolicy: Always - schedulerName: default-scheduler + {{- if .Values.openshift.enabled }} securityContext: {{- .Values.rstudio.podSecurityContext | toYaml | nindent 8 }} {{- end }} - terminationGracePeriodSeconds: 30 volumes: - name: {{ .Values.rstudio.pvc.mountName }} persistentVolumeClaim: @@ -48,13 +54,3 @@ spec: - name: {{ .Values.shiny.pvc.mountName }} persistentVolumeClaim: claimName: {{ .Values.shiny.pvc.mountName }} - triggers: - - type: ConfigChange - - imageChangeParams: - automatic: true - containerNames: - - {{ .Values.appName }} - from: - kind: ImageStreamTag - name: {{ .Values.appName }}:latest - type: ImageChange diff --git a/charts/rstudio/templates/imagestream.yaml b/charts/rstudio/templates/imagestream.yaml index 1bd74a9..8287f8e 100644 --- a/charts/rstudio/templates/imagestream.yaml +++ b/charts/rstudio/templates/imagestream.yaml @@ -4,4 +4,6 @@ metadata: annotations: description: Keeps track of changes in the appliation image name: {{ .Values.appName }} - \ No newline at end of file +spec: + lookupPolicy: + local: true \ No newline at end of file diff --git a/charts/rstudio/templates/pvc.yaml b/charts/rstudio/templates/pvc.yaml index c693e6e..ab4141f 100644 --- a/charts/rstudio/templates/pvc.yaml +++ b/charts/rstudio/templates/pvc.yaml @@ -2,6 +2,8 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: {{ .Values.rstudio.pvc.mountName }} + annotations: + helm.sh/resource-policy: "keep" spec: resources: requests: @@ -15,6 +17,8 @@ apiVersion: v1 kind: PersistentVolumeClaim metadata: name: {{ .Values.shiny.pvc.mountName }} + annotations: + helm.sh/resource-policy: "keep" spec: resources: requests: diff --git a/charts/rstudio/templates/role.yaml b/charts/rstudio/templates/role.yaml new file mode 100644 index 0000000..98a718c --- /dev/null +++ b/charts/rstudio/templates/role.yaml @@ -0,0 +1,13 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: build-reader +rules: +- apiGroups: + - build.openshift.io + resources: + - builds + verbs: + - get + - list + - watch \ No newline at end of file diff --git a/charts/rstudio/templates/rolebinding.yaml b/charts/rstudio/templates/rolebinding.yaml new file mode 100644 index 0000000..e864e32 --- /dev/null +++ b/charts/rstudio/templates/rolebinding.yaml @@ -0,0 +1,11 @@ +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: build-reader +subjects: + - kind: ServiceAccount + name: build-reader +roleRef: + kind: Role + name: build-reader + apiGroup: rbac.authorization.k8s.io \ No newline at end of file diff --git a/charts/rstudio/templates/sa.yaml b/charts/rstudio/templates/sa.yaml new file mode 100644 index 0000000..4ec0faa --- /dev/null +++ b/charts/rstudio/templates/sa.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: build-reader \ No newline at end of file