diff --git a/deploy/kurl/kotsadm/template/base/deployment/kotsadm-deployment.yaml b/deploy/kurl/kotsadm/template/base/deployment/kotsadm-deployment.yaml index 5a9e5f716f..34d54b3c57 100644 --- a/deploy/kurl/kotsadm/template/base/deployment/kotsadm-deployment.yaml +++ b/deploy/kurl/kotsadm/template/base/deployment/kotsadm-deployment.yaml @@ -19,7 +19,7 @@ spec: kots.io/backup: velero annotations: backup.velero.io/backup-volumes: backup - pre.hook.backup.velero.io/command: '["/backup.sh"]' + pre.hook.backup.velero.io/command: '["/scripts/backup.sh"]' pre.hook.backup.velero.io/timeout: 10m spec: securityContext: @@ -90,7 +90,7 @@ spec: key: uri optional: true - name: POSTGRES_SCHEMA_DIR # this is needed for the migration - value: "/postgres/tables" + value: "/scripts/postgres/tables" - name: RQLITE_URI valueFrom: secretKeyRef: @@ -211,7 +211,7 @@ spec: - name: restore-db command: - - "/restore-db.sh" + - "/scripts/restore-db.sh" env: - name: RQLITE_PASSWORD valueFrom: @@ -232,7 +232,7 @@ spec: - name: restore-s3 command: - - /restore-s3.sh + - /scripts/restore-s3.sh env: - name: S3_ENDPOINT valueFrom: diff --git a/deploy/kurl/kotsadm/template/base/statefulset/kotsadm-statefulset.yaml b/deploy/kurl/kotsadm/template/base/statefulset/kotsadm-statefulset.yaml index 62136d1282..dd1ae8d374 100644 --- a/deploy/kurl/kotsadm/template/base/statefulset/kotsadm-statefulset.yaml +++ b/deploy/kurl/kotsadm/template/base/statefulset/kotsadm-statefulset.yaml @@ -33,7 +33,7 @@ spec: kots.io/backup: velero annotations: backup.velero.io/backup-volumes: backup - pre.hook.backup.velero.io/command: '["/backup.sh"]' + pre.hook.backup.velero.io/command: '["/scripts/backup.sh"]' pre.hook.backup.velero.io/timeout: 10m spec: securityContext: @@ -108,7 +108,7 @@ spec: key: uri optional: true - name: POSTGRES_SCHEMA_DIR # this is needed for the migration - value: "/postgres/tables" + value: "/scripts/postgres/tables" - name: RQLITE_URI valueFrom: secretKeyRef: @@ -210,7 +210,7 @@ spec: - name: restore-data command: - - "/restore.sh" + - "/scripts/restore.sh" env: - name: RQLITE_PASSWORD valueFrom: diff --git a/deploy/melange.yaml.tmpl b/deploy/melange.yaml.tmpl index aef53f9010..6c33888aa6 100644 --- a/deploy/melange.yaml.tmpl +++ b/deploy/melange.yaml.tmpl @@ -27,18 +27,7 @@ pipeline: mkdir -p "${DESTDIR}" # Scripts etc. - mv deploy/assets/backup.sh "${DESTDIR}/backup.sh" - mv deploy/assets/restore-db.sh "${DESTDIR}/restore-db.sh" - mv deploy/assets/restore-s3.sh "${DESTDIR}/restore-s3.sh" - mv deploy/assets/restore.sh "${DESTDIR}/restore.sh" - mv deploy/assets/migrate-s3.sh "${DESTDIR}/migrate-s3.sh" - mv deploy/assets/fs-minio-check.sh "${DESTDIR}/fs-minio-check.sh" - mv deploy/assets/fs-minio-reset.sh "${DESTDIR}/fs-minio-reset.sh" - mv deploy/assets/fs-minio-keys-sha.sh "${DESTDIR}/fs-minio-keys-sha.sh" - mv deploy/assets/s3-bucket-create.sh "${DESTDIR}/s3-bucket-create.sh" - mv deploy/assets/s3-bucket-head.sh "${DESTDIR}/s3-bucket-head.sh" - mv deploy/assets/kots-upgrade.sh "${DESTDIR}/kots-upgrade.sh" - mv deploy/assets/postgres "${DESTDIR}/postgres" + mv deploy/assets "${DESTDIR}/scripts" # kotsadm and kots binaries export VERSION=${GIT_TAG} diff --git a/dev/dockerfiles/kotsadm/Dockerfile.ttlsh b/dev/dockerfiles/kotsadm/Dockerfile.ttlsh index 412e3f9039..3646d60bfd 100644 --- a/dev/dockerfiles/kotsadm/Dockerfile.ttlsh +++ b/dev/dockerfiles/kotsadm/Dockerfile.ttlsh @@ -40,24 +40,7 @@ RUN useradd -c 'kotsadm user' -m -d /home/kotsadm -s /bin/bash -u 1001 kotsadm USER kotsadm ENV HOME /home/kotsadm -COPY --chown=kotsadm:kotsadm ./deploy/assets/backup.sh /backup.sh -COPY --chown=kotsadm:kotsadm ./deploy/assets/restore-db.sh /restore-db.sh -COPY --chown=kotsadm:kotsadm ./deploy/assets/restore-s3.sh /restore-s3.sh -COPY --chown=kotsadm:kotsadm ./deploy/assets/restore.sh /restore.sh -COPY --chown=kotsadm:kotsadm ./deploy/assets/migrate-s3.sh /migrate-s3.sh - -COPY --chown=kotsadm:kotsadm ./deploy/assets/fs-minio-check.sh /fs-minio-check.sh -COPY --chown=kotsadm:kotsadm ./deploy/assets/fs-minio-reset.sh /fs-minio-reset.sh -COPY --chown=kotsadm:kotsadm ./deploy/assets/fs-minio-keys-sha.sh /fs-minio-keys-sha.sh - -COPY --chown=kotsadm:kotsadm ./deploy/assets/s3-bucket-create.sh /s3-bucket-create.sh -COPY --chown=kotsadm:kotsadm ./deploy/assets/s3-bucket-head.sh /s3-bucket-head.sh - -COPY --chown=kotsadm:kotsadm ./deploy/assets/kots-upgrade.sh /kots-upgrade.sh - -# only used for the migration -COPY --chown=kotsadm:kotsadm ./deploy/assets/postgres /postgres - +COPY --chown=kotsadm:kotsadm ./deploy/assets /scripts COPY --chown=kotsadm:kotsadm ./bin/kotsadm /kotsadm COPY --chown=kotsadm:kotsadm ./bin/kots /kots diff --git a/dev/patches/kotsadm-up.yaml b/dev/patches/kotsadm-up.yaml index f08028fef1..d6a3b3fcb5 100644 --- a/dev/patches/kotsadm-up.yaml +++ b/dev/patches/kotsadm-up.yaml @@ -6,6 +6,10 @@ spec: hostPath: path: {{ .Env.PROJECT_DIR }} type: Directory + - name: scripts + hostPath: + path: {{ .Env.PROJECT_DIR }}/deploy/assets + type: Directory {{- if .Env.EC_NODE }} affinity: nodeAffinity: @@ -30,6 +34,8 @@ spec: volumeMounts: - name: dev mountPath: /replicatedhq/kots # workdir in the container + - name: scripts + mountPath: /scripts env: # in order to serve from kotsadm-web even in embedded cluster - name: DISABLE_SPA_SERVING diff --git a/pkg/kotsadm/objects/kotsadm_objects.go b/pkg/kotsadm/objects/kotsadm_objects.go index a1e7007e77..0b0112fdf8 100644 --- a/pkg/kotsadm/objects/kotsadm_objects.go +++ b/pkg/kotsadm/objects/kotsadm_objects.go @@ -255,7 +255,7 @@ func KotsadmDeployment(deployOptions types.DeployOptions) (*appsv1.Deployment, e }, { Name: "POSTGRES_SCHEMA_DIR", // this is needed for the migration - Value: "/postgres/tables", + Value: "/scripts/postgres/tables", }, { Name: "POD_NAMESPACE", @@ -357,7 +357,7 @@ func KotsadmDeployment(deployOptions types.DeployOptions) (*appsv1.Deployment, e podAnnotations := map[string]string{ "backup.velero.io/backup-volumes": "backup", - "pre.hook.backup.velero.io/command": `["/backup.sh"]`, + "pre.hook.backup.velero.io/command": `["/scripts/backup.sh"]`, "pre.hook.backup.velero.io/timeout": "10m", } for k, v := range deployOptions.AdditionalAnnotations { @@ -553,7 +553,7 @@ func KotsadmDeployment(deployOptions types.DeployOptions) (*appsv1.Deployment, e ImagePullPolicy: corev1.PullIfNotPresent, Name: "restore-db", Command: []string{ - "/restore-db.sh", + "/scripts/restore-db.sh", }, VolumeMounts: []corev1.VolumeMount{ { @@ -595,7 +595,7 @@ func KotsadmDeployment(deployOptions types.DeployOptions) (*appsv1.Deployment, e ImagePullPolicy: corev1.PullIfNotPresent, Name: "restore-s3", Command: []string{ - "/restore-s3.sh", + "/scripts/restore-s3.sh", }, VolumeMounts: []corev1.VolumeMount{ { @@ -828,7 +828,7 @@ func KotsadmStatefulSet(deployOptions types.DeployOptions, size resource.Quantit }, { Name: "POSTGRES_SCHEMA_DIR", // this is needed for the migration - Value: "/postgres/tables", + Value: "/scripts/postgres/tables", }, { Name: "POD_NAMESPACE", @@ -900,7 +900,7 @@ func KotsadmStatefulSet(deployOptions types.DeployOptions, size resource.Quantit podAnnotations := map[string]string{ "backup.velero.io/backup-volumes": "backup", - "pre.hook.backup.velero.io/command": `["/backup.sh"]`, + "pre.hook.backup.velero.io/command": `["/scripts/backup.sh"]`, "pre.hook.backup.velero.io/timeout": "10m", } for k, v := range deployOptions.AdditionalAnnotations { @@ -1109,7 +1109,7 @@ func KotsadmStatefulSet(deployOptions types.DeployOptions, size resource.Quantit ImagePullPolicy: corev1.PullIfNotPresent, Name: "restore-data", Command: []string{ - "/restore.sh", + "/scripts/restore.sh", }, VolumeMounts: []corev1.VolumeMount{ { @@ -1155,7 +1155,7 @@ func KotsadmStatefulSet(deployOptions types.DeployOptions, size resource.Quantit ImagePullPolicy: corev1.PullIfNotPresent, Name: "migrate-s3", Command: []string{ - "/migrate-s3.sh", + "/scripts/migrate-s3.sh", }, VolumeMounts: []corev1.VolumeMount{ { diff --git a/pkg/kotsadm/updates.go b/pkg/kotsadm/updates.go index f61e82374e..e8a48363f0 100644 --- a/pkg/kotsadm/updates.go +++ b/pkg/kotsadm/updates.go @@ -146,7 +146,7 @@ func UpdateToVersion(newVersion string) error { Name: "kotsadm-updater", Image: fmt.Sprintf("kotsadm/kotsadm:%s", newVersion), ImagePullPolicy: corev1.PullIfNotPresent, - Command: []string{"/kots-upgrade.sh"}, + Command: []string{"/scripts/kots-upgrade.sh"}, Args: args, Env: []corev1.EnvVar{ { diff --git a/pkg/s3/s3.go b/pkg/s3/s3.go index 36ffdff927..98d448d1fc 100644 --- a/pkg/s3/s3.go +++ b/pkg/s3/s3.go @@ -68,7 +68,7 @@ func GetConfig() *aws.Config { // CreateS3BucketUsingAPod is helpful when trying to hit a cluster s3 service using the CLI since that could be used outside the cluster, or due to firewall restrictions func CreateS3BucketUsingAPod(ctx context.Context, clientset kubernetes.Interface, podOptions S3OpsPodOptions) error { - command := []string{"/s3-bucket-create.sh"} + command := []string{"/scripts/s3-bucket-create.sh"} pod, err := s3BucketPod(clientset, podOptions, command) if err != nil { return errors.Wrap(err, "failed to get pod resource") @@ -132,7 +132,7 @@ func CreateS3BucketUsingAPod(ctx context.Context, clientset kubernetes.Interface // HeadS3BucketUsingAPod is helpful when trying to hit a cluster s3 service using the CLI since that could be used outside the cluster, or due to firewall restrictions func HeadS3BucketUsingAPod(ctx context.Context, clientset kubernetes.Interface, podOptions S3OpsPodOptions) error { - command := []string{"/s3-bucket-head.sh"} + command := []string{"/scripts/s3-bucket-head.sh"} pod, err := s3BucketPod(clientset, podOptions, command) if err != nil { return errors.Wrap(err, "failed to get pod resource") diff --git a/pkg/snapshot/filesystem_minio.go b/pkg/snapshot/filesystem_minio.go index c96051c6b9..0f4e3f95e8 100644 --- a/pkg/snapshot/filesystem_minio.go +++ b/pkg/snapshot/filesystem_minio.go @@ -810,17 +810,17 @@ func createFileSystemMinioKeysSHAPod(ctx context.Context, clientset kubernetes.I } func fileSystemMinioCheckPod(ctx context.Context, clientset kubernetes.Interface, deployOptions FileSystemDeployOptions, registryConfig kotsadmtypes.RegistryConfig) (*corev1.Pod, error) { - command := []string{"/fs-minio-check.sh"} + command := []string{"/scripts/fs-minio-check.sh"} return fileSystemMinioConfigPod(clientset, deployOptions, registryConfig, fsMinioCheckTag, command, nil, true) } func fileSystemMinioResetPod(ctx context.Context, clientset kubernetes.Interface, deployOptions FileSystemDeployOptions, registryConfig kotsadmtypes.RegistryConfig) (*corev1.Pod, error) { - command := []string{"/fs-minio-reset.sh"} + command := []string{"/scripts/fs-minio-reset.sh"} return fileSystemMinioConfigPod(clientset, deployOptions, registryConfig, fsMinioResetTag, command, nil, false) } func fileSystemMinioKeysSHAPod(ctx context.Context, clientset kubernetes.Interface, deployOptions FileSystemDeployOptions, registryConfig kotsadmtypes.RegistryConfig, minioKeysSHA string) (*corev1.Pod, error) { - command := []string{"/fs-minio-keys-sha.sh"} + command := []string{"/scripts/fs-minio-keys-sha.sh"} args := []string{minioKeysSHA} return fileSystemMinioConfigPod(clientset, deployOptions, registryConfig, fsMinioKeysSHATag, command, args, false) }