AETHER-2098 Enable install of versioned charts from repo

Change-Id: I1f756a5114c86d3cd91c2603952b1892d155a361
diff --git a/Makefile b/Makefile
index 35952ee..a17129b 100644
--- a/Makefile
+++ b/Makefile
@@ -17,16 +17,16 @@
 K8S_VERSION	?= v1.18.9
 HELM_VERSION	?= v3.2.4
 
-# used to start logging/monitoring and other infrastructure charts
-INFRA_CHARTS	?=
-INFRA_PREREQS   = $(foreach chart,$(INFRA_CHARTS),$(M)/$(chart))
-
-KAFKA_CHART_VERSION ?= 0.13.3
-KAFKA_POD	:= "pod/cord-kafka-0"
-
 HELM_GLOBAL_ARGS ?=
-HELM_NEM_ARGS	?= $(HELM_GLOBAL_ARGS)
-HELM_ONOS_ARGS	?= $(HELM_GLOBAL_ARGS)
+
+# Allow installing local charts or specific versions of published charts.
+# E.g., to install the Aether 1.5 release:
+#    CHARTS=release-1.5 make test
+# Default is to install from the local charts.
+CHARTS     ?= local
+CONFIGFILE := configs/$(CHARTS)
+include $(CONFIGFILE)
+include configs/authentication
 
 cpu_family	:= $(shell lscpu | grep 'CPU family:' | awk '{print $$3}')
 cpu_model	:= $(shell lscpu | grep 'Model:' | awk '{print $$2}')
@@ -118,6 +118,12 @@
 $(M)/helm-ready: | $(M)/k8s-ready
 	helm repo add incubator https://charts.helm.sh/incubator
 	helm repo add cord https://charts.opencord.org
+	helm repo add atomix https://charts.atomix.io
+	helm repo add onosproject https://charts.onosproject.org
+	if [ "$(REPO_PASSWORD)" ]; then \
+		helm repo add aether --username ${REPO_USERNAME} --password ${REPO_PASSWORD} https://charts.aetherproject.org; \
+		helm repo add sdran --username ${REPO_USERNAME} --password ${REPO_PASSWORD} https://sdrancharts.onosproject.org; \
+	fi
 	touch $@
 
 /opt/cni/bin/simpleovs: | $(M)/k8s-ready
@@ -140,55 +146,65 @@
 	sudo ip route replace 192.168.252.0/24 via 192.168.251.1 dev enb
 	kubectl apply -f $(RESOURCEDIR)/router.yaml
 	kubectl wait pod -n default --for=condition=Ready -l app=router --timeout=300s
-	kubectl -n default exec router ip route add 172.250.0.0/16 via 192.168.250.3
+	kubectl -n default exec router -- ip route add 172.250.0.0/16 via 192.168.250.3
 	kubectl delete net-attach-def core-net
 	touch $@
 
-$(M)/omec: | $(M)/helm-ready /opt/cni/bin/simpleovs /opt/cni/bin/static $(M)/fabric
+registry-secret: $(RESOURCEDIR)/aether.registry.yaml
+$(RESOURCEDIR)/aether.registry.yaml:
+	kubectl -n omec create secret docker-registry aether.registry \
+		--docker-server=https://registry.aetherproject.org \
+		--docker-username=${REGISTRY_USERNAME} \
+		--docker-password=${REGISTRY_CLI_SECRET} \
+		--dry-run=client --output=yaml > $@
+
+$(M)/omec: | $(M)/helm-ready /opt/cni/bin/simpleovs /opt/cni/bin/static $(M)/fabric $(RESOURCEDIR)/aether.registry.yaml
 	kubectl get namespace omec 2> /dev/null || kubectl create namespace omec
+	kubectl -n omec get secret aether.registry || kubectl create -f $(RESOURCEDIR)/aether.registry.yaml
 	helm repo update
-	helm dep up $(WORKSPACE)/cord/aether-helm-charts/omec/omec-control-plane
+	if [ "$(CHARTS)" == "local" ]; then helm dep up $(OMEC_CONTROL_PLANE_CHART); fi
 	helm upgrade --install $(HELM_GLOBAL_ARGS) \
 		--namespace omec \
 		--values $(AIABVALUES) \
 		omec-control-plane \
-		$(WORKSPACE)/cord/aether-helm-charts/omec/omec-control-plane && \
+		$(OMEC_CONTROL_PLANE_CHART) && \
 	kubectl wait pod -n omec --for=condition=Ready -l release=omec-control-plane --timeout=300s && \
 	helm upgrade --install $(HELM_GLOBAL_ARGS) \
 		--namespace omec \
 		--values $(AIABVALUES) \
 		omec-user-plane \
-		$(WORKSPACE)/cord/aether-helm-charts/omec/omec-user-plane && \
+		$(OMEC_USER_PLANE_CHART) && \
 	kubectl wait pod -n omec --for=condition=Ready -l release=omec-user-plane --timeout=300s
 	touch $@
 
-$(M)/5g-core: | $(M)/helm-ready /opt/cni/bin/simpleovs /opt/cni/bin/static $(M)/fabric
+$(M)/5g-core: | $(M)/helm-ready /opt/cni/bin/simpleovs /opt/cni/bin/static $(M)/fabric $(RESOURCEDIR)/aether.registry.yaml
 	kubectl get namespace omec 2> /dev/null || kubectl create namespace omec
