Skip to content

Commit 7d8177a

Browse files
salt: Add build and deploy states for shell-ui
1 parent 7d03649 commit 7d8177a

File tree

25 files changed

+296
-35
lines changed

25 files changed

+296
-35
lines changed

buildchain/buildchain/image.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ def _operator_image(name: str, **kwargs: Any) -> targets.OperatorImage:
240240
name="salt-master",
241241
build_args={"SALT_VERSION": versions.SALT_VERSION},
242242
),
243+
_local_image(
244+
name="shell-ui",
245+
build_context=ROOT / "shell-ui",
246+
dockerfile=ROOT / "shell-ui" / "Dockerfile",
247+
file_dep=(list(coreutils.ls_files_rec(ROOT / "shell-ui"))),
248+
),
243249
_local_image(
244250
name="metalk8s-ui",
245251
build_context=config.BUILD_ROOT,

buildchain/buildchain/salt_tree.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def _get_parts(self) -> Iterator[str]:
191191
SCALITY_LOGO: Path = constants.UI_ASSETS / "login/logo.png"
192192
SCALITY_FAVICON: Path = constants.UI_ASSETS / "login/favicon.png"
193193
LOGIN_STYLE: Path = constants.UI_ASSETS / "login/styles.css"
194-
UI_THEME_OPTIONS: Path = constants.UI_BRANDING / "theme.json"
194+
UI_THEME_OPTIONS: Path = constants.ROOT / "shell-ui" / "theme.json"
195195

196196
# List of salt files to install.
197197
SALT_FILES: Tuple[Union[Path, targets.AtomicTarget], ...] = (
@@ -367,11 +367,16 @@ def _get_parts(self) -> Iterator[str]:
367367
Path("salt/metalk8s/addons/ui/deployed/init.sls"),
368368
Path("salt/metalk8s/addons/ui/deployed/files/metalk8s-ui-deployment.yaml"),
369369
Path("salt/metalk8s/addons/ui/deployed/namespace.sls"),
370+
Path("salt/metalk8s/addons/ui/deployed/ui.sls"),
371+
Path("salt/metalk8s/addons/shell-ui/deployed/ingress.sls"),
372+
Path("salt/metalk8s/addons/shell-ui/deployed/init.sls"),
373+
Path("salt/metalk8s/addons/shell-ui/deployed/files/shell-ui-deployment.yaml"),
374+
Path("salt/metalk8s/addons/shell-ui/deployed/namespace.sls"),
370375
targets.TemplateFile(
371-
task_name="salt/metalk8s/addons/ui/deployed/ui.sls",
372-
source=constants.ROOT.joinpath("salt/metalk8s/addons/ui/deployed/ui.sls.in"),
376+
task_name="salt/metalk8s/addons/shell-ui/deployed/shell-ui.sls",
377+
source=constants.ROOT.joinpath("salt/metalk8s/addons/shell-ui/deployed/shell-ui.sls.in"),
373378
destination=constants.ISO_ROOT.joinpath(
374-
"salt/metalk8s/addons/ui/deployed/ui.sls"
379+
"salt/metalk8s/addons/shell-ui/deployed/shell-ui.sls"
375380
),
376381
context={
377382
"ThemeConfig": textwrap.indent(

buildchain/buildchain/versions.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,11 @@ def _version_prefix(version: str, prefix: str = "v") -> str:
202202
version=VERSION,
203203
digest=None,
204204
),
205+
Image(
206+
name="shell-ui",
207+
version=VERSION,
208+
digest=None,
209+
),
205210
Image(
206211
name="metalk8s-utils",
207212
version=VERSION,

images/metalk8s-ui/conf/nginx.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ server {
3232
alias /etc/metalk8s/ui/config/config.json;
3333
}
3434

35-
# Use the theme provided by the customer
35+
# Use the theme provided by the customer TODO discards this once it is managed by the navbar
3636
location ~ /brand/(.+) {
3737
alias /;
3838
try_files /etc/metalk8s/ui/brand/$1 /usr/share/nginx/html/brand/$1 =404;
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{%- from "metalk8s/repo/macro.sls" import build_image_name with context -%}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: shell-ui
6+
namespace: metalk8s-ui
7+
labels:
8+
app: shell-ui
9+
heritage: metalk8s
10+
app.kubernetes.io/name: shell-ui
11+
app.kubernetes.io/component: shell-ui
12+
app.kubernetes.io/part-of: metalk8s
13+
app.kubernetes.io/managed-by: salt
14+
spec:
15+
selector:
16+
matchLabels:
17+
app: shell-ui
18+
template:
19+
metadata:
20+
labels:
21+
app: shell-ui
22+
spec:
23+
tolerations:
24+
- key: "node-role.kubernetes.io/bootstrap"
25+
operator: "Exists"
26+
effect: "NoSchedule"
27+
- key: "node-role.kubernetes.io/infra"
28+
operator: "Exists"
29+
effect: "NoSchedule"
30+
nodeSelector:
31+
kubernetes.io/os: linux
32+
node-role.kubernetes.io/infra: ''
33+
containers:
34+
- name: shell-ui
35+
image: {{ build_image_name('shell-ui') }}
36+
imagePullPolicy: IfNotPresent
37+
resources:
38+
limits:
39+
memory: 170Mi
40+
requests:
41+
cpu: 100m
42+
memory: 70Mi
43+
ports:
44+
- containerPort: 80
45+
name: http
46+
protocol: TCP
47+
livenessProbe:
48+
httpGet:
49+
path: /shell/health
50+
port: http
51+
scheme: HTTP
52+
readinessProbe:
53+
httpGet:
54+
path: /shell/health
55+
port: http
56+
scheme: HTTP
57+
volumeMounts:
58+
- name: shell-ui-volume
59+
mountPath: /etc/metalk8s/shell-ui
60+
readOnly: true
61+
- name: ui-branding-volume
62+
mountPath: /etc/metalk8s/shell-ui
63+
readOnly: true
64+
volumes:
65+
- name: shell-ui-volume
66+
configMap:
67+
name: shell-ui
68+
- name: ui-branding-volume
69+
configMap:
70+
name: ui-branding
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#! metalk8s_kubernetes
2+
---
3+
apiVersion: networking.k8s.io/v1beta1
4+
kind: Ingress
5+
metadata:
6+
name: shell-ui
7+
namespace: metalk8s-ui
8+
labels:
9+
app: shell-ui
10+
app.kubernetes.io/managed-by: salt
11+
app.kubernetes.io/name: shell-ui
12+
app.kubernetes.io/part-of: metalk8s
13+
heritage: metalk8s
14+
annotations:
15+
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
16+
nginx.ingress.kubernetes.io/rewrite-target: /shell/$2
17+
kubernetes.io/ingress.class: "nginx-control-plane"
18+
spec:
19+
rules:
20+
- http:
21+
paths:
22+
- path: /shell(/|$)(.*)
23+
backend:
24+
serviceName: shell-ui
25+
servicePort: 80
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
include:
2+
- .namespace
3+
- .shell-ui
4+
- .ingress
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#! metalk8s_kubernetes
2+
3+
kind: Namespace
4+
apiVersion: v1
5+
metadata:
6+
name: metalk8s-ui
7+
labels:
8+
app.kubernetes.io/managed-by: salt
9+
app.kubernetes.io/part-of: metalk8s
10+
heritage: metalk8s
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
include:
2+
- .namespace
3+
4+
# Todo see how to deal with workload plane config
5+
{%- from "metalk8s/addons/nginx-ingress-control-plane/control-plane-ip.sls"
6+
import ingress_control_plane with context
7+
%}
8+
9+
Create shell-ui deployment:
10+
metalk8s_kubernetes.object_present:
11+
- name: salt://{{ slspath }}/files/shell-ui-deployment.yaml
12+
- template: jinja
13+
14+
Create shell-ui service:
15+
metalk8s_kubernetes.object_present:
16+
- manifest:
17+
apiVersion: v1
18+
kind: Service
19+
metadata:
20+
name: shell-ui
21+
namespace: metalk8s-ui
22+
labels:
23+
run: shell-ui
24+
spec:
25+
ports:
26+
- port: 80
27+
protocol: TCP
28+
targetPort: 80
29+
selector:
30+
app: shell-ui
31+
type: ClusterIP
32+
33+
Create shell-ui ConfigMap:
34+
metalk8s_kubernetes.object_present:
35+
- manifest:
36+
apiVersion: v1
37+
kind: ConfigMap
38+
metadata:
39+
name: shell-ui
40+
namespace: metalk8s-ui
41+
data:
42+
config.json: |
43+
{
44+
"docUrl": "/docs",
45+
"oidc": {
46+
"providerUrl": "/oidc",
47+
"redirectUrl": "https://{{ ingress_control_plane }}",
48+
"clientId": "metalk8s-ui",
49+
"responseType": "id_token",
50+
"scopes": "openid profile email groups offline_access audience:server:client_id:oidc-auth-client"
51+
}
52+
}
53+
54+
Create ui-branding ConfigMap:
55+
metalk8s_kubernetes.object_present:
56+
- manifest:
57+
apiVersion: v1
58+
kind: ConfigMap
59+
metadata:
60+
name: ui-branding
61+
namespace: metalk8s-ui
62+
data:
63+
theme.json: |-
64+
@@ThemeConfig

salt/metalk8s/addons/ui/deployed/ui.sls.in renamed to salt/metalk8s/addons/ui/deployed/ui.sls

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,6 @@ Create metalk8s-ui ConfigMap:
4444
"url_salt": "/api/salt",
4545
"url_prometheus": "/api/prometheus",
4646
"url_grafana": "/grafana",
47-
"url_oidc_provider": "/oidc",
48-
"url_redirect": "https://{{ ingress_control_plane }}",
4947
"url_doc": "/docs",
5048
"url_alertmanager": "/api/alertmanager"
5149
}
52-
53-
Create ui-branding ConfigMap:
54-
metalk8s_kubernetes.object_present:
55-
- manifest:
56-
apiVersion: v1
57-
kind: ConfigMap
58-
metadata:
59-
name: ui-branding
60-
namespace: metalk8s-ui
61-
data:
62-
theme.json: |-
63-
@@ThemeConfig

salt/metalk8s/deployed.sls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ include:
99
- metalk8s.addons.nginx-ingress-control-plane.deployed
1010
- metalk8s.addons.volumes.deployed
1111
- metalk8s.addons.solutions.deployed
12+
- metalk8s.addons.shell-ui.deployed
1213
- metalk8s.addons.ui.deployed
1314
- metalk8s.addons.dex.deployed
1415
- metalk8s.addons.prometheus-adapter.deployed

shell-ui/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ WORKDIR /usr/share/nginx/html/
2121
RUN rm -rf ./*
2222
RUN mkdir shell
2323
COPY health ./shell
24-
COPY conf/config.json /config.json
24+
RUN mkdir -p /etc/metalk8s/shell-ui
25+
COPY conf/config.json /etc/metalk8s/shell-ui/config.json
2526
COPY entrypoint.sh /entrypoint.sh
2627
RUN chmod +x /entrypoint.sh
2728
COPY --from=build-step /home/node/dist ./shell

shell-ui/conf/config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"docUrl": "/docs",
3+
"oidc": {
4+
"providerUrl": "https://{ip}:8443/oidc",
5+
"redirectUrl": "https://{ip}:8443",
6+
"clientId": "metalk8s-ui",
7+
"responseType": "id_token",
8+
"scopes": "openid profile email groups offline_access audience:server:client_id:oidc-auth-client"
9+
}
10+
}

shell-ui/entrypoint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
# vim:sw=4:ts=4:et
3+
set -x
4+
CONFIG=$(sed -e ':a;N;$!ba;s/\n/ /g' /etc/metalk8s/shell-ui/config.json | sed -e 's/"/\\\\"/g')
5+
sed -i "s#%CONFIG%#${CONFIG}#g" $(pwd)/shell/solution-ui-navbar.*.js
6+
7+
/docker-entrypoint.sh "$@"

shell-ui/health

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"status": "ok"
3+
}

shell-ui/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ type Config = {
4141
};
4242

4343
// %CONFIG% is replaced at image boot by a provided configuration
44-
const jsonConfig = '%CONFIG%' || '{}';
44+
const jsonConfig = process.env.NODE_ENV === 'development' ? '{}' : '%CONFIG%' || '{}';
4545
const config: Config = JSON.parse(jsonConfig);
4646

4747
const SolutionsNavbar = ({

shell-ui/theme.json

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"theme":{
3+
"light":{
4+
"brand":{
5+
"alert": "#A39300",
6+
"base": "#607080",
7+
"primary": "#FAF9FB",
8+
"primaryDark1": "#F7F6F9",
9+
"primaryDark2": "#EDEAF0",
10+
"secondary": "#037AFF",
11+
"secondaryDark1": "#1C3D59",
12+
"secondaryDark2": "#1C2E3F",
13+
"success": "#006F62",
14+
"healthy": "#24871D",
15+
"healthyLight": "#33A919",
16+
"warning": "#946F00",
17+
"danger": "#AA1D05",
18+
"critical": "#BE321F",
19+
"background": "#ffffff",
20+
"backgroundBluer": "#ECF4FF",
21+
"textPrimary": "#313B44",
22+
"textSecondary": "#8593A0",
23+
"textTertiary": "#A7B6C3",
24+
"borderLight": "#EBEBEB",
25+
"border": "#A5A5A5",
26+
"info": "#8C8C8C"
27+
},
28+
"logo_path":"/brand/assets/branding-light.svg"
29+
},
30+
"dark":{
31+
"brand":{
32+
"alert": "#FFE508",
33+
"base": "#7B7B7B",
34+
"primary": "#1D1D1D",
35+
"primaryDark1": "#171717",
36+
"primaryDark2": "#0A0A0A",
37+
"secondary": "#055DFF",
38+
"secondaryDark1": "#1C3D59",
39+
"secondaryDark2": "#1C2E3F",
40+
"success": "#006F62",
41+
"healthy": "#30AC26",
42+
"healthyLight": "#69E44C",
43+
"warning": "#FFC10A",
44+
"danger": "#AA1D05",
45+
"critical": "#BE321F",
46+
"background": "#121212",
47+
"backgroundBluer": "#192A41",
48+
"textPrimary": "#FFFFFF",
49+
"textSecondary": "#B5B5B5",
50+
"textTertiary": "#DFDFDF",
51+
"borderLight": "#A5A5A5",
52+
"border": "#313131",
53+
"info": "#434343"
54+
},
55+
"logo_path":"/brand/assets/branding-dark.svg"
56+
},
57+
"custom":{}
58+
},
59+
"default": "dark"
60+
}
61+

shell-ui/webpack.config.dev.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const HtmlWebPackPlugin = require("html-webpack-plugin");
2+
const {DefinePlugin} = require("webpack")
23
module.exports = {
34
mode: "development",
45
devtool: "source-map",
@@ -24,8 +25,13 @@ module.exports = {
2425
historyApiFallback: true
2526
},
2627
plugins: [
28+
new DefinePlugin({
29+
'process.env': {
30+
NODE_ENV: JSON.stringify('development')
31+
}
32+
}),
2733
new HtmlWebPackPlugin({
2834
template: "./index-template.html",
29-
}),
35+
})
3036
],
3137
};

0 commit comments

Comments
 (0)