Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/161 update UI stack #166

Open
wants to merge 38 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
fbe4f01
fix: project won't start on intel machine
AndreaDellaValle Apr 7, 2023
5d018ad
deps: allow yarn to run the old project
AndreaDellaValle Apr 7, 2023
3cf1198
feat: PoC calling APIs from localhost
AndreaDellaValle Apr 7, 2023
67930b8
feat: moved fe to a dedicated helm chart
AndreaDellaValle Apr 13, 2023
fce9fa9
feat: livereload on localhost dev env & code cleanup
AndreaDellaValle Apr 14, 2023
663e5a2
chore: removed UI steps from BE dockerfile
AndreaDellaValle Apr 14, 2023
003afd5
chore: cleanup dockerfiles and added nginx draft for production
AndreaDellaValle Apr 17, 2023
45e4be1
chore: added elastic ui and updated dependencies
AndreaDellaValle Apr 18, 2023
669daab
chore: update react render method with createRoot
AndreaDellaValle Apr 18, 2023
7ca74bb
feat: added new user list view as homepage
AndreaDellaValle Apr 18, 2023
3c9baa5
style: removed tailwind
AndreaDellaValle Apr 19, 2023
79a8372
feat: new users list home and header
AndreaDellaValle Apr 19, 2023
9eaa102
feat: new user creation page
AndreaDellaValle Apr 19, 2023
dc9180a
feaat: fixed new user creation UI
AndreaDellaValle Apr 21, 2023
d76a8b7
feat: form submit PART 1
AndreaDellaValle Apr 21, 2023
8a7f03a
chore: fixed form fields
AndreaDellaValle Apr 27, 2023
2caf007
feat: introduced react-query
AndreaDellaValle Apr 27, 2023
5698378
chore: wip on creating rolebinding
AndreaDellaValle Apr 27, 2023
d4d2c93
fix: typo in role-binding creation payload
AndreaDellaValle Apr 28, 2023
7e4c364
feat: namespace creation calls
AndreaDellaValle Apr 28, 2023
dc89e2f
updated react-quey
AndreaDellaValle May 2, 2023
680ddc7
chore: restored basic auth psw condition
AndreaDellaValle May 2, 2023
48ea93b
feat: user creation for single template
AndreaDellaValle May 2, 2023
be05031
feat: all namespaces checkbox
AndreaDellaValle May 3, 2023
816004f
feat: multiple templates PART 1
AndreaDellaValle May 3, 2023
4690bfb
feat: multiple templates PART 2
AndreaDellaValle May 4, 2023
9f65ad7
feat: multiple templates DONE
AndreaDellaValle May 4, 2023
65e0a43
chore: removed console.log
AndreaDellaValle May 4, 2023
78a4109
style: moved create user button to header
AndreaDellaValle May 5, 2023
f02929b
fix: added specific selector on backend service
AndreaDellaValle May 9, 2023
7541e95
chore: typo
AndreaDellaValle May 9, 2023
f7c702a
feat: return errors descriptions within the api responses
AndreaDellaValle May 9, 2023
30fb392
feat: errors and confirmation modals
AndreaDellaValle May 9, 2023
5073b9b
feat: username FE validation
AndreaDellaValle May 10, 2023
d91408b
feat: handled all namespaces case
AndreaDellaValle May 10, 2023
b253955
feat: dynamic roles retrieval
AndreaDellaValle May 11, 2023
1bd2890
feat: user edit view withuot cluster access
AndreaDellaValle May 12, 2023
d7f02d3
feat: retrieve and set cluster access data
AndreaDellaValle May 15, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ kind 0.17.0
kubectl 1.26.0
make 4.1
mkcert 1.4.4
nodejs 18.0.0
nodejs 16.20.0
shellcheck 0.9.0
tilt 0.31.1
yq 4.30.8
Expand Down
13 changes: 0 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
## UI ##
FROM node:18-alpine3.17 as ui-builder
RUN mkdir /app
COPY web-client /app

ENV NODE_OPTIONS=--openssl-legacy-provider

WORKDIR /app
RUN yarn install && yarn build

## BACKEND ##
FROM golang:1.19.5-alpine3.17 as go-base

Expand Down Expand Up @@ -39,15 +29,12 @@ RUN go mod download

COPY cmd cmd
COPY internal internal
COPY static static

FROM go-base as development
COPY --from=ui-builder /app/build /app/static/build

ENTRYPOINT ["go", "run", "cmd/run-server.go"]

