Skip to content

Commit 3417f8d

Browse files
committed
Initial commit for AMT
1 parent 3c2f7b4 commit 3417f8d

40 files changed

+1897
-0
lines changed

infra-config/values.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ config:
2828
orchKeycloak: keycloak.kind.internal:443
2929
orchTelemetry: telemetry-node.kind.internal:443
3030
# TODO: remove below two lines
31+
orchMPSHost: mps-node.kind.internal:4433
32+
orchMPSWHost: mps-webport-node.kind.internal:443
33+
orchRPSHost: rps-node.kind.internal:443
34+
orchRPSWHost: rps-webport-node.kind.internal:443
35+
orchMPSRHost: mpsrouter-node.kind.internal:443
3136
orchTelemetryHost: telemetry-node.kind.internal
3237
orchTelemetryPort: 443
3338
orchRegistry: registry-rs.edgeorchestration.intel.com:9443

infra-onboarding/Chart.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ dependencies:
2828
condition: import.infra-config.enabled
2929
version: "0.5.1"
3030
repository: "file://../infra-config"
31+
- name: amt
32+
condition: import.amt.enabled
33+
version: "0.0.1"
34+
repository: "file://../amt"

infra-onboarding/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import:
1717
enabled: true
1818
infra-config:
1919
enabled: true
20+
amt:
21+
enabled: true
2022

2123
# Global values overrides
2224
# global:

mi-amt/Chart.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
# SPDX-FileCopyrightText: (C) 2024 Intel Corporation
3+
# SPDX-License-Identifier: LicenseRef-Intel
4+
5+
apiVersion: v2
6+
name: amt
7+
description: Edge Infrastructure Manager AMT
8+
type: application
9+
version: 0.0.1
10+
appVersion: "0.0.1"
11+
home: edge-orchestrator.intel.com
12+
maintainers:
13+
- name: Edge Infrastructure Manager Team
14+
dependencies:
15+
- name: mps
16+
version: "0.0.1"
17+
condition: amt-mps.enabled
18+
repository: "file://charts/mps"
19+
- name: mpsrouter
20+
version: "0.0.1"
21+
condition: amt-mpsrouter.enabled
22+
repository: "file://charts/mpsrouter"
23+
- name: rps
24+
version: "0.0.1"
25+
condition: amt-rps.enabled
26+
repository: "file://charts/rps"

mi-amt/charts/mps/Chart.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-FileCopyrightText: (C) 2023 Intel Corporation
2+
# SPDX-License-Identifier: LicenseRef-Intel
3+
4+
apiVersion: v2
5+
name: mps
6+
description: Edge Infrastructure Manager AMT MPS
7+
type: application
8+
version: 0.0.1
9+
appVersion: "0.0.1"
10+
annotations: {}
11+
home: edge-orchestrator.intel.com
12+
maintainers:
13+
- name: Edge Infrastructure Manager Team

mi-amt/charts/mps/init.sql

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/*********************************************************************
2+
* Copyright (c) Intel Corporation 2020
3+
* SPDX-License-Identifier: Apache-2.0
4+
**********************************************************************/
5+
CREATE EXTENSION IF NOT EXISTS citext;
6+
CREATE USER mpsdb;
7+
CREATE TABLE IF NOT EXISTS ciraconfigs(
8+
cira_config_name citext NOT NULL,
9+
mps_server_address varchar(256),
10+
mps_port integer,
11+
user_name varchar(40),
12+
password varchar(63),
13+
common_name varchar(256),
14+
server_address_format integer,
15+
auth_method integer,
16+
mps_root_certificate text,
17+
proxydetails text,
18+
tenant_id varchar(36) NOT NULL,
19+
PRIMARY KEY (cira_config_name, tenant_id)
20+
);
21+
CREATE TABLE IF NOT EXISTS ieee8021xconfigs(
22+
profile_name citext,
23+
auth_protocol integer,
24+
servername VARCHAR(255),
25+
domain VARCHAR(255),
26+
username VARCHAR(255),
27+
password VARCHAR(255),
28+
roaming_identity VARCHAR(255),
29+
active_in_s0 BOOLEAN,
30+
pxe_timeout integer,
31+
wired_interface BOOLEAN NOT NULL,
32+
tenant_id varchar(36) NOT NULL,
33+
PRIMARY KEY (profile_name, tenant_id)
34+
);
35+
CREATE TABLE IF NOT EXISTS wirelessconfigs(
36+
wireless_profile_name citext NOT NULL,
37+
authentication_method integer,
38+
encryption_method integer,
39+
ssid varchar(32),
40+
psk_value integer,
41+
psk_passphrase varchar(63),
42+
link_policy int[],
43+
creation_date timestamp,
44+
created_by varchar(40),
45+
tenant_id varchar(36) NOT NULL,
46+
ieee8021x_profile_name citext,
47+
FOREIGN KEY (ieee8021x_profile_name,tenant_id) REFERENCES ieee8021xconfigs(profile_name,tenant_id),
48+
PRIMARY KEY (wireless_profile_name, tenant_id)
49+
);
50+
CREATE TABLE IF NOT EXISTS profiles(
51+
profile_name citext NOT NULL,
52+
activation varchar(20) NOT NULL,
53+
amt_password varchar(40),
54+
generate_random_password BOOLEAN NOT NULL,
55+
cira_config_name citext,
56+
FOREIGN KEY (cira_config_name,tenant_id) REFERENCES ciraconfigs(cira_config_name,tenant_id),
57+
creation_date timestamp,
58+
created_by varchar(40),
59+
mebx_password varchar(40),
60+
generate_random_mebx_password BOOLEAN NOT NULL,
61+
tags text[],
62+
dhcp_enabled BOOLEAN,
63+
ip_sync_enabled BOOLEAN NULL,
64+
local_wifi_sync_enabled BOOLEAN NULL,
65+
tenant_id varchar(36) NOT NULL,
66+
tls_mode integer NULL,
67+
user_consent varchar(7) NULL,
68+
ider_enabled BOOLEAN NULL,
69+
kvm_enabled BOOLEAN NULL,
70+
sol_enabled BOOLEAN NULL,
71+
tls_signing_authority varchar(40) NULL,
72+
ieee8021x_profile_name citext,
73+
FOREIGN KEY (ieee8021x_profile_name,tenant_id) REFERENCES ieee8021xconfigs(profile_name,tenant_id),
74+
PRIMARY KEY (profile_name, tenant_id)
75+
);
76+
CREATE TABLE IF NOT EXISTS profiles_wirelessconfigs(
77+
wireless_profile_name citext,
78+
profile_name citext,
79+
FOREIGN KEY (wireless_profile_name,tenant_id) REFERENCES wirelessconfigs(wireless_profile_name,tenant_id),
80+
FOREIGN KEY (profile_name,tenant_id) REFERENCES profiles(profile_name,tenant_id),
81+
priority integer,
82+
creation_date timestamp,
83+
created_by varchar(40),
84+
tenant_id varchar(36) NOT NULL,
85+
PRIMARY KEY (wireless_profile_name, profile_name, priority, tenant_id)
86+
);
87+
CREATE TABLE IF NOT EXISTS domains(
88+
name citext NOT NULL,
89+
domain_suffix citext NOT NULL,
90+
provisioning_cert text,
91+
provisioning_cert_storage_format varchar(40),
92+
provisioning_cert_key text,
93+
creation_date timestamp,
94+
expiration_date timestamp,
95+
created_by varchar(40),
96+
tenant_id varchar(36) NOT NULL,
97+
CONSTRAINT domainname UNIQUE (name, tenant_id),
98+
CONSTRAINT domainsuffix UNIQUE (domain_suffix, tenant_id),
99+
PRIMARY KEY (name, domain_suffix, tenant_id)
100+
);
101+

mi-amt/charts/mps/initMPS.sql

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*********************************************************************
2+
* Copyright (c) Intel Corporation 2021
3+
* SPDX-License-Identifier: Apache-2.0
4+
**********************************************************************/
5+
CREATE DATABASE mpsdb;
6+
7+
\connect mpsdb
8+
9+
CREATE TABLE IF NOT EXISTS devices(
10+
guid uuid NOT NULL,
11+
tags text[],
12+
hostname varchar(256),
13+
mpsinstance text,
14+
connectionstatus boolean,
15+
mpsusername text,
16+
tenantid varchar(36) NOT NULL,
17+
friendlyname varchar(256),
18+
dnssuffix varchar(256),
19+
lastconnected timestamp with time zone,
20+
lastseen timestamp with time zone,
21+
lastdisconnected timestamp with time zone,
22+
deviceinfo JSON,
23+
CONSTRAINT device_guid UNIQUE(guid),
24+
PRIMARY KEY (guid, tenantid)
25+
);
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# SPDX-FileCopyrightText: (C) 2023 Intel Corporation
2+
# SPDX-License-Identifier: LicenseRef-Intel
3+
{{/*
4+
Expand the name of the chart.
5+
*/}}
6+
{{- define "mps.name" -}}
7+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
8+
{{- end }}
9+
10+
{{/*
11+
Create a default fully qualified app name.
12+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
13+
If release name contains chart name it will be used as a full name.
14+
*/}}
15+
{{- define "mps.fullname" -}}
16+
{{- if .Values.fullnameOverride }}
17+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
18+
{{- else }}
19+
{{- $name := default .Chart.Name .Values.nameOverride }}
20+
{{- if contains $name .Release.Name }}
21+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
22+
{{- else }}
23+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
24+
{{- end }}
25+
{{- end }}
26+
{{- end }}
27+
28+
{{/*
29+
Create chart name and version as used by the chart label.
30+
*/}}
31+
{{- define "mps.chart" -}}
32+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
33+
{{- end }}
34+
35+
{{/*
36+
Common labels
37+
*/}}
38+
{{- define "mps.labels" -}}
39+
helm.sh/chart: {{ include "mps.chart" . }}
40+
{{ include "mps.selectorLabels" . }}
41+
{{- if .Chart.AppVersion }}
42+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
43+
{{- end }}
44+
app.kubernetes.io/managed-by: {{ .Release.Service }}
45+
app: mps
46+
{{- end }}
47+
48+
{{/*
49+
Selector labels
50+
*/}}
51+
{{- define "mps.selectorLabels" -}}
52+
app.kubernetes.io/name: {{ include "mps.name" . }}
53+
app.kubernetes.io/instance: {{ .Release.Name }}
54+
app: mps
55+
{{- end }}

