convert docker-compose.yml file to kubernetes
When Kompose warns you:
WARN Volume mount on the host "/usr/docker/adpater/license.json" isn't supported - ignoring path on the host
It means that it can't translate this fragment of the docker-compose.yml
file into Kubernetes syntax:
volumes: - ./license.json:/run/secrets/rji_license.json
In native Kubernetes, you'd need to provide this content in ConfigMap or Secret objects, and then mount the file into the pod. You can't directly access content on the system from which you're launching the containers.
You can't really get around directly working with the Kubernetes YAML files here. You could run kompose convert
to generate the skeleton files, but then you'll need to edit those to add the ConfigMaps, PersistentVolumeClaims (for the database storage), and relevant volume and mount declarations, and then run kubectl apply -f
to actually run them. I'd check the Kubernetes YAML files into source control, and maintain them in parallel with your Docker Compose setup.
Move2Kube (which does support docker-compose translation), can handle this case and tries to convert the volumes by interacting with you.
? 6. [] What type of container registry login do you want to use?Hints: [Docker login from config mode, will use the default config from your local machine.] No authentication? 7. Do you want to create PVC for host path [/Users/ashok/wksps/hc/temp/test2/src/dbdata]?:Hints: [Use PVC for persistent storage wherever applicable] Yes? 8. Do you want to create PVC for host path [/Users/ashok/wksps/hc/temp/test2/src/license.json]?:Hints: [Use PVC for persistent storage wherever applicable] No? 9. Do you want to create PVC for host path [/Users/ashok/wksps/hc/temp/test2/src/certificates/ssl.crt]?:Hints: [Use PVC for persistent storage wherever applicable] No? 10. Do you want to create PVC for host path [/Users/ashok/wksps/hc/temp/test2/src/certificates/ssl.key]?:Hints: [Use PVC for persistent storage wherever applicable] No? 11. Do you want to create PVC for host path [/Users/ashok/wksps/hc/temp/test2/src/server.xml]?:Hints: [Use PVC for persistent storage wherever applicable] No? 12. Which storage class to use for persistent volume claim [vol17655897939759777588] used by [mysql]Hints: [If you have a custom cluster, you can use collect to get storage classes from it.] default? 13. Provide the ingress host domainHints: [Ingress host domain is part of service URL] myproject.com? 14. Provide the TLS secret for ingressHints: [Enter TLS secret name]
If the above choices were made Move2Kube creates the following artifacts:
apiVersion: apps/v1kind: Deploymentmetadata: annotations: move2kube.konveyor.io/service.expose: "true" creationTimestamp: null labels: move2kube.konveyor.io/network/integration: "true" move2kube.konveyor.io/service: tomcat name: tomcatspec: replicas: 2 selector: matchLabels: move2kube.konveyor.io/service: tomcat strategy: {} template: metadata: annotations: move2kube.konveyor.io/service.expose: "true" creationTimestamp: null labels: move2kube.konveyor.io/network/integration: "true" move2kube.konveyor.io/service: tomcat name: tomcat spec: containers: - image: adapter:poc imagePullPolicy: Always name: tomcat ports: - containerPort: 8080 protocol: TCP - containerPort: 8443 protocol: TCP resources: {} volumeMounts: - mountPath: /run/secrets/rji_license.json name: vol16871681589659214643 - mountPath: /usr/local/tomcat/conf/ssl.crt name: vol12635587774184387470 - mountPath: /usr/local/tomcat/conf/ssl.key name: vol7446232639477381794 - mountPath: /usr/local/tomcat/conf/server.xml name: vol4920239289720818926 restartPolicy: Always volumes: - hostPath: path: /Users/ashok/wksps/hc/temp/test2/src/license.json name: vol16871681589659214643 - hostPath: path: /Users/ashok/wksps/hc/temp/test2/src/certificates/ssl.crt name: vol12635587774184387470 - hostPath: path: /Users/ashok/wksps/hc/temp/test2/src/certificates/ssl.key name: vol7446232639477381794 - hostPath: path: /Users/ashok/wksps/hc/temp/test2/src/server.xml name: vol4920239289720818926 status: {}
and
apiVersion: apps/v1kind: Deploymentmetadata: annotations: move2kube.konveyor.io/service.expose: "true" creationTimestamp: null labels: move2kube.konveyor.io/network/integration: "true" move2kube.konveyor.io/service: mysql name: mysqlspec: replicas: 2 selector: matchLabels: move2kube.konveyor.io/service: mysql strategy: {} template: metadata: annotations: move2kube.konveyor.io/service.expose: "true" creationTimestamp: null labels: move2kube.konveyor.io/network/integration: "true" move2kube.konveyor.io/service: mysql name: mysql spec: containers: - env: - name: MYSQL_USER value: integrationdb - name: MYSQL_PASSWORD value: password - name: MYSQL_ROOT_PASSWORD value: password image: db:poc imagePullPolicy: Always name: mysql ports: - containerPort: 3306 protocol: TCP resources: {} volumeMounts: - mountPath: /var/lib/mysql name: vol17655897939759777588 restartPolicy: Always volumes: - name: vol17655897939759777588 persistentVolumeClaim: claimName: vol17655897939759777588status: {}
and
apiVersion: v1kind: PersistentVolumeClaimmetadata: creationTimestamp: null name: vol17655897939759777588spec: resources: requests: storage: 100Mi storageClassName: default volumeName: vol17655897939759777588status: {}
Essentially depending on your choice Move2Kube will create the appropriate artifacts for you.
You can check out how it works in https://konveyor.github.io/move2kube/tutorials/docker-compose/.