FROM go-base as builder
COPY --from=ui-builder /app/build /app/static/build
RUN go build --tags=release -o permission-manager cmd/run-server.go

FROM scratch as release
Expand Down
25 changes: 25 additions & 0 deletions Dockerfile-ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## PERMISSION MANAGER UI ##

# DEVELOPMENT
FROM node:18-alpine3.17 as ui-development
RUN mkdir /app
COPY web-client /app

ENV NODE_OPTIONS=--openssl-legacy-provider

WORKDIR /app
RUN yarn install && yarn build

ENTRYPOINT ["yarn", "start"]

# RELEASE
# TODO test this draft and convert it for production
FROM nginx:latest as release

COPY --from=ui-development /app/build /usr/share/nginx/html

COPY --from=ui-development /app/nginx.conf etc/nginx/nginx.conf

EXPOSE 4001

CMD ["nginx", "-g", "daemon off;"]
30 changes: 28 additions & 2 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ docker_build_with_restart(
sync("./internal", "/app/internal"),
sync("./go.mod", "/app/go.mod"),
sync("./go.sum", "/app/go.sum"),
sync("./web-client", "/app/web-client"),
],
build_args={
"CLUSTER_NAME": os.getenv("CLUSTER_NAME"),
Expand All @@ -25,14 +24,32 @@ docker_build_with_restart(
entrypoint=["go", "run", "cmd/run-server.go"]
)

docker_build(
"permission-manager-ui-image:local-dev",
".",
dockerfile="Dockerfile-ui",
target="ui-development",
live_update=[
sync("./web-client", "/app/web-client"),
],
build_args={
"CLUSTER_NAME": os.getenv("CLUSTER_NAME"),
"CONTROL_PLANE_ADDRESS": os.getenv("CONTROL_PLANE_ADDRESS"),
"BASIC_AUTH_PASSWORD": os.getenv("BASIC_AUTH_PASSWORD"),
"NAMESPACE": os.getenv("NAMESPACE"),
"PORT": os.getenv("PORT"),
}
)

k8s_yaml(
helm(
'./helm_chart',
name='permission-manager',
namespace='permission-manager',
values='development/helm/values.yaml',
set=['config.controlPlaneAddress=' + os.getenv("CONTROL_PLANE_ADDRESS")]
))
)
)