mi-amt/charts/mps/templates/cm.yaml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
# SPDX-FileCopyrightText: (C) 2024 Intel Corporation
3+
# SPDX-License-Identifier: LicenseRef-Intel
4+
5+
apiVersion: v1
6+
kind: ConfigMap
7+
metadata:
8+
name: amt-configmap
9+
data:
10+
amt.sh: |
11+
#!/bin/bash
12+
13+
# DO NOT MODIFY - SEE DESCRIPTION
14+
15+
# Script Name: amt-vault.sh
16+
# Description: This script will accquire the service token to login to vault,
17+
# fetch the vault token to create secret.
18+
# Usage: ./onboard_fm_credentials.sh <KEYCLOAK_URL> <VAULT_URL>
19+
# -h: help (optional)
20+
21+
set -xe
22+
set -o pipefail
23+
24+
HELP=""
25+
26+
while getopts 'h' flag; do
27+
case "${flag}" in
28+
h) HELP='true' ;;
29+
*) HELP='true' ;;
30+
esac
31+
done
32+
shift $((OPTIND -1))
33+
34+
function usage {
35+
cat >&2 <<EOF
36+
Purpose:
37+
Creation of secret for MPS and RPS services.
38+
39+
Usage:
40+
$(basename "$0") <KEYCLOAK_URL> <VAULT_URL>
41+
42+
ex:
43+
./onboard_fm_credentials.sh http://localhost:8090 http://localhost:8200
44+
45+
Options:
46+
-h: help (optional)
47+
EOF
48+
}
49+
50+
KEYCLOAK_URL=$1
51+
VAULT_URL=$2
52+
53+
if [[ "$HELP" || -z "$KEYCLOAK_URL" || -z "$VAULT_URL" || -z "$ADMIN_USER" || -z "$ADMIN_PASS" || -z "$ADMIN_CLIENT" ]]; then
54+
usage
55+
exit 1
56+
fi
57+
58+
# Operation in vault are retried up to $max_retries times
59+
max_retries=5
60+
retry_count=0
61+
# Login to Vault
62+
TOKEN=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token)
63+
while [ "$retry_count" -lt $max_retries ]; do
64+
if vault_login_output=$(curl -k -X PUT \
65+
"$VAULT_URL/v1/auth/kubernetes/login" \
66+
-H "Authorization: Bearer $TOKEN" \
67+
-d '{"jwt": "'"${TOKEN}"'", "role": "orch-svc"}') && \
68+
[[ ! "$vault_login_output" =~ "errors" ]]; then
69+
echo "Vault login successful!"
70+
VAULT_TOKEN=$(echo "$vault_login_output" | jq -r '.auth.client_token')
71+
break
72+
fi
73+
echo "ERROR: $vault_login_output"
74+
sleep 10
75+
retry_count=$((retry_count + 1))
76+
done
77+
78+
if [ $retry_count -eq $max_retries ]; then
79+
echo "ERROR: Too many errors in logging into Vault!"
80+
exit 1
81+
fi
82+
83+
retry_count=0
84+
while [ "$retry_count" -lt $max_retries ]; do
85+
if curl -k -X POST \
86+
"https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1/namespaces/orch-infra/secrets" \
87+
-H "Authorization: Bearer $TOKEN" \
88+
-H "Content-Type: application/json" \
89+
-d '{
90+
"apiVersion": "v1",
91+
"kind": "Secret",
92+
"metadata": {
93+
"name": "vault-token"
94+
},
95+
"data": {
96+
"vault-token": "'$(echo -n "$VAULT_TOKEN" | base64 -w0)'"
97+
}
98+
}'; then
99+
echo "Vault token secret created successfully!"
100+
break
101+
else
102+
echo "Error creating vault token secret, retrying..."
103+
sleep 10
104+
retry_count=$((retry_count + 1))
105+
fi
106+
done
107+
108+
109+
# If Istio proxy is available, quit sidecar
110+
if curl -s -f http://127.0.0.1:15020/healthz/ready; then
111+
response=$(curl -o /dev/null -w "%{http_code}" --location -v --request POST http://127.0.0.1:15000/quitquitquit --header 'Content-Type: text/plain')
112+
if [[ ! "${response}" =~ "200" ]]; then
113+
echo "ERROR: Error while quiting Istio proxy"
114+
exit 1
115+
fi
116+
fi

0 commit comments

Comments
 (0)