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

Error transforming Kubernetes objects #876

Closed
Arnold1 opened this issue Nov 27, 2017 · 31 comments · Fixed by #957 or #1244
Closed

Error transforming Kubernetes objects #876

Arnold1 opened this issue Nov 27, 2017 · 31 comments · Fixed by #957 or #1244

Comments

@Arnold1
Copy link

Arnold1 commented Nov 27, 2017

Hi,

i run into some issues with kompose when i run the following command. do you know what is wrong and how to resolve it?

kompose convert -f docker-compose.yml
WARN Unsupported links key - ignoring             
WARN Volume mount on the host "./alertmanager/alertmanager.yml" isn't supported - ignoring path on the host 
FATA Error transforming Kubernetes objects: k.UpdateController failed: updateTemplate failed: Unknown restart policy unless-stopped for servicealertmanager

docker-compose.yml:

version: "2"

services:

  prometheus-server:
    image: prom/prometheus
    ports:
      - 9090:9090
    volumes:
      - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
      - ./prometheus/alert.yml:/etc/prometheus/alert.yml
    links:
      - "alertmanager:alertmanager"

  alertmanager:
    image: prom/alertmanager
    restart: unless-stopped
    ports:
      - 9093:9093
    volumes:
      - ./alertmanager/alertmanager.yml:/etc/alertmanager/config.yml
    command:
      - '-config.file=/etc/alertmanager/config.yml'
      - '-storage.path=/alertmanager'
      - '-log.level=debug'

  grafana:
    image: grafana/grafana
    ports:
      - 3000:3000
    environment:
      - GF_SECURITY_ADMIN_PASSWORD=password
    links:
      - prometheus-server:prometheus

  go-mux-example:
    image: mux:v1
    ports:
      - 8080:8080
@cdrage
Copy link
Member

cdrage commented Nov 27, 2017

Thanks for pointing this out! Looks like unless-stopped isn't implemented. We should have a fix out this week 👍

@Arnold1
Copy link
Author

Arnold1 commented Nov 27, 2017

what happens if i remove the restart policy from the yml file?

here is what happens without the restart policy. how can i fix the warnings?

$ kompose convert -f docker-compose.yml
WARN Unsupported links key - ignoring             
WARN Volume mount on the host "./alertmanager/alertmanager.yml" isn't supported - ignoring path on the host 
WARN Volume mount on the host "./prometheus/prometheus.yml" isn't supported - ignoring path on the host 
WARN Volume mount on the host "./prometheus/alert.yml" isn't supported - ignoring path on the host 
INFO Kubernetes file "alertmanager-service.yaml" created 
INFO Kubernetes file "go-mux-example-service.yaml" created 
INFO Kubernetes file "grafana-service.yaml" created 
INFO Kubernetes file "prometheus-server-service.yaml" created 
INFO Kubernetes file "alertmanager-deployment.yaml" created 
INFO Kubernetes file "alertmanager-claim0-persistentvolumeclaim.yaml" created 
INFO Kubernetes file "go-mux-example-deployment.yaml" created 
INFO Kubernetes file "grafana-deployment.yaml" created 
INFO Kubernetes file "prometheus-server-deployment.yaml" created 
INFO Kubernetes file "prometheus-server-claim0-persistentvolumeclaim.yaml" created 
INFO Kubernetes file "prometheus-server-claim1-persistentvolumeclaim.yaml" created

how can i start the containers on my kubernetes with Minikube?
just run the following? kompose up

@cdrage
Copy link
Member

cdrage commented Nov 27, 2017

With regards to the warnings, yes, you're free to ignore them, but due to using host volumes, Kubernetes doesn't support it.

Yup! It should theoretically work (you may have to modify your volumes). Using minikube and doing kompose up will bring it up on Kubernetes.

EDIT: Yes, removing restart, or changing it to on-failure will resolve the errors.

@Arnold1
Copy link
Author

Arnold1 commented Nov 27, 2017