k8s_resource(
workload="permission-manager",
Expand All @@ -42,3 +59,12 @@ k8s_resource(
# objects=[] + cms,
labels="control-plane"
)

k8s_resource(
workload="permission-manager-ui",
links=[
link("https://permission-manager.dev/", "permission-manager-ui"),
],
# objects=[] + cms,
labels="front-end"
)
4 changes: 3 additions & 1 deletion development/helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ ingress:
hosts:
- host: permission-manager.dev
paths:
- path: /
- path: /api/
pathType: ImplementationSpecific
tls:
- secretName: permission-manager.dev-tls
Expand Down Expand Up @@ -105,6 +105,8 @@ config:
# Password for basic auth to access the UI
basicAuthPassword: "admin"

initialDelaySeconds: 60

templates:
- name: operation
rules:
Expand Down
2 changes: 1 addition & 1 deletion development/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ function setup_certs {
# This function will start the ctlptl registry (which is local registry used by Tilt) and the kind cluster.
function start {
echo "Starting cluster and local registry..."
docker start permission-manager-kind-registry permission-manager-kind-control-plane
docker start permission-manager-kind-registry permission-manager-kind-control-plane permission-manager-ui
}
69 changes: 69 additions & 0 deletions helm_chart/templates/deployment-ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "permission-manager.fullname" . }}-ui
labels:
{{- include "permission-manager.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "permission-manager.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "permission-manager.selectorLabels" . | nindent 8 }}
permission-manager: ui
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "permission-manager.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: permission-manager-ui-image:local-dev
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
envFrom:
- secretRef:
name: {{ include "permission-manager.fullname" . }}
ports:
- name: http
containerPort: 4001
protocol: TCP
livenessProbe:
initialDelaySeconds: {{ .Values.config.initialDelaySeconds }}
tcpSocket:
port: 4001
readinessProbe:
tcpSocket:
port: 4001
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
2 changes: 2 additions & 0 deletions helm_chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ spec:
{{- end }}
labels:
{{- include "permission-manager.selectorLabels" . | nindent 8 }}
permission-manager: api
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
Expand Down Expand Up @@ -46,6 +47,7 @@ spec:
containerPort: 4000
protocol: TCP
livenessProbe:
initialDelaySeconds: {{ .Values.config.initialDelaySeconds }}
tcpSocket:
port: 4000
readinessProbe:
Expand Down
7 changes: 7 additions & 0 deletions helm_chart/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,12 @@ spec:
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
- path: /
pathType: ImplementationSpecific
backend:
service:
name: permission-manager-ui
port:
number: 80
{{- end }}
{{- end }}
21 changes: 21 additions & 0 deletions helm_chart/templates/service-ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
kind: Service
metadata:
name: permission-manager-ui
labels:
{{- include "permission-manager.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: 4001
protocol: TCP
name: http
{{- if .Values.service.nodePort }}
nodePort: {{ .Values.service.nodePort }}
{{- else }}
nodePort: null
{{- end }}
selector:
{{- include "permission-manager.selectorLabels" . | nindent 4 }}
permission-manager: ui
1 change: 1 addition & 0 deletions helm_chart/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ spec:
{{- end }}
selector:
{{- include "permission-manager.selectorLabels" . | nindent 4 }}
permission-manager: api
6 changes: 5 additions & 1 deletion helm_chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ ingress:
hosts:
- host: permission-manager.domain.com
paths:
- path: /
- path: /api/
pathType: ImplementationSpecific
# - path: /
# pathType: ImplementationSpecific
# tls:
# - secretName: permission-manager-tls
# hosts:
Expand Down Expand Up @@ -101,6 +103,8 @@ config:
# Password for basic auth to access the UI
basicAuthPassword: ""

initialDelaySeconds: 0

templates:
- name: operation
rules:
Expand Down
9 changes: 6 additions & 3 deletions internal/server/clusterrole.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package server

import (
"fmt"

"github.com/labstack/echo/v4"
rbacv1 "k8s.io/api/rbac/v1"
)
Expand All @@ -17,19 +19,20 @@ func createClusterRole(c echo.Context) error {
err := ac.validateAndBindRequest(r)

if err != nil {
return err
validateAndBindErr := fmt.Sprintf("Validate Cluster Role: %s", err)
return ac.errorResponse(validateAndBindErr)
}

_, err = ac.ResourceManager.ClusterRoleCreate(r.RoleName, r.Rules)

if err != nil {
return err
clusterRoleErr := fmt.Sprintf("Cluster Role creation: %s", err)
return ac.errorResponse(clusterRoleErr)
}

return ac.okResponse()
}


func deleteClusterRole(c echo.Context) error {
ac := c.(*AppContext)
type Request struct {
Expand Down
8 changes: 6 additions & 2 deletions internal/server/clusterrolebinding.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package server

import (
"fmt"

"github.com/labstack/echo/v4"
rbacv1 "k8s.io/api/rbac/v1"
)
Expand All @@ -19,7 +21,8 @@ func createClusterRolebinding(c echo.Context) error {
err := ac.validateAndBindRequest(r)

if err != nil {
return err
validateAndBindErr := fmt.Sprintf("Validate Cluster Role Binding: %s", err)
return ac.errorResponse(validateAndBindErr)
}

// This is only a workaround: https://github.com/sighupio/permission-manager/issues/140
Expand All @@ -32,7 +35,8 @@ func createClusterRolebinding(c echo.Context) error {
_, err = ac.ResourceManager.ClusterRoleBindingCreate(r.ClusterRolebindingName, r.Username, r.RoleName, subjs)

if err != nil {
return err
clusterRoleBindingErr := fmt.Sprintf("ClusterRoleBinding creation: %s", err)
return ac.errorResponse(clusterRoleBindingErr)
}

return ac.okResponse()
Expand Down
7 changes: 5 additions & 2 deletions internal/server/role.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package server

import (
"fmt"
"sighupio/permission-manager/internal/resources"

"github.com/labstack/echo/v4"
Expand Down Expand Up @@ -73,7 +74,8 @@ func createRoleBinding(c echo.Context) error {
err := ac.validateAndBindRequest(r)

if err != nil {
return err
validateAndBindErr := fmt.Sprintf("Validate Role: %s", err)
return ac.errorResponse(validateAndBindErr)
}

// This is only a workaround: https://github.com/sighupio/permission-manager/issues/140
Expand All @@ -91,7 +93,8 @@ func createRoleBinding(c echo.Context) error {
})

if err != nil {
return err
RoleErr := fmt.Sprintf("Role creation: %s", err)
return ac.errorResponse(RoleErr)
}

return ac.okResponse()
Expand Down
Loading