Commit 777ab8a6 authored by Kevin Di Lallo's avatar Kevin Di Lallo
Browse files

sandbox pods list passed to virt-engine using environment variable

parent 4f7156ef
Loading
Loading
Loading
Loading
+29 −20
Original line number Diff line number Diff line
@@ -31,15 +31,35 @@ repo:
          - -mod=vendor
        codecov: true
        lint: true
        monitor: true
        api: go-apps/meep-mon-engine/api/swagger.yaml
        dependency-pods:
          - meep-couchdb
          - meep-docker-registry
          - meep-grafana
          - meep-ingress
          - meep-influxdb
          - meep-kube-state-metrics
          - meep-open-map-tiles
          - meep-postgis
          - meep-redis
        core-pods:
          - meep-mon-engine
          - meep-platform-ctrl
          - meep-virt-engine
          - meep-webhook
        sandbox-pods:
          - meep-loc-serv
          - meep-metrics-engine
          - meep-mg-manager
          - meep-rnis
          - meep-sandbox-ctrl
          - meep-tc-engine
      meep-platform-ctrl:
        src: go-apps/meep-platform-ctrl
        bin: bin/meep-platform-ctrl
        chart: charts/meep-platform-ctrl
        codecov: true
        lint: true
        monitor: true
        api: go-apps/meep-platform-ctrl/api/swagger.yaml
        docker-data:
          swagger: bin/meep-platform-swagger-ui
@@ -50,7 +70,6 @@ repo:
        chart: charts/meep-virt-engine
        codecov: true
        lint: true
        monitor: true
        docker-data:
          'entrypoint.sh': go-apps/meep-virt-engine/entrypoint.sh
          meep-loc-serv: charts/meep-loc-serv
@@ -60,6 +79,13 @@ repo:
          meep-sandbox-ctrl: charts/meep-sandbox-ctrl
          meep-tc-engine: charts/meep-tc-engine
          meep-virt-chart-templates: charts/meep-virt-chart-templates
        sandbox-pods:
          - meep-loc-serv
          - meep-metrics-engine
          - meep-mg-manager
          - meep-rnis
          - meep-sandbox-ctrl
          - meep-tc-engine
      meep-webhook:
        src: go-apps/meep-webhook
        bin: bin/meep-webhook
@@ -68,7 +94,6 @@ repo:
          - -mod=vendor
        codecov: false
        lint: true
        monitor: true

    # Javascript Applications
    js-apps:
@@ -117,7 +142,6 @@ repo:
          - -mod=vendor
        codecov: false
        lint: true
        monitor: true
        api: go-apps/meep-loc-serv/api/swagger.yaml
      meep-metrics-engine:
        src: go-apps/meep-metrics-engine
@@ -127,7 +151,6 @@ repo:
          - -mod=vendor
        codecov: false
        lint: true
        monitor: true
        api: go-apps/meep-metrics-engine/api/v2/swagger.yaml
      meep-mg-manager:
        src: go-apps/meep-mg-manager
@@ -135,7 +158,6 @@ repo:
        chart: charts/meep-mg-manager
        codecov: false
        lint: true
        monitor: true
        api: go-apps/meep-mg-manager/api/swagger.yaml
      meep-rnis:
        src: go-apps/meep-rnis
@@ -145,7 +167,6 @@ repo:
          - -mod=vendor
        codecov: false
        lint: true
        monitor: true
        api: go-apps/meep-rnis/api/swagger.yaml
      meep-sandbox-ctrl:
        src: go-apps/meep-sandbox-ctrl
@@ -153,7 +174,6 @@ repo:
        chart: charts/meep-sandbox-ctrl
        codecov: false
        lint: true
        monitor: true
        api: go-apps/meep-sandbox-ctrl/api/swagger.yaml
        docker-data:
          'entrypoint.sh': go-apps/meep-sandbox-ctrl/entrypoint.sh
@@ -164,13 +184,11 @@ repo:
        chart: charts/meep-tc-engine
        codecov: false
        lint: true
        monitor: true
      meep-tc-sidecar:
        src: go-apps/meep-tc-sidecar
        bin: bin/meep-tc-sidecar
        codecov: false
        lint: true
        monitor: false

  #------------------------------
  #  Dependencies
@@ -178,31 +196,22 @@ repo:
  dep:
    meep-couchdb:
      chart: charts/couchdb
      monitor: true
    meep-docker-registry:
      chart: charts/docker-registry
      monitor: true
    meep-grafana:
      chart: charts/grafana
      monitor: true
    meep-influxdb:
      chart: charts/influxdb
      monitor: true
    meep-kube-state-metrics:
      chart: charts/kube-state-metrics
      monitor: true
    meep-ingress:
      chart: charts/nginx-ingress
      monitor: true
    meep-redis:
      chart: charts/redis
      monitor: true
    meep-open-map-tiles:
      chart: charts/open-map-tiles
      monitor: true
    meep-postgis:
      chart: charts/postgis
      monitor: true

  #------------------------------
  #  Packages
