2 Revize 546c564109 ... ee26f4d43f

Autor SHA1 Zpráva Datum
  iwanhae ee26f4d43f update rbac před 1 rokem
  iwanhae 077678a24a add Dockerfile před 1 rokem

+ 11 - 1
Dockerfile

@@ -1,3 +1,11 @@
+FROM node:18 as web-builder
+WORKDIR /workspace
+COPY frontend/package.json .
+COPY frontend/package-lock.json .
+RUN npm install
+COPY frontend/. .
+RUN npm run build
+
 # Build the manager binary
 FROM golang:1.20 as builder
 ARG TARGETOS
@@ -14,7 +22,8 @@ RUN go mod download
 # Copy the go source
 COPY cmd/main.go cmd/main.go
 COPY api/ api/
-COPY internal/controller/ internal/controller/
+COPY internal/ internal/
+COPY pkg/ pkg/
 
 # Build
 # the GOARCH has not a default value to allow the binary be built according to the host where the command
@@ -28,6 +37,7 @@ RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o ma
 FROM gcr.io/distroless/static:nonroot
 WORKDIR /
 COPY --from=builder /workspace/manager .
+COPY --from=web-builder /workspace/build/. ./frontend/build/.
 USER 65532:65532
 
 ENTRYPOINT ["/manager"]

+ 14 - 14
config/rbac/kustomization.yaml

@@ -1,18 +1,18 @@
 resources:
-# All RBAC will be applied under this service account in
-# the deployment namespace. You may comment out this resource
-# if your manager will use a service account that exists at
-# runtime. Be sure to update RoleBinding and ClusterRoleBinding
-# subjects if changing service account names.
-- service_account.yaml
-- role.yaml
-- role_binding.yaml
-- leader_election_role.yaml
-- leader_election_role_binding.yaml
+  # All RBAC will be applied under this service account in
+  # the deployment namespace. You may comment out this resource
+  # if your manager will use a service account that exists at
+  # runtime. Be sure to update RoleBinding and ClusterRoleBinding
+  # subjects if changing service account names.
+  - service_account.yaml
+  - role.yaml
+  - role_binding.yaml
+  - leader_election_role.yaml
+  - leader_election_role_binding.yaml
 # Comment the following 4 lines if you want to disable
 # the auth proxy (https://github.com/brancz/kube-rbac-proxy)
 # which protects your /metrics endpoint.
-- auth_proxy_service.yaml
-- auth_proxy_role.yaml
-- auth_proxy_role_binding.yaml
-- auth_proxy_client_clusterrole.yaml
+# - auth_proxy_service.yaml
+# - auth_proxy_role.yaml
+# - auth_proxy_role_binding.yaml
+# - auth_proxy_client_clusterrole.yaml

+ 3 - 0
config/rbac/role.yaml

@@ -11,13 +11,16 @@ rules:
   verbs:
   - create
   - get
+  - list
   - watch
 - apiGroups:
   - ""
   resources:
   - services
   verbs:
+  - create
   - get
+  - list
   - watch
 - apiGroups:
   - database.iwanhae.kr

+ 10 - 0
frontend/package-lock.json

@@ -9,6 +9,7 @@
 			"version": "0.0.1",
 			"devDependencies": {
 				"@sveltejs/adapter-auto": "^2.0.0",
+				"@sveltejs/adapter-static": "^2.0.3",
 				"@sveltejs/kit": "^1.20.4",
 				"autoprefixer": "^10.4.16",
 				"eslint": "^8.28.0",
@@ -609,6 +610,15 @@
 				"@sveltejs/kit": "^1.0.0"
 			}
 		},