+	kubectl -n omec get secret aether.registry || kubectl creates -f $(RESOURCEDIR)/aether.registry.yaml
 	helm repo update
-	helm dep up $(WORKSPACE)/cord/aether-helm-charts/omec/5g-control-plane
+	if [ "$(CHARTS)" == "local" ]; then helm dep up $(5GC_CONTROL_PLANE_CHART); fi
 	helm upgrade --install $(HELM_GLOBAL_ARGS) \
 		--namespace omec \
 		--values $(AIABVALUES) \
 		sim-app \
-		$(WORKSPACE)/cord/aether-helm-charts/omec/omec-sub-provision && \
+		$(OMEC_SUB_PROVISION_CHART) && \
 	kubectl wait pod -n omec --for=condition=Ready -l release=sim-app --timeout=300s
 	helm upgrade --install $(HELM_GLOBAL_ARGS) \
 		--namespace omec \
 		--values $(AIABVALUES) \
 		5g-core-up \
-		$(WORKSPACE)/cord/aether-helm-charts/omec/omec-user-plane && \
+		$(OMEC_USER_PLANE_CHART) && \
 	kubectl wait pod -n omec --for=condition=Ready -l release=5g-core-up --timeout=300s
 	helm upgrade --install $(HELM_GLOBAL_ARGS) \
 		--namespace omec \
 		--values $(AIABVALUES) \
 		fgc-core \
-		$(WORKSPACE)/cord/aether-helm-charts/omec/5g-control-plane && \
+		$(5GC_CONTROL_PLANE_CHART) && \
 	kubectl wait pod -n omec --for=condition=Ready -l release=fgc-core --timeout=300s && \
 	helm upgrade --install $(HELM_GLOBAL_ARGS) \
 		--namespace omec \
 		--values $(AIABVALUES) \
 		5g-ransim-plane \
-		$(WORKSPACE)/cord/aether-helm-charts/omec/5g-ran-sim && \
+		$(5G_RAN_SIM_CHART) && \
 	kubectl wait pod -n omec --for=condition=Ready -l release=5g-ransim-plane --timeout=300s
 	touch $@
 
diff --git a/configs/authentication b/configs/authentication
new file mode 100644
index 0000000..e8cd76a
--- /dev/null
+++ b/configs/authentication
@@ -0,0 +1,12 @@
+# Copyright 2021-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+# Configure auth for private Helm repos.  Override with your credentials.
+REPO_USERNAME := onfstaff
+REPO_PASSWORD :=
+
+# Configure auth for private Docker registry.  Override with credentials
+# obtained from https://registry.aetherproject.org.
+REGISTRY_USERNAME   := myuser
+REGISTRY_CLI_SECRET := my-cli-secret
\ No newline at end of file
diff --git a/configs/latest b/configs/latest
new file mode 100644
index 0000000..0ddf53e
--- /dev/null
+++ b/configs/latest
@@ -0,0 +1,9 @@
+# Copyright 2021-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+OMEC_CONTROL_PLANE_CHART := aether/omec-control-plane
+OMEC_USER_PLANE_CHART    := aether/omec-user-plane
+OMEC_SUB_PROVISION_CHART := aether/omec-sub-provision
+5GC_CONTROL_PLANE_CHART  := aether/5g-control-plane
+5G_RAN_SIM_CHART         := aether/5g-ran-sim
\ No newline at end of file
diff --git a/configs/local b/configs/local
new file mode 100644
index 0000000..f0ecf6f
--- /dev/null
+++ b/configs/local
@@ -0,0 +1,9 @@
+# Copyright 2021-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+OMEC_CONTROL_PLANE_CHART := $(WORKSPACE)/cord/aether-helm-charts/omec/omec-control-plane
+OMEC_USER_PLANE_CHART    := $(WORKSPACE)/cord/aether-helm-charts/omec/omec-user-plane
+OMEC_SUB_PROVISION_CHART := $(WORKSPACE)/cord/aether-helm-charts/omec/omec-sub-provision
+5GC_CONTROL_PLANE_CHART  := $(WORKSPACE)/cord/aether-helm-charts/omec/5g-control-plane
+5G_RAN_SIM_CHART         := $(WORKSPACE)/cord/aether-helm-charts/omec/5g-ran-sim
\ No newline at end of file
diff --git a/configs/rc-1.5 b/configs/rc-1.5
new file mode 100644
index 0000000..c655621
--- /dev/null
+++ b/configs/rc-1.5
@@ -0,0 +1,9 @@
+# Copyright 2021-present Open Networking Foundation
+#
+# SPDX-License-Identifier: LicenseRef-ONF-Member-Only-1.0
+
+OMEC_CONTROL_PLANE_CHART := aether/omec-control-plane --version 0.6.23
+OMEC_USER_PLANE_CHART    := aether/omec-user-plane --version 0.3.33
+OMEC_SUB_PROVISION_CHART := aether/omec-sub-provision --version 0.0.6
+5GC_CONTROL_PLANE_CHART  := aether/5g-control-plane --version 0.2.20
+5G_RAN_SIM_CHART         := aether/5g-ran-sim --version 0.0.2
\ No newline at end of file