From f3c569549ced4eec2c7545c4d6a77f91c7f1e758 Mon Sep 17 00:00:00 2001 From: Mauran Date: Wed, 19 Jun 2024 01:08:13 +0200 Subject: [PATCH] feat: v3.0.0 Signed-off-by: Mauran --- api/main.go | 36 +++++++++++------------ kube/web/deployment.yaml | 62 ++++++++++++++++++++-------------------- kube/web/service.yaml | 30 +++++++++---------- 3 files changed, 63 insertions(+), 65 deletions(-) diff --git a/api/main.go b/api/main.go index 2c978e5..c2aeb12 100644 --- a/api/main.go +++ b/api/main.go @@ -2,7 +2,6 @@ package main import ( "database/sql" - "encoding/json" "fmt" "log" "net/http" @@ -10,7 +9,6 @@ import ( "time" "github.com/do3-2023/thomas-kube/dbHelper" - person "github.com/do3-2023/thomas-kube/struct" "github.com/do3-2023/thomas-kube/utils" "github.com/go-chi/chi/v5" "github.com/go-chi/chi/v5/middleware" @@ -185,25 +183,25 @@ func main() { // }) // Person POST - r.Post("/person", func(w http.ResponseWriter, r *http.Request) { - var Obj person.Person - err := json.NewDecoder(r.Body).Decode(&Obj) - if err != nil { - log.Println("Error decoding JSON:", err) - utils.Response(w, r, http.StatusInternalServerError, "Internal Server Error") - return - } + // r.Post("/person", func(w http.ResponseWriter, r *http.Request) { + // var Obj person.Person + // err := json.NewDecoder(r.Body).Decode(&Obj) + // if err != nil { + // log.Println("Error decoding JSON:", err) + // utils.Response(w, r, http.StatusInternalServerError, "Internal Server Error") + // return + // } - sqlStatement := `INSERT INTO person (last_name, phone_number, location) VALUES ($1, $2, $3)` - _, errQuery := db.Exec(sqlStatement, Obj.LastName, Obj.PhoneNumber, Obj.Location) - if errQuery != nil { - log.Println("Error executing SQL query:", errQuery) - utils.Response(w, r, http.StatusInternalServerError, "Internal Server Error") - return - } + // sqlStatement := `INSERT INTO person (last_name, phone_number, location) VALUES ($1, $2, $3)` + // _, errQuery := db.Exec(sqlStatement, Obj.LastName, Obj.PhoneNumber, Obj.Location) + // if errQuery != nil { + // log.Println("Error executing SQL query:", errQuery) + // utils.Response(w, r, http.StatusInternalServerError, "Internal Server Error") + // return + // } - utils.Response(w, r, http.StatusCreated, "Posted!") - }) + // utils.Response(w, r, http.StatusCreated, "Posted!") + // }) errServ := http.ListenAndServe(":" + APIPort, r) if errServ != nil { diff --git a/kube/web/deployment.yaml b/kube/web/deployment.yaml index f38d0cc..55a1eea 100644 --- a/kube/web/deployment.yaml +++ b/kube/web/deployment.yaml @@ -1,31 +1,31 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - labels: - app: webapp - name: webapp - namespace: frontend -spec: - replicas: 1 - selector: - matchLabels: - app: webapp - strategy: {} - template: - metadata: - labels: - app: webapp - spec: - containers: - - image: ghcr.io/do3-2023/thomas-kube-web:latest - name: thomas-kube-frontend - resources: - limits: {} - requests: - memory: 500Mi - cpu: 250m - initContainers: - - name: init-frontend - image: busybox - command: ['sh', '-c', 'until nc -zv backend-service.backend.svc.cluster.local 80; do echo waiting for API; sleep 2; done;'] -status: {} +# apiVersion: apps/v1 +# kind: Deployment +# metadata: +# labels: +# app: webapp +# name: webapp +# namespace: frontend +# spec: +# replicas: 1 +# selector: +# matchLabels: +# app: webapp +# strategy: {} +# template: +# metadata: +# labels: +# app: webapp +# spec: +# containers: +# - image: ghcr.io/do3-2023/thomas-kube-web:latest +# name: thomas-kube-frontend +# resources: +# limits: {} +# requests: +# memory: 500Mi +# cpu: 250m +# initContainers: +# - name: init-frontend +# image: busybox +# command: ['sh', '-c', 'until nc -zv backend-service.backend.svc.cluster.local 80; do echo waiting for API; sleep 2; done;'] +# status: {} diff --git a/kube/web/service.yaml b/kube/web/service.yaml index f00f271..f9dbf6f 100644 --- a/kube/web/service.yaml +++ b/kube/web/service.yaml @@ -1,16 +1,16 @@ -apiVersion: v1 -kind: Service -metadata: - name: webapp - namespace: frontend +# apiVersion: v1 +# kind: Service +# metadata: +# name: webapp +# namespace: frontend -spec: - selector: - app: webapp - ports: - - name: http - port: 80 - protocol: TCP - targetPort: 3000 - nodePort: 30080 - type: NodePort +# spec: +# selector: +# app: webapp +# ports: +# - name: http +# port: 80 +# protocol: TCP +# targetPort: 3000 +# nodePort: 30080 +# type: NodePort