Skip to content

Commit

Permalink
added k8s deploy section
Browse files Browse the repository at this point in the history
  • Loading branch information
bralbral committed Jun 20, 2024
1 parent fdf4359 commit 0100e65
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 6 deletions.
28 changes: 23 additions & 5 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Use this bot for communicate with users in case you do not want to provide your

Messages with an **available content type** *(TEXT, ANIMATION, AUDIO, DOCUMENT, PHOTO, VIDEO, VOICE)* will be transferred to **admin group** or **admin chat**.

*(See variable `chat_id` from [config.yaml](./deploy/example.config.yaml#L6))*
*(See variable `chat_id` from [config.yaml](deploy/docker/example.config.yaml#L6))*

If the transfer is successful, the requesting party will be notified.

Expand All @@ -26,7 +26,7 @@ The user will receive the reply as a **reply** to the original message. If the m

If the transfer is successful, the administrator will be notified.

You can [customize the bot's responses](./deploy/example.config.yaml#12), or use default values.
You can [customize the bot's responses](deploy/docker/example.config.yaml#12), or use default values.

## Deploy

Expand All @@ -42,7 +42,7 @@ Install requirements:

`pip install -r requirements.txt`

Fill [config.yml](./deploy/example.config.yaml) and place it to root dir. (In parent dir to `src`)
Fill [config.yml](deploy/docker/example.config.yaml) and place it to root dir. (In parent dir to `src`)

Run:

Expand All @@ -52,7 +52,7 @@ Run:

> Stable release with `main` tag on [dockerhub](https://hub.docker.com/r/bral1488/telegram-feedback-bot/tags)
Just copy [docker-compose.yml](./deploy/example.docker-compose.yml) and fill in [config.yaml](./deploy/example.config.yaml).
Just copy [docker-compose.yml](deploy/docker/example.docker-compose.yml) and fill in [config.yaml](deploy/docker/example.config.yaml).

Run containers:

Expand All @@ -68,7 +68,25 @@ and build docker image:

`docker build -t <your_image_name>:<your_tag_name>`

And use this image with [docker-compose.yml](./deploy/example.docker-compose.yml) from `deploy` dir.
### Install with k8s

> Stable release with `main` tag on [dockerhub](https://hub.docker.com/r/bral1488/telegram-youtube-notifier/tags)
Manifests located in [k8s](deploy%2Fk8s) directory.

It consists of `Namespace`, `ConfigMap`, and `Deployment` files.

You need fill sections in [01_configmap.yaml](deploy%2Fk8s%2F01_configmap.yaml) file.

Apply deployment:

`kubectl apply -f <directory with configs>`

Or you can do it step by step:

`kubectl apply -f <file from config dir>`

And use this image with [docker-compose.yml](deploy/docker/example.docker-compose.yml) from `deploy` dir.

## Hosting
You can rent a server from various hosters, for example from [Aeza](https://aeza.net/?ref=380831).
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions deploy/k8s/00_namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# create separate namespace
apiVersion: v1
kind: Namespace
metadata:
name: tg-feedback-namespace
43 changes: 43 additions & 0 deletions deploy/k8s/01_configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# create config map
# for config.yaml
# and cookies.txt (optional)
apiVersion: v1
kind: ConfigMap
metadata:
name: tg-feedback-config
namespace: tg-feedback-namespace
data:
config.yaml: |
bot:
# get bot token from https://t.me/botfather
token: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# chat id for redirect messages
chat_id: -100XXXXXXXXXXXXX
# Fill variables below as you want, or use default values.
# You can use HTML tags provided by the sulguk package.
# https://github.com/Tishka17/sulguk#readme
#messages:
# notify_user_about_success_deliver: ✅ Please wait for response.
# help_message: |
# <h1>
# 👋 Hello!
# </h1>
# <p>
# I can redirect to recipient <b>text, audios, voice messages, images, files</b> to recipient.
# </p>
#
# <p>
# Just send your message and wait for a response!
# </p>
# notify_admin_about_success_answer: ✅ Answered.
#
#errors:
# unsupported_type: ❌ Unsupported message type.<br/>Please check <b>/help</b> command.
# too_long_message_text: ❌ Too long message text.
# too_long_message_caption: ❌ Too long message caption.
# copy_message: ❌ Error during copying
# extract_user_id: ❌ Error during extract_id
# chat_not_found: ❌ Chat not found. Make sure you have added the bot to the admin group
40 changes: 40 additions & 0 deletions deploy/k8s/02_deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# create deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: tg-feedback
namespace: tg-feedback-namespace
spec:
replicas: 1
selector:
matchLabels:
app: tg-feedback
template:
metadata:
labels:
app: tg-feedback
spec:
containers:
- name: tg-feedback
image: bral1488/telegram-feedback-bot:main
imagePullPolicy: Always
command: ["sh", "-c", "python -m src"]
volumeMounts:
- name: config-volume
mountPath: /app/config.yaml
subPath: config.yaml
readOnly: true
resources:
limits:
memory: "64Mi"
cpu: "125m"
securityContext:
runAsUser: 0
volumes:
- name: config-volume
configMap:
name: tg-feedback-config
tolerations:
- key: "node.kubernetes.io/disk-pressure"
operator: "Exists"
effect: "NoSchedule"
2 changes: 1 addition & 1 deletion src/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

VERSION: str = "2024-06-16.18"
VERSION: str = "2024-06-20.19"
ROOT_DIR: str = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
CONFIG_FILE_PATH: str = os.path.join(ROOT_DIR, "config.yaml")

Expand Down

0 comments on commit 0100e65

Please sign in to comment.