Welcome to the CatBot repository! CatBot is an engaging Telegram bot designed to share random cat images. This project is particularly focused on demonstrating Kubernetes deployment and is an excellent resource for those learning about bot development, Docker, and Kubernetes.
main.py
: The core Python script powering the CatBot.requirements.txt
: Contains all necessary Python dependencies.aDockerfile
: Docker instructions to build the bot's image.k8s/
: Kubernetes deployment manifests for orchestrating the bot on a cluster.
- Interactive Commands: Users can interact with CatBot through
/start
and/cat
commands. - Docker Deployment: Easily deployable in Docker environments.
- Kubernetes Integration: Ready for deployment on Kubernetes with provided manifest files.
- Docker (for Docker deployment)
- Access to a Kubernetes cluster (for Kubernetes deployment)
- A Telegram bot token and TheCatApi key
- Build and run the Docker image:
docker build -t cat . docker run -d -e BOT_TOKEN=your-bot-token -e CAT_API_KEY=your-cat-api-key cat
This repository includes a Jenkins pipeline script for the automated deployment of CatBot. The pipeline handles fetching the repository, building the Docker image, pushing it to DockerHub, and deploying to Kubernetes. Additionally, the setup integrates GitHub webhooks for a complete CI/CD experience.
- Ensure your Jenkins environment is set up with an agent labeled 'eks-cluster' that has access to your Kubernetes cluster.
- Alternatively, you can use
agent any
in the pipeline script if your Jenkins master or other agents are configured to interact with Kubernetes.
- Add your DockerHub credentials in Jenkins with the ID
dockerhub
('Manage Jenkins' > 'Manage Credentials').
- Add the pipeline script to your Jenkins setup and run the pipeline through your Jenkins dashboard.
- In your GitHub repository, navigate to 'Settings' > 'Webhooks' > 'Add webhook'.
- Enter your Jenkins URL with
/github-webhook/
appended (e.g.,http://your-jenkins-url/github-webhook/
). - Select 'Just the push event' for the trigger.
- In Jenkins, under your project's configuration, select 'Git' under 'Source Code Management'.
- Enter your repository URL and credentials if required.
- Check 'GitHub hook trigger for GITScm polling' under 'Build Triggers'.
- Pushes to the repository trigger the GitHub webhook.
- Jenkins automatically triggers the pipeline, performing the tasks of fetching the repo, building the Docker image, pushing it to DockerHub, and deploying to Kubernetes.
- Ensure Jenkins has proper network access to GitHub and your Kubernetes cluster.
- Verify Jenkins server reachability from GitHub via the webhook URL.
- Test the setup by pushing changes to your repository.
-
Encode your Telegram bot token and TheCatApi key in base64:
echo -n 'your-bot-token' | base64 echo -n 'your-cat-api-key' | base64
-
Fill in the
BOT_TOKEN
andCAT_API_KEY
in thek8s/secret.yaml
file with the generated base64 values. -
Apply the Kubernetes manifests:
kubectl apply -f k8s/
Interact with your deployed Telegram bot using /start and /cat commands.
This is an open-source project and we welcome contributions. Feel free to fork, improve, and submit pull requests. Contributions can range from new features and bug fixes to documentation enhancements.
- Replace placeholders like
your-image-name
,your-bot-token
, andyour-cat-api-key
with the actual values relevant to your setup. - The instructions assume basic familiarity with command-line operations and Kubernetes. You might want to add more detailed instructions if your target audience includes beginners.