https://github.com/illimanijavier/jenkins
https://github.com/illimanijavier/jenkins
cloud devops docker jenkins
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/illimanijavier/jenkins
- Owner: illimaniJavier
- Created: 2025-03-05T18:58:31.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-15T19:08:48.000Z (about 1 year ago)
- Last Synced: 2025-03-18T21:47:34.184Z (about 1 year ago)
- Topics: cloud, devops, docker, jenkins
- Homepage:
- Size: 61.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Jenkins on Kubernetes
A production-ready deployment of Jenkins CI/CD server on Kubernetes using Kustomize for configuration management.

## 🚀 Features
- **Scalable**: Runs on Kubernetes for high availability
- **Persistent**: Configured with persistent storage to maintain state
- **Secure**: Preconfigured with best security practices
- **Customizable**: Uses Kustomize for environment-specific configurations
- **Ingress Ready**: Includes ingress configuration for easy access
## 🏗️ Architecture
This deployment uses:
- Jenkins master deployment with configurable resources
- Persistent volume claims for durability
- Kubernetes Service for network access
- Ingress configuration for external access
- Kustomize overlays for environment-specific configurations
## 📋 Prerequisites
- Kubernetes cluster (v1.25+)
- kubectl configured to communicate with your cluster
- Kustomize (v4.0+)
- Storage class available in your cluster
## 🔧 Installation
### 1. Namespace Setup
Create the Jenkins namespace first:
```bash
kubectl create namespace jenkins
```
### 2. Clone the Repository
```bash
git clone https://github.com/illimaniJavier/jenkins.git
cd jenkins
```
### 3. Jenkins User Setup
This deployment requires a Jenkins user on your host system for proper permissions:
```bash
# Create the Jenkins user
sudo adduser jenkins
# Verify the user's UID and GID
id jenkins
```
You should see output like:
```
uid=1004(jenkins) gid=1004(jenkins) groups=1004(jenkins),100(users)
```
Now update your deployment.yaml with your Jenkins user's UID/GID:
```yaml
securityContext:
fsGroup: 1004 # Replace with YOUR jenkins user's GID
runAsUser: 1004 # Replace with YOUR jenkins user's UID
runAsNonRoot: true
```
### 4. Ingress Configuration for DNS
The Ingress configuration uses a placeholder domain `jenkins.example.com`.
**You must replace this with your actual domain before deploying:**
```yaml
# In base/ingress.yaml
spec:
rules:
- host: jenkins.example.com # Replace with your domain
```
### 5. Deploy Using Kustomize
```bash
kubectl apply -k overlays/dev/
```
## 🔍 Verification
Verify your deployment is running correctly:
```bash
# Check if pods are running
kubectl get pods -n jenkins
# Check the service
kubectl get svc -n jenkins
# Check the ingress
kubectl get ingress -n jenkins
```
## ⚠️ Troubleshooting
### Permission Issues
If Jenkins fails to start or you see permission errors in the logs:
1. **Verify user setup**:
```bash
id jenkins
```
2. **Check directory permissions**:
```bash
ls -la /home/jenkins/
```
3. **Ensure values match** in your deployment.yaml:
```yaml
securityContext:
fsGroup: YOUR_JENKINS_GID
runAsUser: YOUR_JENKINS_UID
```
4. **Check pod status and events**:
```bash
kubectl describe pod -n jenkins -l app=jenkins
```
## 🔍 Environment Details
This deployment has been successfully tested with the following environment:
```bash
$ kubectl version
Client Version: v1.31.4+k3s1
Kustomize Version: v5.4.2
Server Version: v1.31.4+k3s1
```
## 🌐 Post-Installation Environment
Upon successful deployment, you'll have access to a fully configured Jenkins instance. The initial admin password is automatically generated during the first startup.
### Accessing Jenkins
1. Navigate to your configured domain (e.g., `https://jenkins.example.com`.
2. You'll be presented with the Jenkins unlock screen as shown below:

3. Retrieve the initial admin password:
```bash
kubectl exec -n jenkins $(kubectl get pods -n jenkins -l app=jenkins -o jsonpath='{.items[0].metadata.name}') -- cat /var/jenkins_home/secrets/initialAdminPassword
```
4. Enter the password to unlock Jenkins and proceed with the setup wizard to:
- Install recommended plugins or select specific plugins
- Create your first admin user
- Configure the Jenkins URL
### Initial System Configuration
After installation, consider implementing these best practices:
- Configure proper backup solutions for the Jenkins home directory
- Set up CI/CD pipelines using Jenkins Pipeline or Multibranch Pipeline jobs
- Implement Jenkins Configuration as Code (JCasC) for reproducible configurations
- Connect your source code repositories (GitHub, GitLab, etc.)
- Configure build agents for distributed workloads
The deployed environment provides a solid foundation for implementing enterprise-grade CI/CD workflows with proper security and scalability considerations.
## 📄 License
MIT
## 🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.