i installed minicube and can run the sample they have here:
https://github.com/kubernetes/minikube/blob/v0.22.3/README.md

i run into the following issue, any why it cannot startup?

$ kompose convert -f docker-compose.yml
WARN Unsupported links key - ignoring             
WARN Volume mount on the host "./alertmanager/alertmanager.yml" isn't supported - ignoring path on the host 
WARN Volume mount on the host "./prometheus/prometheus.yml" isn't supported - ignoring path on the host 
WARN Volume mount on the host "./prometheus/alert.yml" isn't supported - ignoring path on the host 
INFO Kubernetes file "go-mux-example-service.yaml" created 
INFO Kubernetes file "grafana-service.yaml" created 
INFO Kubernetes file "prometheus-server-service.yaml" created 
INFO Kubernetes file "alertmanager-pod.yaml" created 
INFO Kubernetes file "alertmanager-claim0-persistentvolumeclaim.yaml" created 
INFO Kubernetes file "go-mux-example-deployment.yaml" created 
INFO Kubernetes file "grafana-deployment.yaml" created 
INFO Kubernetes file "prometheus-server-deployment.yaml" created 
INFO Kubernetes file "prometheus-server-claim0-persistentvolumeclaim.yaml" created 
INFO Kubernetes file "prometheus-server-claim1-persistentvolumeclaim.yaml" created

$ kompose up
WARN Unsupported links key - ignoring             
WARN Volume mount on the host "./alertmanager/alertmanager.yml" isn't supported - ignoring path on the host 
WARN Volume mount on the host "./prometheus/prometheus.yml" isn't supported - ignoring path on the host 
WARN Volume mount on the host "./prometheus/alert.yml" isn't supported - ignoring path on the host 
INFO We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead. 
 
FATA Error while deploying application: Get https://192.168.99.100:8443/api: dial tcp 192.168.99.100:8443: getsockopt: operation timed out 

@cdrage
Copy link
Member

cdrage commented Nov 27, 2017

@Arnold1 for some reason Kompose isn't able to communicate to your Kubernetes cluster.

After you run "minikube start" are you able to access your cluster with kubectl? Ex. kubectl get pods ?

@Arnold1
Copy link
Author

Arnold1 commented Nov 27, 2017

i think i stopped minikube before...

here is what i get now, but only grafana is running. alertmanager, go-mux-example, prometheus-server seem to have issues to run?

$ minikube start
Starting local Kubernetes v1.8.0 cluster...
Starting VM...
Getting VM IP address...
Moving files into cluster...
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.

$ kompose up
WARN Unsupported links key - ignoring             
WARN Volume mount on the host "./alertmanager/alertmanager.yml" isn't supported - ignoring path on the host 
WARN Volume mount on the host "./prometheus/prometheus.yml" isn't supported - ignoring path on the host 
WARN Volume mount on the host "./prometheus/alert.yml" isn't supported - ignoring path on the host 
INFO We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead. 
 
INFO Deploying application in "default" namespace 
INFO Successfully created Service: go-mux-example 
INFO Successfully created Service: grafana        
INFO Successfully created Service: prometheus-server 
INFO Successfully created Pod: alertmanager       
INFO Successfully created PersistentVolumeClaim: alertmanager-claim0 of size 100Mi. If your cluster has dynamic storage provisioning, you don't have to do anything. Otherwise you have to create PersistentVolume to make PVC work 
INFO Successfully created Deployment: go-mux-example 
INFO Successfully created Deployment: grafana     
INFO Successfully created Deployment: prometheus-server 
INFO Successfully created PersistentVolumeClaim: prometheus-server-claim0 of size 100Mi. If your cluster has dynamic storage provisioning, you don't have to do anything. Otherwise you have to create PersistentVolume to make PVC work 
INFO Successfully created PersistentVolumeClaim: prometheus-server-claim1 of size 100Mi. If your cluster has dynamic storage provisioning, you don't have to do anything. Otherwise you have to create PersistentVolume to make PVC work 

