Azure / draft-classic

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

Draft generates outdated helm chart for python pack #952

Closed eyjohn closed 4 years ago

eyjohn commented 4 years ago

The charts generated were not compatible with modern versions of Helm/Kubernetes.

Steps to replicate:

$ mkdir drafttest && cd drafttest
$ touch requirements.txt app.py
$ draft create -p python
$ draft up
Draft Up Started: 'drafttest': 01DSE6J1HSGRXQKSATAS578Q1T
drafttest: Building Docker Image: SUCCESS ⚓  (7.0061s)
drafttest: Releasing Application: FAIL ❌  (1.5054s)
Inspect the logs with `draft logs 01DSE6J1HSGRXQKSATAS578Q1T`
Step 1/9 : FROM python
 ---> d6a7b0694364
Step 2/9 : ENV PORT 8080
 ---> Using cache
 ---> dd6e3c3d089d
Step 3/9 : EXPOSE 8080
 ---> Using cache
 ---> b50e30b0c444
Step 4/9 : WORKDIR /usr/src/app
 ---> Using cache
 ---> 933ee5cedba5
Step 5/9 : COPY requirements.txt ./
 ---> 98568ecdf7e9
Step 6/9 : RUN pip install --no-cache-dir -r requirements.txt
 ---> Running in 59688b4e4ffa
 ---> d4f33a4b32d2
Step 7/9 : COPY . .
 ---> c3da2eadaebf
Step 8/9 : ENTRYPOINT ["python"]
 ---> Running in a788ed1d0581
 ---> 8adf105c98c8
Step 9/9 : CMD ["app.py"]
 ---> Running in fca968ad9f58
 ---> 4a41e83ccca9
Successfully built 4a41e83ccca9
Successfully tagged drafttest:962ee57a08dda75893da8ccd41f887ebb2793c0f
2019/11/11 21:40:25 error while releasing: could not install release: rpc error: code = Unknown desc = validation failed: unable to recognize "": no matches for kind "Deployment" in version "extensions/v1beta1"

I had to make the following changes for it to work

diff --git a/charts/drafttest/templates/deployment.yaml b/charts/drafttest/templates/deployment.yaml
index 9139f99..fe5d3f6 100755
--- a/charts/drafttest/templates/deployment.yaml
+++ b/charts/drafttest/templates/deployment.yaml
@@ -1,4 +1,4 @@
-apiVersion: extensions/v1beta1
+apiVersion: apps/v1
 kind: Deployment
 metadata:
   name: {{ template "fullname" . }}
@@ -7,6 +7,10 @@ metadata:
     chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
 spec:
   replicas: {{ .Values.replicaCount }}
+  selector:
+    matchLabels:
+      draft: {{ default "draft-app" .Values.draft }}
+      app: {{ template "fullname" . }}
   template:
     metadata:
       annotations:
$ draft up
Draft Up Started: 'drafttest': 01DSE6XPT5RYNK0P73N624VVG2
drafttest: Building Docker Image: SUCCESS ⚓  (1.0011s)
drafttest: Releasing Application: SUCCESS ⚓  (20.2313s)
Inspect the logs with `draft logs 01DSE6XPT5RYNK0P73N624VVG2`

Versions:

$ draft version
&version.Version{SemVer:"v0.16.0", GitCommit:"5433afea1421810ae9d828631d8651de913b347a", GitTreeState:"dirty"}
$ helm version
Client: &version.Version{SemVer:"v2.15.0", GitCommit:"c2440264ca6c078a06e088a838b0476d2fc14750", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.15.0", GitCommit:"c2440264ca6c078a06e088a838b0476d2fc14750", GitTreeState:"clean"}
$ minikube.exe version
minikube version: v1.4.0 
commit: 7969c25a98a018b94ea87d949350f3271e9d64b6
(* Preparing Kubernetes v1.16.0 on Docker 18.09.9 ...)
bacongobbler commented 4 years ago

Duplicate of #937