Skip to content

Commit

Permalink
Outline Klat deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
NeonDaniel committed Oct 17, 2023
1 parent 53e885e commit cff4bf6
Show file tree
Hide file tree
Showing 8 changed files with 197 additions and 1 deletion.
23 changes: 23 additions & 0 deletions neon_diana_utils/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}}}
7 changes: 7 additions & 0 deletions neon_diana_utils/helm_charts/klat-chat/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v2
name: klat-chat
description: Deploy Klat Services

type: application
version: 0.0.1
appVersion: "1.0.1a3"
40 changes: 40 additions & 0 deletions neon_diana_utils/helm_charts/klat-chat/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
38 changes: 38 additions & 0 deletions neon_diana_utils/helm_charts/klat-chat/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
50 changes: 50 additions & 0 deletions neon_diana_utils/helm_charts/klat-chat/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions neon_diana_utils/helm_charts/klat-chat/values.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 3 additions & 1 deletion neon_diana_utils/templates/mq_user_mapping.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ neon_llm_chatgpt:
neon_llm_fastchat:
- neon_llm_fastchat
neon_core:
- chat_api_proxy
- chat_api_proxy
chat_observer:
- chat_observer
11 changes: 11 additions & 0 deletions neon_diana_utils/templates/rmq_backend_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ users:
tags:
- backend
- core
- name: "chat_observer"
password:
tags:
- backend
- klat
vhosts:
- name: "/neon_emails"
- name: "/neon_api"
Expand Down Expand Up @@ -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: ".*"

0 comments on commit cff4bf6

Please sign in to comment.