I want to initially execute app:rake db:setup from GitLab so the db could be initialized.
Snippet from my GitLab YAML (init-db.yaml)
...
name: gitlab
image: docker.artifactory.abc.net/sameersbn/gitlab:9.3.9
command:
- app:rake db:setup
volumeMounts:
- name: gfs-vol-gitlab
mountPath: /home/git/data
ports:
- containerPort: 443
resources: {}
volumes:
...But when i check the status of the pod, i get the following error message:
...
Command:
app:rake db:setup
State: Waiting
Reason: CrashLoopBackOff
Last State: Terminated
Reason: ContainerCannotRun
Message: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused \"exec: \\\"app:rake db:setup\\\": executable file not found in $PATH\"\n"
...
Snippet from Dockerfile
...
...
EXPOSE 22/tcp 80/tcp 443/tcp
VOLUME ["${GITLAB_DATA_DIR}", "${GITLAB_LOG_DIR}"]
WORKDIR ${GITLAB_INSTALL_DIR}
ENTRYPOINT ["/sbin/entrypoint.sh"]
CMD ["app:start"]Snippet from entrypoint.sh
...
...
case ${1} in
app:init|app:start|app:sanitize|app:rake)
...UPDATE: When i run this:
command:
- "app:rake"
- "db:setup"I get:
to open log file "/var/log/pods/5b604971-b5ac-11e7-9ee5-021bfed3b32a/gitlab_0.log": open /var/log/pods/5b604971-b5ac-11e7-9ee5-021bfed3b32a/gitlab_0.log: no such file or directoryWhen i try this:
command:
- "/bin/sh"
args:
- "-c"
- "app:rake db:setup"I get: /bin/sh: 1: app:rake: not found
This link describes running app:rake db:setup command to setup database.
I earlier tried running this command outside Kubernetes and it worked fine using the code shown below:
docker run --name gitlab -it --rm \
--link gitlab-postgresql:postgresql --link gitlab-redis:redisio \
--publish 443:443 --publish 80:80 \
--env 'GITLAB_PORT=80' \
--env 'GITLAB_SECRETS_DB_KEY_BASE=64_bit_key_A' \
--env 'GITLAB_SECRETS_SECRET_KEY_BASE=64_bit_key_B' \
--env 'GITLAB_SECRETS_OTP_KEY_BASE=64_bit_key_C' \
--volume /srv/docker/gitlab/gitlab:/home/git/data \
sameersbn/gitlab:9.3.9 app:rake db:setupUPDATE_1:
$ kubectl describe pod gitlab-1108406018-3lvh7
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 18m default-scheduler Successfully assigned gitlab-1108406018-3lvh7 to rancher-a
Normal SuccessfulMountVolume 18m kubelet, rancher-a MountVolume.SetUp succeeded for volume "default-token-qv8dm"
Normal SuccessfulMountVolume 18m kubelet, rancher-a MountVolume.SetUp succeeded for volume "pvc-304c48a5-b430-11e7-9ee5-021bfed3b32a"
Normal Pulling 17m kubelet, rancher-a pulling image "docker.artifactory.abc.net/sameersbn/gitlab:9.3.9"
Normal Pulled 16m kubelet, rancher-a Successfully pulled image "docker.artifactory.abc.net/sameersbn/gitlab:9.3.9"
Normal Pulled 2m (x7 over 16m) kubelet, rancher-a Container image "docker.artifactory.abc.net/sameersbn/gitlab:9.3.9" already present on machine
Normal Created 2m (x8 over 16m) kubelet, rancher-a Created container
Normal Started 2m (x8 over 16m) kubelet, rancher-a Started container
Warning BackOff 8s (x56 over 15m) kubelet, rancher-a Back-off restarting failed container
Warning FailedSync 8s (x56 over 15m) kubelet, rancher-a Error syncing podUPDATE: This is not the right answer. Please refer to Andy Shinn's answer.
Each command should be an item inside the command array. As you want to execute two commands, try this:
...
name: gitlab
image: docker.artifactory.abc.net/sameersbn/gitlab:9.3.9
command:
- "app:rake"
- "db:setup"
volumeMounts:
- name: gfs-vol-gitlab
mountPath: /home/git/data
ports:
- containerPort: 443
resources: {}
volumes:
...
You can also use the args parameter to write your app:rake db:setup command pair in one line (by basically forcing the commands to run in a shell context):
...
name: gitlab
image: docker.artifactory.abc.net/sameersbn/gitlab:9.3.9
command:
- "/bin/sh"
args:
- "-c"
- "app:rake db:setup"
volumeMounts:
- name: gfs-vol-gitlab
mountPath: /home/git/data
ports:
- containerPort: 443
resources: {}
volumes:
...
I think this might just be a mixup of the Pod spec. In Kubernetes, the command is the equivalent of the Docker ENTRYPOINT and the args are the equivalent of CMD. In your case, I think you want:
...
name: gitlab
image: docker.artifactory.abc.net/sameersbn/gitlab:9.3.9
command:
- "/sbin/entrypoint.sh"
args:
- "app:rake"
- "db:setup"
volumeMounts:
- name: gfs-vol-gitlab
mountPath: /home/git/data
ports:
- containerPort: 443
resources: {}
volumes:
...