diff --git a/build_system/charts/open-appsec-k8s-nginx-ingress/templates/controller-statefulset.yaml b/build_system/charts/open-appsec-k8s-nginx-ingress/templates/controller-statefulset.yaml index af082a3..5502372 100644 --- a/build_system/charts/open-appsec-k8s-nginx-ingress/templates/controller-statefulset.yaml +++ b/build_system/charts/open-appsec-k8s-nginx-ingress/templates/controller-statefulset.yaml @@ -103,12 +103,15 @@ spec: - {{ .Values.appsec.proxy }} {{- end }} imagePullPolicy: {{ .Values.appsec.image.pullPolicy }} - {{- if eq .Values.appsec.playground false }} env: + {{- if eq .Values.appsec.playground false }} - name: SHARED_STORAGE_HOST value: {{ .Values.appsec.storage.name }}-svc - name: LEARNING_HOST value: {{ .Values.appsec.learning.name }}-svc + {{- else }} + - name: PLAYGROUND + value: "true" {{- end }} resources: {{ toYaml .Values.resources | nindent 12 }} diff --git a/components/security_apps/orchestration/local_policy_mgmt_gen/local_policy_mgmt_gen.cc b/components/security_apps/orchestration/local_policy_mgmt_gen/local_policy_mgmt_gen.cc index 2f56bb8..94f1288 100644 --- a/components/security_apps/orchestration/local_policy_mgmt_gen/local_policy_mgmt_gen.cc +++ b/components/security_apps/orchestration/local_policy_mgmt_gen/local_policy_mgmt_gen.cc @@ -13,9 +13,12 @@ #include "local_policy_mgmt_gen.h" +#include +#include #include #include #include +#include #include #include #include @@ -1215,9 +1218,28 @@ private: LocalPolicyEnv env_type; map practice_name_to_id_map; + bool + isPlaygroundEnv() + { + string playground_variable = "PLAYGROUND"; + const char* env_string = getenv(playground_variable.c_str()); + + if (env_string) + { + string env_value = env_string; + std::transform(env_value.begin(), env_value.end(), env_value.begin(), + [](unsigned char c){ return std::tolower(c); }); + return env_value == "true"; + } + + return false; + } + bool getClusterId() { + string playground_uid = isPlaygroundEnv() ? "playground-" : ""; + dbgTrace(D_K8S_POLICY) << "Getting cluster UID"; auto maybe_namespaces_data = getObjectFromCluster("/api/v1/namespaces/"); @@ -1241,7 +1263,7 @@ private: uid, EnvKeyAttr::LogSection::SOURCE ); - Singleton::Consume::by()->setClusterId(uid); + Singleton::Consume::by()->setClusterId(playground_uid + uid); return true; } }