about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2024-04-29 22:17:41 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2024-04-29 22:45:11 +0200
commit14c229c8e3c2a3e1c381747f556c78b0a15ef402 (patch)
tree462d902c79205f05b81059747727c1b283bd8f7e
parentSwitch to k3s from kind (diff)
downloadfs-tracer-backend-14c229c8e3c2a3e1c381747f556c78b0a15ef402.tar.gz
fs-tracer-backend-14c229c8e3c2a3e1c381747f556c78b0a15ef402.tar.bz2
fs-tracer-backend-14c229c8e3c2a3e1c381747f556c78b0a15ef402.zip
Create dummy rest-api service
-rw-r--r--k8s/rest-api/README.md1
-rw-r--r--k8s/rest-api/templates/service.yaml2
-rw-r--r--k8s/rest-api/values.yaml4
-rw-r--r--src/rest-api/Dockerfile11
-rwxr-xr-xsrc/rest-api/build-and-push-to-registry.sh1
-rw-r--r--src/rest-api/cmd/main.go11
6 files changed, 25 insertions, 5 deletions
diff --git a/k8s/rest-api/README.md b/k8s/rest-api/README.md
new file mode 100644
index 0000000..4381b6f
--- /dev/null
+++ b/k8s/rest-api/README.md
@@ -0,0 +1 @@
+helm upgrade rest-api --set image.tag=$(git rev-parse --short HEAD) .
diff --git a/k8s/rest-api/templates/service.yaml b/k8s/rest-api/templates/service.yaml
index 12994b1..e8deb79 100644
--- a/k8s/rest-api/templates/service.yaml
+++ b/k8s/rest-api/templates/service.yaml
@@ -8,7 +8,7 @@ spec:
   type: {{ .Values.service.type }}
   ports:
     - port: 9999
-      targetPort: 80
+      targetPort: 8080
       protocol: TCP
       name: http
   selector:
diff --git a/k8s/rest-api/values.yaml b/k8s/rest-api/values.yaml
index e444f95..550eb82 100644
--- a/k8s/rest-api/values.yaml
+++ b/k8s/rest-api/values.yaml
@@ -5,7 +5,7 @@
 replicaCount: 1
 
 image:
-  repository: nginx
+  repository: docker.io/baitinq/fs-tracer
   pullPolicy: IfNotPresent
   # Overrides the image tag whose default is the chart appVersion.
   tag: ""
@@ -38,7 +38,7 @@ securityContext: {}
 
 service:
   type: LoadBalancer
-  port: 80
+  port: 8080
 
 ingress:
   enabled: false
diff --git a/src/rest-api/Dockerfile b/src/rest-api/Dockerfile
new file mode 100644
index 0000000..b8eccf0
--- /dev/null
+++ b/src/rest-api/Dockerfile
@@ -0,0 +1,11 @@
+FROM golang
+
+WORKDIR /app
+
+COPY . /app
+
+RUN go build cmd/main.go
+
+EXPOSE 8080
+
+CMD ["/app/main"]
diff --git a/src/rest-api/build-and-push-to-registry.sh b/src/rest-api/build-and-push-to-registry.sh
new file mode 100755
index 0000000..a132b7d
--- /dev/null
+++ b/src/rest-api/build-and-push-to-registry.sh
@@ -0,0 +1 @@
+docker buildx build -t docker.io/baitinq/fs-tracer:$(git rev-parse --short HEAD) --push .
diff --git a/src/rest-api/cmd/main.go b/src/rest-api/cmd/main.go
index 94fb4bc..bfeb752 100644
--- a/src/rest-api/cmd/main.go
+++ b/src/rest-api/cmd/main.go
@@ -1,7 +1,14 @@
 package main
 
-import "fmt"
+import (
+	"fmt"
+	"net/http"
+)
 
 func main() {
-  fmt.Println("Hi!")
+  http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+  fmt.Fprint(w, "Hello, World!")
+ })
+
+  http.ListenAndServe(":8080", nil)
 }