Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(local-dev): fix backups in local dev #5063

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -211,7 +211,7 @@ spec:

- name: restore-db
command:
- "/restore-db.sh"
- "/scripts/restore-db.sh"
env:
- name: RQLITE_PASSWORD
valueFrom:
Expand All @@ -232,7 +232,7 @@ spec:

- name: restore-s3
command:
- /restore-s3.sh
- /scripts/restore-s3.sh
env:
- name: S3_ENDPOINT
valueFrom:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -210,7 +210,7 @@ spec:

- name: restore-data
command:
- "/restore.sh"
- "/scripts/restore.sh"
env:
- name: RQLITE_PASSWORD
valueFrom:
Expand Down
13 changes: 1 addition & 12 deletions deploy/melange.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
19 changes: 1 addition & 18 deletions dev/dockerfiles/kotsadm/Dockerfile.ttlsh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions dev/patches/kotsadm-up.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
16 changes: 8 additions & 8 deletions pkg/kotsadm/objects/kotsadm_objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
{
Expand Down Expand Up @@ -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{
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
{
Expand Down Expand Up @@ -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{
{
Expand Down
2 changes: 1 addition & 1 deletion pkg/kotsadm/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
{
Expand Down
4 changes: 2 additions & 2 deletions pkg/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions pkg/snapshot/filesystem_minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Loading