microservices-demo icon indicating copy to clipboard operation
microservices-demo copied to clipboard

Unable to deploy this apps on OpenShift

Open coolpalani opened this issue 6 years ago • 8 comments

I am trying to deploy this micro service on OpenShift 3.7. It's throwing an error message while create catalogue-db pods

NAME READY STATUS RESTARTS AGE catalogue-db-1846494424-2j29q 0/1 CrashLoopBackOff 6 8m

Error message

Initializing database mysqld: Can't create/write to file '/var/lib/mysql/is_writable' (Errcode: 13 - Permission denied) 2018-03-14T13:11:18.115358Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2018-03-14T13:11:18.120035Z 0 [ERROR] --initialize specified but the data directory exists and is not writable. Aborting. 2018-03-14T13:11:18.120064Z 0 [ERROR] Aborting

coolpalani avatar Mar 14 '18 13:03 coolpalani

That's odd. I suspect the volume creates as a result of the VOLUME declaration ends up being read-only. Perhaps that's some strange OpenShift default permissions issue.

rade avatar Mar 15 '18 07:03 rade

It seems permission issue. We need to add user: "1000:50" in docker file.

workaround solutions provided here: https://github.com/docker-library/mysql/issues/219

We are directly pulling docker image "weaveworksdemos/catalogue-db:0.3.0" but not creating any docker image as manually. could you guide me where I have to insert this permission complete-demo.yaml file

apiVersion: extensions/v1beta1 kind: Deployment metadata: name: catalogue-db labels: name: catalogue-db namespace: sock-shop spec: replicas: 1 template: metadata: labels: name: catalogue-db spec: containers: - name: catalogue-db image: weaveworksdemos/catalogue-db:0.3.0 env: - name: MYSQL_ROOT_PASSWORD value: fake_password - name: MYSQL_DATABASE value: socksdb ports: - name: mysql containerPort: 3306 nodeSelector: beta.kubernetes.io/os: linux

coolpalani avatar Mar 15 '18 12:03 coolpalani

Are you sure that will solve the problem? The catalogue-db k8s manifest isn't mounting any dirs from the host into the container.

Nevertheless, to experiment, I suggest creating your own catalogue-db image.

rade avatar Mar 15 '18 14:03 rade

Let me try with 0.3.5 docker image https://hub.docker.com/r/weaveworksdemos/catalogue-db/tags/

coolpalani avatar Mar 15 '18 17:03 coolpalani

@rade

I eventually deployed this application in OpenShift :)

[root@master ~]# oc get pods NAME READY STATUS RESTARTS AGE carts-515570173-69nkf 1/1 Running 0 56m carts-db-224813618-4kdcl 1/1 Running 0 1h catalogue-3634130434-nwfgg 1/1 Running 0 1h catalogue-db-4001046256-dbj5d 1/1 Running 0 46m front-end-4148163561-5xbsk 1/1 Running 0 42m orders-3874398928-2w49n 1/1 Running 0 1h orders-db-1112365690-n5lnl 1/1 Running 0 1h payment-716517544-l9zj6 1/1 Running 0 59m queue-master-2067646375-4w8kj 1/1 Running 0 1h rabbitmq-2169020979-blv2b 1/1 Running 0 59m shipping-1884913266-8v5hm 1/1 Running 0 58m user-1155543707-7cl4s 1/1 Running 0 57m user-db-1749560319-7jt9l 1/1 Running 0 58m

Fix: I removed all the security context and run catalogue-db as user 0 It may not be best practice, but we have to run this application for experimental. The way of this application design for kubernetes, they are more focused in security. In OpenShift each project will be isolated, hopefully not going to harm.

Thanks for your support

coolpalani avatar Mar 16 '18 15:03 coolpalani

@coolpalani Can you share your yaml which you used it to deploy it to openshift

sunilk747 avatar Oct 30 '18 05:10 sunilk747

Think i am getting a similar issue. What was the fix?

Initializing database   | mysqld: Can't create/write to file '/var/lib/mysql/is_writable' (Errcode: 13 - Permission denied)   | 2019-03-16T05:43:04.624144Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).   | 2019-03-16T05:43:04.625694Z 0 [ERROR] --initialize specified but the data directory exists and is not writable. Aborting.  

spzorn123 avatar Mar 16 '19 05:03 spzorn123

It seems permission issue. We need to add user: "1000:50" in docker file.

workaround solutions provided here: docker-library/mysql#219

We are directly pulling docker image "weaveworksdemos/catalogue-db:0.3.0" but not creating any docker image as manually. could you guide me where I have to insert this permission complete-demo.yaml file

apiVersion: extensions/v1beta1 kind: Deployment metadata: name: catalogue-db labels: name: catalogue-db namespace: sock-shop spec: replicas: 1 template: metadata: labels: name: catalogue-db spec: containers:

  • name: catalogue-db image: weaveworksdemos/catalogue-db:0.3.0 env:
  • name: MYSQL_ROOT_PASSWORD value: fake_password
  • name: MYSQL_DATABASE value: socksdb ports:
  • name: mysql containerPort: 3306 nodeSelector: beta.kubernetes.io/os: linux

@coolpalani did you ever get this running on OpenShift?

spzorn123 avatar Mar 16 '19 21:03 spzorn123