Your application has been deployed to Kubernetes. You can run 'kubectl get deployment,svc,pods,pvc' for details.
$ kubectl get pods
NAME                                 READY     STATUS             RESTARTS   AGE
alertmanager                         0/1       CrashLoopBackOff   4          3m
go-mux-example-7c96ff7bfd-78dz7      0/1       ImagePullBackOff   0          3m
grafana-85f8b648d8-kqpj9             1/1       Running            0          3m
prometheus-server-6bc89bcb6f-4tvmk   0/1       CrashLoopBackOff   4          3m

$ kubectl get services
NAME                TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)          AGE
go-mux-example      ClusterIP   10.0.0.93    <none>        8080/TCP         7m
grafana             ClusterIP   10.0.0.11    <none>        3000/TCP         7m
kubernetes          ClusterIP   10.0.0.1     <none>        443/TCP          2h
prometheus-server   ClusterIP   10.0.0.130   <none>        9090/TCP         7m

$ kubectl get pods --all-namespaces 
NAMESPACE     NAME                                 READY     STATUS             RESTARTS   AGE
default       alertmanager                         0/1       CrashLoopBackOff   8          19m
default       go-mux-example-7c96ff7bfd-78dz7      0/1       ImagePullBackOff   0          19m
default       grafana-85f8b648d8-kqpj9             1/1       Running            0          19m
default       prometheus-server-6bc89bcb6f-4tvmk   0/1       CrashLoopBackOff   8          19m
kube-system   kube-addon-manager-minikube          1/1       Running            3          2h
kube-system   kube-dns-6fc954457d-swcln            3/3       Running            6          2h
kube-system   kubernetes-dashboard-b55k5           1/1       Running            2          2h

in the dashboard i see:
screen shot 2017-11-27 at 2 11 38 pm

screen shot 2017-11-27 at 2 12 57 pm

go-mux-example uses the mux image, which i build as follows: docker build -t mux:v1 .

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
mux                 v1                  4c514d3a0cc9        5 days ago          784MB

@Arnold1
Copy link
Author

Arnold1 commented Nov 29, 2017

@cdrage any idea?

@cdrage
Copy link
Member

cdrage commented Nov 29, 2017

@Arnold1 Unfortunately when it comes down to volumes within Docker Compose / Kompose, it get's fairly tricky.

Mind posting your full docker-compose example (the one you're using now) and we can go from there? Volumes are the worst part of this entire operation, very difficult to get right since some containers (such as prometheus) rely on them to be EXACT.

@Arnold1
Copy link
Author

Arnold1 commented Nov 29, 2017

@cdrage do you mean all the files?

@cdrage
Copy link
Member

cdrage commented Nov 29, 2017

@Arnold1 just your modified docker-compose.yaml file so I can test it my-side.

I've had a conversion with @kadel on how we could improve volumes, it's the trickiest part of Kompose unfortunately.

@Arnold1
Copy link
Author

Arnold1 commented Nov 29, 2017

@cdrage i added all files here: https://github.com/Arnold1/prometheus_kubernetes incl. docker-compose.yml

steps:

$ ./build_docker.sh
$ kompose convert -f docker-compose.yml
$ minikube start
$ kubectl delete --all deployments; kubectl delete --all pods; kubectl delete --all services; kubectl delete --all persistentvolumeclaims
$ kompose up

@cdrage can you reproduce it on your machine?

@surajnarwade
Copy link
Contributor

@Arnold1 , there's no Dockerfile in your repo :(

$ ./build_docker.sh 
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /tmp/arnold/prometheus_kubernetes/Dockerfile: no such file or directory

@Arnold1
Copy link
Author

Arnold1 commented Nov 30, 2017

@surajnarwade @cdrage I added the missing dockerfile. can you execute it now? please let me know.

@Arnold1
Copy link
Author

Arnold1 commented Dec 2, 2017

@cdrage is there a workaround for the meantime?

@cdrage
Copy link
Member

cdrage commented Dec 4, 2017

@Arnold1 Sorry, it's been quite a busy week for us, we're going to try and get around to it this week. It may involve modifying some of the containers since for some reason they like Docker Compose but now when it's on Kubernetes. I'll try your updated repo it soon 👍

@Arnold1
Copy link
Author

Arnold1 commented Dec 10, 2017

@cdrage any update?

@surajnarwade
Copy link
Contributor

surajnarwade commented Dec 11, 2017

@Arnold1 some of your services has volumes which may contain some file which are necessary for your applcation. Hence, status for your application is Crashloopbackoff, Recently I wrote a blog about sharing host directory into minkube (you can check blog here)

So first do kompose convert and generate kubernetes files and then edit those files accordingly with volume details

and push your image go mux to some registry and provide full name for docker image,
for example,

<registry_name>/<image_name>:tag

@Arnold1
Copy link
Author

Arnold1 commented Dec 11, 2017

@surajnarwade ok, i currently try to find a workaround. how can i make it work? im not sure how the volumes in the kubernetes files... would it work when i follow your blog?

why do you want to push the docker images to some registry? do you mean docker hub or what do you mean?

@Arnold1
Copy link
Author

Arnold1 commented Dec 16, 2017

@cdrage some time to look into? :)

