|
| 1 | +apiVersion: apps/v1 |
| 2 | +kind: Deployment |
| 3 | +metadata: |
| 4 | + name: rcloneproxy |
| 5 | + labels: |
| 6 | + app: rcloneproxy |
| 7 | +spec: |
| 8 | + replicas: {{ .Values.replicaCount }} |
| 9 | + selector: |
| 10 | + matchLabels: |
| 11 | + app: rcloneproxy |
| 12 | + template: |
| 13 | + metadata: |
| 14 | + labels: |
| 15 | + app: rcloneproxy |
| 16 | + spec: |
| 17 | + {{- if .Values.podSecurityContext.enabled }} |
| 18 | + securityContext: |
| 19 | + {{- if .Values.podSecurityContext.fsGroup }} |
| 20 | + fsGroup: {{ .Values.podSecurityContext.fsGroup }} |
| 21 | + {{- end }} |
| 22 | + {{- if .Values.podSecurityContext.fsGroupChangePolicy }} |
| 23 | + fsGroupChangePolicy: {{ .Values.podSecurityContext.fsGroupChangePolicy }} |
| 24 | + {{- end }} |
| 25 | + {{- if .Values.podSecurityContext.seLinuxOptions }} |
| 26 | + seLinuxOptions: |
| 27 | + {{- toYaml .Values.podSecurityContext.seLinuxOptions | nindent 10 }} |
| 28 | + {{- end }} |
| 29 | + {{- end }} |
| 30 | + initContainers: |
| 31 | + - name: generate-config |
| 32 | + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" |
| 33 | + imagePullPolicy: {{ .Values.image.pullPolicy }} |
| 34 | + {{- if .Values.containerSecurityContext.enabled }} |
| 35 | + securityContext: |
| 36 | + {{- if .Values.containerSecurityContext.runAsUser }} |
| 37 | + runAsUser: {{ .Values.containerSecurityContext.runAsUser }} |
| 38 | + {{- end }} |
| 39 | + {{- if .Values.containerSecurityContext.runAsNonRoot }} |
| 40 | + runAsNonRoot: {{ .Values.containerSecurityContext.runAsNonRoot }} |
| 41 | + {{- end }} |
| 42 | + {{- if ne .Values.containerSecurityContext.allowPrivilegeEscalation nil }} |
| 43 | + allowPrivilegeEscalation: {{ .Values.containerSecurityContext.allowPrivilegeEscalation }} |
| 44 | + {{- end }} |
| 45 | + {{- if ne .Values.containerSecurityContext.readOnlyRootFilesystem nil }} |
| 46 | + readOnlyRootFilesystem: {{ .Values.containerSecurityContext.readOnlyRootFilesystem }} |
| 47 | + {{- end }} |
| 48 | + {{- if .Values.containerSecurityContext.capabilities }} |
| 49 | + capabilities: |
| 50 | + {{- toYaml .Values.containerSecurityContext.capabilities | nindent 14 }} |
| 51 | + {{- end }} |
| 52 | + {{- end }} |
| 53 | + command: |
| 54 | + - /bin/sh |
| 55 | + - -c |
| 56 | + args: |
| 57 | + - | |
| 58 | + set -e |
| 59 | + # Obscure the encryption passwords |
| 60 | + OBSCURED_PASSWORD=$(echo -n "$ENCRYPTION_PASSWORD" | rclone obscure -) |
| 61 | + OBSCURED_PASSWORD2=$(echo -n "$ENCRYPTION_PASSWORD2" | rclone obscure -) |
| 62 | +
|
| 63 | + # Generate rclone.conf with obscured passwords |
| 64 | + cat > /config/rclone/rclone.conf <<EOF |
| 65 | + [target] |
| 66 | + type = s3 |
| 67 | + provider = Other |
| 68 | + env_auth = false |
| 69 | + access_key_id = $BACKEND_ACCESS_KEY_ID |
| 70 | + secret_access_key = $BACKEND_SECRET_ACCESS_KEY |
| 71 | + endpoint = $BACKEND_ENDPOINT |
| 72 | + region = $BACKEND_REGION |
| 73 | + location_constraint = $BACKEND_REGION |
| 74 | + force_path_style = true |
| 75 | +
|
| 76 | + [s3-crypt] |
| 77 | + type = crypt |
| 78 | + remote = target:$BACKEND_BUCKET |
| 79 | + filename_encryption = standard |
| 80 | + directory_name_encryption = true |
| 81 | + password = $OBSCURED_PASSWORD |
| 82 | + password2 = $OBSCURED_PASSWORD2 |
| 83 | + EOF |
| 84 | +
|
| 85 | + echo "Generated rclone.conf with obscured passwords" |
| 86 | + env: |
| 87 | + - name: BACKEND_ACCESS_KEY_ID |
| 88 | + valueFrom: |
| 89 | + secretKeyRef: |
| 90 | + name: {{ .Values.backend.secretRef.name }} |
| 91 | + key: {{ .Values.backend.secretRef.keys.accessKeyID }} |
| 92 | + - name: BACKEND_SECRET_ACCESS_KEY |
| 93 | + valueFrom: |
| 94 | + secretKeyRef: |
| 95 | + name: {{ .Values.backend.secretRef.name }} |
| 96 | + key: {{ .Values.backend.secretRef.keys.accessKeySecret }} |
| 97 | + - name: BACKEND_ENDPOINT |
| 98 | + valueFrom: |
| 99 | + secretKeyRef: |
| 100 | + name: {{ .Values.backend.secretRef.name }} |
| 101 | + key: {{ .Values.backend.secretRef.keys.endpoint }} |
| 102 | + - name: BACKEND_REGION |
| 103 | + valueFrom: |
| 104 | + secretKeyRef: |
| 105 | + name: {{ .Values.backend.secretRef.name }} |
| 106 | + key: {{ .Values.backend.secretRef.keys.region }} |
| 107 | + - name: BACKEND_BUCKET |
| 108 | + valueFrom: |
| 109 | + secretKeyRef: |
| 110 | + name: {{ .Values.backend.secretRef.name }} |
| 111 | + key: {{ .Values.backend.secretRef.keys.bucket }} |
| 112 | + - name: ENCRYPTION_PASSWORD |
| 113 | + valueFrom: |
| 114 | + secretKeyRef: |
| 115 | + name: rcloneproxy-encryption-key |
| 116 | + key: password |
| 117 | + - name: ENCRYPTION_PASSWORD2 |
| 118 | + valueFrom: |
| 119 | + secretKeyRef: |
| 120 | + name: rcloneproxy-encryption-key |
| 121 | + key: password2 |
| 122 | + volumeMounts: |
| 123 | + - name: rclone-config |
| 124 | + mountPath: /config/rclone |
| 125 | + containers: |
| 126 | + - name: rcloneproxy |
| 127 | + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" |
| 128 | + imagePullPolicy: {{ .Values.image.pullPolicy }} |
| 129 | + {{- if .Values.containerSecurityContext.enabled }} |
| 130 | + securityContext: |
| 131 | + {{- if .Values.containerSecurityContext.runAsUser }} |
| 132 | + runAsUser: {{ .Values.containerSecurityContext.runAsUser }} |
| 133 | + {{- end }} |
| 134 | + {{- if .Values.containerSecurityContext.runAsNonRoot }} |
| 135 | + runAsNonRoot: {{ .Values.containerSecurityContext.runAsNonRoot }} |
| 136 | + {{- end }} |
| 137 | + {{- if ne .Values.containerSecurityContext.allowPrivilegeEscalation nil }} |
| 138 | + allowPrivilegeEscalation: {{ .Values.containerSecurityContext.allowPrivilegeEscalation }} |
| 139 | + {{- end }} |
| 140 | + {{- if ne .Values.containerSecurityContext.readOnlyRootFilesystem nil }} |
| 141 | + readOnlyRootFilesystem: {{ .Values.containerSecurityContext.readOnlyRootFilesystem }} |
| 142 | + {{- end }} |
| 143 | + {{- if .Values.containerSecurityContext.capabilities }} |
| 144 | + capabilities: |
| 145 | + {{- toYaml .Values.containerSecurityContext.capabilities | nindent 14 }} |
| 146 | + {{- end }} |
| 147 | + {{- end }} |
| 148 | + command: |
| 149 | + - /bin/sh |
| 150 | + - -c |
| 151 | + args: |
| 152 | + - | |
| 153 | + rclone serve s3 s3-crypt: --addr :{{ .Values.service.port }} --auth-key "${BACKEND_ACCESS_KEY_ID},${BACKEND_SECRET_ACCESS_KEY}" |
| 154 | + env: |
| 155 | + - name: RCLONE_CONFIG |
| 156 | + value: /config/rclone/rclone.conf |
| 157 | + - name: BACKEND_ACCESS_KEY_ID |
| 158 | + valueFrom: |
| 159 | + secretKeyRef: |
| 160 | + name: {{ .Values.backend.secretRef.name }} |
| 161 | + key: {{ .Values.backend.secretRef.keys.accessKeyID }} |
| 162 | + - name: BACKEND_SECRET_ACCESS_KEY |
| 163 | + valueFrom: |
| 164 | + secretKeyRef: |
| 165 | + name: {{ .Values.backend.secretRef.name }} |
| 166 | + key: {{ .Values.backend.secretRef.keys.accessKeySecret }} |
| 167 | + ports: |
| 168 | + - name: s3 |
| 169 | + containerPort: {{ .Values.service.port }} |
| 170 | + protocol: TCP |
| 171 | + resources: |
| 172 | + {{- toYaml .Values.resources | nindent 12 }} |
| 173 | + volumeMounts: |
| 174 | + - name: rclone-config |
| 175 | + mountPath: /config/rclone |
| 176 | + readOnly: true |
| 177 | + stdin: true |
| 178 | + tty: true |
| 179 | + volumes: |
| 180 | + - name: rclone-config |
| 181 | + emptyDir: {} |
0 commit comments