---
apiVersion: batch/v1
kind: CronJob
metadata:
name: daily-task-2am
spec:
schedule: "0 2 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: worker-container
image: busybox:1.28
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- date; echo "새벽 2시 작업 시작 - 특정 커맨드 실행 중"
restartPolicy: OnFailure
---
kubectl create job --from=cronjob/daily-task-2am manual-test-run
kubectl create configmap mc-config --from-file=config.yaml=./local-folder/your-config.yaml
---
spec:
jobTemplate:
spec:
template:
spec:
containers:
- name: mc-client
image: minio/mc:latest
command:
- /bin/sh
- -c
- |
mc alias set myminio http://minio-service:9000 $ACCESS_KEY $SECRET_KEY;
mc cp /data/backup.tar.gz myminio/backups/;
restartPolicy: OnFailure
---
FROM alpine:3.18
RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc \
&& chmod +x mc \
&& mv mc /usr/local/bin/mc
RUN apk add --no-cache curl
ENTRYPOINT ["mc"]
---
apiVersion: v1
kind: ConfigMap
metadata:
name: mc-config
data:
config.yaml: |
# 여기에 실제 mc가 참조할 YAML 내용을 작성하세요
key: value
setting: enabled
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: mc-task-with-yaml
spec:
schedule: "0 2 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: mc-container
image: minio/mc:latest
command:
- /bin/sh
- -c
- |
# 1. MinIO 접속 설정 (환경변수 활용 권장)
mc alias set myminio $ENDPOINT $ACCESS_KEY $SECRET_KEY
mc --config-dir /config some-command --file /config/config.yaml
env:
- name: ENDPOINT
value: "http://minio-service:9000"
volumeMounts:
- name: config-volume
mountPath: /config
volumes:
- name: config-volume
configMap:
name: mc-config
restartPolicy: OnFailure
---