diff --git a/neon_diana_utils/configuration.py b/neon_diana_utils/configuration.py index 8d33bcf4..15fae0c3 100644 --- a/neon_diana_utils/configuration.py +++ b/neon_diana_utils/configuration.py @@ -493,3 +493,26 @@ def configure_neon_core(mq_user: str = None, click.echo(f"Outputs generated in {output_path}") except Exception as e: click.echo(e) + + +def configure_klat_chat(): + internal_url = "http://klat-chat:8010" + external_url = "" # TODO: Get external URL + mongo_config = {"host": "", + # "port": 27017, + "database": "klatchat"} # TODO: Get MongoDB Config + config = {"SIO_URL": internal_url, + "SOCKET_IO_SERVER_URL": external_url, + # TODO: Get chat_observer MQ config + "MQ": {"users": {}, + "server": "neon-rabbitmq", + "port": 5672}, + "CHAT_CLIENT": {"PROD": { + "SERVER_URL": internal_url, + "RUNTIME_CONFIG": {"CHAT_SERVER_URL_BASE": external_url} + }}, + "CHAT_SERVER": {"PROD": { + "connection_properties": mongo_config, + "SERVER_IP": "klat-chat" + }}, + "DATABASE_CONFIG": {"PROD": {"pyklatchat_3333": mongo_config}}} diff --git a/neon_diana_utils/helm_charts/klat-chat/Chart.yaml b/neon_diana_utils/helm_charts/klat-chat/Chart.yaml new file mode 100644 index 00000000..c66598aa --- /dev/null +++ b/neon_diana_utils/helm_charts/klat-chat/Chart.yaml @@ -0,0 +1,7 @@ +apiVersion: v2 +name: klat-chat +description: Deploy Klat Services + +type: application +version: 0.0.1 +appVersion: "1.0.1a3" \ No newline at end of file diff --git a/neon_diana_utils/helm_charts/klat-chat/templates/deployment.yaml b/neon_diana_utils/helm_charts/klat-chat/templates/deployment.yaml new file mode 100644 index 00000000..e042b260 --- /dev/null +++ b/neon_diana_utils/helm_charts/klat-chat/templates/deployment.yaml @@ -0,0 +1,40 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Chart.Name }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + neon.diana.service: {{ .Chart.Name }} + strategy: + type: Recreate + template: + metadata: + annotations: + releaseTime: {{ dateInZone "2006-01-02 15:04:05Z" (now) "UTC"| quote }} + labels: + neon.diana.service: {{ .Chart.Name }} + neon.project.name: klat + neon.service.class: klat-chat + spec: + restartPolicy: Always + imagePullSecrets: + - name: {{ .Values.imagePullSecret }} + containers: + {{- range .Values.images.containers }} + - image: {{ .image }}:{{ $.Values.images.tag }} + imagePullPolicy: {{ $.Values.images.pullPolicy }} + name: {{ .name }} + env: + - name: {{ $.Values.configEnvVar }} + value: /config/neon/{{ $.Values.configFilename }} + volumeMounts: + - name: config + mountPath: /config/neon/{{ $.Values.configFilename }} + subPath: {{ $.Values.configFilename }} + {{- if $.Values.resources }} + resources: + {{- toYaml $.Values.resources | nindent 12 -}} + {{ end }} + {{ end }} \ No newline at end of file diff --git a/neon_diana_utils/helm_charts/klat-chat/templates/ingress.yaml b/neon_diana_utils/helm_charts/klat-chat/templates/ingress.yaml new file mode 100644 index 00000000..c054bc4f --- /dev/null +++ b/neon_diana_utils/helm_charts/klat-chat/templates/ingress.yaml @@ -0,0 +1,38 @@ +{{ if .Values.ingress.enabled }} +{{- $domain := .Values.domain -}} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: ingress-klat-http + annotations: + kubernetes.io/ingress.class: {{ .Values.ingress.ingressClassName }} + cert-manager.io/issuer: {{ .Values.ingress.certIssuer }} +spec: + tls: + - secretName: {{ .Values.ingress.tlsSecretName }} + hosts: + {{- range $rules }} + - {{ printf "%s.%s " .host $.Values.domain }} + {{- end }} + + rules: + {{- range $rules }} + - host: {{ printf "%s.%s " .host $.Values.domain }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .serviceName }} + port: + number: {{ .servicePort}} + {{- end }} + + {{- end }} \ No newline at end of file diff --git a/neon_diana_utils/helm_charts/klat-chat/templates/service.yaml b/neon_diana_utils/helm_charts/klat-chat/templates/service.yaml new file mode 100644 index 00000000..0861d75e --- /dev/null +++ b/neon_diana_utils/helm_charts/klat-chat/templates/service.yaml @@ -0,0 +1,50 @@ +- apiVersion: v1 + kind: Service + metadata: + labels: + neon.project.name: klat + neon.diana.service: {{ .Chart.Name }} + neon.service.class: klat-client + name: {{ .Chart.Name }} + spec: + clusterIP: None + selector: + neon.diana.service: {{ .Chart.Name }}-client + ports: + - name: klat-client + port: 8001 + targetPort: 8001 + protocol: TCP +- apiVersion: v1 + kind: Service + metadata: + labels: + neon.project.name: klat + neon.diana.service: {{ .Chart.Name }} + neon.service.class: klat-server + name: {{ .Chart.Name }} + spec: + clusterIP: None + selector: + neon.diana.service: {{ .Chart.Name }}-server + ports: + - name: klat-server + port: 8010 + targetPort: 8010 + protocol: TCP +- apiVersion: v1 + kind: Service + metadata: + labels: + neon.project.name: klat + neon.diana.service: {{ .Chart.Name }} + neon.service.class: klat-observer + name: {{ .Chart.Name }} + spec: + clusterIP: None + selector: + neon.diana.service: {{ .Chart.Name }}-observer + ports: + - name: headless + port: 55555 + targetPort: 0 \ No newline at end of file diff --git a/neon_diana_utils/helm_charts/klat-chat/values.yaml b/neon_diana_utils/helm_charts/klat-chat/values.yaml new file mode 100644 index 00000000..eb62bd1c --- /dev/null +++ b/neon_diana_utils/helm_charts/klat-chat/values.yaml @@ -0,0 +1,25 @@ +replicaCount: 1 +imagePullSecret: github-auth +configFilename: klat.yaml +domain: diana.k8s + +images: + tag: dev + pullPolicy: Always + containers: + - image: ghcr.io/neongeckocom/klatchat_observer + name: klat-observer + - image: ghcr.io/neongeckocom/chat_server + name: klat-server + - image: ghcr.io/neongeckocom/chat_client + name: klat-client + +ingress: + enabled: True + ingressClassName: nginx + tlsSecretName: tls-letsencrypt-prod + certIssuer: letsencrypt-private-key + rules: + - host: klat + serviceName: klat + servicePort: 8010 \ No newline at end of file diff --git a/neon_diana_utils/templates/mq_user_mapping.yml b/neon_diana_utils/templates/mq_user_mapping.yml index 6dc02119..9ed362e3 100644 --- a/neon_diana_utils/templates/mq_user_mapping.yml +++ b/neon_diana_utils/templates/mq_user_mapping.yml @@ -16,4 +16,6 @@ neon_llm_chatgpt: neon_llm_fastchat: - neon_llm_fastchat neon_core: - - chat_api_proxy \ No newline at end of file + - chat_api_proxy +chat_observer: + - chat_observer \ No newline at end of file diff --git a/neon_diana_utils/templates/rmq_backend_config.yml b/neon_diana_utils/templates/rmq_backend_config.yml index 7604b038..1900ffbe 100644 --- a/neon_diana_utils/templates/rmq_backend_config.yml +++ b/neon_diana_utils/templates/rmq_backend_config.yml @@ -49,6 +49,11 @@ users: tags: - backend - core + - name: "chat_observer" + password: + tags: + - backend + - klat vhosts: - name: "/neon_emails" - name: "/neon_api" @@ -144,4 +149,10 @@ permissions: vhost: "/neon_coupons" configure: ".*" write: ".*" + read: ".*" + # TODO: More specific permissions + - user: "chat_observer" + vhost: "/neon_chat_api" + configure: ".*" + write: ".*" read: ".*" \ No newline at end of file