@cdrage
Copy link
Member

cdrage commented Dec 18, 2017

@Arnold1 Sorry, I haven't found time to look into this yet :( I did have very brief look and as what @surajnarwade said, it's most likely because the containers are trying to retrieve information that's originally suppose to be passed in through volumes.

@Arnold1
Copy link
Author

Arnold1 commented Dec 18, 2017

i guess you have some time over christmas? :)
will reading and applying @surajnarwade article solve the issue? refering to: http://suraj.pro/post/hostmount-minikube/

@d-mcd
Copy link

d-mcd commented Jan 18, 2018

Any update on this? Same issue here when trying to convert from Docker Compose to Kubernetes for containerized applications that use volume mappings out to OS for persistent data.

Thanks

@cdrage
Copy link
Member

cdrage commented Jan 18, 2018

@d-mcd Unfortunately volumes is very tricky since it's a completely different concept within Kubernetes. One of the solutions is to create a hostPath volumes which were in the PR and issues here: #109 #734

We're still investigating and will most likely push a PR out for adding hostPath volumes by next release. It's a hack to get it working (hostPath volumes are only recommended for development), but it's a solution nevertheless.

@Arnold1
Copy link
Author

Arnold1 commented May 3, 2018

hi, just wondering what is the solution now? can i retry and test it? if so how?

@cdrage
Copy link
Member

cdrage commented May 8, 2018

@hangyan contributed the hostpath volume, so this is solved! 👍

@Arnold1
Copy link
Author

Arnold1 commented May 29, 2018

@Could you show how to run my example using the change he did?

@lmangani
Copy link

lmangani commented Jun 2, 2018

@Arnold1 the test compose file and command in the PR might help

@vikasgubbi
Copy link

@Arnold1 did you able to run successfully

@Arnold1
Copy link
Author

Arnold1 commented Oct 23, 2018

have not tested yet, how to test it with latest code?

@marner2
Copy link

marner2 commented Feb 19, 2020

I'm still getting the originally mentioned error: "Unknown restart policy unless-stopped for service" I'm using version 2.20. Did that ever get fixed?

@cdrage said in this comment from 2.5 years ago:

Thanks for pointing this out! Looks like unless-stopped isn't implemented. We should have a fix out this week 👍

EDIT: it looks like it only breaks if you're using version: '2' at the top. I was able to fix it in my specific case by changing it to version: '3'.

@hangyan
Copy link
Contributor

hangyan commented Feb 22, 2020

@marner2 If this a supported field in version 2, it's a bug. I will look up into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants