Azure / draft-classic

A tool for developers to create cloud-native applications on Kubernetes.
https://draft.sh
MIT License
3.92k stars 397 forks source link

help wanted: draft up failing with `invalid reference format` #830

Closed nasreddineskandrani closed 6 years ago

nasreddineskandrani commented 6 years ago

Hi, I did a setup of minikube to get a kubernetes cluster running locally like 2 days ago. I used this repo that i forked: https://github.com/nasreddineskandrani/minions I am able to see the deployment of this example minions java app in kubernetes dashboard and access the java app when i follow the steps from the README file of this repo.

Now when i try to use draft inside the same minions project (i want to streamline the dev cycle). as mentionned here: https://azure.microsoft.com/en-ca/blog/streamlining-kubernetes-development-with-draft/ When i reach the step: draft up i have an error (please check the image attach.)

draftup_fail

Question1 why draft up is failing with ...invalid reference format....?

Question2 how i can debug this kind of errors?

Question3 Can someone tell me if with draft up it's right to expect a deployment to be done in the local kubernetes cluster and java app to be accessible?

bjornmagnusson commented 6 years ago

I tried that repo with draft, and seems to be working. Draft Up Started: 'minions': 01CHEB1WBGQ76ZE0CZ1BMAY8GD minions: Building Docker Image: SUCCESS ⚓ (167.0839s) minions: Releasing Application: SUCCESS ⚓ (8.4211s) Inspect the logs with draft logs 01CHEB1WBGQ76ZE0CZ1BMAY8GD

From your image it states "chart directory already exists". Maybe try removing it and try again?

nasreddineskandrani commented 6 years ago

Thanks for trying! at least i know i have something wrong my side.

I removed chart folder and retried => not working (I am using docker toolbox since i am in a desktop win10 Home Edition maybe it affects).

After executing draft init, draft create, draft up do i need to do something to target my local kubernetes cluster in the generated files?

bacongobbler commented 6 years ago

Nope! Draft will use your existing kubeconfig (like kubectl) to target your cluster.

bjornmagnusson commented 6 years ago

Can you give us a output of draft logs , exact command is stated during your draft up

nasreddineskandrani commented 6 years ago

@bjornmagnusson the output is the last line of the printscreen i posted. Their is nothing more than that.

So if it's using the same file as my kubectl create how it knows which one.

In the readme file of the example project i am using, they ask to do:

docker build . -t minion
kubectl create -f minion-army.yml

@bacongobbler i supply explicitly the file name in kubectl create command to deploy. => how draft knows which file it has to use to deploy? what is existing kubeconfig for you the .yml file from the example project?

bjornmagnusson commented 6 years ago

Draft does not use the yaml file available in the repo. Under the hood it uses the Helm Chart (collection of yaml files) created by the draft create command, available in the charts folder.

But the failing step is the building of the Docker image, which is done before the deployment into the cluster. Somehow the docker image name being create is invalid / malformed (decided by Docker)

bjornmagnusson commented 6 years ago

Can you output the folder structure (for example with the use of tree) and the content of the draft.toml file?

nasreddineskandrani commented 6 years ago

note: docker build . => working with the new generated dockerfile by draft create ^^. but draft up failing on image build :/

Files-------------

Dockerfile

FROM maven:3.5-jdk-8 as BUILD

COPY . /usr/src/app
RUN mvn --batch-mode -f /usr/src/app/pom.xml clean package

FROM openjdk:8-jdk
ENV PORT 4567
EXPOSE 4567
COPY --from=BUILD /usr/src/app/target /opt/target
WORKDIR /opt/target

CMD ["/bin/bash", "-c", "find -type f -name '*-with-dependencies.jar' | xargs java -jar"]

draft.toml

[environments]
  [environments.development]
    name = "minions"
    namespace = "default"
    wait = true
    watch = false
    watch-delay = 2
    auto-connect = false
    dockerfile = ""
    chart = ""

tree

Folder PATH listing
C:.
│   .dockerignore
│   .draft-tasks.toml
│   .draftignore
│   .gitignore
│   Dockerfile
│   draft.toml
│   mvnw
│   mvnw.cmd
│   pom.xml
│   README.md
│
├───charts
│   └───java
│       │   .helmignore
│       │   Chart.yaml
│       │   values.yaml
│       │
│       ├───charts
│       └───templates
│               deployment.yaml
│               ingress.yaml
│               NOTES.txt
│               service.yaml
│               _helpers.tpl
│
└───src
    ├───main
    │   ├───java
    │   │   └───org
    │   │       └───minions
    │   │           └───demo
    │   │                   Application.java
    │   │                   Controller.java
    │   │                   MinionsLibrary.java
    │   │
    │   └───resources
    │           application.properties
    │
    └───test
        └───java
            └───org
                └───minions
                    └───demo
                            ApplicationTests.java
bjornmagnusson commented 6 years ago

OK, looks fine. Actually very hard to debug this.

@bacongobbler Is there any situation where the sha256 generated in Azure/draft/pkg/builder/builder.go could potentially be an empty string? Maybe in case of some kind of failure or windows quirk? If that would be the case, then the image name would be testtest: which would cause the docker daemon to object with the above error message.

bacongobbler commented 6 years ago

It's possible that the registry name may be mis-configured, causing the image name to be invalid. It's not that informative of an error, sorry 😭

Can you show the output of draft config get registry, and the output of draft up/draft logs one more time? Thanks for being so patient while we try to nail this down!

bjornmagnusson commented 6 years ago

Maybe even the full output of draft config list?

nasreddineskandrani commented 6 years ago
draft config get registry
http://192.168.99.100:30000

draft up
Draft Up Started: 'minions': 01CHKZ5ZW1N0DYMB0WE3T9THRC
minions: Building Docker Image: FAIL ❌  (1.0018s)
Inspect the logs with `draft logs 01CHKZ5ZW1N0DYMB0WE3T9THRC`

draft logs
2018/07/04 20:58:57 error while building: Error response from daemon: invalid reference format

draft config list
KEY             VALUE
registry        http://192.168.99.100:30000
bacongobbler commented 6 years ago

That's it. Remove the http:// from the registry name and it should work.

bacongobbler commented 6 years ago

So it should be draft config set registry 192.168.99.100:30000

nasreddineskandrani commented 6 years ago

cool it's solved with @bacongobbler suggestion! the docker build is ok now! i don't really need to know why not the http:// for now :) but if you can explain it or share a link about it, i am interested. image

thank you all