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

0 commit comments

Comments
 (0)