Changing Subscriber namespace and deployer namespace to env var (#2107)
Signed-off-by: Raj Babu Das <raj.das@mayadata.io>
This commit is contained in:
parent
e7cd9a7769
commit
8ad6ecc9a8
|
|
@ -1029,7 +1029,7 @@ apiVersion: apps/v1
|
|||
kind: Deployment
|
||||
metadata:
|
||||
name: subscriber
|
||||
namespace: litmus
|
||||
namespace: #{SUB-NAMESPACE}
|
||||
labels:
|
||||
app: subscriber
|
||||
spec:
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ import (
|
|||
func FileHandler(w http.ResponseWriter, r *http.Request) {
|
||||
serviceAddr := os.Getenv("SERVICE_ADDRESS")
|
||||
subscriberImage := os.Getenv("SUBSCRIBER_IMAGE")
|
||||
subscriberNS := os.Getenv("DEPLOYER_NAMESPACE")
|
||||
|
||||
vars := mux.Vars(r)
|
||||
token := vars["key"]
|
||||
|
||||
|
|
@ -35,7 +37,7 @@ func FileHandler(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if !reqCluster.IsRegistered {
|
||||
var respData []byte
|
||||
respData, err = utils.ManifestParser(reqCluster.ClusterID, reqCluster.AccessKey, serviceAddr+"/query", subscriberImage, "manifests/subscriber.yml")
|
||||
respData, err = utils.ManifestParser(reqCluster.ClusterID, reqCluster.AccessKey, serviceAddr+"/query", subscriberImage, subscriberNS, "manifests/subscriber.yml")
|
||||
|
||||
if err != nil {
|
||||
log.Print("ERROR", err)
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package self_deployer
|
|||
import (
|
||||
"encoding/json"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/litmuschaos/litmus/litmus-portal/graphql-server/graph/model"
|
||||
"github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/graphql/mutations"
|
||||
|
|
@ -12,6 +13,8 @@ import (
|
|||
// StartDeployer registers a new internal self-cluster and starts the deployer
|
||||
func StartDeployer(projectId string) {
|
||||
log.Print("STARTING SELF-DEPLOYER")
|
||||
DEPLOYER_NAMESPACE := os.Getenv("DEPLOYER_NAMESPACE")
|
||||
|
||||
clusterInput := model.ClusterInput{
|
||||
ProjectID: projectId,
|
||||
ClusterName: "Self-Cluster",
|
||||
|
|
@ -22,7 +25,7 @@ func StartDeployer(projectId string) {
|
|||
if err != nil {
|
||||
log.Print("SELF CLUSTER REG FAILED[DB-REG] : ", err)
|
||||
}
|
||||
response, err := k8s.CreateDeployment("litmus", key)
|
||||
response, err := k8s.CreateDeployment(DEPLOYER_NAMESPACE, key)
|
||||
if err != nil {
|
||||
log.Print("SELF CLUSTER REG FAILED[DEPLOY-CREATION] : ", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ func RandomString(n int) string {
|
|||
}
|
||||
|
||||
//ManifestParser parses manifests yaml and generates dynamic manifest with specified keys
|
||||
func ManifestParser(id, key, server, subscriberImage, template string) ([]byte, error) {
|
||||
func ManifestParser(id, key, server, subscriberImage, subscriberNS, template string) ([]byte, error) {
|
||||
file, err := os.Open(template)
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
|
|
@ -45,6 +45,8 @@ func ManifestParser(id, key, server, subscriberImage, template string) ([]byte,
|
|||
line = strings.Replace(line, "#{SERVER}", server, -1)
|
||||
} else if strings.Contains(line, "#{SUB-IMAGE}") {
|
||||
line = strings.Replace(line, "#{SUB-IMAGE}", subscriberImage, -1)
|
||||
} else if strings.Contains(line, "#{SUB-NAMESPACE}") {
|
||||
line = strings.Replace(line, "#{SUB-NAMESPACE}", subscriberNS, -1)
|
||||
}
|
||||
lines = append(lines, line)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,8 +75,12 @@ spec:
|
|||
value: "true"
|
||||
- name: SUBSCRIBER_IMAGE
|
||||
value: "litmuschaos/litmusportal-subscriber:ci"
|
||||
- name: SUBSCRIBER_NAMESPACE
|
||||
value: "litmus"
|
||||
- name: DEPLOYER_IMAGE
|
||||
value: "litmuschaos/litmusportal-self-deployer:ci"
|
||||
- name: DEPLOYER_NAMESPACE
|
||||
value: "litmus"
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
imagePullPolicy: Always
|
||||
|
|
|
|||
Loading…
Reference in New Issue