+		"node_modules/@sveltejs/adapter-static": {
+			"version": "2.0.3",
+			"resolved": "https://registry.npmjs.org/@sveltejs/adapter-static/-/adapter-static-2.0.3.tgz",
+			"integrity": "sha512-VUqTfXsxYGugCpMqQv1U0LIdbR3S5nBkMMDmpjGVJyM6Q2jHVMFtdWJCkeHMySc6mZxJ+0eZK3T7IgmUCDrcUQ==",
+			"dev": true,
+			"peerDependencies": {
+				"@sveltejs/kit": "^1.5.0"
+			}
+		},
 		"node_modules/@sveltejs/kit": {
 			"version": "1.26.0",
 			"resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.26.0.tgz",

+ 1 - 0
frontend/package.json

@@ -13,6 +13,7 @@
 	},
 	"devDependencies": {
 		"@sveltejs/adapter-auto": "^2.0.0",
+		"@sveltejs/adapter-static": "^2.0.3",
 		"@sveltejs/kit": "^1.20.4",
 		"autoprefixer": "^10.4.16",
 		"eslint": "^8.28.0",

+ 2 - 1
frontend/src/routes/+layout.js

@@ -1 +1,2 @@
-export const ssr = false;
+export const ssr = false;
+export const prerender = true

+ 1 - 1
frontend/svelte.config.js

@@ -1,4 +1,4 @@
-import adapter from '@sveltejs/adapter-auto';
+import adapter from '@sveltejs/adapter-static';
 import { vitePreprocess } from '@sveltejs/kit/vite';
 
 /** @type {import('@sveltejs/kit').Config} */

+ 1 - 0
go.mod

@@ -13,6 +13,7 @@ require (
 )
 
 require (
+	github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
 	github.com/labstack/gommon v0.4.0 // indirect
 	github.com/mattn/go-colorable v0.1.13 // indirect
 	github.com/mattn/go-isatty v0.0.19 // indirect

+ 2 - 0
go.sum

@@ -42,6 +42,8 @@ github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEe
 github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
 github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
 github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
+github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
+github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
 github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
 github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=

+ 1 - 0
internal/controller/postgresql_controller.go

@@ -51,6 +51,7 @@ type PostgreSQLReconciler struct {
 //+kubebuilder:rbac:groups=database.iwanhae.kr,resources=postgresqls/status,verbs=get;update;patch
 //+kubebuilder:rbac:groups=database.iwanhae.kr,resources=postgresqls/finalizers,verbs=update
 //+kubebuilder:rbac:groups="",resources=pods,verbs=get;create
+//+kubebuilder:rbac:groups="",resources=services,verbs=get;create
 
 // Reconcile is part of the main kubernetes reconciliation loop which aims to
 // move the current state of the cluster closer to the desired state.

+ 1 - 1
internal/controller/postgresql_pod_controller.go

@@ -36,7 +36,7 @@ type PostgreSQLPodReconciler struct {
 	Scheme *runtime.Scheme
 }
 
-//+kubebuilder:rbac:groups="",resources=pods,verbs=watch;get
+//+kubebuilder:rbac:groups="",resources=pods,verbs=watch;get;list
 //+kubebuilder:rbac:groups=database.iwanhae.kr,resources=postgresqls/status,verbs=get;update;patch
 
 func (r *PostgreSQLPodReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, err error) {

+ 1 - 1
internal/controller/postgresql_svc_controller.go

@@ -35,7 +35,7 @@ type PostgreSQLServiceReconciler struct {
 	Scheme *runtime.Scheme
 }
 
-//+kubebuilder:rbac:groups="",resources=services,verbs=watch;get
+//+kubebuilder:rbac:groups="",resources=services,verbs=watch;get;list
 //+kubebuilder:rbac:groups=database.iwanhae.kr,resources=postgresqls/status,verbs=get;update;patch
 
 func (r *PostgreSQLServiceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ctrl.Result, err error) {

+ 5 - 0
internal/server/init.go

@@ -4,6 +4,7 @@ import (
 	"net/http"
 
 	"github.com/labstack/echo/v4"
+	"github.com/labstack/echo/v4/middleware"
 )
 
 func NewServer(s Server) *echo.Echo {
@@ -17,6 +18,10 @@ func NewServer(s Server) *echo.Echo {
 			return nil
 		}
 	})
+	e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
+		Root:  "frontend/build",
+		HTML5: true,
+	}))
 	e.GET("/api", s.watchUpdates)
 	e.POST("/api/:type", s.create)
 	e.DELETE("/api/:type/:namespace/:name", s.delete)