4 SCRIPTDIR="$(readlink -f $(dirname ${BASH_SOURCE[0]}))"
5 LIBDIR="${SCRIPTDIR}/../../env/lib"
7 source ${LIBDIR}/common.sh
11 Usage: $(basename $0) -n nodes.json -p provisioning.yaml >site.yaml
13 This tool assists in migrating ICN R5 and earlier configurations to R6
14 by translating an existing nodes.json and Provisioning resource YAML
15 into values files to provide to the ICN machine and cluster Helm
18 IMPORTANT: The tool is only intended to be a starting point. The
19 following limitations should be noted:
20 - The Kubernetes control plane endpoint must be explicitly specified
21 with the controlPlaneEndpoint and controlPlanePrefix values in the
23 - The value of image_name in nodes.json is ignored.
24 - The SSH authorized key that will copied to the provisioned nodes is
25 ${HOME}/.ssh/id_rsa.pub.
26 - spec.KUDPlugins in the Provisioning resource is ignored. This
27 functionality is accomplished in R6 with Flux.
29 After reviewing and updating the migrated site YAML as needed, the
30 YAML secrets may be encrypted with the below command before committing
31 to source control for use with Flux:
33 $(readlink -f ${SCRIPTDIR}/../../deploy/site/site.sh) sops-encrypt-site site.yaml key-name
46 apiVersion: source.toolkit.fluxcd.io/v1beta1
52 gitImplementation: go-git
57 url: https://gerrit.akraino.org/r/icn
59 list_nodes | while IFS=',' read -r name ipmi_username ipmi_password ipmi_address boot_mac os_username os_password os_image_name; do
62 apiVersion: helm.toolkit.fluxcd.io/v2beta1
78 node_machine_values | sed -e 's/^/ /'
82 apiVersion: helm.toolkit.fluxcd.io/v2beta1
85 name: $(provisioning_json | jq -r '.metadata.name')
98 cluster_values | sed -e 's/^/ /'
101 function cluster_values {
103 clusterName: $(cluster_name)
105 owner: $(provisioning_json | jq -r '.metadata.labels.owner')
106 provider: $(provisioning_json | jq -r '.metadata.labels.owner')
108 if [[ $(cluster_type) != "null" ]]; then
110 cluster-type: $(cluster_type)
114 numControlPlaneMachines: $(provisioning_json | jq -r '.spec.masters | length')
115 numWorkerMachines: $(provisioning_json | jq -r '.spec.workers | length')
116 controlPlaneEndpoint: # TODO
117 controlPlanePrefix: # TODO
118 controlPlaneHostSelector:
123 $(provisioning_json | jq -r '.spec.masters[] | keys[0]' | awk '{print " - " $0}')
129 $(provisioning_json | jq -r '.spec.workers[] | keys[0]' | awk '{print " - " $0}')
133 # url: https://gerrit.akraino.org/r/icn
135 # path: ./deploy/site/cluster-icn
139 function cluster_name {
140 provisioning_json | jq -r '.metadata.labels.cluster'
143 function cluster_type {
144 provisioning_json | jq -r '.metadata.labels."cluster-type"'
147 function provisioning_json {
148 cat ${PROVISIONING_YAML} | python3 -c 'import sys, yaml, json; print(json.dumps(yaml.safe_load(sys.stdin.read())))'
151 while getopts ":n:o:p:" opt; do
157 PROVISIONING_YAML=${OPTARG}
166 if [[ -z "${NODES_JSON}" ]] || [[ -z "${PROVISIONING_YAML}" ]]; then
170 export NODES_FILE=${NODES_JSON}