+1 −1
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ image:
  tag: latest
  pullPolicy: Always
  env:
    # Provide comma-spearated list of expected pods to be monitored
    # Provide comma-separated list of expected pods to be monitored
    MEEP_DEPENDENCY_PODS: ""
    MEEP_CORE_PODS: ""
    MEEP_SANDBOX_PODS: ""
+2 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ image:
  tag: latest
  pullPolicy: Always      
  env:
    # Provide comma-separated list of pods to create in sandbox
    MEEP_SANDBOX_PODS: ""
    MEEP_HOST_URL: "http://www.example.com"

service:
+17 −45
Original line number Diff line number Diff line
@@ -337,7 +337,6 @@ func generateScenarioCharts(sandboxName string, model *mod.Model) (charts []helm
}

func deployCharts(charts []helm.Chart) error {

	err := helm.InstallCharts(charts)
	if err != nil {
		return err
@@ -397,13 +396,18 @@ func createChart(chartName string, sandboxName string, scenarioName string, temp

func newChart(chartName string, sandboxName string, scenarioName string, chartLocation string, valuesFile string) helm.Chart {
	var chart helm.Chart

	// Create release name by adding sandbox + scenario prefix
	prefix := "meep-"
	sandboxPrefix := prefix + sandboxName + "-"
	if scenarioName == "" {
		chart.Name = "meep-" + chartName
		chart.ReleaseName = "meep-" + sandboxName + "-" + chartName
		prefix := "meep-"
		chart.ReleaseName = sandboxPrefix + chartName[len(prefix):]
	} else {
		chart.Name = chartName
		chart.ReleaseName = "meep-" + sandboxName + "-" + scenarioName + "-" + chartName
		chart.ReleaseName = sandboxPrefix + scenarioName + "-" + chartName
	}

	chart.Name = chartName
	chart.Namespace = sandboxName
	chart.Location = chartLocation
	chart.ValuesFile = valuesFile
@@ -503,47 +507,15 @@ func generateSandboxCharts(sandboxName string) (charts []helm.Chart, err error)
	sandboxTemplate.HostUrl = ve.hostUrl

	// Create sandbox charts
	chartLocation, err := createChart("meep-loc-serv", sandboxName, "", sandboxTemplate)
	for pod := range ve.sboxPods {
		var chartLocation string
		chartLocation, err = createChart(pod, sandboxName, "", sandboxTemplate)
		if err != nil {
			return
		}
	chart := newChart("loc-serv", sandboxName, "", chartLocation, "")
		chart := newChart(pod, sandboxName, "", chartLocation, "")
		charts = append(charts, chart)

	chartLocation, err = createChart("meep-rnis", sandboxName, "", sandboxTemplate)
	if err != nil {
		return
	}
	chart = newChart("rnis", sandboxName, "", chartLocation, "")
	charts = append(charts, chart)

	chartLocation, err = createChart("meep-metrics-engine", sandboxName, "", sandboxTemplate)
	if err != nil {
		return
	}
	chart = newChart("metrics-engine", sandboxName, "", chartLocation, "")
	charts = append(charts, chart)

	chartLocation, err = createChart("meep-mg-manager", sandboxName, "", sandboxTemplate)
	if err != nil {
		return
	}
	chart = newChart("mg-manager", sandboxName, "", chartLocation, "")
	charts = append(charts, chart)

	chartLocation, err = createChart("meep-tc-engine", sandboxName, "", sandboxTemplate)
	if err != nil {
		return
	}
	chart = newChart("tc-engine", sandboxName, "", chartLocation, "")
	charts = append(charts, chart)

	chartLocation, err = createChart("meep-sandbox-ctrl", sandboxName, "", sandboxTemplate)
	if err != nil {
		return
	}
	chart = newChart("sandbox-ctrl", sandboxName, "", chartLocation, "")
	charts = append(charts, chart)

	return charts, nil
}
+17 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ type VirtEngine struct {
	activeScenarioNames map[string]string
	hostUrl             string
	handlerId           int
	sboxPods            map[string]string
}

var ve *VirtEngine
@@ -58,6 +59,22 @@ func Init() (err error) {
	ve.activeModels = make(map[string]*mod.Model)
	ve.activeScenarioNames = make(map[string]string)

	// Retrieve sandbox pods list from environment variable
	ve.sboxPods = make(map[string]string)
	sboxPodsStr := strings.TrimSpace(os.Getenv("MEEP_SANDBOX_PODS"))
	log.Info("MEEP_SANDBOX_PODS: ", sboxPodsStr)
	if sboxPodsStr != "" {
		sboxPodsList := strings.Split(sboxPodsStr, ",")
		for _, pod := range sboxPodsList {
			ve.sboxPods[pod] = pod
		}
	}
	if len(ve.sboxPods) == 0 {
		err = errors.New("MEEP_SANDBOX_PODS env variable does not contain sbox pod list")
		log.Error(err.Error())
		return err
	}

	// Retrieve Host Name from environment variable
	ve.hostUrl = strings.TrimSpace(os.Getenv("MEEP_HOST_URL"))
	if ve.hostUrl == "" {
Loading